已合并
aclnnLogAddExp2 950芯片私有数据格式拦截 #3653
aclnnLogAddExp2 950芯片私有数据格式拦截 #3653
已合并
zhangqijia1创建于 6月30日
1 个文件变更+33-2
@@ -13,6 +13,7 @@
13#include "aclnn_kernels/cast.h"13#include "aclnn_kernels/cast.h"
14#include "aclnn_kernels/contiguous.h"14#include "aclnn_kernels/contiguous.h"
15#include "op_api/op_api_def.h"15#include "op_api/op_api_def.h"
16+#include "op_api/aclnn_check.h"
16#include "aclnn_kernels/common/op_error_check.h"17#include "aclnn_kernels/common/op_error_check.h"
17#include "opdev/common_types.h"18#include "opdev/common_types.h"
18#include "opdev/data_type_utils.h"19#include "opdev/data_type_utils.h"
@@ -134,6 +135,30 @@ static bool CheckShape(const aclTensor* self, const aclTensor* other, const aclT
134 return true;135 return true;
135}136}
136 137 
138+static bool CheckFormat(const aclTensor* self, const aclTensor* other, const aclTensor* out)
139+{
140+ if (self->GetStorageFormat() != out->GetStorageFormat()) {
141+ OP_LOGE(
142+ ACLNN_ERR_PARAM_INVALID, "Format of self and output should be equal. self [%s], out [%s].",
C
Cclinglai05176月30日

考虑使用error message打印错误日志?

likedislike
zhangqijia1
6月30日 评论:
143+ ToString(self->GetStorageFormat()).GetString(), ToString(out->GetStorageFormat()).GetString());
144+ return false;
145+ }
146+ 
147+ if (other->GetStorageFormat() != out->GetStorageFormat()) {
148+ OP_LOGE(
149+ ACLNN_ERR_PARAM_INVALID, "Format of other and output should be equal. other [%s], out [%s].",
150+ ToString(other->GetStorageFormat()).GetString(), ToString(out->GetStorageFormat()).GetString());
151+ return false;
152+ }
153+ 
154+ if (IsPrivateFormat(self->GetStorageFormat())) {
155+ OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Format only support ND、NCHW、NHWC、HWCN、NDHWC、NCDHW.");
156+ return false;
157+ }
158+ 
159+ return true;
160+}
161+ 
137static aclnnStatus CheckParams(const aclTensor* self, const aclTensor* other, const aclTensor* out) {162static aclnnStatus CheckParams(const aclTensor* self, const aclTensor* other, const aclTensor* out) {
138 // 1. 检查参数是否为空指针163 // 1. 检查参数是否为空指针
139 CHECK_RET(CheckNotNull(self, other, out), ACLNN_ERR_PARAM_NULLPTR);164 CHECK_RET(CheckNotNull(self, other, out), ACLNN_ERR_PARAM_NULLPTR);
@@ -144,10 +169,14 @@ static aclnnStatus CheckParams(const aclTensor* self, const aclTensor* other, co
144 // 3. 检查输入的shape169 // 3. 检查输入的shape
145 CHECK_RET(CheckShape(self, other, out), ACLNN_ERR_PARAM_INVALID);170 CHECK_RET(CheckShape(self, other, out), ACLNN_ERR_PARAM_INVALID);
146 171 
172+ if (IsRegBase()) {
173+ CHECK_RET(CheckFormat(self, other, out), ACLNN_ERR_PARAM_INVALID);
174+ }
175+ 
147 return ACLNN_SUCCESS;176 return ACLNN_SUCCESS;
148}177}
149 178 
150-static void CheckFormat(const aclTensor* self, const aclTensor* target){179+static void WarnFormat(const aclTensor* self, const aclTensor* target){
151 ge::Format selfStorageFormat = self->GetStorageFormat();180 ge::Format selfStorageFormat = self->GetStorageFormat();
152 ge::Format targetStorageFormat = target->GetStorageFormat();181 ge::Format targetStorageFormat = target->GetStorageFormat();
153 if (selfStorageFormat != ge::Format::FORMAT_ND || targetStorageFormat != ge::Format::FORMAT_ND){182 if (selfStorageFormat != ge::Format::FORMAT_ND || targetStorageFormat != ge::Format::FORMAT_ND){
@@ -168,7 +197,9 @@ aclnnStatus aclnnLogAddExp2GetWorkspaceSize(const aclTensor* self, const aclTens
168 auto ret = CheckParams(self, other, out);197 auto ret = CheckParams(self, other, out);
169 CHECK_RET(ret == ACLNN_SUCCESS, ret);198 CHECK_RET(ret == ACLNN_SUCCESS, ret);
170 199 
171- CheckFormat(self, other);200+ if (!IsRegBase()) {
201+ WarnFormat(self, other);
202+ }
172 203 
173 // 算子的空tensor在kernel中支持,对标竞品根据算子实际情况补充204 // 算子的空tensor在kernel中支持,对标竞品根据算子实际情况补充
174 if (self->IsEmpty() || other->IsEmpty()) {205 if (self->IsEmpty() || other->IsEmpty()) {