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

[Doc] TFLite frontend tutorial #2508

Merged
merged 2 commits into from
Jan 29, 2019
Merged

Conversation

FrozenGene
Copy link
Member

@FrozenGene FrozenGene commented Jan 25, 2019

This is the following up PR #2365 . It shows us how to use TFLite in TVM.

@srkreddy1238 @junrushao1994 please help to review.

Copy link
Member

@yzhliu yzhliu left a 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.

.. code-block:: bash

# Get the flatc compiler.
# You could go to https://github.com/google/flatbuffers to know how to do it.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# 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


# 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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# And you should make sure flatc compiler is installed successfully.
# and make sure it is properly installed.

# Generate TFLite package.
flatc --python schema.fbs

# Make PYTHONPATH could find generated TFLite package. For example:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Make PYTHONPATH could find generated TFLite package. For example:
# Add it to PYTHONPATH,

flatc --python schema.fbs

# Make PYTHONPATH could find generated TFLite package. For example:
export PYTHONPATH=/home/someone/tflite
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
export PYTHONPATH=/home/someone/tflite
export PYTHONPATH=/path/to/tflite


This article is an introductory tutorial to deploy TFLite models with Relay.

For us to begin with, Flatbuffers and TFLite package must be installed.
Copy link
Member

@yzhliu yzhliu Jan 27, 2019

Choose a reason for hiding this comment

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

Suggested change
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.


For us to begin with, Flatbuffers and TFLite package must be installed.

A quick solution is to install Flatbuffers
Copy link
Member

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"

Copy link
Member Author

Choose a reason for hiding this comment

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

yes. omit some words.

export PYTHONPATH=/home/someone/tflite


After these steps, you could check TFLite package is installed successfully or not.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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"``



After these steps, you could check TFLite package is installed successfully or not.
For example: ``python -c "import tflite"``
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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))
Copy link
Member

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?

Copy link
Member Author

@FrozenGene FrozenGene Jan 27, 2019

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

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

RFC: #2519

@FrozenGene
Copy link
Member Author

@yzhliu Have applied your comments and add one note about TVM TFLite frontend input layout. Please review it again, thanks.

@yzhliu yzhliu merged commit 1120655 into apache:master Jan 29, 2019
@yzhliu
Copy link
Member

yzhliu commented Jan 29, 2019

Awesome. Thanks @FrozenGene this is now merged.

merrymercy pushed a commit to merrymercy/tvm that referenced this pull request Feb 18, 2019
* TFLite frontend tutorial

* Modify as suggestion
wweic pushed a commit to neo-ai/tvm that referenced this pull request Feb 20, 2019
* TFLite frontend tutorial

* Modify as suggestion
wweic pushed a commit to neo-ai/tvm that referenced this pull request Feb 20, 2019
* TFLite frontend tutorial

* Modify as suggestion
@FrozenGene FrozenGene deleted the tflite_fe_tutorial branch September 10, 2019 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants