-
Notifications
You must be signed in to change notification settings - Fork 157
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
[recipe] Add recipe for Decomposed GRU #13649
base: master
Are you sure you want to change the base?
Conversation
This pr adds recipe for decomposed GRU. ONE-DCO-1.0-Signed-off-by: Artem Balyshev <[email protected]>
For generation I used the following python script to get tflite model import tensorflow as tf
from tensorflow import keras
import numpy as np
activation = 'tanh'
model = tf.keras.models.Sequential([
tf.keras.Input(shape=(1,2)),
tf.keras.layers.GRU(units=1, activation=activation, return_sequences=False, time_major=True),
])
model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=0.001))
model.summary()
run_model = tf.function(lambda x: model(x))
# This is important, let's fix the input size.
BATCH_SIZE = 1
X = 1
Y = 2
concrete_func = run_model.get_concrete_function(
tf.TensorSpec([BATCH_SIZE, X,Y], model.inputs[0].dtype))
# model directory.
MODEL_DIR = "keras_model"
model.save(MODEL_DIR, save_format="tf", signatures=concrete_func)
converter = tf.lite.TFLiteConverter.from_saved_model(MODEL_DIR)
converter.experimental_new_converter = True
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS,
]
converted_model = converter.convert()
save_to = "my_gru.tflite"
if save_to is not None:
with open(save_to, 'wb') as tf_lite_file:
tf_lite_file.write(converted_model)
To obtain result recipe I used |
#13602 failed with CI pass. I need that OK. |
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.
LGTM
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.
This pr adds recipe for decomposed GRU.
from #13602
ONE-DCO-1.0-Signed-off-by: Artem Balyshev [email protected]