|
|
@@ -95,7 +95,34 @@ map<string, Format> kFormatDict = { |
|
|
|
{"fractal_z", FORMAT_FRACTAL_Z}, |
|
|
|
{"nc1hwc0", FORMAT_NC1HWC0}, |
|
|
|
}; |
|
|
|
|
|
|
|
std::string GenerateFileName(const SingleOpDesc &single_op_desc, int index) { |
|
|
|
std::stringstream file_name_ss; |
|
|
|
file_name_ss << index; |
|
|
|
file_name_ss << "_" << single_op_desc.op; |
|
|
|
for (auto &desc : single_op_desc.input_desc) { |
|
|
|
file_name_ss << "_" << desc.type << "_" << desc.format; |
|
|
|
for (auto dim : desc.dims) { |
|
|
|
file_name_ss << "_" << dim; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for (auto &desc : single_op_desc.output_desc) { |
|
|
|
file_name_ss << "_" << desc.type << "_" << desc.format; |
|
|
|
for (auto dim : desc.dims) { |
|
|
|
file_name_ss << "_" << dim; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
std:string file_name = file_name_ss.str(); |
|
|
|
if (file_name.length() > kMaxFileNameLen) { |
|
|
|
GELOGI("Trim file name for it is too long, origin file name = %s", file_name.c_str()); |
|
|
|
file_name = file_name.substr(0, kMaxFileNameLen); |
|
|
|
} |
|
|
|
file_name += kFileSuffix; |
|
|
|
return file_name; |
|
|
|
} |
|
|
|
} // namespace |
|
|
|
|
|
|
|
template<typename T> |
|
|
|
void SetAttrValue(const Json &j, SingleOpAttr &attr) { |
|
|
@@ -309,14 +336,7 @@ Status SingleOpParser::ConvertToBuildParam(int index, |
|
|
|
return MEMALLOC_FAILED; |
|
|
|
} |
|
|
|
|
|
|
|
std::stringstream file_name; |
|
|
|
file_name << index; |
|
|
|
file_name << "_" << single_op_desc.op; |
|
|
|
for (auto &desc : single_op_desc.input_desc) { |
|
|
|
file_name << "_" << desc.type << "_" << desc.format; |
|
|
|
for (auto dim : desc.dims) { |
|
|
|
file_name << "_" << dim; |
|
|
|
} |
|
|
|
GeTensorDesc ge_tensor_desc(GeShape(desc.dims), |
|
|
|
desc.format, |
|
|
|
desc.type); |
|
|
@@ -334,11 +354,6 @@ Status SingleOpParser::ConvertToBuildParam(int index, |
|
|
|
} |
|
|
|
|
|
|
|
for (auto &desc : single_op_desc.output_desc) { |
|
|
|
file_name << "_" << desc.type << "_" << desc.format; |
|
|
|
for (auto dim : desc.dims) { |
|
|
|
file_name << "_" << dim; |
|
|
|
} |
|
|
|
|
|
|
|
GeTensorDesc ge_tensor_desc(GeShape(desc.dims), |
|
|
|
desc.format, |
|
|
|
desc.type); |
|
|
@@ -364,12 +379,7 @@ Status SingleOpParser::ConvertToBuildParam(int index, |
|
|
|
return PARAM_INVALID; |
|
|
|
} |
|
|
|
|
|
|
|
build_param.file_name = file_name.str(); |
|
|
|
if (build_param.file_name.length() > kMaxFileNameLen) { |
|
|
|
GELOGI("Trim file name for it is too long, origin file name = %s", build_param.file_name.c_str()); |
|
|
|
build_param.file_name = build_param.file_name.substr(0, kMaxFileNameLen); |
|
|
|
} |
|
|
|
build_param.file_name += kFileSuffix; |
|
|
|
build_param.file_name = GenerateFileName(single_op_desc, index); |
|
|
|
build_param.op_desc.reset(op_desc.release()); |
|
|
|
return SUCCESS; |
|
|
|
} |
|
|
|