-
Notifications
You must be signed in to change notification settings - Fork 44
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
Conversation
heromapwrd
commented
Sep 29, 2024
- [tf-frontend] convert tf.Reshpe, which has dynamic input shape and output shape, to byteir.reshape
- [compiler] add inferReturnType function for byteir.reshape op
- [compiler] add inferReturnType function for byteir.one_hot op
@@ -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"; |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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:
- If possible, convert regular op (such as reshape op) to custom_call@byteir., rather than custom_call@tf.
- 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
- 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
- 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> |
There was a problem hiding this comment.
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