没有注册OpKernel来支持Op' Switch'在iOS上使用这些功能

时间:2016-11-28 23:25:50

标签: tensorflow

在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

有关

1 个答案:

答案 0 :(得分:0)

这个解决方法对我有用 - 在源代码中更改以下行并重建。

#define TF_CALL_bool(m)

#define TF_CALL_bool(m) m(bool)

我找到了指令here