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

Commit

Permalink
add decimals argument to round (#66195)
Browse files Browse the repository at this point in the history
Summary:
Fixes pytorch/pytorch#65908

Added a new overload instead of updating the current signature. (Had issues with JIT and **maybe** it would have been FC breaking)

TODO:

* [x] Don't compute `std::pow(10, decimals)` for each element.
* [x] Update docs (https://docs-preview.pytorch.org/66195/generated/torch.round.html?highlight=round#torch.round)
* [x] Add tests
* ~~Should we try to make it composite?~~
* ~~Should we add specialized test with more values of `decimals` outside of OpInfo with larger range of values in input tensor?~~

cc mruberry rgommers

Pull Request resolved: pytorch/pytorch#66195

Reviewed By: anjali411

Differential Revision: D31821385

Pulled By: mruberry

fbshipit-source-id: 9a03fcb809440f0c83530108284e69c345e1850f
  • Loading branch information
kshitij12345 authored and facebook-github-bot committed Jan 26, 2022
1 parent 9a62188 commit a8a82fa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nestedtensor/csrc/UnaryOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ TORCH_LIBRARY_IMPL(aten, NestedTensor, m) {
// UNARY_OP(mvlgamma);
UNARY_OP(neg);
UNARY_OP(reciprocal);
UNARY_OP(round);
// UNARY_OP(round);
UNARY_OP(rsqrt);
UNARY_OP(sigmoid);
UNARY_OP_INPLACE_METHOD(sign)
Expand Down
4 changes: 2 additions & 2 deletions test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def get_unary_C_functions():
"nonzero",
"real",
"reciprocal",
"round",
# "round",
"rsqrt",
"sigmoid",
"sign",
Expand Down Expand Up @@ -234,7 +234,7 @@ def get_unary_functions():
'reciprocal',
# 'relu', # TODO: no relu_out in aten
# 'renorm', # TODO: Requires extra kwargs
'round',
# 'round', # TODO: has decimals arg (and in general depending on an exact signature is not supported)
'rsqrt',
'sigmoid',
'sign',
Expand Down

0 comments on commit a8a82fa

Please sign in to comment.