diff --git a/mindspore/ccsrc/backend/kernel_compiler/common_utils.cc b/mindspore/ccsrc/backend/kernel_compiler/common_utils.cc index ad2ccb2e7f8..a5d4dcf7993 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/common_utils.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/common_utils.cc @@ -708,27 +708,35 @@ bool GetInputTensorValue(const AnfNodePtr &anf_node, size_t input_idx, nlohmann: return false; } - if (type_id == kFloat32->type_id()) { - float *val = static_cast(data); - MS_EXCEPTION_IF_NULL(val); - (*node_json)["value"] = val[0]; - MS_LOG(DEBUG) << "Value of tensor[" << cnode->DebugString() << "] is [float32][" << *val << "]."; - return true; + if (type_id == kFloat64->type_id()) { + (*node_json)["value"] = static_cast(data)[0]; + } else if (type_id == kFloat32->type_id()) { + (*node_json)["value"] = static_cast(data)[0]; } else if (type_id == kFloat16->type_id()) { float16 *val = static_cast(data); - MS_EXCEPTION_IF_NULL(val); (*node_json)["value"] = static_cast(val[0]); - MS_LOG(INFO) << "Value of tensor[" << cnode->DebugString() << "] is [float16][" << *val << "]."; - return true; + } else if (type_id == kUInt64->type_id()) { + (*node_json)["value"] = static_cast(data)[0]; + } else if (type_id == kUInt32->type_id()) { + (*node_json)["value"] = static_cast(data)[0]; + } else if (type_id == kUInt16->type_id()) { + (*node_json)["value"] = static_cast(data)[0]; + } else if (type_id == kUInt8->type_id()) { + (*node_json)["value"] = static_cast(data)[0]; + } else if (type_id == kInt64->type_id()) { + (*node_json)["value"] = static_cast(data)[0]; } else if (type_id == kInt32->type_id()) { - int *val = static_cast(data); - MS_EXCEPTION_IF_NULL(val); - (*node_json)["value"] = val[0]; - MS_LOG(INFO) << "Value of tensor[" << cnode->DebugString() << "] is [int32][" << *val << "]."; - return true; + (*node_json)["value"] = static_cast(data)[0]; + } else if (type_id == kInt16->type_id()) { + (*node_json)["value"] = static_cast(data)[0]; + } else if (type_id == kInt8->type_id()) { + (*node_json)["value"] = static_cast(data)[0]; + } else if (type_id == kBool->type_id()) { + (*node_json)["value"] = static_cast(data)[0]; + } else { + MS_LOG(EXCEPTION) << "Unknown value type of tensor[" << cnode->DebugString() << "]"; } - MS_LOG(ERROR) << "Unknown value type of tensor[" << cnode->DebugString() << "]"; - return false; + return true; } bool IsWeightBoundary(const AnfNodePtr &node) {