Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nn.ZeroPad2d 行为与 pytorch 不一致 #234

Closed
triple-Mu opened this issue Jun 2, 2022 · 1 comment
Closed

nn.ZeroPad2d 行为与 pytorch 不一致 #234

triple-Mu opened this issue Jun 2, 2022 · 1 comment

Comments

@triple-Mu
Copy link
Contributor

问题

nn.ZeroPad2d 行为与 pytorch 不一致

报错

loaded library: /lib/x86_64-linux-gnu/libibverbs.so.1
torch.Size([2, 10, 1, 64, 58, 58])
Traceback (most recent call last):
  File "/home/ubuntu/work/oneflow/vision/flowvision/models/ttest.py", line 16, in <module>
    fOut = fPad(flowTensor)
  File "/home/ubuntu/miniconda3/envs/flow/lib/python3.8/site-packages/oneflow/nn/module.py", line 115, in __call__
    res = self.forward(*args, **kwargs)
  File "/home/ubuntu/miniconda3/envs/flow/lib/python3.8/site-packages/oneflow/nn/modules/padding.py", line 414, in forward
    return flow._C.pad(x, pad=self.padding, mode="constant", value=self.value)
RuntimeError: 
  File "/home/ci-user/runners/release/_work/oneflow/oneflow/oneflow/core/functional/impl/nn_functor.cpp", line 1858, in operator()
    Check failed: (ndim) <= (5) (6 vs 5) Dimension of input tensor should less than or equal to 5

最小复现

import torch
import torch.nn as tnn
import oneflow as flow
import oneflow.nn as fnn
import numpy as np

inp = np.random.randn(2, 10, 1, 64, 56, 56).astype(np.float32)

torchTensor = torch.from_numpy(inp)
tPad = tnn.ZeroPad2d(1)
tOut = tPad(torchTensor)
print(tOut.shape)

flowTensor = flow.from_numpy(inp)
fPad = fnn.ZeroPad2d(1)
fOut = fPad(flowTensor)
print(fOut.shape)
@Flowingsun007
Copy link
Contributor

这个问题是因为functor内部错误地check了input的dim,这个pr修复了此问题:Oneflow-Inc/oneflow#8354

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants