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

[Add] avgpool1d avgpool3d #5165

Merged
merged 24 commits into from
Jun 18, 2021
Merged

[Add] avgpool1d avgpool3d #5165

merged 24 commits into from
Jun 18, 2021

Conversation

zev123456
Copy link
Contributor

@zev123456 zev123456 commented Jun 10, 2021

avgpool1d
avgpool3d

@zev123456 zev123456 marked this pull request as ready for review June 17, 2021 08:25
out = out.reshape(out_shape)
return out

def backward(self, d_loss):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个numpy模拟的grad没有使用吧?没用的话可以删掉

output = output.sum()
output.backward()
doutput = np.ones_like(numpy_output, dtype=np.float64)
#numpy_grad = m_numpy.backward(doutput)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注释删了吧

output.backward()
doutput = np.ones_like(numpy_output, dtype=np.float64)
#numpy_grad = m_numpy.backward(doutput)
numpy_grad = np.array(#torch grad out
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numpy_grad可以直接用:numpy_grad = np.zeros(shape=xxx) + numpy_grad[...] = 0.125完成

@oneflow-ci-bot oneflow-ci-bot self-requested a review June 17, 2021 09:03
>>> inputarr = np.array([[[[[-0.74832135, 0.03151652],[ 1.08632752, 0.53338843]],[[ 0.70026413, -0.62565466], [-0.59692776, -1.00883888]]],[[[-0.26829566, -0.31759021],[ 1.46828945, -2.61885422]],[[-0.67331338, 1.31144767],[-0.85747376, -0.38252167]]]],[[[[-1.54668075, -0.935113 ],[ 0.19119924, -0.83618886]],[[ 0.17532863, 0.6574685 ],[-1.10141786, 1.1819236 ]]],[[[-1.1367412 , 0.68027652],[ 0.98564578, 0.04861313]],[[-0.69807858, 0.75021497],[ 0.62720175, -0.76607257]]]]])
>>> of_avgpool3d = flow.nn.AvgPool3d(kernel_size=(2,2,2),padding=(0,0,0),stride=(1,1,1),)
>>> x = flow.Tensor(inputarr)
>>> flow.enable_eager_execution()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flow.enable_eager_execution()这个放上面吧

>>> of_y = of_avgpool3d(x)
>>> print(of_y.dtype)
oneflow.float32
>>> print(of_y.numpy().sum())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接>>>of_y 就行,不需要.numpy().sum()了

@oneflow-ci-bot oneflow-ci-bot removed their request for review June 17, 2021 09:33
@oneflow-ci-bot oneflow-ci-bot self-requested a review June 17, 2021 09:33
@Flowingsun007 Flowingsun007 removed the request for review from oneflow-ci-bot June 17, 2021 10:15
@BBuf BBuf added the interface label Jun 18, 2021
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot June 18, 2021 08:03
@oneflow-ci-bot oneflow-ci-bot requested review from oneflow-ci-bot and removed request for oneflow-ci-bot June 18, 2021 08:38
@oneflow-ci-bot oneflow-ci-bot merged commit d1c24ae into master Jun 18, 2021
@oneflow-ci-bot oneflow-ci-bot deleted the yzw_avgpool1d_3d branch June 18, 2021 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants