Skip to content

Conversation

chenmoneygithub
Copy link
Contributor

Magically the shape is lost after tflite conversion, and ensure_shape works.

@chenmoneygithub chenmoneygithub force-pushed the fix-shape branch 3 times, most recently from 773fb94 to 1cc280b Compare March 22, 2023 06:46
@mattdangerw mattdangerw self-assigned this Mar 22, 2023
next_token = tf.cast(next_token, prompt.dtype)
# Ensure shape is `[None]`, otherwise it causes issues after
# converting to TFLite.
next_token = tf.ensure_shape(next_token, [None])
Copy link
Member

Choose a reason for hiding this comment

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

Do you have an example of where this is causing a failure? Very curious why this is needed.

Is there someway we can test the failure without needing to depend on TFLite you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very good question - I am going to talk to TFLite folks after I get back, I know there is some effort on bringing TFLite testing to TF/Keras before conversion.

For the issue I saw - without this ensure_shape, next_token becomes shape [] instead of [None], which causes dynamic_update_slice to have a shape mismatch between operand (1st arg) and update (2nd arg).

@chenmoneygithub chenmoneygithub force-pushed the fix-shape branch 6 times, most recently from e1da248 to 76b9bbb Compare March 28, 2023 05:19
@chenmoneygithub chenmoneygithub force-pushed the fix-shape branch 3 times, most recently from d549804 to f1b5567 Compare March 29, 2023 00:44
@chenmoneygithub chenmoneygithub merged commit 3ab4c37 into keras-team:master Mar 29, 2023
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