提交 88f97b9e 编写于 作者: P Pete Warden 提交者: TensorFlower Gardener

Added extra information to missing kernel error message

Change: 125660054
上级 bcc4dd68
...@@ -708,8 +708,10 @@ Status AttrsMatch(const NodeDef& node_def, const KernelDef& kernel_def, ...@@ -708,8 +708,10 @@ Status AttrsMatch(const NodeDef& node_def, const KernelDef& kernel_def,
} }
Status FindKernelRegistration(DeviceType device_type, const NodeDef& node_def, Status FindKernelRegistration(DeviceType device_type, const NodeDef& node_def,
const KernelRegistration** reg) { const KernelRegistration** reg,
bool* was_attr_mismatch) {
*reg = nullptr; *reg = nullptr;
*was_attr_mismatch = false;
string label; // Label defaults to empty if not found in NodeDef. string label; // Label defaults to empty if not found in NodeDef.
GetNodeAttr(node_def, "_kernel", &label); GetNodeAttr(node_def, "_kernel", &label);
const string key = Key(node_def.op(), device_type, label); const string key = Key(node_def.op(), device_type, label);
...@@ -728,6 +730,8 @@ Status FindKernelRegistration(DeviceType device_type, const NodeDef& node_def, ...@@ -728,6 +730,8 @@ Status FindKernelRegistration(DeviceType device_type, const NodeDef& node_def,
ProtoShortDebugString(iter->second.def), "'"); ProtoShortDebugString(iter->second.def), "'");
} }
*reg = &iter->second; *reg = &iter->second;
} else {
*was_attr_mismatch = true;
} }
} }
return Status::OK(); return Status::OK();
...@@ -738,12 +742,19 @@ Status FindKernelRegistration(DeviceType device_type, const NodeDef& node_def, ...@@ -738,12 +742,19 @@ Status FindKernelRegistration(DeviceType device_type, const NodeDef& node_def,
Status FindKernelDef(DeviceType device_type, const NodeDef& node_def, Status FindKernelDef(DeviceType device_type, const NodeDef& node_def,
const KernelDef** def, string* kernel_class_name) { const KernelDef** def, string* kernel_class_name) {
const KernelRegistration* reg = nullptr; const KernelRegistration* reg = nullptr;
TF_RETURN_IF_ERROR(FindKernelRegistration(device_type, node_def, &reg)); bool was_attr_mismatch;
TF_RETURN_IF_ERROR(
FindKernelRegistration(device_type, node_def, &reg, &was_attr_mismatch));
if (reg == nullptr) { if (reg == nullptr) {
return errors::NotFound("No registered '", node_def.op(), "' OpKernel for ", Status s = errors::NotFound(
DeviceTypeString(device_type), "No registered '", node_def.op(), "' OpKernel for ",
" devices compatible with node ", DeviceTypeString(device_type), " devices compatible with node ",
SummarizeNodeDef(node_def)); SummarizeNodeDef(node_def));
if (was_attr_mismatch) {
errors::AppendToMessage(
&s, " (OpKernel was found, but attributes didn't match)");
}
return s;
} }
if (def != nullptr) *def = &reg->def; if (def != nullptr) *def = &reg->def;
if (kernel_class_name != nullptr) *kernel_class_name = reg->kernel_class_name; if (kernel_class_name != nullptr) *kernel_class_name = reg->kernel_class_name;
...@@ -762,7 +773,9 @@ Status SupportedDeviceTypesForNode( ...@@ -762,7 +773,9 @@ Status SupportedDeviceTypesForNode(
if (s.ok()) { if (s.ok()) {
for (const DeviceType& device_type : prioritized_types) { for (const DeviceType& device_type : prioritized_types) {
const KernelRegistration* reg = nullptr; const KernelRegistration* reg = nullptr;
TF_RETURN_IF_ERROR(FindKernelRegistration(device_type, def, &reg)); bool was_attr_mismatch;
TF_RETURN_IF_ERROR(
FindKernelRegistration(device_type, def, &reg, &was_attr_mismatch));
if (reg != nullptr) device_types->push_back(device_type); if (reg != nullptr) device_types->push_back(device_type);
} }
} else { } else {
...@@ -800,7 +813,9 @@ Status CreateOpKernel(DeviceType device_type, DeviceBase* device, ...@@ -800,7 +813,9 @@ Status CreateOpKernel(DeviceType device_type, DeviceBase* device,
// Look up kernel registration. // Look up kernel registration.
const KernelRegistration* registration; const KernelRegistration* registration;
s = FindKernelRegistration(device_type, node_def, &registration); bool was_attr_mismatch;
s = FindKernelRegistration(device_type, node_def, &registration,
&was_attr_mismatch);
if (!s.ok()) { if (!s.ok()) {
errors::AppendToMessage(&s, " when instantiating ", node_def.op()); errors::AppendToMessage(&s, " when instantiating ", node_def.op());
return s; return s;
...@@ -810,6 +825,10 @@ Status CreateOpKernel(DeviceType device_type, DeviceBase* device, ...@@ -810,6 +825,10 @@ Status CreateOpKernel(DeviceType device_type, DeviceBase* device,
"' OpKernel for ", DeviceTypeString(device_type), "' OpKernel for ", DeviceTypeString(device_type),
" devices compatible with node ", " devices compatible with node ",
SummarizeNodeDef(node_def))); SummarizeNodeDef(node_def)));
if (was_attr_mismatch) {
errors::AppendToMessage(
&s, " (OpKernel was found, but attributes didn't match)");
}
return s; return s;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册