change shape to support dynamic batch input in tf.function XLA generate for tf serving#18372
change shape to support dynamic batch input in tf.function XLA generate for tf serving#18372gante merged 2 commits intohuggingface:mainfrom
Conversation
|
The documentation is not available anymore as the PR was closed or merged. |
d4b873f to
59e80ca
Compare
|
Hi @nlpcat 👋 I see the change is needed because an unknown batch size is specified (hence the need for dynamic shapes). I'm going to double-check a few cases against this branch and, if all goes well, I may propose a few changes. In general, I'm in favor of adding the change, thank you for the PR :) |
gante
left a comment
There was a problem hiding this comment.
Thank you for this contribution! (I've double-checked that it doesn't affect the performance of generate)
One bit is missing, if you're up to it -- a test to ensure we don't lose this feature. The best place would probably be UtilsFunctionsTest inside test_modeling_tf_common.py, and the test could be a copy of the example you shared in the PR description.
Let us know if you'd rather have us adding the test instead :)
sgugger
left a comment
There was a problem hiding this comment.
Yes, adding a test would be nice.
Thanks a lot for your PR!
|
(edited the PR header to link more issues this PR fixes :) ) |
59e80ca to
596ecf4
Compare
|
@nlpcat this is fantastic! Thank you so much for your contribution 🙏 |
|
The whole idea of Tensorflow in Huggingface is very complicated and a pain. |
|
I was testing this code, but I have found an issue with my model: I think the file tf_logits_process.py, also needs to use the |
|
@rafaellemay can you open an issue with the problem that you found (and a snippet containing an example)? It would help us ensure the library works well in all cases :) |
What does this PR do?
support dynamic input for tf.function + generate (XLA). needed for batch tf serving
export:
tf model run
xla_run
this also works for beam search by changing exported code as
Fixes #18357
Fixes #16823
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
cc @gante @patrickvonplaten