arina-grovety commented on code in PR #13212:
URL: https://github.com/apache/tvm/pull/13212#discussion_r1084048146
##########
tests/python/driver/tvmc/test_compiler.py:
##########
@@ -48,6 +51,144 @@ def test_save_dumps(tmpdir_factory):
assert path.exists("{}/{}".format(tmpdir, "fake_module.relay"))
+def test_save_dump_offloads_ethosu(tmp_path_factory):
+ def representative_dataset_random_gen():
+ np.random.seed(0)
+ data = np.random.random_sample(input_shape)
+ yield [data.astype(np.float32)]
+
+ tflite = pytest.importorskip("tflite")
+ tensorflow = pytest.importorskip("tensorflow")
+ pytest.importorskip("ethosu.vela")
+
+ from tensorflow.keras import layers
+ from tensorflow.keras.models import Model
+ from tvm.driver.tvmc.model import TVMCModel
+
+ inp = (224, 224, 8)
+ input_shape = (1, *inp)
+
+ inputs = layers.Input(shape=inp)
+ conv_1 = layers.Conv2D(32, (3, 3), padding="same", strides=2)(inputs)
+ dns_1 = layers.Dense(12, activation="linear")(conv_1)
+ outputs = layers.ZeroPadding2D()(dns_1)
+
+ tf_model = Model(inputs, outputs)
+
+ converter = tensorflow.lite.TFLiteConverter.from_keras_model(tf_model)
+ converter.optimizations = [tensorflow.lite.Optimize.DEFAULT]
+ converter.representative_dataset = representative_dataset_random_gen
+ converter.target_spec.supported_ops =
[tensorflow.lite.OpsSet.TFLITE_BUILTINS_INT8]
+ converter.inference_input_type = tensorflow.int8
+ converter.inference_output_type = tensorflow.int8
+ tflite_model_buf = converter.convert()
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]