google-coral / tflite

Examples using TensorFlow Lite API to run inference on Coral devices
https://coral.withgoogle.com
Apache License 2.0
182 stars 68 forks source link

Wierd Javascript error when converting TF model to #43

Closed Songyun-Tao closed 3 years ago

Songyun-Tao commented 3 years ago

HI, I tried to convert my pytorch model to a deployable tflite model on my coral edge TPU: My environment are: PyTorch: 1.7.1 Onnx: 1.8.0 Onnx_tf: 1.7.0 Tensorflow: 2.3.0 Python: 3.8.5 Desktop: Ubuntu 20.04 Jupyter Lab: 3.0.1

And my torch model architecture is:

EncoderDecoder(
  (encoder): ResNet(
    (conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)
    (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
    (relu): ReLU(inplace=True)
    (maxpool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
    (layer1): Sequential(
      (0): BasicBlock(
        (conv1): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (relu): ReLU(inplace=True)
        (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      )
      (1): BasicBlock(
        (conv1): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (relu): ReLU(inplace=True)
        (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      )
      (2): BasicBlock(
        (conv1): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (relu): ReLU(inplace=True)
        (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      )
    )
    (layer2): Sequential(
      (0): BasicBlock(
        (conv1): Conv2d(64, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
        (bn1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (relu): ReLU(inplace=True)
        (conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn2): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (downsample): Sequential(
          (0): Conv2d(64, 128, kernel_size=(1, 1), stride=(2, 2), bias=False)
          (1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        )
      )
      (1): BasicBlock(
        (conv1): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (relu): ReLU(inplace=True)
        (conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn2): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      )
      (2): BasicBlock(
        (conv1): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (relu): ReLU(inplace=True)
        (conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn2): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      )
      (3): BasicBlock(
        (conv1): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (relu): ReLU(inplace=True)
        (conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn2): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      )
    )
    (layer3): Sequential(
      (0): BasicBlock(
        (conv1): Conv2d(128, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
        (bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (relu): ReLU(inplace=True)
        (conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (downsample): Sequential(
          (0): Conv2d(128, 256, kernel_size=(1, 1), stride=(2, 2), bias=False)
          (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        )
      )
      (1): BasicBlock(
        (conv1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (relu): ReLU(inplace=True)
        (conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      )
      (2): BasicBlock(
        (conv1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (relu): ReLU(inplace=True)
        (conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      )
      (3): BasicBlock(
        (conv1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (relu): ReLU(inplace=True)
        (conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      )
      (4): BasicBlock(
        (conv1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (relu): ReLU(inplace=True)
        (conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      )
      (5): BasicBlock(
        (conv1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (relu): ReLU(inplace=True)
        (conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      )
    )
    (layer4): Sequential(
      (0): BasicBlock(
        (conv1): Conv2d(256, 512, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
        (bn1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (relu): ReLU(inplace=True)
        (conv2): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn2): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (downsample): Sequential(
          (0): Conv2d(256, 512, kernel_size=(1, 1), stride=(2, 2), bias=False)
          (1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        )
      )
      (1): BasicBlock(
        (conv1): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (relu): ReLU(inplace=True)
        (conv2): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn2): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      )
      (2): BasicBlock(
        (conv1): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        (relu): ReLU(inplace=True)
        (conv2): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
        (bn2): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      )
    )
  )
  (decoder): CatLinear(
    (avgpool): AdaptiveAvgPool2d(output_size=(1, 1))
    (dropout): Dropout(p=0.5, inplace=False)
    (fc1): Linear(in_features=512, out_features=55, bias=True)
  )
  (criterion): SmoothL1Loss()
)

I followed the instructions and I successfully converted from torch to onnx and to tensorflow. However, when it comes to the tflite model, I met some problem. The first method is:

def representative_dataset():
    for _ in range(100):
      data = np_input
      yield [data.astype(np.float32)]

converter = tf.lite.TFLiteConverter.from_saved_model(tfpath)
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  # or tf.uint8
converter.inference_output_type = tf.int8 
tflite_model = converter.convert()
open("test.tflite", "wb").write(tflite_model)

During the conversion, the page froze and evetually gave me an error: Javascript Error: too much recurtion I also tried run a python script instead of in a Jupyter notebook, the terminal output seems indicate a successful conversion, but there is no tflite file generated. The output is:

  %0 = "tfl.pad"(%arg0, %cst) : (tensor<1x3x960x360xf32>, tensor<4x2xi32>) -> tensor<1x3x966x366xf32>
  %1 = "tfl.transpose"(%0, %cst_5) : (tensor<1x3x966x366xf32>, tensor<4xi32>) -> tensor<1x966x366x3xf32>
  %2 = "tfl.split"(%cst_4, %1) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x966x366x3xf32>) -> tensor<1x966x366x3xf32>
  %3 = "tfl.conv_2d"(%2, %cst_12, %cst_48) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "RELU", padding = "VALID", stride_h = 2 : i32, stride_w = 2 : i32} : (tensor<1x966x366x3xf32>, tensor<64x7x7x3xf32>, tensor<64xf32>) -> tensor<1x480x180x64xf32>
  %4 = "tfl.transpose"(%3, %cst_6) : (tensor<1x480x180x64xf32>, tensor<4xi32>) -> tensor<1x64x480x180xf32>
  %5 = "tfl.pad"(%4, %cst_0) : (tensor<1x64x480x180xf32>, tensor<4x2xi32>) -> tensor<1x64x482x182xf32>
  %6 = "tfl.transpose"(%5, %cst_5) : (tensor<1x64x482x182xf32>, tensor<4xi32>) -> tensor<1x482x182x64xf32>
  %7 = "tfl.split"(%cst_4, %6) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x482x182x64xf32>) -> tensor<1x482x182x64xf32>
  %8 = "tfl.conv_2d"(%7, %cst_13, %cst_49) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "RELU", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x482x182x64xf32>, tensor<64x3x3x64xf32>, tensor<64xf32>) -> tensor<1x480x180x64xf32>
  %9 = "tfl.transpose"(%8, %cst_6) : (tensor<1x480x180x64xf32>, tensor<4xi32>) -> tensor<1x64x480x180xf32>
  %10 = "tfl.pad"(%9, %cst_0) : (tensor<1x64x480x180xf32>, tensor<4x2xi32>) -> tensor<1x64x482x182xf32>
  %11 = "tfl.transpose"(%10, %cst_5) : (tensor<1x64x482x182xf32>, tensor<4xi32>) -> tensor<1x482x182x64xf32>
  %12 = "tfl.split"(%cst_4, %11) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x482x182x64xf32>) -> tensor<1x482x182x64xf32>
  %13 = "tfl.conv_2d"(%12, %cst_14, %cst_50) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x482x182x64xf32>, tensor<64x3x3x64xf32>, tensor<64xf32>) -> tensor<1x480x180x64xf32>
  %14 = "tfl.transpose"(%13, %cst_6) : (tensor<1x480x180x64xf32>, tensor<4xi32>) -> tensor<1x64x480x180xf32>
  %15 = "tfl.add"(%14, %4) {fused_activation_function = "RELU"} : (tensor<1x64x480x180xf32>, tensor<1x64x480x180xf32>) -> tensor<1x64x480x180xf32>
  %16 = "tfl.pad"(%15, %cst_0) : (tensor<1x64x480x180xf32>, tensor<4x2xi32>) -> tensor<1x64x482x182xf32>
  %17 = "tfl.transpose"(%16, %cst_5) : (tensor<1x64x482x182xf32>, tensor<4xi32>) -> tensor<1x482x182x64xf32>
  %18 = "tfl.split"(%cst_4, %17) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x482x182x64xf32>) -> tensor<1x482x182x64xf32>
  %19 = "tfl.conv_2d"(%18, %cst_15, %cst_51) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "RELU", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x482x182x64xf32>, tensor<64x3x3x64xf32>, tensor<64xf32>) -> tensor<1x480x180x64xf32>
  %20 = "tfl.transpose"(%19, %cst_6) : (tensor<1x480x180x64xf32>, tensor<4xi32>) -> tensor<1x64x480x180xf32>
  %21 = "tfl.pad"(%20, %cst_0) : (tensor<1x64x480x180xf32>, tensor<4x2xi32>) -> tensor<1x64x482x182xf32>
  %22 = "tfl.transpose"(%21, %cst_5) : (tensor<1x64x482x182xf32>, tensor<4xi32>) -> tensor<1x482x182x64xf32>
  %23 = "tfl.split"(%cst_4, %22) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x482x182x64xf32>) -> tensor<1x482x182x64xf32>
  %24 = "tfl.gather"(%cst_1, %cst_52) {axis = 0 : i32} : (tensor<4xi64>, tensor<0xi64>) -> tensor<0xi64>
  %25 = "tfl.sparse_to_dense"(%cst_11, %cst_2, %24, %cst_7) : (tensor<0x1xi64>, tensor<1xi64>, tensor<0xi64>, tensor<i64>) -> tensor<2xi64>
  %26 = "tf.AddV2"(%25, %cst_10) {device = ""} : (tensor<2xi64>, tensor<2xi64>) -> tensor<2xi64>
  %27 = "tfl.conv_2d"(%23, %cst_16, %cst_53) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x482x182x64xf32>, tensor<64x3x3x64xf32>, tensor<64xf32>) -> tensor<1x480x180x64xf32>
  %28 = "tfl.transpose"(%27, %cst_6) : (tensor<1x480x180x64xf32>, tensor<4xi32>) -> tensor<1x64x480x180xf32>
  %29 = "tfl.add"(%28, %15) {fused_activation_function = "RELU"} : (tensor<1x64x480x180xf32>, tensor<1x64x480x180xf32>) -> tensor<1x64x480x180xf32>
  %30 = "tfl.pad"(%29, %cst_0) : (tensor<1x64x480x180xf32>, tensor<4x2xi32>) -> tensor<1x64x482x182xf32>
  %31 = "tfl.transpose"(%30, %cst_5) : (tensor<1x64x482x182xf32>, tensor<4xi32>) -> tensor<1x482x182x64xf32>
  %32 = "tfl.split"(%cst_4, %31) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x482x182x64xf32>) -> tensor<1x482x182x64xf32>
  %33 = "tfl.conv_2d"(%32, %cst_17, %cst_54) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "RELU", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x482x182x64xf32>, tensor<64x3x3x64xf32>, tensor<64xf32>) -> tensor<1x480x180x64xf32>
  %34 = "tfl.transpose"(%33, %cst_6) : (tensor<1x480x180x64xf32>, tensor<4xi32>) -> tensor<1x64x480x180xf32>
  %35 = "tfl.pad"(%34, %cst_0) : (tensor<1x64x480x180xf32>, tensor<4x2xi32>) -> tensor<1x64x482x182xf32>
  %36 = "tfl.transpose"(%35, %cst_5) : (tensor<1x64x482x182xf32>, tensor<4xi32>) -> tensor<1x482x182x64xf32>
  %37 = "tfl.split"(%cst_4, %36) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x482x182x64xf32>) -> tensor<1x482x182x64xf32>
  %38 = "tfl.conv_2d"(%37, %cst_18, %cst_55) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x482x182x64xf32>, tensor<64x3x3x64xf32>, tensor<64xf32>) -> tensor<1x480x180x64xf32>
  %39 = "tfl.transpose"(%38, %cst_6) : (tensor<1x480x180x64xf32>, tensor<4xi32>) -> tensor<1x64x480x180xf32>
  %40 = "tfl.add"(%39, %29) {fused_activation_function = "RELU"} : (tensor<1x64x480x180xf32>, tensor<1x64x480x180xf32>) -> tensor<1x64x480x180xf32>
  %41 = "tfl.pad"(%40, %cst_0) : (tensor<1x64x480x180xf32>, tensor<4x2xi32>) -> tensor<1x64x482x182xf32>
  %42 = "tfl.transpose"(%41, %cst_5) : (tensor<1x64x482x182xf32>, tensor<4xi32>) -> tensor<1x482x182x64xf32>
  %43 = "tfl.split"(%cst_4, %42) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x482x182x64xf32>) -> tensor<1x482x182x64xf32>
  %44 = "tfl.conv_2d"(%43, %cst_19, %cst_56) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "RELU", padding = "VALID", stride_h = 2 : i32, stride_w = 2 : i32} : (tensor<1x482x182x64xf32>, tensor<128x3x3x64xf32>, tensor<128xf32>) -> tensor<1x240x90x128xf32>
  %45 = "tfl.transpose"(%44, %cst_6) : (tensor<1x240x90x128xf32>, tensor<4xi32>) -> tensor<1x128x240x90xf32>
  %46 = "tfl.pad"(%45, %cst_0) : (tensor<1x128x240x90xf32>, tensor<4x2xi32>) -> tensor<1x128x242x92xf32>
  %47 = "tfl.transpose"(%46, %cst_5) : (tensor<1x128x242x92xf32>, tensor<4xi32>) -> tensor<1x242x92x128xf32>
  %48 = "tfl.split"(%cst_4, %47) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x242x92x128xf32>) -> tensor<1x242x92x128xf32>
  %49 = "tfl.conv_2d"(%48, %cst_20, %cst_57) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x242x92x128xf32>, tensor<128x3x3x128xf32>, tensor<128xf32>) -> tensor<1x240x90x128xf32>
  %50 = "tfl.transpose"(%49, %cst_6) : (tensor<1x240x90x128xf32>, tensor<4xi32>) -> tensor<1x128x240x90xf32>
  %51 = "tfl.transpose"(%40, %cst_5) : (tensor<1x64x480x180xf32>, tensor<4xi32>) -> tensor<1x480x180x64xf32>
  %52 = "tfl.split"(%cst_4, %51) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x480x180x64xf32>) -> tensor<1x480x180x64xf32>
  %53 = "tfl.conv_2d"(%52, %cst_21, %cst_58) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 2 : i32, stride_w = 2 : i32} : (tensor<1x480x180x64xf32>, tensor<128x1x1x64xf32>, tensor<128xf32>) -> tensor<1x240x90x128xf32>
  %54 = "tfl.transpose"(%53, %cst_6) : (tensor<1x240x90x128xf32>, tensor<4xi32>) -> tensor<1x128x240x90xf32>
  %55 = "tfl.add"(%50, %54) {fused_activation_function = "RELU"} : (tensor<1x128x240x90xf32>, tensor<1x128x240x90xf32>) -> tensor<1x128x240x90xf32>
  %56 = "tfl.pad"(%55, %cst_0) : (tensor<1x128x240x90xf32>, tensor<4x2xi32>) -> tensor<1x128x242x92xf32>
  %57 = "tfl.transpose"(%56, %cst_5) : (tensor<1x128x242x92xf32>, tensor<4xi32>) -> tensor<1x242x92x128xf32>
  %58 = "tfl.split"(%cst_4, %57) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x242x92x128xf32>) -> tensor<1x242x92x128xf32>
  %59 = "tfl.conv_2d"(%58, %cst_22, %cst_59) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "RELU", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x242x92x128xf32>, tensor<128x3x3x128xf32>, tensor<128xf32>) -> tensor<1x240x90x128xf32>
  %60 = "tfl.transpose"(%59, %cst_6) : (tensor<1x240x90x128xf32>, tensor<4xi32>) -> tensor<1x128x240x90xf32>
  %61 = "tfl.pad"(%60, %cst_0) : (tensor<1x128x240x90xf32>, tensor<4x2xi32>) -> tensor<1x128x242x92xf32>
  %62 = "tfl.transpose"(%61, %cst_5) : (tensor<1x128x242x92xf32>, tensor<4xi32>) -> tensor<1x242x92x128xf32>
  %63 = "tfl.split"(%cst_4, %62) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x242x92x128xf32>) -> tensor<1x242x92x128xf32>
  %64 = "tfl.conv_2d"(%63, %cst_23, %cst_60) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x242x92x128xf32>, tensor<128x3x3x128xf32>, tensor<128xf32>) -> tensor<1x240x90x128xf32>
  %65 = "tfl.transpose"(%64, %cst_6) : (tensor<1x240x90x128xf32>, tensor<4xi32>) -> tensor<1x128x240x90xf32>
  %66 = "tfl.add"(%65, %55) {fused_activation_function = "RELU"} : (tensor<1x128x240x90xf32>, tensor<1x128x240x90xf32>) -> tensor<1x128x240x90xf32>
  %67 = "tfl.pad"(%66, %cst_0) : (tensor<1x128x240x90xf32>, tensor<4x2xi32>) -> tensor<1x128x242x92xf32>
  %68 = "tfl.transpose"(%67, %cst_5) : (tensor<1x128x242x92xf32>, tensor<4xi32>) -> tensor<1x242x92x128xf32>
  %69 = "tfl.split"(%cst_4, %68) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x242x92x128xf32>) -> tensor<1x242x92x128xf32>
  %70 = "tfl.conv_2d"(%69, %cst_24, %cst_61) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "RELU", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x242x92x128xf32>, tensor<128x3x3x128xf32>, tensor<128xf32>) -> tensor<1x240x90x128xf32>
  %71 = "tfl.transpose"(%70, %cst_6) : (tensor<1x240x90x128xf32>, tensor<4xi32>) -> tensor<1x128x240x90xf32>
  %72 = "tfl.pad"(%71, %cst_0) : (tensor<1x128x240x90xf32>, tensor<4x2xi32>) -> tensor<1x128x242x92xf32>
  %73 = "tfl.transpose"(%72, %cst_5) : (tensor<1x128x242x92xf32>, tensor<4xi32>) -> tensor<1x242x92x128xf32>
  %74 = "tfl.split"(%cst_4, %73) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x242x92x128xf32>) -> tensor<1x242x92x128xf32>
  %75 = "tfl.conv_2d"(%74, %cst_25, %cst_62) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x242x92x128xf32>, tensor<128x3x3x128xf32>, tensor<128xf32>) -> tensor<1x240x90x128xf32>
  %76 = "tfl.transpose"(%75, %cst_6) : (tensor<1x240x90x128xf32>, tensor<4xi32>) -> tensor<1x128x240x90xf32>
  %77 = "tfl.add"(%76, %66) {fused_activation_function = "RELU"} : (tensor<1x128x240x90xf32>, tensor<1x128x240x90xf32>) -> tensor<1x128x240x90xf32>
  %78 = "tfl.pad"(%77, %cst_0) : (tensor<1x128x240x90xf32>, tensor<4x2xi32>) -> tensor<1x128x242x92xf32>
  %79 = "tfl.transpose"(%78, %cst_5) : (tensor<1x128x242x92xf32>, tensor<4xi32>) -> tensor<1x242x92x128xf32>
  %80 = "tfl.split"(%cst_4, %79) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x242x92x128xf32>) -> tensor<1x242x92x128xf32>
  %81 = "tfl.conv_2d"(%80, %cst_26, %cst_63) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "RELU", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x242x92x128xf32>, tensor<128x3x3x128xf32>, tensor<128xf32>) -> tensor<1x240x90x128xf32>
  %82 = "tfl.transpose"(%81, %cst_6) : (tensor<1x240x90x128xf32>, tensor<4xi32>) -> tensor<1x128x240x90xf32>
  %83 = "tfl.pad"(%82, %cst_0) : (tensor<1x128x240x90xf32>, tensor<4x2xi32>) -> tensor<1x128x242x92xf32>
  %84 = "tfl.transpose"(%83, %cst_5) : (tensor<1x128x242x92xf32>, tensor<4xi32>) -> tensor<1x242x92x128xf32>
  %85 = "tfl.split"(%cst_4, %84) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x242x92x128xf32>) -> tensor<1x242x92x128xf32>
  %86 = "tfl.conv_2d"(%85, %cst_27, %cst_64) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x242x92x128xf32>, tensor<128x3x3x128xf32>, tensor<128xf32>) -> tensor<1x240x90x128xf32>
  %87 = "tfl.transpose"(%86, %cst_6) : (tensor<1x240x90x128xf32>, tensor<4xi32>) -> tensor<1x128x240x90xf32>
  %88 = "tfl.add"(%87, %77) {fused_activation_function = "RELU"} : (tensor<1x128x240x90xf32>, tensor<1x128x240x90xf32>) -> tensor<1x128x240x90xf32>
  %89 = "tfl.pad"(%88, %cst_0) : (tensor<1x128x240x90xf32>, tensor<4x2xi32>) -> tensor<1x128x242x92xf32>
  %90 = "tfl.transpose"(%89, %cst_5) : (tensor<1x128x242x92xf32>, tensor<4xi32>) -> tensor<1x242x92x128xf32>
  %91 = "tfl.split"(%cst_4, %90) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x242x92x128xf32>) -> tensor<1x242x92x128xf32>
  %92 = "tfl.conv_2d"(%91, %cst_28, %cst_65) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "RELU", padding = "VALID", stride_h = 2 : i32, stride_w = 2 : i32} : (tensor<1x242x92x128xf32>, tensor<256x3x3x128xf32>, tensor<256xf32>) -> tensor<1x120x45x256xf32>
  %93 = "tfl.transpose"(%92, %cst_6) : (tensor<1x120x45x256xf32>, tensor<4xi32>) -> tensor<1x256x120x45xf32>
  %94 = "tfl.pad"(%93, %cst_0) : (tensor<1x256x120x45xf32>, tensor<4x2xi32>) -> tensor<1x256x122x47xf32>
  %95 = "tfl.transpose"(%94, %cst_5) : (tensor<1x256x122x47xf32>, tensor<4xi32>) -> tensor<1x122x47x256xf32>
  %96 = "tfl.split"(%cst_4, %95) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x122x47x256xf32>) -> tensor<1x122x47x256xf32>
  %97 = "tfl.conv_2d"(%96, %cst_29, %cst_66) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x122x47x256xf32>, tensor<256x3x3x256xf32>, tensor<256xf32>) -> tensor<1x120x45x256xf32>
  %98 = "tfl.transpose"(%97, %cst_6) : (tensor<1x120x45x256xf32>, tensor<4xi32>) -> tensor<1x256x120x45xf32>
  %99 = "tfl.transpose"(%88, %cst_5) : (tensor<1x128x240x90xf32>, tensor<4xi32>) -> tensor<1x240x90x128xf32>
  %100 = "tfl.split"(%cst_4, %99) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x240x90x128xf32>) -> tensor<1x240x90x128xf32>
  %101 = "tfl.conv_2d"(%100, %cst_30, %cst_67) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 2 : i32, stride_w = 2 : i32} : (tensor<1x240x90x128xf32>, tensor<256x1x1x128xf32>, tensor<256xf32>) -> tensor<1x120x45x256xf32>
  %102 = "tfl.transpose"(%101, %cst_6) : (tensor<1x120x45x256xf32>, tensor<4xi32>) -> tensor<1x256x120x45xf32>
  %103 = "tfl.add"(%98, %102) {fused_activation_function = "RELU"} : (tensor<1x256x120x45xf32>, tensor<1x256x120x45xf32>) -> tensor<1x256x120x45xf32>
  %104 = "tfl.pad"(%103, %cst_0) : (tensor<1x256x120x45xf32>, tensor<4x2xi32>) -> tensor<1x256x122x47xf32>
  %105 = "tfl.transpose"(%104, %cst_5) : (tensor<1x256x122x47xf32>, tensor<4xi32>) -> tensor<1x122x47x256xf32>
  %106 = "tfl.split"(%cst_4, %105) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x122x47x256xf32>) -> tensor<1x122x47x256xf32>
  %107 = "tfl.conv_2d"(%106, %cst_31, %cst_68) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "RELU", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x122x47x256xf32>, tensor<256x3x3x256xf32>, tensor<256xf32>) -> tensor<1x120x45x256xf32>
  %108 = "tfl.transpose"(%107, %cst_6) : (tensor<1x120x45x256xf32>, tensor<4xi32>) -> tensor<1x256x120x45xf32>
  %109 = "tfl.pad"(%108, %cst_0) : (tensor<1x256x120x45xf32>, tensor<4x2xi32>) -> tensor<1x256x122x47xf32>
  %110 = "tfl.transpose"(%109, %cst_5) : (tensor<1x256x122x47xf32>, tensor<4xi32>) -> tensor<1x122x47x256xf32>
  %111 = "tfl.split"(%cst_4, %110) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x122x47x256xf32>) -> tensor<1x122x47x256xf32>
  %112 = "tfl.conv_2d"(%111, %cst_32, %cst_69) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x122x47x256xf32>, tensor<256x3x3x256xf32>, tensor<256xf32>) -> tensor<1x120x45x256xf32>
  %113 = "tfl.transpose"(%112, %cst_6) : (tensor<1x120x45x256xf32>, tensor<4xi32>) -> tensor<1x256x120x45xf32>
  %114 = "tfl.add"(%113, %103) {fused_activation_function = "RELU"} : (tensor<1x256x120x45xf32>, tensor<1x256x120x45xf32>) -> tensor<1x256x120x45xf32>
  %115 = "tfl.pad"(%114, %cst_0) : (tensor<1x256x120x45xf32>, tensor<4x2xi32>) -> tensor<1x256x122x47xf32>
  %116 = "tfl.transpose"(%115, %cst_5) : (tensor<1x256x122x47xf32>, tensor<4xi32>) -> tensor<1x122x47x256xf32>
  %117 = "tfl.split"(%cst_4, %116) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x122x47x256xf32>) -> tensor<1x122x47x256xf32>
  %118 = "tfl.conv_2d"(%117, %cst_33, %cst_70) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "RELU", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x122x47x256xf32>, tensor<256x3x3x256xf32>, tensor<256xf32>) -> tensor<1x120x45x256xf32>
  %119 = "tfl.transpose"(%118, %cst_6) : (tensor<1x120x45x256xf32>, tensor<4xi32>) -> tensor<1x256x120x45xf32>
  %120 = "tfl.pad"(%119, %cst_0) : (tensor<1x256x120x45xf32>, tensor<4x2xi32>) -> tensor<1x256x122x47xf32>
  %121 = "tfl.transpose"(%120, %cst_5) : (tensor<1x256x122x47xf32>, tensor<4xi32>) -> tensor<1x122x47x256xf32>
  %122 = "tfl.split"(%cst_4, %121) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x122x47x256xf32>) -> tensor<1x122x47x256xf32>
  %123 = "tfl.conv_2d"(%122, %cst_34, %cst_71) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x122x47x256xf32>, tensor<256x3x3x256xf32>, tensor<256xf32>) -> tensor<1x120x45x256xf32>
  %124 = "tfl.transpose"(%123, %cst_6) : (tensor<1x120x45x256xf32>, tensor<4xi32>) -> tensor<1x256x120x45xf32>
  %125 = "tfl.add"(%124, %114) {fused_activation_function = "RELU"} : (tensor<1x256x120x45xf32>, tensor<1x256x120x45xf32>) -> tensor<1x256x120x45xf32>
  %126 = "tfl.pad"(%125, %cst_0) : (tensor<1x256x120x45xf32>, tensor<4x2xi32>) -> tensor<1x256x122x47xf32>
  %127 = "tfl.transpose"(%126, %cst_5) : (tensor<1x256x122x47xf32>, tensor<4xi32>) -> tensor<1x122x47x256xf32>
  %128 = "tfl.split"(%cst_4, %127) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x122x47x256xf32>) -> tensor<1x122x47x256xf32>
  %129 = "tfl.conv_2d"(%128, %cst_35, %cst_72) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "RELU", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x122x47x256xf32>, tensor<256x3x3x256xf32>, tensor<256xf32>) -> tensor<1x120x45x256xf32>
  %130 = "tfl.transpose"(%129, %cst_6) : (tensor<1x120x45x256xf32>, tensor<4xi32>) -> tensor<1x256x120x45xf32>
  %131 = "tfl.pad"(%130, %cst_0) : (tensor<1x256x120x45xf32>, tensor<4x2xi32>) -> tensor<1x256x122x47xf32>
  %132 = "tfl.transpose"(%131, %cst_5) : (tensor<1x256x122x47xf32>, tensor<4xi32>) -> tensor<1x122x47x256xf32>
  %133 = "tfl.split"(%cst_4, %132) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x122x47x256xf32>) -> tensor<1x122x47x256xf32>
  %134 = "tfl.conv_2d"(%133, %cst_36, %cst_73) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x122x47x256xf32>, tensor<256x3x3x256xf32>, tensor<256xf32>) -> tensor<1x120x45x256xf32>
  %135 = "tfl.transpose"(%134, %cst_6) : (tensor<1x120x45x256xf32>, tensor<4xi32>) -> tensor<1x256x120x45xf32>
  %136 = "tfl.add"(%135, %125) {fused_activation_function = "RELU"} : (tensor<1x256x120x45xf32>, tensor<1x256x120x45xf32>) -> tensor<1x256x120x45xf32>
  %137 = "tfl.pad"(%136, %cst_0) : (tensor<1x256x120x45xf32>, tensor<4x2xi32>) -> tensor<1x256x122x47xf32>
  %138 = "tfl.transpose"(%137, %cst_5) : (tensor<1x256x122x47xf32>, tensor<4xi32>) -> tensor<1x122x47x256xf32>
  %139 = "tfl.split"(%cst_4, %138) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x122x47x256xf32>) -> tensor<1x122x47x256xf32>
  %140 = "tfl.conv_2d"(%139, %cst_37, %cst_74) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "RELU", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x122x47x256xf32>, tensor<256x3x3x256xf32>, tensor<256xf32>) -> tensor<1x120x45x256xf32>
  %141 = "tfl.transpose"(%140, %cst_6) : (tensor<1x120x45x256xf32>, tensor<4xi32>) -> tensor<1x256x120x45xf32>
  %142 = "tfl.pad"(%141, %cst_0) : (tensor<1x256x120x45xf32>, tensor<4x2xi32>) -> tensor<1x256x122x47xf32>
  %143 = "tfl.transpose"(%142, %cst_5) : (tensor<1x256x122x47xf32>, tensor<4xi32>) -> tensor<1x122x47x256xf32>
  %144 = "tfl.split"(%cst_4, %143) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x122x47x256xf32>) -> tensor<1x122x47x256xf32>
  %145 = "tfl.conv_2d"(%144, %cst_38, %cst_75) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x122x47x256xf32>, tensor<256x3x3x256xf32>, tensor<256xf32>) -> tensor<1x120x45x256xf32>
  %146 = "tfl.transpose"(%145, %cst_6) : (tensor<1x120x45x256xf32>, tensor<4xi32>) -> tensor<1x256x120x45xf32>
  %147 = "tfl.add"(%146, %136) {fused_activation_function = "RELU"} : (tensor<1x256x120x45xf32>, tensor<1x256x120x45xf32>) -> tensor<1x256x120x45xf32>
  %148 = "tfl.pad"(%147, %cst_0) : (tensor<1x256x120x45xf32>, tensor<4x2xi32>) -> tensor<1x256x122x47xf32>
  %149 = "tfl.transpose"(%148, %cst_5) : (tensor<1x256x122x47xf32>, tensor<4xi32>) -> tensor<1x122x47x256xf32>
  %150 = "tfl.split"(%cst_4, %149) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x122x47x256xf32>) -> tensor<1x122x47x256xf32>
  %151 = "tfl.conv_2d"(%150, %cst_39, %cst_76) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "RELU", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x122x47x256xf32>, tensor<256x3x3x256xf32>, tensor<256xf32>) -> tensor<1x120x45x256xf32>
  %152 = "tfl.transpose"(%151, %cst_6) : (tensor<1x120x45x256xf32>, tensor<4xi32>) -> tensor<1x256x120x45xf32>
  %153 = "tfl.pad"(%152, %cst_0) : (tensor<1x256x120x45xf32>, tensor<4x2xi32>) -> tensor<1x256x122x47xf32>
  %154 = "tfl.transpose"(%153, %cst_5) : (tensor<1x256x122x47xf32>, tensor<4xi32>) -> tensor<1x122x47x256xf32>
  %155 = "tfl.split"(%cst_4, %154) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x122x47x256xf32>) -> tensor<1x122x47x256xf32>
  %156 = "tfl.conv_2d"(%155, %cst_40, %cst_77) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x122x47x256xf32>, tensor<256x3x3x256xf32>, tensor<256xf32>) -> tensor<1x120x45x256xf32>
  %157 = "tfl.transpose"(%156, %cst_6) : (tensor<1x120x45x256xf32>, tensor<4xi32>) -> tensor<1x256x120x45xf32>
  %158 = "tfl.add"(%157, %147) {fused_activation_function = "RELU"} : (tensor<1x256x120x45xf32>, tensor<1x256x120x45xf32>) -> tensor<1x256x120x45xf32>
  %159 = "tfl.pad"(%158, %cst_0) : (tensor<1x256x120x45xf32>, tensor<4x2xi32>) -> tensor<1x256x122x47xf32>
  %160 = "tfl.transpose"(%159, %cst_5) : (tensor<1x256x122x47xf32>, tensor<4xi32>) -> tensor<1x122x47x256xf32>
  %161 = "tfl.split"(%cst_4, %160) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x122x47x256xf32>) -> tensor<1x122x47x256xf32>
  %162 = "tfl.conv_2d"(%161, %cst_41, %cst_78) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "RELU", padding = "VALID", stride_h = 2 : i32, stride_w = 2 : i32} : (tensor<1x122x47x256xf32>, tensor<512x3x3x256xf32>, tensor<512xf32>) -> tensor<1x60x23x512xf32>
  %163 = "tfl.transpose"(%162, %cst_6) : (tensor<1x60x23x512xf32>, tensor<4xi32>) -> tensor<1x512x60x23xf32>
  %164 = "tfl.pad"(%163, %cst_0) : (tensor<1x512x60x23xf32>, tensor<4x2xi32>) -> tensor<1x512x62x25xf32>
  %165 = "tfl.transpose"(%164, %cst_5) : (tensor<1x512x62x25xf32>, tensor<4xi32>) -> tensor<1x62x25x512xf32>
  %166 = "tfl.split"(%cst_4, %165) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x62x25x512xf32>) -> tensor<1x62x25x512xf32>
  %167 = "tfl.conv_2d"(%166, %cst_42, %cst_79) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x62x25x512xf32>, tensor<512x3x3x512xf32>, tensor<512xf32>) -> tensor<1x60x23x512xf32>
  %168 = "tfl.transpose"(%167, %cst_6) : (tensor<1x60x23x512xf32>, tensor<4xi32>) -> tensor<1x512x60x23xf32>
  %169 = "tfl.transpose"(%158, %cst_5) : (tensor<1x256x120x45xf32>, tensor<4xi32>) -> tensor<1x120x45x256xf32>
  %170 = "tfl.split"(%cst_4, %169) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x120x45x256xf32>) -> tensor<1x120x45x256xf32>
  %171 = "tfl.conv_2d"(%170, %cst_43, %cst_80) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 2 : i32, stride_w = 2 : i32} : (tensor<1x120x45x256xf32>, tensor<512x1x1x256xf32>, tensor<512xf32>) -> tensor<1x60x23x512xf32>
  %172 = "tfl.transpose"(%171, %cst_6) : (tensor<1x60x23x512xf32>, tensor<4xi32>) -> tensor<1x512x60x23xf32>
  %173 = "tfl.add"(%168, %172) {fused_activation_function = "RELU"} : (tensor<1x512x60x23xf32>, tensor<1x512x60x23xf32>) -> tensor<1x512x60x23xf32>
  %174 = "tfl.pad"(%173, %cst_0) : (tensor<1x512x60x23xf32>, tensor<4x2xi32>) -> tensor<1x512x62x25xf32>
  %175 = "tfl.transpose"(%174, %cst_5) : (tensor<1x512x62x25xf32>, tensor<4xi32>) -> tensor<1x62x25x512xf32>
  %176 = "tfl.split"(%cst_4, %175) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x62x25x512xf32>) -> tensor<1x62x25x512xf32>
  %177 = "tfl.conv_2d"(%176, %cst_44, %cst_81) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "RELU", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x62x25x512xf32>, tensor<512x3x3x512xf32>, tensor<512xf32>) -> tensor<1x60x23x512xf32>
  %178 = "tfl.transpose"(%177, %cst_6) : (tensor<1x60x23x512xf32>, tensor<4xi32>) -> tensor<1x512x60x23xf32>
  %179 = "tfl.pad"(%178, %cst_0) : (tensor<1x512x60x23xf32>, tensor<4x2xi32>) -> tensor<1x512x62x25xf32>
  %180 = "tfl.transpose"(%179, %cst_5) : (tensor<1x512x62x25xf32>, tensor<4xi32>) -> tensor<1x62x25x512xf32>
  %181 = "tfl.split"(%cst_4, %180) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x62x25x512xf32>) -> tensor<1x62x25x512xf32>
  %182 = "tfl.conv_2d"(%181, %cst_45, %cst_82) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x62x25x512xf32>, tensor<512x3x3x512xf32>, tensor<512xf32>) -> tensor<1x60x23x512xf32>
  %183 = "tfl.transpose"(%182, %cst_6) : (tensor<1x60x23x512xf32>, tensor<4xi32>) -> tensor<1x512x60x23xf32>
  %184 = "tfl.add"(%183, %173) {fused_activation_function = "RELU"} : (tensor<1x512x60x23xf32>, tensor<1x512x60x23xf32>) -> tensor<1x512x60x23xf32>
  %185 = "tfl.pad"(%184, %cst_0) : (tensor<1x512x60x23xf32>, tensor<4x2xi32>) -> tensor<1x512x62x25xf32>
  %186 = "tfl.transpose"(%185, %cst_5) : (tensor<1x512x62x25xf32>, tensor<4xi32>) -> tensor<1x62x25x512xf32>
  %187 = "tfl.split"(%cst_4, %186) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x62x25x512xf32>) -> tensor<1x62x25x512xf32>
  %188 = "tfl.conv_2d"(%187, %cst_46, %cst_83) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "RELU", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x62x25x512xf32>, tensor<512x3x3x512xf32>, tensor<512xf32>) -> tensor<1x60x23x512xf32>
  %189 = "tfl.transpose"(%188, %cst_6) : (tensor<1x60x23x512xf32>, tensor<4xi32>) -> tensor<1x512x60x23xf32>
  %190 = "tfl.pad"(%189, %cst_0) : (tensor<1x512x60x23xf32>, tensor<4x2xi32>) -> tensor<1x512x62x25xf32>
  %191 = "tfl.transpose"(%190, %cst_5) : (tensor<1x512x62x25xf32>, tensor<4xi32>) -> tensor<1x62x25x512xf32>
  %192 = "tfl.split"(%cst_4, %191) {num_splits = 1 : i32} : (tensor<i32>, tensor<1x62x25x512xf32>) -> tensor<1x62x25x512xf32>
  %193 = "tfl.conv_2d"(%192, %cst_47, %cst_84) {dilation_h_factor = 1 : i32, dilation_w_factor = 1 : i32, fused_activation_function = "NONE", padding = "VALID", stride_h = 1 : i32, stride_w = 1 : i32} : (tensor<1x62x25x512xf32>, tensor<512x3x3x512xf32>, tensor<512xf32>) -> tensor<1x60x23x512xf32>
  %194 = "tfl.transpose"(%193, %cst_6) : (tensor<1x60x23x512xf32>, tensor<4xi32>) -> tensor<1x512x60x23xf32>
  %195 = "tfl.add"(%194, %184) {fused_activation_function = "RELU"} : (tensor<1x512x60x23xf32>, tensor<1x512x60x23xf32>) -> tensor<1x512x60x23xf32>
  %196 = "tfl.mean"(%195, %cst_3) {keep_dims = true} : (tensor<1x512x60x23xf32>, tensor<2xi32>) -> tensor<1x512x1x1xf32>
  %197 = "tfl.cast"(%26) : (tensor<2xi64>) -> tensor<2xi32>
  %198 = "tfl.reshape"(%196, %197) : (tensor<1x512x1x1xf32>, tensor<2xi32>) -> tensor<1x512xf32>
  %199 = "tfl.fully_connected"(%198, %cst_8, %cst_9) {fused_activation_function = "NONE", keep_num_dims = false, weights_format = "DEFAULT"} : (tensor<1x512xf32>, tensor<55x512xf32>, tensor<55xf32>) -> tensor<1x55xf32>
  "std.return"(%199) : (tensor<1x55xf32>) -> ()
}) {sym_name = "main", tf.entry_function = {control_outputs = "", inputs = "input", outputs = "Identity"}, type = (tensor<1x3x960x360xf32>) -> tensor<1x55xf32>} : () -> ()

