#286 fix maxpool1d, maxpool2d, torch.histc

Merged
zoulq merged 68 commits from tanh01 into master 1 year ago
kcl commented 1 year ago
frelam reviewed 1 year ago
ms_adapter/pytorch/nn/functional.py
@@ -1415,0 +1425,4 @@

_extra_pad_h = 0
_extra_pad_w = 0
#TODO: this method do not support GRAPH_MODE
frelam commented 1 year ago
图模式下报什么错误?
kcl commented 1 year ago
RuntimeError: For operation 'getitem', current input arguments types are <Number, Number>. The 1-th argument type 'Number' is not supported now.
frelam commented 1 year ago
嗯嗯, 了解了, 谢谢。
frelam reviewed 1 year ago
ms_adapter/pytorch/nn/functional.py
@@ -1415,0 +1440,4 @@
# if tmp < _valid_in_w:
# _extra_pad_w = min(tmp + _stride[1] - _valid_in_w, kernel_size[1] - _padding[1] - 1)
_pad = (_padding[1], _padding[1] + _extra_pad_w, _padding[0], _padding[0] + _extra_pad_h)
neg_inf = -float('inf')
frelam commented 1 year ago
这个地方我刚才试了一下, ms.ops.pad(input_x, _pad, value=neg_inf), neg_inf的dtype要与input_x相同, 所以如果input_x是int的话, 可能会报错。
kcl commented 1 year ago
maxpool本身不支持int,理论上讲这种情形不需要支持,但是报错信息会由pad发出,对这一点进行修改,检测到int输入会在最开始报错
frelam reviewed 1 year ago
@@ -1415,0 +1449,4 @@
ndim = input.ndim
if ndim == 3:
input = input.expand_dims(0)
input = ms.ops.pad(input, _pad, value=neg_inf)
frelam commented 1 year ago
ops.pad 虽然在ascend上已经支持了, 但由于还未正式发布, 所以有些场景结果可能不太对。 比如以下用例: import mindspore as ms import numpy as np a = ms.Tensor([[1, 2, 3.], [4, 5, 6]], dtype=ms.float32) _pad = (1, 1, 0, 0) a = ms.ops.pad(a , _pad, mode='constant', value=3) print(a) CPU结果:[[3. 1. 2. 3. 3.] [3. 4. 5. 6. 3.]] Ascend结果: [[0. 0. 0. 1. 2.] [3. 4. 5. 6. 0.]] 建议先不要在Ascend上使用ms.ops.pad
frelam commented 1 year ago
a = ms.Tensor([[1, 2, 3.], [4, 5, 6]], dtype=ms.float32)
kcl changed title from fix maxpool1d, maxpool2d to fix maxpool1d, maxpool2d, torch.histc 1 year ago
zoulq merged commit d3528d05ca into master 1 year ago
The pull request has been merged as d3528d05ca.
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This pull request currently doesn't have any dependencies.

Loading…
There is no content yet.