Skip to content

[Unity] Add R.quantize and R.dequantize ops#15849

Merged
masahi merged 1 commit intoapache:unityfrom
ibsidorenko:unity-qdq
Oct 3, 2023
Merged

[Unity] Add R.quantize and R.dequantize ops#15849
masahi merged 1 commit intoapache:unityfrom
ibsidorenko:unity-qdq

Conversation

@ibsidorenko
Copy link
Copy Markdown
Contributor

This commit adds 2 new operations (R.quantize and R.dequantize) and supports them in LegalizeOps pass.

@ibsidorenko
Copy link
Copy Markdown
Contributor Author

cc @masahi @quic-sanirudh

@ibsidorenko ibsidorenko changed the title [Unity] Add R.quantize and R.dequantize ops. [Unity] Add R.quantize and R.dequantize ops Oct 1, 2023
Copy link
Copy Markdown
Member

@masahi masahi left a comment

Choose a reason for hiding this comment

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

Also needs to fix the conflict.

The output scale.

zero_point : tvm.relay.Expr
The output zero_point.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think "input" scale / zp would be more correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

}

// Check datatype of zero_point param:
if (zp_sinfo->dtype != DataType::Int(32)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I remember that zp needs to be 8 bit in practice. How about enforcing int8 here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it is possible. I have never met the cases when zero_point is out of [-128, 127] range.


/*!
* \file src/relax/op/tensor/qdq.h
* \brief The functions to make Relax quantize/dequantize operator calls.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this header needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There's no need for that in this PR. But it was added for the future when we want to construct quantize/dequantize op in one of TVM passes.

This commit adds 2 new operations (R.quantize and R.dequantize) and
supports them in LegalizeOps pass.
@masahi masahi merged commit 8954139 into apache:unity Oct 3, 2023
@ibsidorenko ibsidorenko deleted the unity-qdq branch October 10, 2023 08:37
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.

2 participants