Hi tflite team and friends,
After using tflite python APIs to do inference, I would like to save the invoked tensors to model file and override the original tensors. Is that possible? Is there any API that I can leverage?
To better explain my question, let's say I have a script containing following python codes to do inference:
from tflite_runtime.interpreter import Interpreter
import tensorflow as tf
interpreter = Interpreter(model_path="model.tflite")
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
interpreter.set_tensor(input_details[0]['index'], tf.constant(3))
interpreter.invoke()
output_data = interpreter.get_tensor(output_details[0]['index'])
After calling the invoke() method, all the input and output tensors of each layer will be changed so I can get the inference result output_data. But when the python script execution ends, these tensors will be restored to original states which are saved in the model file.
What I want is to save the invoked tensor states into model file and override the original tensors. Is there any way to achieve this?
Best,
Simon