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

[compiler] add interReturnType function for byteir.reshape and byteir.one_hot #451

Closed
wants to merge 4 commits into from

Conversation

heromapwrd
Copy link
Collaborator

  1. [tf-frontend] convert tf.Reshpe, which has dynamic input shape and output shape, to byteir.reshape
  2. [compiler] add inferReturnType function for byteir.reshape op
  3. [compiler] add inferReturnType function for byteir.one_hot op

@heromapwrd heromapwrd enabled auto-merge (squash) October 9, 2024 02:24
@@ -69,6 +69,10 @@ constexpr llvm::StringRef getOneHotName() {
return CUSTOM_CALL_NAME_PREFIX "one_hot";
}

constexpr llvm::StringRef getReshapeName() {
return CUSTOM_CALL_NAME_PREFIX "reshape";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it necessary to add byteir.reshape?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There are four reasons for switching to byteir.reshape instead of retaining the original tf.Reshape form:

  1. If possible, convert regular op (such as reshape op) to custom_call@byteir., rather than custom_call@tf.
  2. custom_call@byteir.*** indicates that it cannot be converted to regular mhlo op, but we have identified this case. But the form custom_call@tf.*** does not convey this meaning
  3. when other front-end reshape op appears and cannot be converted into regular mhlo.reshape op and mhlo.dynamic_reshape op, it can also be converted into byteir.reshape, a unified representation
  4. getReshapeName function will be used in shape/bounded shape inference


func.func @reshape_case0(%arg0: tensor<?x24xf16>) -> tensor<?x24x1xf16> {
%cst = "tf.Const"() <{value = dense<[-1, 24, 1]> : tensor<3xi64>}> : () -> tensor<3xi64>
%0 = "tf.Reshape"(%arg0, %cst) : (tensor<?x24xf16>, tensor<3xi64>) -> tensor<?x24x1xf16>
Copy link
Collaborator

Choose a reason for hiding this comment

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

=> compute_reshape_shape + mhlo.dynamic_reshape

@heromapwrd heromapwrd closed this Oct 14, 2024
auto-merge was automatically disabled October 14, 2024 13:08

Pull request was closed

@heromapwrd heromapwrd deleted the tf-frontend branch October 14, 2024 13:08
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.

3 participants