提交 8ac582ab 编写于 作者: L liangzelang

make notes more clear and accurate

上级 f3044f00
......@@ -19,6 +19,9 @@
#ifndef MINDSPORE_CCSRC_IR_DTYPE_TYPE_ID_H_
#define MINDSPORE_CCSRC_IR_DTYPE_TYPE_ID_H_
#include <unordered_map>
#include <string>
namespace mindspore {
//
// Supported meta type
......@@ -77,5 +80,12 @@ enum TypeId : int {
kNumberTypeFloat64,
kNumberTypeEnd
};
//
// TypeId name map
//
const std::unordered_map<TypeId, std::string> type_name_map = {
{kNumberTypeBool, "Bool"}, {kNumberTypeInt8, "Int8"}, {kNumberTypeUInt8, "UInt8"},
{kNumberTypeInt16, "Int16"}, {kNumberTypeInt32, "Int32"}, {kNumberTypeInt64, "Int64"},
{kNumberTypeFloat16, "Float16"}, {kNumberTypeFloat32, "Float32"}, {kNumberTypeFloat64, "Float64"}};
} // namespace mindspore
#endif // MINDSPORE_CCSRC_IR_DTYPE_TYPE_ID_H_
......@@ -215,15 +215,21 @@ void DoAutoCast(const std::string &func_name, const std::vector<Signature> &sign
TypeId arg_type_id = kTypeUnknown;
AbstractBasePtr arg_value = args_spec_list[i];
(void)GetTensorOrScalarTypeInfo(arg_value, is_write, &arg_type_id);
auto it_map = type_map.find(arg_type_id);
if (it_map == type_map.end()) {
auto it_map = type_name_map.find(arg_type_id);
if (it_map == type_name_map.end()) {
continue;
}
if (is_write) {
if (arg_type_id != it->second) {
MS_LOG(EXCEPTION) << "In op '" << func_name << "', argument '" << args_spec_list[i]
<< "' can not cast type from '" << TypeIdLabel(arg_type_id) << "' to '"
<< TypeIdLabel(it->second) << "' automatically.";
auto it_name_map = type_name_map.find(it->second);
if (it_name_map == type_name_map.end()) {
continue;
}
MS_LOG(EXCEPTION) << "In op '" << func_name << "', \n"
<< "the type of writable argument is '" << it_map->second << "', "
<< "but the largest type in the same SignatureEumDtype is '" << it_name_map->second
<< "'. The writable arg type is not equal to the largest type, "
<< "so can not cast automatically.";
}
continue;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册