!2432 make notes more clear and accurate

Merge pull request !2432 from liangzelang/dev1
pull/2432/MERGE
mindspore-ci-bot 5 years ago committed by Gitee
commit 32f3a65705

@ -19,6 +19,9 @@
#ifndef MINDSPORE_CCSRC_IR_DTYPE_TYPE_ID_H_ #ifndef MINDSPORE_CCSRC_IR_DTYPE_TYPE_ID_H_
#define MINDSPORE_CCSRC_IR_DTYPE_TYPE_ID_H_ #define MINDSPORE_CCSRC_IR_DTYPE_TYPE_ID_H_
#include <unordered_map>
#include <string>
namespace mindspore { namespace mindspore {
// //
// Supported meta type // Supported meta type
@ -77,5 +80,12 @@ enum TypeId : int {
kNumberTypeFloat64, kNumberTypeFloat64,
kNumberTypeEnd 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 } // namespace mindspore
#endif // MINDSPORE_CCSRC_IR_DTYPE_TYPE_ID_H_ #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; TypeId arg_type_id = kTypeUnknown;
AbstractBasePtr arg_value = args_spec_list[i]; AbstractBasePtr arg_value = args_spec_list[i];
(void)GetTensorOrScalarTypeInfo(arg_value, is_write, &arg_type_id); (void)GetTensorOrScalarTypeInfo(arg_value, is_write, &arg_type_id);
auto it_map = type_map.find(arg_type_id); auto it_map = type_name_map.find(arg_type_id);
if (it_map == type_map.end()) { if (it_map == type_name_map.end()) {
continue; continue;
} }
if (is_write) { if (is_write) {
if (arg_type_id != it->second) { if (arg_type_id != it->second) {
MS_LOG(EXCEPTION) << "In op '" << func_name << "', argument '" << args_spec_list[i] auto it_name_map = type_name_map.find(it->second);
<< "' can not cast type from '" << TypeIdLabel(arg_type_id) << "' to '" if (it_name_map == type_name_map.end()) {
<< TypeIdLabel(it->second) << "' automatically."; 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; continue;
} }

Loading…
Cancel
Save