margelo / margelo/react-native-fast-tflite

How to run inference with dynamic shape model ?

Open
#16 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.2k
Forks
92
Avg merge
13h 9m
Merged PRs (30d)
2

Description

Hi bro,
I have a model that supports dynamic shape, but tflite does not support it when converting, but it does support it from the code.

Doc from TFL
https://www.tensorflow.org/lite/guide/inference#run_inference_with_dynamic_shape_model

If you want to run a model with dynamic input shape, resize the input shape before running inference. Otherwise, the None shape in Tensorflow models will be replaced by a placeholder of 1 in TFLite models.

The following examples show how to resize the input shape before running inference in different languages. All the examples assume that the input shape is defined as [1/None, 10], and need to be resized to [3, 10].

// Resize input tensors before allocate tensors
interpreter->ResizeInputTensor(/*tensor_index=*/0, std::vector<int>{3,10});
interpreter->AllocateTensors();

How to operate with react-native-fast-tflite

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked TensorFlow Lite dynamic-shape inference documentation and the react-native-fast-tflite usage entry points. Determine whether the exposed API supports resizing the input before tensor allocation, and document the supported steps or limitations with a working example; the answer should be verifiable by running dynamic-shape inference.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, tensorflow
Domain
machine-learning, mobile
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.