Skip to content

feat(atenlib): op(trunc) #515

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

Merged
merged 3 commits into from
Mar 10, 2023
Merged

feat(atenlib): op(trunc) #515

merged 3 commits into from
Mar 10, 2023

Conversation

justinchuby
Copy link
Collaborator

@justinchuby justinchuby commented Mar 10, 2023

aten::trunc

<
  domain: "onnxscript.atenlib",
  opset_import: ["" : 18]
>
aten_trunc (self) => (return_val)
{
   tmp = Abs (self)
   integer_parts = Floor (tmp)
   tmp_0 = Constant <value = float tmp_0 {0}> ()
   tmp_0_cast = CastLike (tmp_0, self)
   is_negative = Less (self, tmp_0_cast)
   tmp_1 = Neg (integer_parts)
   return_val = Where (is_negative, tmp_1, integer_parts)
}

@justinchuby justinchuby added the module: torchlib Related to the torch/aten function lib in development label Mar 10, 2023
@codecov
Copy link

codecov bot commented Mar 10, 2023

Codecov Report

Merging #515 (18d19ad) into main (510db96) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #515      +/-   ##
==========================================
+ Coverage   72.71%   72.72%   +0.01%     
==========================================
  Files         109      109              
  Lines       10686    10689       +3     
  Branches     1102     1102              
==========================================
+ Hits         7770     7774       +4     
+ Misses       2612     2611       -1     
  Partials      304      304              
Impacted Files Coverage Δ
...s/function_libs/torch_aten/ops_correctness_test.py 87.93% <ø> (ø)
onnxscript/function_libs/torch_aten/ops/core.py 70.79% <100.00%> (+0.10%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

raise NotImplementedError()
# Reference https://github.com/onnx/onnx/issues/4588#issuecomment-1463970126
integer_parts = op.Floor(op.Abs(self))
is_negative = op.Less(self, 0.0)
Copy link
Contributor

Choose a reason for hiding this comment

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

side note: the number (0.0) being scripted as constant + castlike seems like a common and important pattern. Let's mention this in the authoring guide. (and onnxscript itself too if not already)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@justinchuby justinchuby merged commit aa93917 into main Mar 10, 2023
@justinchuby justinchuby deleted the justinchu/trunc branch March 10, 2023 18:38
@@ -389,6 +389,7 @@ def _where_input_wrangler(
"tan": core_ops.aten_tan,
"tanh": core_ops.aten_tanh,
"topk": core_ops.aten_topk,
"trunc": core_ops.aten_trunc,
Copy link
Contributor

@BowenBao BowenBao Mar 10, 2023

Choose a reason for hiding this comment

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

I wonder if there is anything we can do to improve the clarity on actual test cases. Seems hard to check what are the inputs coverage without running it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Any suggestions? What kind of information will be useful?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: torchlib Related to the torch/aten function lib in development
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants