【问题标题】:No OpKernel Tensorflow Mobile Android. How to debug?没有 OpKernel TensorFlow Mobile Android。如何调试?
【发布时间】:2017-12-25 19:11:57
【问题描述】:

我知道这是在 Android Studio 中很常见的错误。我曾经在“GatherNd”中看到这个,直到我检查了我的 tf_op_files.txt 和 master 中的那个,发现最近添加了“gather_nd_op”。在使用 bazel 构建之后(尽管看起来 jcenter/'none' 仍然会产生 'GatherNd' not found),我不再看到这个了。但是,我现在确实通过“StridedSlice”看到了这一点。

java.lang.IllegalArgumentException: No OpKernel was registered to support Op 'StridedSlice' with these attrs.  Registered devices: [CPU], Registered kernels:
                                                                       device='CPU'; T in [DT_BFLOAT16]
                                                                       device='CPU'; T in [DT_BOOL]
                                                                       device='CPU'; T in [DT_FLOAT]
                                                                       device='CPU'; T in [DT_INT32]

                                                                         [[Node: roi_align_classifier/strided_slice = StridedSlice[Index=DT_INT32, T=DT_INT64, begin_mask=1, ellipsis_mask=0, end_mask=1, new_axis_mask=0, shrink_axis_mask=2](roi_align_classifier/Where, roi_align_classifier/strided_slice/stack, roi_align_classifier/strided_slice/stack_1, roi_align_classifier/strided_slice/stack_2)]]
                                                                         at org.tensorflow.Session.run(Native Method)
                                                                         at org.tensorflow.Session.access$100(Session.java:48)
                                                                         at org.tensorflow.Session$Runner.runHelper(Session.java:298)
                                                                         at org.tensorflow.Session$Runner.run(Session.java:248)
                                                                         at org.tensorflow.contrib.android.TensorFlowInferenceInterface.run(TensorFlowInferenceInterface.java:218)

我看到此操作存在于tf_op_files.txt 中,并且使用错误的参数可能会发生错误。我尝试将输入和输出类型从 float[] 更改为 int[] 但没有运气。

我在 array_ops.cc 和 https://www.tensorflow.org/api_docs/python/tf/strided_slice 中看到了有关 strided_slice 的类型签名和信息。但是,这些并不能很好地了解我是否只是提供了错误的参数或我使用的 StridedSlice 实际上不存在!

我的问题是:如何以比随机猜测更确定的方式进行调试?

编辑 检查http://www.oreilly.com/data/free/files/building-mobile-applications-with-tensorflow.pdf,看来这个实现是正确的并且目前不支持移动设备? IE。此错误消息不依赖于传递的输入和输出。这是正确的吗?我认为添加操作会相当简单。我只需要知道这是否是问题所在以及类型应该是什么。

我还找到了https://medium.com/joytunes/deploying-a-tensorflow-model-to-android-69d04d1b0cba。也就是说,android/type 方面的任何调试信息都会很棒。 IE。传递给操作的类型是什么,它期望什么?看来我必须使用外部资源来确定这一点

编辑 2

在找到所有操作、量化、获取输入节点的输入和输出节点的输出后,我尝试将 strided_slice_op.cc 添加到 android_extended_ops_group2 中,只是在构建时看到它已经存在。我想我必须添加另一个实现。有谁知道如何获得节点的完整类型签名,这看起来像我走在正确的道路上吗?在张量板和错误中,操作是 strided_slice[0-9] 而构建是这样的:

`tf_kernel_library(
    name = "strided_slice_op",
    srcs = [
        "strided_slice_op.cc",
        "strided_slice_op_inst_0.cc",
        "strided_slice_op_inst_1.cc",
        "strided_slice_op_inst_2.cc",
        "strided_slice_op_inst_3.cc",
        "strided_slice_op_inst_4.cc",
        "strided_slice_op_inst_5.cc",
        "strided_slice_op_inst_6.cc",
        "strided_slice_op_inst_7.cc",
    ],
    hdrs = [
        "slice_op.h",
        "strided_slice_op.h",
        "strided_slice_op_impl.h",
    ],
    gpu_srcs = [
        "slice_op.h",
        "strided_slice_op.h",
        "strided_slice_op_impl.h",
        "strided_slice_op_gpu.cu.cc",
    ],
    deps = [
        ":bounds_check",
        ":dense_update_functor",
        ":ops_util",
        ":variable_ops",
        "//tensorflow/core:framework",
        "//tensorflow/core:lib",
        "//third_party/eigen3",
    ],
)`

【问题讨论】:

    标签: android tensorflow


    【解决方案1】:

    问题一直盯着我。 T=DT_INT64 不是 strided_slice 的注册内核之一。在切片之前编辑要投射的模型为我解决了这个问题。

    参考: https://github.com/tensorflow/tensorflow/issues/13772

    开始注册自定义操作!

    编辑

    只需要更改操作顺序!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-10
      • 2017-08-11
      • 2012-07-14
      • 1970-01-01
      相关资源
      最近更新 更多