-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Doc] TFLite frontend tutorial #2508
Conversation
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.
good to me generally, left some suggestion for writing.
tutorials/frontend/from_tflite.py
Outdated
.. code-block:: bash | ||
|
||
# Get the flatc compiler. | ||
# You could go to https://github.com/google/flatbuffers to know how to do it. |
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.
# You could go to https://github.com/google/flatbuffers to know how to do it. | |
# Please refer to https://github.com/google/flatbuffers for details |
tutorials/frontend/from_tflite.py
Outdated
|
||
# Get the flatc compiler. | ||
# You could go to https://github.com/google/flatbuffers to know how to do it. | ||
# And you should make sure flatc compiler is installed successfully. |
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.
# And you should make sure flatc compiler is installed successfully. | |
# and make sure it is properly installed. |
tutorials/frontend/from_tflite.py
Outdated
# Generate TFLite package. | ||
flatc --python schema.fbs | ||
|
||
# Make PYTHONPATH could find generated TFLite package. For example: |
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.
# Make PYTHONPATH could find generated TFLite package. For example: | |
# Add it to PYTHONPATH, |
tutorials/frontend/from_tflite.py
Outdated
flatc --python schema.fbs | ||
|
||
# Make PYTHONPATH could find generated TFLite package. For example: | ||
export PYTHONPATH=/home/someone/tflite |
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.
export PYTHONPATH=/home/someone/tflite | |
export PYTHONPATH=/path/to/tflite |
tutorials/frontend/from_tflite.py
Outdated
|
||
This article is an introductory tutorial to deploy TFLite models with Relay. | ||
|
||
For us to begin with, Flatbuffers and TFLite package must be installed. |
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.
For us to begin with, Flatbuffers and TFLite package must be installed. | |
To get started, Flatbuffers and TFLite package needs to be installed as prerequisites. |
tutorials/frontend/from_tflite.py
Outdated
|
||
For us to begin with, Flatbuffers and TFLite package must be installed. | ||
|
||
A quick solution is to install Flatbuffers |
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.
I guess you mean "A quick solution is to install Flatbuffers via pip" ? suggest to say "For Flatbuffers it is easy to install via pip"
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.
yes. omit some words.
tutorials/frontend/from_tflite.py
Outdated
export PYTHONPATH=/home/someone/tflite | ||
|
||
|
||
After these steps, you could check TFLite package is installed successfully or not. |
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.
After these steps, you could check TFLite package is installed successfully or not. | |
Now please check if TFLite package is installed successfully, ``python -c "import tflite"`` |
tutorials/frontend/from_tflite.py
Outdated
|
||
|
||
After these steps, you could check TFLite package is installed successfully or not. | ||
For example: ``python -c "import tflite"`` |
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.
For example: ``python -c "import tflite"`` | |
Below you can find an example for how to ... |
image_data = np.asarray(resized_image).astype("float32") | ||
|
||
# convert HWC to CHW | ||
image_data = image_data.transpose((2, 0, 1)) |
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.
so tf-lite model itself is in NCHW format?
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.
TFLite itself is NHWC, we accept NCHW currently like other converters (for example Tensorflow to CoreML converters). Have done it in TFLite Relay frontend transparently currently. We could leave it for future discussion whether we should do it in graph pass or other places. This is a start. You could refer PR #2365 to see more details.
I will update the docs as your comments
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.
Thanks, can we explain this a bit in the comments? Since the layout assumption might change later, we'd better ask users to pay attention.
Besides, would you mind open an RFC since it might deserve a serious design discussion.
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.
My note has been added to users for paying attention.
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.
RFC: #2519
@yzhliu Have applied your comments and add one note about TVM TFLite frontend input layout. Please review it again, thanks. |
Awesome. Thanks @FrozenGene this is now merged. |
* TFLite frontend tutorial * Modify as suggestion
* TFLite frontend tutorial * Modify as suggestion
* TFLite frontend tutorial * Modify as suggestion
This is the following up PR #2365 . It shows us how to use TFLite in TVM.
@srkreddy1238 @junrushao1994 please help to review.