{
  "id": 395597,
  "title": "TF Select ops: Cast, RealDiv error",
  "url": "/competitions/asl-signs/discussion/395597",
  "author_name": "",
  "post_date": "2023-03-17T21:08:59.696606800Z",
  "votes": null,
  "comment_count": 2,
  "views": 0,
  "content": "<p>Hi!</p>\n<p>I am trying to convert my PyTorch model to tflife and getting the following error:  </p>\n<p><code>Some 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: Cast, RealDiv  \nDetails:  \n    tf.Cast(tensor&lt;f64&gt;) -&gt; (tensor&lt;i64&gt;) : {Truncate = false, device = \"\"}  \n    tf.Cast(tensor&lt;i64&gt;) -&gt; (tensor&lt;f64&gt;) : {Truncate = false, device = \"\"}  \n    tf.RealDiv(tensor&lt;f64&gt;, tensor&lt;f64&gt;) -&gt; (tensor&lt;f64&gt;) : {device = \"\"}  \n</code></p>\n<p>Searching online suggests using <code>converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS,  tf.lite.OpsSet.SELECT_TF_OPS ]</code>.</p>\n<p>However, according to my experience and <a href=\"https://www.kaggle.com/competitions/asl-signs/discussion/395332\" target=\"_blank\">this</a> discussion it leads to an error during submission.</p>\n<p>Is there any other way to fix it? I'll also be grateful for an explanation which PyTorch operations are converted to tf.Cast or tf.Realdiv, since I'm not very familiar very Tensorflow. In this case, I would rewrite them.</p>",
  "messages": [
    {
      "id": "2186528",
      "postDate": "03/17/2023 21:08:59",
      "content": "<p>Hi!</p>\n<p>I am trying to convert my PyTorch model to tflife and getting the following error:  </p>\n<p><code>Some 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: Cast, RealDiv  \nDetails:  \n    tf.Cast(tensor&lt;f64&gt;) -&gt; (tensor&lt;i64&gt;) : {Truncate = false, device = \"\"}  \n    tf.Cast(tensor&lt;i64&gt;) -&gt; (tensor&lt;f64&gt;) : {Truncate = false, device = \"\"}  \n    tf.RealDiv(tensor&lt;f64&gt;, tensor&lt;f64&gt;) -&gt; (tensor&lt;f64&gt;) : {device = \"\"}  \n</code></p>\n<p>Searching online suggests using <code>converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS,  tf.lite.OpsSet.SELECT_TF_OPS ]</code>.</p>\n<p>However, according to my experience and <a href=\"https://www.kaggle.com/competitions/asl-signs/discussion/395332\" target=\"_blank\">this</a> discussion it leads to an error during submission.</p>\n<p>Is there any other way to fix it? I'll also be grateful for an explanation which PyTorch operations are converted to tf.Cast or tf.Realdiv, since I'm not very familiar very Tensorflow. In this case, I would rewrite them.</p>",
      "rawMarkdown": "Hi!\n\nI am trying to convert my PyTorch model to tflife and getting the following error:  \n\n`Some 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: Cast, RealDiv  \nDetails:  \n\ttf.Cast(tensor<f64>) -> (tensor<i64>) : {Truncate = false, device = \"\"}  \n\ttf.Cast(tensor<i64>) -> (tensor<f64>) : {Truncate = false, device = \"\"}  \n\ttf.RealDiv(tensor<f64>, tensor<f64>) -> (tensor<f64>) : {device = \"\"}  \n`\n\nSearching online suggests using `converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS,  tf.lite.OpsSet.SELECT_TF_OPS ]`.\n\nHowever, according to my experience and [this](https://www.kaggle.com/competitions/asl-signs/discussion/395332) discussion it leads to an error during submission.\n\nIs there any other way to fix it? I'll also be grateful for an explanation which PyTorch operations are converted to tf.Cast or tf.Realdiv, since I'm not very familiar very Tensorflow. In this case, I would rewrite them.",
      "votes": null
    },
    {
      "id": "2186653",
      "postDate": "03/18/2023 01:21:27",
      "content": "<p><a href=\"https://www.kaggle.com/competitions/asl-signs/discussion/390935\" target=\"_blank\">https://www.kaggle.com/competitions/asl-signs/discussion/390935</a></p>",
      "rawMarkdown": "https://www.kaggle.com/competitions/asl-signs/discussion/390935",
      "votes": null
    },
    {
      "id": "2186862",
      "postDate": "03/18/2023 07:19:49",
      "content": "<p>Thank you, that what I was looking for!</p>",
      "rawMarkdown": "Thank you, that what I was looking for!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2186653,
      "author_name": "hengck23",
      "author_url": "",
      "post_date": "03/18/2023 01:21:27",
      "content": "<p><a href=\"https://www.kaggle.com/competitions/asl-signs/discussion/390935\" target=\"_blank\">https://www.kaggle.com/competitions/asl-signs/discussion/390935</a></p>",
      "votes": null,
      "replies": [
        {
          "id": 2186862,
          "author_name": "vadimtimakin",
          "author_url": "",
          "post_date": "03/18/2023 07:19:49",
          "content": "<p>Thank you, that what I was looking for!</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2186528": "Hi!\n\nI am trying to convert my PyTorch model to tflife and getting the following error:  \n\n`Some 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: Cast, RealDiv  \nDetails:  \n\ttf.Cast(tensor<f64>) -> (tensor<i64>) : {Truncate = false, device = \"\"}  \n\ttf.Cast(tensor<i64>) -> (tensor<f64>) : {Truncate = false, device = \"\"}  \n\ttf.RealDiv(tensor<f64>, tensor<f64>) -> (tensor<f64>) : {device = \"\"}  \n`\n\nSearching online suggests using `converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS,  tf.lite.OpsSet.SELECT_TF_OPS ]`.\n\nHowever, according to my experience and [this](https://www.kaggle.com/competitions/asl-signs/discussion/395332) discussion it leads to an error during submission.\n\nIs there any other way to fix it? I'll also be grateful for an explanation which PyTorch operations are converted to tf.Cast or tf.Realdiv, since I'm not very familiar very Tensorflow. In this case, I would rewrite them.",
    "2186653": "https://www.kaggle.com/competitions/asl-signs/discussion/390935",
    "2186862": "Thank you, that what I was looking for!"
  },
  "source": "meta"
}