TensorFlowASR: streaming_transducer can't convert h5 to tflite

Hi,

I try to convert transducer .h5 to tflite using tflite_streaming_transducer.py. But It’s not work…

First, I fix concrete_func = streaming_transducer.make_tflite_function().get_concrete_function() (remove greedy=True argument of make_tflite_function() because error, tflite_streaming_transducer.py’s 60 line)

The below is the end of error result

 %42:3 = "tf.If"(%41, %40, %arg4, %arg2, %24) {else_branch = @"streaming_transducer_greedy/while/cond_else", is_stateless = true, then_branch = @"streaming_transducer_greedy/while/cond_then"} : (tensor<i1>, tensor<i32>, tensor<2x2x1x1024xf32>) -> (tensor<i32>, tensor<i32>, tensor<2x2x1x1024xf32>)
  %43 = "tfl.reshape"(%42#1, %cst_19) : (tensor<i32>, tensor<1xi32>) -> tensor<1xi32>
  %44 = "tf.TensorScatterUpdate"(%arg3, %1, %43) {device = ""} : (tensor<?xi32>, tensor<1x1xi32>, tensor<1xi32>) -> tensor<?xi32>
  %45 = "tfl.add"(%arg0, %cst_18) {fused_activation_function = "NONE"} : (tensor<i32>, tensor<i32>) -> tensor<i32>
  "std.return"(%45, %2, %42#0, %44, %42#2, %arg5, %arg6) : (tensor<i32>, tensor<i32>, tensor<i32>, tensor<?xi32>, tensor<2x2x1x1024xf32>, tensor<i32>, tensor<?x320xf32>) -> ()
}) {sym_name = "streaming_transducer_greedy/while_body", sym_visibility = "private", type = (tensor<i32>, tensor<i32>, tensor<i32>, tensor<?xi32>, tensor<2x2x1x1024xf32>, tensor<i32>, tensor<?x320xf32>) -> (tensor<i32>, tensor<i32>, tensor<i32>, tensor<?xi32>, tensor<2x2x1x1024xf32>, tensor<i32>, tensor<?x320xf32>)} : () -> ()

I give timestamp argument such as make_tflite_function(timestamp=False). But It’s not work too

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17

Most upvoted comments

Hi, @usimarit Thank you for your reply always.

I encounter another issue about tflite. Specifically, loading tflite model problem

  1. I make h5 model with tensorflow=2.3, TensorASR=0.6.3
  2. Can’t convert h5 to tflite at the same env. So, using tf-nightly instead of tensorflow=2.3. It works. I get the tflite model
  3. After that, I test below code and encounter error
import tensorflow as tf

tf.lite.Interpreter(model_path="./latest-0.6.3-20epoch.tflite")

at tf-nightly:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "path/lib/python3.8/site-packages/tensorflow/lite/python/interpreter.py", line 280, in __init__
    _interpreter_wrapper.CreateWrapperFromFile(
ValueError: Did not get operators or tensors in subgraph 1.

at tensorflow=2.3:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "path\lib\site-packages\tensorflow\lite\python\interpreter.py", line 197, in __init__
    _interpreter_wrapper.CreateWrapperFromFile(
ValueError: Op builtin_code out of range: 127. Are you using old TFLite binary with newer model?Registration failed.

@usimarit Hi, I convert that with tf-nightly-cpu It work, Thanks.

@JeongWoonPark try using tf-nightly to convert to tflite.