{
  "id": 402533,
  "title": "Issue with converting Conv_2d layer at TFLite model (Solved)",
  "url": "/competitions/asl-signs/discussion/402533",
  "author_name": "Stanislav Cherkasov",
  "post_date": "2023-04-18T19:17:09.274000",
  "votes": 0,
  "comment_count": 0,
  "views": 0,
  "content": "<p>Hello<br>\nI receive error message: </p>\n<pre><code>error:  op  neither a custom op nor a flex op\nerror: failed  converting: : \nSome ops are  supported by the native TFLite runtime, you can enable TF kernels fallback using TF Select. See instructions: https://www.tensorflow.org/lite/guide/ops_select \nTF Select ops: Conv2D\nDetails:\n    tf.Conv2D(tensor&lt;*xf32&gt;, tensor&lt;2x2x3x32xf32&gt;) -&gt; (tensor&lt;?x?x?x32xf32&gt;) : {data_format = , device = , dilations = [, , , ], explicit_paddings = [], padding = , strides = [, , , ], use_cudnn_on_gpu = true}\n</code></pre>\n<p>Why it's happens? According <a href=\"https://www.tensorflow.org/mlir/tfl_ops?hl=ru#tflconv_2d_mlirtflconv2dop\" target=\"_blank\">https://www.tensorflow.org/mlir/tfl_ops?hl=ru#tflconv_2d_mlirtflconv2dop</a> conv_2d layers are supported</p>\n<p><strong>Update: I found a solution</strong><br>\nI simply added Reshape layer.</p>\n<pre><code>model = tf.keras.Sequential([\n  tf.keras.layers.Input(shape=input_shape[:]),\n  tf.keras.layers.Reshape(( INPUT_SIZE, N_COLS, N_DIMS)),\n  ...\n</code></pre>\n<p>I think it happened because of dynamic batch size doesn't supported by current version of TF. Nightly version supports it well. But when you'll try code with this additions final graph may be different on Nightly version</p>",
  "messages": [
    {
      "id": 2226247,
      "postDate": "2023-04-18T19:17:09.273Z",
      "content": "<p>Hello<br>\nI receive error message: </p>\n<pre><code>error:  op  neither a custom op nor a flex op\nerror: failed  converting: : \nSome ops are  supported by the native TFLite runtime, you can enable TF kernels fallback using TF Select. See instructions: https://www.tensorflow.org/lite/guide/ops_select \nTF Select ops: Conv2D\nDetails:\n    tf.Conv2D(tensor&lt;*xf32&gt;, tensor&lt;2x2x3x32xf32&gt;) -&gt; (tensor&lt;?x?x?x32xf32&gt;) : {data_format = , device = , dilations = [, , , ], explicit_paddings = [], padding = , strides = [, , , ], use_cudnn_on_gpu = true}\n</code></pre>\n<p>Why it's happens? According <a href=\"https://www.tensorflow.org/mlir/tfl_ops?hl=ru#tflconv_2d_mlirtflconv2dop\" target=\"_blank\">https://www.tensorflow.org/mlir/tfl_ops?hl=ru#tflconv_2d_mlirtflconv2dop</a> conv_2d layers are supported</p>\n<p><strong>Update: I found a solution</strong><br>\nI simply added Reshape layer.</p>\n<pre><code>model = tf.keras.Sequential([\n  tf.keras.layers.Input(shape=input_shape[:]),\n  tf.keras.layers.Reshape(( INPUT_SIZE, N_COLS, N_DIMS)),\n  ...\n</code></pre>\n<p>I think it happened because of dynamic batch size doesn't supported by current version of TF. Nightly version supports it well. But when you'll try code with this additions final graph may be different on Nightly version</p>",
      "rawMarkdown": "Hello\nI receive error message: \n```python\nerror: 'tf.Conv2D' op is neither a custom op nor a flex op\nerror: failed while converting: 'main': \nSome ops are not supported by the native TFLite runtime, you can enable TF kernels fallback using TF Select. See instructions: https://www.tensorflow.org/lite/guide/ops_select \nTF Select ops: Conv2D\nDetails:\n\ttf.Conv2D(tensor<*xf32>, tensor<2x2x3x32xf32>) -> (tensor<?x?x?x32xf32>) : {data_format = \"NHWC\", device = \"\", dilations = [1, 1, 1, 1], explicit_paddings = [], padding = \"SAME\", strides = [1, 1, 1, 1], use_cudnn_on_gpu = true}\n```\nWhy it's happens? According https://www.tensorflow.org/mlir/tfl_ops?hl=ru#tflconv_2d_mlirtflconv2dop conv_2d layers are supported\n\n**Update: I found a solution**\nI simply added Reshape layer.\n```python\nmodel = tf.keras.Sequential([\n  tf.keras.layers.Input(shape=input_shape[1:]),\n  tf.keras.layers.Reshape(( INPUT_SIZE, N_COLS, N_DIMS)),\n  ...\n```\nI think it happened because of dynamic batch size doesn't supported by current version of TF. Nightly version supports it well. But when you'll try code with this additions final graph may be different on Nightly version\n"
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "2226247": "Hello\nI receive error message: \n```python\nerror: 'tf.Conv2D' op is neither a custom op nor a flex op\nerror: failed while converting: 'main': \nSome ops are not supported by the native TFLite runtime, you can enable TF kernels fallback using TF Select. See instructions: https://www.tensorflow.org/lite/guide/ops_select \nTF Select ops: Conv2D\nDetails:\n\ttf.Conv2D(tensor<*xf32>, tensor<2x2x3x32xf32>) -> (tensor<?x?x?x32xf32>) : {data_format = \"NHWC\", device = \"\", dilations = [1, 1, 1, 1], explicit_paddings = [], padding = \"SAME\", strides = [1, 1, 1, 1], use_cudnn_on_gpu = true}\n```\nWhy it's happens? According https://www.tensorflow.org/mlir/tfl_ops?hl=ru#tflconv_2d_mlirtflconv2dop conv_2d layers are supported\n\n**Update: I found a solution**\nI simply added Reshape layer.\n```python\nmodel = tf.keras.Sequential([\n  tf.keras.layers.Input(shape=input_shape[1:]),\n  tf.keras.layers.Reshape(( INPUT_SIZE, N_COLS, N_DIMS)),\n  ...\n```\nI think it happened because of dynamic batch size doesn't supported by current version of TF. Nightly version supports it well. But when you'll try code with this additions final graph may be different on Nightly version\n"
  }
}