When I use another method, the tflite model seem converted successful,

converter = tf.lite.TFLiteConverter.from_saved_model(tfpath)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.target_spec.supported_ops = [
  tf.lite.OpsSet.TFLITE_BUILTINS, # enable TensorFlow Lite ops.
  tf.lite.OpsSet.SELECT_TF_OPS # enable TensorFlow ops.
]
tflite_model = converter.convert()
open("test.tflite", "wb").write(tflite_model)

But since this is not quantized, when I deployed the model on my Coral USB TPU, it stated: ERROR: Regular TensorFlow ops are not supported by this interpreter. Make sure you apply/link the Flex delegate before inference. Which makes sense since I addedtf.lite.OpsSet.SELECT_TF_OPS. And I used the edgetpu compiler, which gave me the same error. It seems I can only convert my tensorflow to tflite model successfully using this parameter 'tf.lite.OpsSet.SELECT_TF_OPS' (other wise I will have a wierd Javascript Error. I am kinda stuck between a unsupported, yet converted tflite model and a wierd error that did not even generated a tflite model.

I also tried a definetaly unreasonable combination:

def representative_dataset():
    for _ in range(100):
      data = np_input
      yield [data.astype(np.float32)]

converter = tf.lite.TFLiteConverter.from_saved_model(tfpath)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.representative_dataset = representative_dataset
**converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS, tf.lite.OpsSet.SELECT_TF_OPS]**
converter.inference_input_type = tf.int8  # or tf.uint8
converter.inference_output_type = tf.int8 
tflite_model = converter.convert()
open("test.tflite", "wb").write(tflite_model)

Which gave me a tflite model, with unsupported ops and uint8 as i/o

Does anyone met this problem and know how to solve this? Thank you!

Namburger commented 3 years ago

Hi @Derricktao sorry, but for this tflite conversion issue, please open an issue here: https://github.com/tensorflow/tensorflow/issues for a more appropriate answer

manoj7410 commented 3 years ago

@Derricktao Did you check with the TensorFlow team regarding this issue ?

manoj7410 commented 3 years ago

Closing this due to lack of activity. Feel free to reopen this thread if the issue still persists.