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

[ONNX] Fix Onnx.Hardsigmoid lowering #3239

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vivekkhandelwal1
Copy link
Collaborator

Signed-Off By: Vivek Khandelwal vivekkhandelwal1424@gmail.com

Signed-Off By: Vivek Khandelwal <vivekkhandelwal1424@gmail.com>
Copy link
Collaborator

@zjgarvey zjgarvey left a comment

Choose a reason for hiding this comment

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

Thanks!

rewriter.getF64FloatAttr(1.0));
Value alphaMulXPlusBeta = rewriter.create<Torch::AtenAddScalarOp>(
binder.getLoc(), resultType, alphaMulX, constBeta,
/*alpha=*/constOne);
Copy link
Collaborator

Choose a reason for hiding this comment

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

AtenAddScalarOp has the input signature (tensor, float, float) and performs result = operand[0] + operand[1]*operand[2], correct? I feel like this op would be way more useful if it multiplied the tensor operand[0] with operand[2].

Copy link
Collaborator

Choose a reason for hiding this comment

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

i wonder if this is just to be consistent with the aten.add.Tensor op

where you get tensor1+tensor2*alpha

Copy link
Collaborator

Choose a reason for hiding this comment

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

but also this leave the question of why we have the alpha in the first place ... for quantization maybe?

/*alpha=*/constAlpha);
Value alphaMulX = rewriter.create<Torch::AtenMulScalarOp>(
binder.getLoc(), resultType, tensorOperand, constAlpha);
Value constOne = rewriter.create<Torch::ConstantFloatOp>(
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is an aten minimum op that compares the result of the linear expression with a constant oneTensor a few lines below this, and for some reason it is using a constant int one instead of a constant float one. I'm sure it will get cast to a float at some point, but maybe this could just be cleaned up here to use your constOne.

If you make a change to use constOne for the oneTensor, it might also make sense just to change constantZero below to a float as well.

rewriter.getF64FloatAttr(1.0));
Value alphaMulXPlusBeta = rewriter.create<Torch::AtenAddScalarOp>(
binder.getLoc(), resultType, alphaMulX, constBeta,
/*alpha=*/constOne);
Copy link
Collaborator

Choose a reason for hiding this comment

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

but also this leave the question of why we have the alpha in the first place ... for quantization maybe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants