Add 2 ops zeros and zeros_like.#251
Add 2 ops zeros and zeros_like.#251fatcat-z merged 9 commits intomicrosoft:mainfrom fatcat-z:new_aten_ops
Conversation
Codecov Report
@@ Coverage Diff @@
## main #251 +/- ##
==========================================
+ Coverage 72.16% 72.20% +0.04%
==========================================
Files 93 93
Lines 8916 8923 +7
==========================================
+ Hits 6434 6443 +9
+ Misses 2482 2480 -2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
| zero = op.Constant(value=0) # type: ignore[arg-type] | ||
| else: | ||
| zero = op.Cast(0, to=dtype) # type: ignore[arg-type] | ||
| return op.ConstantOfShape(size, zero) |
There was a problem hiding this comment.
ConstantOfShape takes an attribute as the second argument. You may need to use expand
There was a problem hiding this comment.
There was a problem hiding this comment.
ConstantOfShape takes an attribute as the second argument. You may need to use expand
Got it, has updated to use a constant of tensor instead.
I guess ConstantOfShape is just like a constant, while Expand may still need to do some computation to broadcast.
Thoughts?
There was a problem hiding this comment.
As long as it runs I am for anything that’s more simple. Were you able to run the tests? Expand was what Rama suggested when I initially used ConstantOfShape, because the zero here is not compile time constant.
Remove self because this function doesn't have it as a parameter. Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com>
| from onnxscript.onnx_opset import opset18 as op | ||
| from onnxscript.onnx_types import TensorType | ||
|
|
||
| const_zero_int = helper.make_tensor("zero_tensor", TensorProto.INT64, [1], [0]) |
There was a problem hiding this comment.
Just a note: for anything that is a global constant, prefer UPPER_CASE. If private, prefix with _.
|
|
||
| from typing import Any, Optional, Sequence | ||
|
|
||
| from onnx import TensorProto, helper |
There was a problem hiding this comment.
Try to implement 2 ops in aten lib functions: zeros and zeros_like.