已合并
fix range infershape of double type #1484
AlfengYuan创建于 3月4日
fix range infershape of double type #1484
已合并
AlfengYuan创建于 3月4日
2 个文件变更+15-1
@@ -15,6 +15,8 @@
15#include "log/log.h"15#include "log/log.h"
16#include "register/op_impl_registry.h"16#include "register/op_impl_registry.h"
17#include "util/math_util.h"17#include "util/math_util.h"
18+#include "platform/platform_infos_def.h"
19+#include "platform/platform_info.h"
18 20 
19using namespace ge;21using namespace ge;
20namespace ops {22namespace ops {
@@ -25,8 +27,18 @@ static ge::graphStatus InferDataType4Range(gert::InferDataTypeContext* context)
25 DataType startDataType = context->GetInputDataType(0);27 DataType startDataType = context->GetInputDataType(0);
26 DataType limitDataType = context->GetInputDataType(1);28 DataType limitDataType = context->GetInputDataType(1);
27 DataType deltaDataType = context->GetInputDataType(2);29 DataType deltaDataType = context->GetInputDataType(2);
30+ fe::PlatformInfo platform_info;
31+ fe::OptionalInfo optional_info;
32+ OP_CHECK_IF(
33+ (fe::PlatformInfoManager::Instance().GetPlatformInfoWithOutSocVersion(platform_info, optional_info) !=
34+ ge::GRAPH_SUCCESS), OP_LOGE(context->GetNodeName(), "Cannot get platform info!"), return ge::GRAPH_FAILED);
35+ OP_LOGD(context->GetNodeName(), "soc version is %s", platform_info.str_info.short_soc_version.c_str());
28 if ((startDataType == limitDataType) && (limitDataType == deltaDataType)) {36 if ((startDataType == limitDataType) && (limitDataType == deltaDataType)) {
29- context->SetOutputDataType(0, startDataType);37+ if (startDataType == ge::DT_DOUBLE && platform_info.str_info.short_soc_version == "Ascend950") {
38+ context->SetOutputDataType(0, ge::DT_FLOAT);
39+ } else {
40+ context->SetOutputDataType(0, startDataType);
41+ }
30 } else {42 } else {
31 context->SetOutputDataType(0, ge::DT_FLOAT);43 context->SetOutputDataType(0, ge::DT_FLOAT);
32 }44 }
@@ -42,6 +42,8 @@ namespace ge {
42* The auto inferred type of output is the same as input when the types of start/limit/delta are the same,42* The auto inferred type of output is the same as input when the types of start/limit/delta are the same,
43* otherwise the auto inferred type of output is float32. \n43* otherwise the auto inferred type of output is float32. \n
44* The double type of y is not supported in Ascend950 AI Processor. \n44* The double type of y is not supported in Ascend950 AI Processor. \n
45+* If the input parameters start, limit, delta are all of type double,
46+* the output parameters y is only supported as float32 in Ascend950 AI Processor. \n
45*47*
46* @par Attributes:48* @par Attributes:
47* is_closed: An optional attribute of type bool, inducating upper limit is closed or not.49* is_closed: An optional attribute of type bool, inducating upper limit is closed or not.