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

[recipe] Add recipe for Decomposed GRU #13649

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BalyshevArtem
Copy link
Contributor

This pr adds recipe for decomposed GRU.

from #13602

ONE-DCO-1.0-Signed-off-by: Artem Balyshev [email protected]

This pr adds recipe for decomposed GRU.

ONE-DCO-1.0-Signed-off-by: Artem Balyshev <[email protected]>
@BalyshevArtem BalyshevArtem added the approval: 2 Require at least 2 approvals label Aug 12, 2024
@BalyshevArtem
Copy link
Contributor Author

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 ./tflchef-reverse

@BalyshevArtem BalyshevArtem changed the title [recipe] Add recipe for Decomposed GRU. [recipe] Add recipe for Decomposed GRU Aug 12, 2024
@seanshpark
Copy link
Contributor

#13602 failed with CI pass. I need that OK.
there is no dredd test. plz add test.rule file too.

Copy link
Contributor

@SlavikMIPT SlavikMIPT left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@seanshpark seanshpark left a comment

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: 2 Require at least 2 approvals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants