chunit-quic commented on code in PR #13212: URL: https://github.com/apache/tvm/pull/13212#discussion_r1145618964
########## tests/python/contrib/test_ethosu/test_pass_operations_distribution.py: ########## @@ -0,0 +1,87 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +from tvm.relay.analysis.operations_distribution import analyze_operations_distribution +from tvm.relay.transform.suffixes import tag_suffixes +from . import infra +import pytest +import numpy as np + + +def test_operations_distribution(): + + tflite = pytest.importorskip("tflite") + tensorflow = pytest.importorskip("tensorflow") + pytest.importorskip("ethosu.vela") + + import tensorflow as tf + + inp = (224, 224, 9) + input_shape = (1, *inp) + kernel_shape = (3, 3) + padding = (1, 1, 1, 1) + padding_out = (1, 33, 33, 1) + + @tf.function + def simple_net(x): + weight_shape = [kernel_shape[0], kernel_shape[1], input_shape[3], 3] + weights = tf.constant(np.random.uniform(size=weight_shape), dtype=tf.float32) + op = tf.nn.conv2d( + x, + filters=weights, + strides=1, + padding="SAME", + data_format="NHWC", + dilations=1, + ) + op = tf.pad( + op, + [[0, 0], [padding[0], padding_out[2]], [padding_out[1], padding[3]], [0, 0]], + "CONSTANT", + ) + op = tf.pad( + op, + [[0, 0], [padding[0], padding[2]], [padding[1], padding[3]], [0, 0]], + "CONSTANT", + ) + return tf.pad( + op, + [[0, 0], [padding_out[0], padding[2]], [padding[1], padding_out[3]], [0, 0]], + "CONSTANT", + ) + + from tests.python.contrib.test_ethosu.infra import get_tflite_graph Review Comment: Perhaps it might be good to add this try catch for tflite import in infra.py: ```python # Get TFLite model from buffer try: import tflite tflite_model = tflite.Model.GetRootAsModel([tflite_model_buf], 0) except AttributeError: import tflite.Model tflite_model = tflite.Model.Model.GetRootAsModel([tflite_model_buf], 0) ```` https://tvm.apache.org/docs/how_to/compile_models/from_tflite.html#load-pretrained-tflite-model -- 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]
