Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

add zero-grad for rounding ops #9040

Merged
merged 2 commits into from
Dec 19, 2017
Merged

add zero-grad for rounding ops #9040

merged 2 commits into from
Dec 19, 2017

Conversation

szha
Copy link
Member

@szha szha commented Dec 12, 2017

Description

add zero gradients to rounding operators including 'rint', 'ceil', 'floor', 'trunc', and 'fix'.

Checklist

Essentials

  • Passed code style checking (make lint)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • register FGradient with MakeZeroGradNodes for 'rint', 'ceil', 'floor', 'trunc', 'fix'

@piiswrong
Copy link
Contributor

Are these zero for other frameworks?

@szha
Copy link
Member Author

szha commented Dec 14, 2017

TF has None which means zero tensorflow/tensorflow#5888

@szha
Copy link
Member Author

szha commented Dec 14, 2017

pytorch has zeros for round

In [1]: import torch

In [2]: from torch.autograd import Variable

In [3]: x = Variable(torch.randn(4), requires_grad=True)

In [4]: y = x.round()

In [5]: z = y.sum()

In [6]: z.backward()

In [7]: x.grad
Out[7]:
Variable containing:
 0
 0
 0
 0
[torch.FloatTensor of size 4]

@piiswrong piiswrong merged commit ae70769 into apache:master Dec 19, 2017
@szha szha deleted the round_grad branch December 19, 2017 20:43
rahul003 pushed a commit to rahul003/mxnet that referenced this pull request Jun 4, 2018
* add zero-grad for rounding ops

* Update test_symbol.py
zheng-da pushed a commit to zheng-da/incubator-mxnet that referenced this pull request Jun 28, 2018
* add zero-grad for rounding ops

* Update test_symbol.py
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants