Hi,
I’m following 自定义算子 | TensorFlow Lite to create a custom operator (to use it on a micocontroller) which can be supported by Tensorflow Lite. For the sine operator the tutorial uses
converter = tf.lite.TFLiteConverter.from_concrete_functions([sin.get_concrete_function(x)])
converter.allow_custom_ops = True
tflite_model = converter.convert()
Does this snippet of code allow you to convert the entire model which uses sine op, right?
Hi @Gianni_Rossi ,
For the function from_concrete_functions
, along with sin.get_concrete_function(x)
you need to pass defined sine function. Please see the modified code snippet for conversion .
# Convert the model to TensorFlow Lite
converter = tf.lite.TFLiteConverter.from_concrete_functions([my_function.get_concrete_function(tf.constant(x, dtype=tf.float32))], my_function)
converter.allow_custom_ops = True
tflite_model = converter.convert()
Also find the complete code in the gist for custom sine operator conversion