没有注册 OpKernel 以在 iOS 上使用这些属性支持 Op'Switch'
Posted
技术标签:
【中文标题】没有注册 OpKernel 以在 iOS 上使用这些属性支持 Op\'Switch\'【英文标题】:No OpKernel was registered to support Op 'Switch' with these attrs on iOS没有注册 OpKernel 以在 iOS 上使用这些属性支持 Op'Switch' 【发布时间】:2017-04-12 19:44:50 【问题描述】:在 ios 上,我正在尝试加载我使用 convert_variables_to_constants
冻结的张量流图,但是我得到了:
No OpKernel was registered to support Op 'Switch' with these attrs. Registered devices: [CPU], Registered kernels:
device='GPU'; T in [DT_FLOAT]
device='GPU'; T in [DT_INT32]
device='GPU'; T in [DT_BOOL]
device='GPU'; T in [DT_STRING]
device='CPU'; T in [DT_INT32]
device='CPU'; T in [DT_FLOAT]
[[Node: dropout6/cond/Switch = Switch[T=DT_BOOL](Placeholder_2, Placeholder_2)]]
如果然后在图表上调用optimize_for_inference
并尝试加载,我得到:
Input 0 of node dropout6/cond/dropout/random_uniform/max was passed bool from dropout6/cond/Switch:1 incompatible with expected INVALID.
这是Placeholder_2
节点的样子:
name: "Placeholder_2"
op: "Const"
attr
key: "dtype"
value
type: DT_BOOL
attr
key: "value"
value
tensor
dtype: DT_BOOL
tensor_shape
bool_val: false
这就是 Switch 节点的样子:
name: "dropout6/cond/Switch"
op: "Switch"
input: "Placeholder_2"
input: "Placeholder_2"
attr
key: "T"
value
type: DT_BOOL
优化后我们有:
name: "dropout6/cond/dropout/random_uniform/max"
op: "Const"
input: "dropout6/cond/Switch:1"
attr
key: "dtype"
value
type: DT_FLOAT
attr
key: "value"
value
tensor
dtype: DT_FLOAT
tensor_shape
float_val: 1.0
这可能与:https://github.com/tensorflow/tensorflow/issues/4790
【问题讨论】:
ios 上似乎不支持布尔值的开关操作,可能是为了避免过多地增加二进制大小。是否可以使用不开启布尔值的不同图表? 我实际上刚刚提交了这个:github.com/tensorflow/tensorflow/issues/5919. 【参考方案1】:此解决方法对我有用 - 更改源代码中的以下行并重新构建。
#define TF_CALL_bool(m)
到
#define TF_CALL_bool(m) m(bool)
我找到了指令here。
【讨论】:
以上是关于没有注册 OpKernel 以在 iOS 上使用这些属性支持 Op'Switch'的主要内容,如果未能解决你的问题,请参考以下文章
InvalidArgumentError:没有注册 OpKernel 来支持 Op 'CudnnRNN'
没有注册 OpKernel 以支持具有这些属性的 Op 'Conv2D'