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 Cast-like operator #3558

Merged
merged 10 commits into from
Jul 14, 2021
Merged

Add Cast-like operator #3558

merged 10 commits into from
Jul 14, 2021

Conversation

gramalingam
Copy link
Contributor

Signed-off-by: Ganesan Ramalingam grama@microsoft.com

Description
Introduces an operator CastLike(X,Y) that casts X to the same type as Y.

Motivation and Context
A common use-case in the definition of function-bodies is to produce a constant, like 0.5 or 1, of the same type/precision as an input Y. This enables such functionality (without requiring the use of a type-context and a context-dependent-function). This will also be useful in defining similar functions that are stored in a model (aka model-local functions).

Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
@gramalingam gramalingam requested review from a team as code owners July 6, 2021 23:54
Copy link
Member

@jcwchen jcwchen left a comment

Choose a reason for hiding this comment

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

Please note that TestCoverage.md needs to be updated as well

Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
inputs=['input', 'like'],
outputs=['output'],
)
if input_type and output_type:
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure I understand why would these 2 be None?

Copy link
Contributor Author

@gramalingam gramalingam Jul 9, 2021

Choose a reason for hiding this comment

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

I copied it from Cast. My guess is that minor adjustments were needed for types like bfloat16 because of the numpy doesn't support this type, so the numpy values have a different type from the intended type (so, the call to expect is different here, and the intended-type is explicitly mentioned).

@askhade askhade added this to the 1.10 milestone Jul 12, 2021
@gramalingam gramalingam added the operator Issues related to ONNX operators label Jul 12, 2021
@askhade askhade merged commit e7c8edc into onnx:master Jul 14, 2021
@gramalingam gramalingam deleted the cast-like branch April 14, 2022 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
operator Issues related to ONNX operators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants