class_docstr: Creates TFLite Model and facilitates reference data generation
class_docstr_tok: ["Creates","TFLite","Model","and","facilitates","reference","data","generation"]
docstr: Creates TFLite serial graph
docstr_tok: ["Creates","TFLite","serial","graph"]
code: def create_tflite_model(self, tfl_function, shapes, ranges=None):
      """Creates TFLite serial graph"""
      tensor_specs = []
      for i, shape in enumerate(shapes):
          input_name = "input_" + str(i)
          self.shape_dict.update({input_name: shape})
          self.dtype_dict.update({input_name: self.dtype})
          tensor_specs.append(
              tf.TensorSpec(shape, dtype=tf.float32, name=input_name)
          )
      concrete_func = tfl_function.get_concrete_function(*tensor_specs)
  
      if not ranges:
          ranges = [(0, 1) for _ in shapes]
  
      def representative_dataset():
          for _ in range(100):
              inputs = []
              for i, shape in enumerate(shapes):
                  data = np.random.uniform(
                      low=ranges[i][0],
                      high=ranges[i][1],
                      size=tuple(shape),
                  ).astype("float32")
                  inputs.append(data)
  
              yield inputs
  
      converter = tf.lite.TFLiteConverter.from_concrete_functions(
          [concrete_func]
      )
      converter.optimizations = [tf.lite.Optimize.DEFAULT]
      converter.representative_dataset = representative_dataset
      converter.target_spec.supported_ops = [
          tf.lite.OpsSet.TFLITE_BUILTINS_INT8
      ]
      converter.inference_input_type = tf.int8
      converter.inference_output_type = tf.int8
      self.serial_model = converter.convert()
  
file_path: tvm/python/tvm/relay/testing/tflite.py
imports: from distutils.version import LooseVersion
  import numpy
  import pytest
  import tflite.Model
  import tensorflow
  import tvm
label_desc: Use image node_id 4 for calling the TFLiteModel obj's underlying member method code with example usage: obj.create_tflite_model(tfl_function, shapes, ranges) without return types