已合并
优化多个文件中的代码风格 #1295
yuantao创建于 2月24日
优化多个文件中的代码风格 #1295
已合并
yuantao创建于 2月24日
38 个文件变更+103-115
@@ -205,8 +205,7 @@ int32_t GenOnesData(
205 205 
206int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t* inputData)206int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t* inputData)
207{207{
208- FILE* fp;208+ FILE* fp = fopen(bin_file.c_str(), "w");
209- fp = fopen(bin_file.c_str(), "w");
210 fwrite(inputData, sizeof(uint8_t), data_size, fp);209 fwrite(inputData, sizeof(uint8_t), data_size, fp);
211 fclose(fp);210 fclose(fp);
212 return SUCCESS;211 return SUCCESS;
@@ -86,7 +86,7 @@ using std::vector;
86 graph.AddOp(placeholder##intputIndex); \86 graph.AddOp(placeholder##intputIndex); \
87 broadcast_to_1.set_input_##intputName(placeholder##intputIndex); \87 broadcast_to_1.set_input_##intputName(placeholder##intputIndex); \
88 broadcast_to_1.update_input_desc_##intputName(placeholder##intputIndex##_desc); \88 broadcast_to_1.update_input_desc_##intputName(placeholder##intputIndex##_desc); \
89- inputs.push_back(placeholder##intputIndex);89+ inputs.push_back(placeholder##intputIndex)
90 90 
91#define LOG_PRINT(message, ...) \91#define LOG_PRINT(message, ...) \
92 do { \92 do { \
@@ -33,7 +33,7 @@ static ge::graphStatus BroadcastToInferShapeWithShapeValues(const gert::InferSha
33 const gert::ContinuousVector* shape_attr,33 const gert::ContinuousVector* shape_attr,
34 gert::Shape* out_shape) {34 gert::Shape* out_shape) {
35 OP_LOGD(context->GetNodeName(), "Begin to do BroadcastToInfershape.");35 OP_LOGD(context->GetNodeName(), "Begin to do BroadcastToInfershape.");
36- const int64_t* shape_value = reinterpret_cast<const int64_t*>(shape_attr->GetData());36+ const int64_t* shape_value = static_cast<const int64_t*>(shape_attr->GetData());
37 OP_CHECK_NULL_WITH_CONTEXT(context, shape_value);37 OP_CHECK_NULL_WITH_CONTEXT(context, shape_value);
38 const size_t dim_num = shape_attr->GetSize();38 const size_t dim_num = shape_attr->GetSize();
39 39 
@@ -13,7 +13,6 @@
13 * \brief13 * \brief
14 */14 */
15 15 
16-#include <cstdint>
17#include "register/op_def_registry.h"16#include "register/op_def_registry.h"
18 17 
19namespace ops {18namespace ops {
@@ -432,7 +432,7 @@ const aclTensor* AddBroadcastNode(const op::Shape& broadcastShape, const aclTens
432 return l0op::BroadcastTo(clipValue, broadcastDstTensor, shape, executor);432 return l0op::BroadcastTo(clipValue, broadcastDstTensor, shape, executor);
433}433}
434 434 
435-bool ClampTensorPromoteShape(435+static bool ClampTensorPromoteShape(
436 const aclTensor* self, const aclTensor* clipValueMin, const aclTensor* clipValueMax, const aclTensor* out,436 const aclTensor* self, const aclTensor* clipValueMin, const aclTensor* clipValueMax, const aclTensor* out,
437 op::Shape& broadcastShape)437 op::Shape& broadcastShape)
438{438{
@@ -481,7 +481,7 @@ bool ClampTensorPromoteShape(
481 return true;481 return true;
482}482}
483 483 
484-bool ClampTensorPromoteType(484+static bool ClampTensorPromoteType(
485 const aclTensor* self, const aclTensor* clipValueMin, const aclTensor* clipValueMax, const aclTensor* out,485 const aclTensor* self, const aclTensor* clipValueMin, const aclTensor* clipValueMax, const aclTensor* out,
486 op::DataType& promoteType)486 op::DataType& promoteType)
487{487{
@@ -511,7 +511,7 @@ bool ClampTensorPromoteType(
511 return true;511 return true;
512}512}
513 513 
514-aclnnStatus aclnnClampTensorCommon(514+static aclnnStatus aclnnClampTensorCommon(
515 const aclTensor* self, const aclTensor* clipValueMin, const aclTensor* clipValueMax, aclTensor* out,515 const aclTensor* self, const aclTensor* clipValueMin, const aclTensor* clipValueMax, aclTensor* out,
516 uint64_t* workspaceSize, aclOpExecutor** executor)516 uint64_t* workspaceSize, aclOpExecutor** executor)
517{517{
@@ -13,7 +13,6 @@
13 * \brief13 * \brief
14 */14 */
15 15 
16-#include <cstdint>
17#include "register/op_def_registry.h"16#include "register/op_def_registry.h"
18 17 
19namespace ops {18namespace ops {
@@ -41,6 +41,10 @@ constexpr uint32_t SMALL_BAG = 128;
41constexpr uint32_t SINGLE_CORE_PROCESS_SIZE = 8192;41constexpr uint32_t SINGLE_CORE_PROCESS_SIZE = 8192;
42constexpr int32_t DIM_TWO = 2;42constexpr int32_t DIM_TWO = 2;
43 43 
44+constexpr size_t CAT_INPUT_NUM_32 = 32;
45+constexpr size_t CAT_INPUT_NUM_REGBASE_512 = 512;
46+constexpr size_t CAT_INPUT_NUM_V2_512 = 512;
47+ 
44static const std::initializer_list<op::DataType> ASCEND910_DTYPE_SUPPORT_LIST = {48static const std::initializer_list<op::DataType> ASCEND910_DTYPE_SUPPORT_LIST = {
45 DataType::DT_FLOAT, DataType::DT_INT32, DataType::DT_INT64, DataType::DT_FLOAT16, DataType::DT_INT16,49 DataType::DT_FLOAT, DataType::DT_INT32, DataType::DT_INT64, DataType::DT_FLOAT16, DataType::DT_INT16,
46 DataType::DT_INT8, DataType::DT_UINT8, DataType::DT_DOUBLE, DataType::DT_COMPLEX64, DataType::DT_BOOL};50 DataType::DT_INT8, DataType::DT_UINT8, DataType::DT_DOUBLE, DataType::DT_COMPLEX64, DataType::DT_BOOL};
@@ -339,10 +343,10 @@ static aclnnStatus SplitToConcat(const aclTensorList* tensors, int64_t dim, aclT
339 }343 }
340 344 
341 auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch();345 auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch();
342- size_t catMaxInputs = (IsRegBase(npuArch)) ? 512 : 32;346+ size_t catMaxInputs = (IsRegBase(npuArch)) ? CAT_INPUT_NUM_REGBASE_512 : CAT_INPUT_NUM_32;
343 auto tensorListV2 = executor->AllocTensorList(tensorListA.data(), tensorListA.size());347 auto tensorListV2 = executor->AllocTensorList(tensorListA.data(), tensorListA.size());
344 if (l0op::IsSupportConcatDV2(tensorListV2, dim)) {348 if (l0op::IsSupportConcatDV2(tensorListV2, dim)) {
345- catMaxInputs = 512;349+ catMaxInputs = CAT_INPUT_NUM_V2_512;
346 }350 }
347 bool firstLoop = true;351 bool firstLoop = true;
348 while (tensorListA.size() > 1) {352 while (tensorListA.size() > 1) {
@@ -21,6 +21,9 @@
21#include "opdev/platform.h"21#include "opdev/platform.h"
22#include "op_api/aclnn_check.h"22#include "op_api/aclnn_check.h"
23 23 
24+#define NUM_32 32
25+#define NUM_512 512
26+ 
24using namespace op;27using namespace op;
25namespace l0op {28namespace l0op {
26 29 
@@ -42,7 +45,7 @@ bool IsSupportConcatDV2(const aclTensorList* inputs, int64_t dim)
42 if (dim != 0){45 if (dim != 0){
43 return false;46 return false;
44 }47 }
45- if (inputs->Size() > 512 || inputs->Size() < 33) {48+ if (inputs->Size() > NUM_512 || inputs->Size() <= NUM_32) {
46 return false;49 return false;
47 }50 }
48 51 
@@ -51,7 +54,7 @@ bool IsSupportConcatDV2(const aclTensorList* inputs, int64_t dim)
51 op::Shape shape = (*inputs)[i]->GetViewShape();54 op::Shape shape = (*inputs)[i]->GetViewShape();
52 int64_t dim_num = shape.GetDimNum();55 int64_t dim_num = shape.GetDimNum();
53 int64_t tail_dim = shape.GetDim(dim_num - 1); // 获取尾轴维度56 int64_t tail_dim = shape.GetDim(dim_num - 1); // 获取尾轴维度
54- if (tail_dim * type_size[promoteType] % 32 != 0) {57+ if (tail_dim * type_size[promoteType] % NUM_32 != 0) {
55 return false;58 return false;
56 }59 }
57 }60 }
@@ -86,10 +89,10 @@ aclTensor* ConcatD(const aclTensorList* inputs, int64_t dim, aclOpExecutor* exec
86{89{
87 L0_DFX(ConcatD, inputs, dim);90 L0_DFX(ConcatD, inputs, dim);
88 auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch();91 auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch();
89- size_t catMaxInputSize = (IsRegBase(npuArch)) ? 512 : 32;92+ size_t catMaxInputSize = (IsRegBase(npuArch)) ? NUM_512 : NUM_32;
90 93 
91 if (IsSupportConcatDV2(inputs, dim)) {94 if (IsSupportConcatDV2(inputs, dim)) {
92- catMaxInputSize = 512;95+ catMaxInputSize = NUM_512;
93 }96 }
94 97 
95 if (inputs->Size() == 0 || inputs->Size() > catMaxInputSize) {98 if (inputs->Size() == 0 || inputs->Size() > catMaxInputSize) {
@@ -42,7 +42,6 @@ public:
42 this->Attr("concat_dim").Int();42 this->Attr("concat_dim").Int();
43 this->AICore().AddConfig("ascend910b");43 this->AICore().AddConfig("ascend910b");
44 this->AICore().AddConfig("ascend910_93");44 this->AICore().AddConfig("ascend910_93");
45- 
46 }45 }
47};46};
48OP_ADD(ConcatDV2);47OP_ADD(ConcatDV2);
@@ -57,15 +57,15 @@ using std::vector;
57 input.push_back(tensor_placeholder##intputIndex); \57 input.push_back(tensor_placeholder##intputIndex); \
58 graph.AddOp(placeholder##intputIndex); \58 graph.AddOp(placeholder##intputIndex); \
59 add1.set_input_##intputName(placeholder##intputIndex); \59 add1.set_input_##intputName(placeholder##intputIndex); \
60- inputs.push_back(placeholder##intputIndex);60+ inputs.push_back(placeholder##intputIndex)
61 61 
62#define ADD_INPUT_ATTR(attrName, attrValue) \62#define ADD_INPUT_ATTR(attrName, attrValue) \
63- add1.set_attr_##attrName(attrValue);63+ add1.set_attr_##attrName(attrValue)
64 64 
65#define ADD_OUTPUT(outputIndex, outputName, outputDtype, outputShape) \65#define ADD_OUTPUT(outputIndex, outputName, outputDtype, outputShape) \
66 TensorDesc outputName##outputIndex##_desc = \66 TensorDesc outputName##outputIndex##_desc = \
67 TensorDesc(ge::Shape(outputShape), FORMAT_NHWC, outputDtype); \67 TensorDesc(ge::Shape(outputShape), FORMAT_NHWC, outputDtype); \
68- add1.update_output_desc_##outputName(outputName##outputIndex##_desc);68+ add1.update_output_desc_##outputName(outputName##outputIndex##_desc)
69 69 
70#define LOG_PRINT(message, ...) \70#define LOG_PRINT(message, ...) \
71 do { \71 do { \
@@ -150,8 +150,7 @@ int32_t GenOnesData(
150 150 
151int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t *inputData)151int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t *inputData)
152{152{
153- FILE *fp;153+ FILE *fp = fopen(bin_file.c_str(), "w");
154- fp = fopen(bin_file.c_str(), "w");
155 fwrite(inputData, sizeof(uint8_t), data_size, fp);154 fwrite(inputData, sizeof(uint8_t), data_size, fp);
156 fclose(fp);155 fclose(fp);
157 return SUCCESS;156 return SUCCESS;
@@ -199,7 +198,6 @@ int main(int argc, char *argv[])
199 std::vector<Operator> outputs{};198 std::vector<Operator> outputs{};
200 199 
201 std::cout << argv[1] << std::endl;200 std::cout << argv[1] << std::endl;
202- char *endptr;
203 201 
204 DataType inDtype = DT_FLOAT;202 DataType inDtype = DT_FLOAT;
205 std::cout << inDtype << std::endl;203 std::cout << inDtype << std::endl;
@@ -57,10 +57,10 @@ using std::vector;
57 input.push_back(tensor_placeholder##intputIndex); \57 input.push_back(tensor_placeholder##intputIndex); \
58 graph.AddOp(placeholder##intputIndex); \58 graph.AddOp(placeholder##intputIndex); \
59 add1.set_input_##intputName(placeholder##intputIndex); \59 add1.set_input_##intputName(placeholder##intputIndex); \
60- inputs.push_back(placeholder##intputIndex);60+ inputs.push_back(placeholder##intputIndex)
61 61 
62#define ADD_INPUT_ATTR(attrName, attrValue) \62#define ADD_INPUT_ATTR(attrName, attrValue) \
63- add1.set_attr_##attrName(attrValue);63+ add1.set_attr_##attrName(attrValue)
64 64 
65#define ADD_CONST_INPUT(intputIndex, intputName, intputDtype, inputShape) \65#define ADD_CONST_INPUT(intputIndex, intputName, intputDtype, inputShape) \
66 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \66 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \
@@ -89,7 +89,7 @@ using std::vector;
89#define ADD_OUTPUT(outputIndex, outputName, outputDtype, outputShape) \89#define ADD_OUTPUT(outputIndex, outputName, outputDtype, outputShape) \
90 TensorDesc outputName##outputIndex##_desc = \90 TensorDesc outputName##outputIndex##_desc = \
91 TensorDesc(ge::Shape(outputShape), FORMAT_ND, outputDtype); \91 TensorDesc(ge::Shape(outputShape), FORMAT_ND, outputDtype); \
92- add1.update_output_desc_##outputName(outputName##outputIndex##_desc); 92+ add1.update_output_desc_##outputName(outputName##outputIndex##_desc)
93 93 
94#define LOG_PRINT(message, ...) \94#define LOG_PRINT(message, ...) \
95 do { \95 do { \
@@ -174,8 +174,7 @@ int32_t GenOnesData(
174 174 
175int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t *inputData)175int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t *inputData)
176{176{
177- FILE *fp;177+ FILE *fp = fopen(bin_file.c_str(), "w");
178- fp = fopen(bin_file.c_str(), "w");
179 fwrite(inputData, sizeof(uint8_t), data_size, fp);178 fwrite(inputData, sizeof(uint8_t), data_size, fp);
180 fclose(fp);179 fclose(fp);
181 return SUCCESS;180 return SUCCESS;
@@ -217,7 +216,6 @@ int main(int argc, char *argv[])
217 std::vector<Operator> outputs{};216 std::vector<Operator> outputs{};
218 217 
219 std::cout << argv[1] << std::endl;218 std::cout << argv[1] << std::endl;
220- char *endptr;
221 219 
222 DataType inDtype = DT_FLOAT;220 DataType inDtype = DT_FLOAT;
223 std::cout << inDtype << std::endl;221 std::cout << inDtype << std::endl;
@@ -13,8 +13,6 @@
13 * \brief op config of DynamicPartition13 * \brief op config of DynamicPartition
14 */14 */
15 15 
16-#include <cstdint>
17- 
18#include "register/op_def_registry.h"16#include "register/op_def_registry.h"
19 17 
20namespace ops18namespace ops
@@ -20,7 +20,7 @@ using NodeProto = ge::onnx::NodeProto;
20 20 
21static Status ParseParamsFlatten(const Message* op_src, ge::Operator& op_dest)21static Status ParseParamsFlatten(const Message* op_src, ge::Operator& op_dest)
22{22{
23- const NodeProto* node = reinterpret_cast<const NodeProto*>(op_src);23+ const NodeProto* node = dynamic_cast<const NodeProto*>(op_src);
24 if (node == nullptr) {24 if (node == nullptr) {
25 OP_LOGE(GetOpName(op_dest).c_str(), "Dynamic cast op_src to NodeProto failed.");25 OP_LOGE(GetOpName(op_dest).c_str(), "Dynamic cast op_src to NodeProto failed.");
26 return FAILED;26 return FAILED;
@@ -278,7 +278,6 @@ public:
278 for (uint8_t i = 0; i < MAX_DIMS_NUM; i++) {278 for (uint8_t i = 0; i < MAX_DIMS_NUM; i++) {
279 inAddr += inIndex_[i] * inStride_[i];279 inAddr += inIndex_[i] * inStride_[i];
280 }280 }
281- 
282 // 初始化搬运参数281 // 初始化搬运参数
283 DataCopyExtParams copyInParams;282 DataCopyExtParams copyInParams;
284 DataCopyPadExtParams<T> padParams{true, 0, 0, 0};283 DataCopyPadExtParams<T> padParams{true, 0, 0, 0};
@@ -366,7 +365,8 @@ public:
366 uint32_t hSlideNum = CeilDiv(ubFactorH, convKernelNumInWidth_);365 uint32_t hSlideNum = CeilDiv(ubFactorH, convKernelNumInWidth_);
367 uint32_t wSlideNum = Std::min(ubFactorH,366 uint32_t wSlideNum = Std::min(ubFactorH,
368 (inW + wPaddingBottom_ - 1 -(inIndex_[W_AXIS] + wKernelEffSize_ - 1)) / wStride_ + 1);367 (inW + wPaddingBottom_ - 1 -(inIndex_[W_AXIS] + wKernelEffSize_ - 1)) / wStride_ + 1);
369- if (hSlideNum == 1 || wSlideNum >= hSlideNum) { // W方向有效滑动次数多,优化将W方向的有效滑动次数作为loop参数368+ // W方向有效滑动次数多,优化将W方向的有效滑动次数作为loop参数
369+ if (hSlideNum == 1 || wSlideNum >= hSlideNum) {
370 DoCopyInAxisConvWPrefer(hSlideNum, wSlideNum, src);370 DoCopyInAxisConvWPrefer(hSlideNum, wSlideNum, src);
371 return;371 return;
372 }372 }
@@ -382,6 +382,7 @@ public:
382 int64_t startValidHIndex = inIndex_[H_AXIS] + CeilDiv(Std::max(382 int64_t startValidHIndex = inIndex_[H_AXIS] + CeilDiv(Std::max(
383 0L, inIndex_[H_AXIS]) - inIndex_[H_AXIS], hDilation_) * hDilation_;383 0L, inIndex_[H_AXIS]) - inIndex_[H_AXIS], hDilation_) * hDilation_;
384 int64_t endValidHIndex = inIndex_[H_AXIS] + (Std::min(inHLast, inH - 1) - inIndex_[H_AXIS]) / hDilation_ * hDilation_;384 int64_t endValidHIndex = inIndex_[H_AXIS] + (Std::min(inHLast, inH - 1) - inIndex_[H_AXIS]) / hDilation_ * hDilation_;
385+ // h没有落在有效范围内
385 if (inIndex_[H_AXIS] >= inH || inHLast < 0 ||386 if (inIndex_[H_AXIS] >= inH || inHLast < 0 ||
386 startValidHIndex < 0 || startValidHIndex > inHLast || endValidHIndex < 0) { // h没有落在有效范围内387 startValidHIndex < 0 || startValidHIndex > inHLast || endValidHIndex < 0) { // h没有落在有效范围内
387 inIndex_[H_AXIS] += hStride_;388 inIndex_[H_AXIS] += hStride_;
@@ -511,6 +512,7 @@ public:
511 int64_t startValidWIndex = inIndex_[W_AXIS] + CeilDiv(Std::max(512 int64_t startValidWIndex = inIndex_[W_AXIS] + CeilDiv(Std::max(
512 0L, inIndex_[W_AXIS]) - inIndex_[W_AXIS], wDilation_) * wDilation_;513 0L, inIndex_[W_AXIS]) - inIndex_[W_AXIS], wDilation_) * wDilation_;
513 int64_t endValidWIndex = inIndex_[W_AXIS] + (Std::min(inWLast, inW - 1) - inIndex_[W_AXIS]) / wDilation_ * wDilation_;514 int64_t endValidWIndex = inIndex_[W_AXIS] + (Std::min(inWLast, inW - 1) - inIndex_[W_AXIS]) / wDilation_ * wDilation_;
515+ // w没有落在有效范围内
514 if (inIndex_[W_AXIS] >= inW || inWLast < 0 || startValidWIndex < 0 ||516 if (inIndex_[W_AXIS] >= inW || inWLast < 0 || startValidWIndex < 0 ||
515 startValidWIndex > inWLast || endValidWIndex < 0) { // w没有落在有效范围内517 startValidWIndex > inWLast || endValidWIndex < 0) { // w没有落在有效范围内
516 return;518 return;
@@ -43,7 +43,7 @@ static const std::initializer_list<op::DataType> ASCEND910B_DTYPE_DTYPE_SUPPORT_
43 op::DataType::DT_FLOAT16, op::DataType::DT_FLOAT, op::DataType::DT_BOOL, op::DataType::DT_DOUBLE,43 op::DataType::DT_FLOAT16, op::DataType::DT_FLOAT, op::DataType::DT_BOOL, op::DataType::DT_DOUBLE,
44 op::DataType::DT_COMPLEX64, op::DataType::DT_COMPLEX128, op::DataType::DT_BF16};44 op::DataType::DT_COMPLEX64, op::DataType::DT_COMPLEX128, op::DataType::DT_BF16};
45 45 
46-static bool CheckNotNull(const aclTensorList* tensors, int64_t* realDim, const aclTensor* out)46+static bool CheckNotNull(const aclTensorList* tensors, const int64_t* realDim, const aclTensor* out)
47{47{
48 if (tensors == nullptr || realDim == nullptr) {48 if (tensors == nullptr || realDim == nullptr) {
49 OP_LOGE(ACLNN_ERR_INNER_NULLPTR, "Input of aclnnStack should not be null.");49 OP_LOGE(ACLNN_ERR_INNER_NULLPTR, "Input of aclnnStack should not be null.");
@@ -59,7 +59,7 @@ static const aclTensor* PackAiCpu(
59 L0_DFX(PackAiCpu, inputs, dim, out, out_dtype);59 L0_DFX(PackAiCpu, inputs, dim, out, out_dtype);
60 static internal::AicpuTaskSpace space("Pack", ge::DEPEND_IN_SHAPE, true);60 static internal::AicpuTaskSpace space("Pack", ge::DEPEND_IN_SHAPE, true);
61 auto ret = ADD_TO_LAUNCHER_LIST_AICPU(61 auto ret = ADD_TO_LAUNCHER_LIST_AICPU(
62- Pack, OP_ATTR_NAMES({"N", "axis"}), OP_INPUT(inputs), OP_OUTPUT(out), OP_ATTR((int64_t)inputs->Size(), dim));62+ Pack, OP_ATTR_NAMES({"N", "axis"}), OP_INPUT(inputs), OP_OUTPUT(out), OP_ATTR(static_cast<int64_t>(inputs->Size()), dim));
63 CHECK_RET(ret == ACLNN_SUCCESS, nullptr);63 CHECK_RET(ret == ACLNN_SUCCESS, nullptr);
64 return out;64 return out;
65}65}
@@ -15,7 +15,7 @@ using domi::ONNX;
15namespace domi {15namespace domi {
16static Status ParseParamsSqueeze(const Message* op_src, ge::Operator& op_dest)16static Status ParseParamsSqueeze(const Message* op_src, ge::Operator& op_dest)
17{17{
18- const ge::onnx::NodeProto* node = reinterpret_cast<const ge::onnx::NodeProto*>(op_src);18+ auto node = dynamic_cast<const ge::onnx::NodeProto*>(op_src);
19 if (node == nullptr) {19 if (node == nullptr) {
20 OP_LOGE(GetOpName(op_dest).c_str(), "Dynamic cast op_src to NodeProto failed.");20 OP_LOGE(GetOpName(op_dest).c_str(), "Dynamic cast op_src to NodeProto failed.");
21 return FAILED;21 return FAILED;
@@ -36,7 +36,7 @@ static Status ParseParamsSqueeze(const Message* op_src, ge::Operator& op_dest)
36 36 
37static Status ParseParamsSqueezeV3(const Message* op_src, ge::Operator& op_dest)37static Status ParseParamsSqueezeV3(const Message* op_src, ge::Operator& op_dest)
38{38{
39- const ge::onnx::NodeProto* node = reinterpret_cast<const ge::onnx::NodeProto*>(op_src);39+ const ge::onnx::NodeProto* node = dynamic_cast<const ge::onnx::NodeProto*>(op_src);
40 if (node == nullptr) {40 if (node == nullptr) {
41 OP_LOGE(GetOpName(op_dest).c_str(), "Dynamic cast op_src to NodeProto failed.");41 OP_LOGE(GetOpName(op_dest).c_str(), "Dynamic cast op_src to NodeProto failed.");
42 return FAILED;42 return FAILED;
@@ -83,7 +83,7 @@ static ge::graphStatus InferShapeForSqueezeV2(gert::InferShapeContext* context)
83 // solve unknown_rank83 // solve unknown_rank
84 auto x_dim_num = x_shape->GetDimNum();84 auto x_dim_num = x_shape->GetDimNum();
85 if (x_dim_num == 1U && x_shape->GetDim(0U) == ge::UNKNOWN_DIM_NUM) {85 if (x_dim_num == 1U && x_shape->GetDim(0U) == ge::UNKNOWN_DIM_NUM) {
86- OP_LOGD(context, "Input shape is unkown rank!");86+ OP_LOGD(context, "Input shape is unknown rank!");
87 *y_shape = *x_shape;87 *y_shape = *x_shape;
88 return ge::SUCCESS;88 return ge::SUCCESS;
89 }89 }
@@ -29,6 +29,8 @@
29 29 
30#define FAILED -130#define FAILED -1
31#define SUCCESS 031#define SUCCESS 0
32+#define DEFAULT_DATA_SIZE 4
33+#define GEN_ONES_DATA_FLOAT32_GENERATOR(ORIG_VAL, IDX) ORIG_VAL + (IDX % 3) * 0.4f
32 34 
33using namespace ge;35using namespace ge;
34using std::map;36using std::map;
@@ -121,9 +123,9 @@ int32_t GenOnesDataFloat32(vector<int64_t> shapes, Tensor& input_tensor, TensorD
121 }123 }
122 uint32_t data_len = size * 4;124 uint32_t data_len = size * 4;
123 float* pData = new (std::nothrow) float[size];125 float* pData = new (std::nothrow) float[size];
124- 
125 for (size_t i = 0; i < size; ++i) {126 for (size_t i = 0; i < size; ++i) {
126- pData[i] = value + (i % 3) * 0.4f; // 让数据更有意义127+ // make data meaningful
128+ pData[i] = GEN_ONES_DATA_FLOAT32_GENERATOR(value, i);
127 }129 }
128 input_tensor = Tensor(input_tensor_desc, (uint8_t*)pData, data_len);130 input_tensor = Tensor(input_tensor_desc, (uint8_t*)pData, data_len);
129 return SUCCESS;131 return SUCCESS;
@@ -96,7 +96,6 @@ static int64_t GetConstIndexValue(const gert::Tensor* tensor, int32_t idx, int64
96 96 
97 int64_t value = defaultValue;97 int64_t value = defaultValue;
98 const auto dataType = tensor->GetDataType();98 const auto dataType = tensor->GetDataType();
99- 
100 if (dataType == ge::DT_INT32) {99 if (dataType == ge::DT_INT32) {
101 const int32_t* data = tensor->GetData<int32_t>();100 const int32_t* data = tensor->GetData<int32_t>();
102 if (data == nullptr) {101 if (data == nullptr) {
@@ -219,7 +218,6 @@ static ge::graphStatus InferShape4StridedSliceV2(gert::InferShapeContext* contex
219 218 
220 // Calculate max shape of (begin, end, strides)219 // Calculate max shape of (begin, end, strides)
221 int64_t shape_max = CalcMaxShapeSize(shape_begin->GetDim(0), shape_end->GetDim(0));220 int64_t shape_max = CalcMaxShapeSize(shape_begin->GetDim(0), shape_end->GetDim(0));
222- 
223 // Necessary input valid check221 // Necessary input valid check
224 if (shape_max == static_cast<int64_t>(-1)) {222 if (shape_max == static_cast<int64_t>(-1)) {
225 OP_LOGD(OP_NAME, "max shape is -1.");223 OP_LOGD(OP_NAME, "max shape is -1.");
@@ -254,7 +252,7 @@ static ge::graphStatus InferShape4StridedSliceV2(gert::InferShapeContext* contex
254#define GET_MASK_VALUE(index, mask_name) \252#define GET_MASK_VALUE(index, mask_name) \
255 const int64_t* mask_##mask_name = attrs->GetAttrPointer<int64_t>(index); \253 const int64_t* mask_##mask_name = attrs->GetAttrPointer<int64_t>(index); \
256 OP_CHECK_NULL_WITH_CONTEXT(context, mask_##mask_name); \254 OP_CHECK_NULL_WITH_CONTEXT(context, mask_##mask_name); \
257- input_params.mask_name##_mask = static_cast<uint64_t>(*mask_##mask_name);255+ input_params.mask_name##_mask = static_cast<uint64_t>(*mask_##mask_name)
258 256 
259 GET_MASK_VALUE(IDX_MASK_BEGIN, begin);257 GET_MASK_VALUE(IDX_MASK_BEGIN, begin);
260 GET_MASK_VALUE(IDX_MASK_END, end);258 GET_MASK_VALUE(IDX_MASK_END, end);
@@ -147,7 +147,7 @@ static ge::graphStatus StridedSliceV3InferShape(gert::InferShapeContext* context
147 }147 }
148 end_value = GetConstIndexValue(end_tensor, i, cur_axis_input_size, clip_lower, cur_axis_input_size);148 end_value = GetConstIndexValue(end_tensor, i, cur_axis_input_size, clip_lower, cur_axis_input_size);
149 }149 }
150- int64_t cur_out_size = std::ceil((end_value - begin_value) / static_cast<float>(step_value));150+ int64_t cur_out_size = static_cast<int64_t>(std::ceil((end_value - begin_value) / static_cast<float>(step_value)));
151 if (cur_out_size < 0) {151 if (cur_out_size < 0) {
152 cur_out_size = 0;152 cur_out_size = 0;
153 }153 }
@@ -53,7 +53,6 @@ public:
53 } else {53 } else {
54 SumFP32ResInGMFinalAxeBigSize<T1>(curDstStart, i, this->tasksOnce, this->dstGlobal);54 SumFP32ResInGMFinalAxeBigSize<T1>(curDstStart, i, this->tasksOnce, this->dstGlobal);
55 }55 }
56-
57 }56 }
58 if (this->tail > 0) {57 if (this->tail > 0) {
59 this->tasksOnce = this->tail;58 this->tasksOnce = this->tail;
@@ -86,8 +86,8 @@ ge::graphStatus InferShapeMainImplForUnsqueezeV3(const gert::Shape *x_shape, ger
86 }86 }
87 // solve normal axes87 // solve normal axes
88 int64_t copied_axes_data[gert::Shape::kMaxDimNum] = {0};88 int64_t copied_axes_data[gert::Shape::kMaxDimNum] = {0};
89- if (memcpy_s(reinterpret_cast<uint8_t*>(copied_axes_data), sizeof(int64_t) * gert::Shape::kMaxDimNum,89+ if (memcpy_s(copied_axes_data, sizeof(int64_t) * gert::Shape::kMaxDimNum,
90- reinterpret_cast<uint8_t*>(axes_data), sizeof(int64_t) * axes_size) != 0) {90+ axes_data, sizeof(int64_t) * axes_size) != 0) {
91 OP_LOGE("UnsqueezeV3", "memcpy_s not success!");91 OP_LOGE("UnsqueezeV3", "memcpy_s not success!");
92 return ge::GRAPH_FAILED;92 return ge::GRAPH_FAILED;
93 }93 }
@@ -153,8 +153,7 @@ int32_t GenOnesData(
153 153 
154int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t* inputData)154int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t* inputData)
155{155{
156- FILE* fp;156+ FILE* fp = fopen(bin_file.c_str(), "w");
157- fp = fopen(bin_file.c_str(), "w");
158 fwrite(inputData, sizeof(uint8_t), data_size, fp);157 fwrite(inputData, sizeof(uint8_t), data_size, fp);
159 fclose(fp);158 fclose(fp);
160 return SUCCESS;159 return SUCCESS;
@@ -149,7 +149,7 @@ static aclnnStatus CheckParams(const aclTensor *self, int64_t numsamples, bool r
149}149}
150 150 
151const aclTensor *GetRandomUniformReplaceMent(const aclTensor *selfContiguous, int64_t numsamples,151const aclTensor *GetRandomUniformReplaceMent(const aclTensor *selfContiguous, int64_t numsamples,
152- const int64_t *randomParams, aclOpExecutor *executor)152+ const int64_t seed, const int64_t offset, aclOpExecutor *executor)
153{153{
154 const int64_t randAShape[] = {numsamples};154 const int64_t randAShape[] = {numsamples};
155 auto randAShapeArray = executor->AllocIntArray(randAShape, 1);155 auto randAShapeArray = executor->AllocIntArray(randAShape, 1);
@@ -157,14 +157,14 @@ const aclTensor *GetRandomUniformReplaceMent(const aclTensor *selfContiguous, in
157 if (!IsRegBase()) {157 if (!IsRegBase()) {
158 auto low = executor->AllocScalar(0.0f);158 auto low = executor->AllocScalar(0.0f);
159 auto high = executor->AllocScalar(1.0f);159 auto high = executor->AllocScalar(1.0f);
160- randomUniform = l0op::DSARandomUniform(randAShapeArray, *randomParams, *(randomParams + 1), low, high, executor);160+ randomUniform = l0op::DSARandomUniform(randAShapeArray, seed, offset, low, high, executor);
161 } else {161 } else {
162 int32_t alg = 1;162 int32_t alg = 1;
163 op::Shape shape;163 op::Shape shape;
164 op::ToShape(randAShapeArray->GetData(), randAShapeArray->Size(), shape);164 op::ToShape(randAShapeArray->GetData(), randAShapeArray->Size(), shape);
165 auto randAShapeTensor = executor->AllocTensor(shape, selfContiguous->GetDataType(), selfContiguous->GetViewFormat());165 auto randAShapeTensor = executor->AllocTensor(shape, selfContiguous->GetDataType(), selfContiguous->GetViewFormat());
166 CHECK_RET(randAShapeTensor != nullptr, nullptr);166 CHECK_RET(randAShapeTensor != nullptr, nullptr);
167- randomUniform = l0op::StatelessRandomUniformV2(randAShapeTensor, *randomParams, *(randomParams + 1), alg, executor);167+ randomUniform = l0op::StatelessRandomUniformV2(randAShapeTensor, seed, offset, alg, executor);
168 }168 }
169 CHECK_RET(randomUniform != nullptr, nullptr);169 CHECK_RET(randomUniform != nullptr, nullptr);
170 return randomUniform;170 return randomUniform;
@@ -245,7 +245,7 @@ const aclTensor *RunMultinomialReplaceMent(const aclTensor *selfContiguous, int6
245 return multinomialOut;245 return multinomialOut;
246}246}
247 247 
248-const aclTensor *GetRandomUniformNoReplaceMent(const aclTensor *selfContiguous, const int64_t *randomParams,248+const aclTensor *GetRandomUniformNoReplaceMent(const aclTensor *selfContiguous, const int64_t seed, const int64_t offset,
249 aclOpExecutor *executor)249 aclOpExecutor *executor)
250{250{
251 // exponentialOne = torch.exponential_(1)251 // exponentialOne = torch.exponential_(1)
@@ -256,10 +256,10 @@ const aclTensor *GetRandomUniformNoReplaceMent(const aclTensor *selfContiguous,
256 CHECK_RET(inputShapeArray != nullptr, nullptr);256 CHECK_RET(inputShapeArray != nullptr, nullptr);
257 auto low = executor->AllocScalar(0.0f);257 auto low = executor->AllocScalar(0.0f);
258 auto high = executor->AllocScalar(1.0f);258 auto high = executor->AllocScalar(1.0f);
259- randomUniform = l0op::DSARandomUniform(inputShapeArray, *randomParams, *(randomParams + 1), low, high, executor);259+ randomUniform = l0op::DSARandomUniform(inputShapeArray, seed, offset, low, high, executor);
260 } else {260 } else {
261 int32_t alg = 1;261 int32_t alg = 1;
262- auto statelessUniform = l0op::StatelessRandomUniformV2(selfContiguous, *randomParams, *(randomParams + 1), alg, executor);262+ auto statelessUniform = l0op::StatelessRandomUniformV2(selfContiguous, seed, offset, alg, executor);
263 CHECK_RET(statelessUniform != nullptr, nullptr);263 CHECK_RET(statelessUniform != nullptr, nullptr);
264 randomUniform = l0op::Cast(statelessUniform, DataType::DT_FLOAT, executor);264 randomUniform = l0op::Cast(statelessUniform, DataType::DT_FLOAT, executor);
265 }265 }
@@ -365,7 +365,6 @@ aclnnStatus aclnnMultinomialGetWorkspaceSize(const aclTensor *self, int64_t nums
365 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_PARAM_NULLPTR);365 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_PARAM_NULLPTR);
366 366 
367 const aclTensor *multinomialOut;367 const aclTensor *multinomialOut;
368- int64_t randomParams[2] = {seed, offset};
369 if (!CheckSocVersionGe910B() || selfSize <= CPU_NPU_BOUNDARY) {368 if (!CheckSocVersionGe910B() || selfSize <= CPU_NPU_BOUNDARY) {
370 multinomialOut = l0op::MultinomialWithReplacement(selfContiguous,369 multinomialOut = l0op::MultinomialWithReplacement(selfContiguous,
371 numsamples,370 numsamples,
@@ -374,7 +373,7 @@ aclnnStatus aclnnMultinomialGetWorkspaceSize(const aclTensor *self, int64_t nums
374 offset,373 offset,
375 uniqueExecutor.get());374 uniqueExecutor.get());
376 } else if (!replacement || numsamples == 1) {375 } else if (!replacement || numsamples == 1) {
377- auto randomUniform = GetRandomUniformNoReplaceMent(selfContiguous, randomParams, uniqueExecutor.get());376+ auto randomUniform = GetRandomUniformNoReplaceMent(selfContiguous, seed, offset, uniqueExecutor.get());
378 CHECK_RET(randomUniform != nullptr, ACLNN_ERR_PARAM_NULLPTR);377 CHECK_RET(randomUniform != nullptr, ACLNN_ERR_PARAM_NULLPTR);
379 multinomialOut=RunMultinomialNoReplaceMent(selfContiguous,378 multinomialOut=RunMultinomialNoReplaceMent(selfContiguous,
380 numsamples,379 numsamples,
@@ -383,7 +382,7 @@ aclnnStatus aclnnMultinomialGetWorkspaceSize(const aclTensor *self, int64_t nums
383 uniqueExecutor.get());382 uniqueExecutor.get());
384 } else {383 } else {
385 // RandomUniform, shape = {1, ..., 1, numsamples}384 // RandomUniform, shape = {1, ..., 1, numsamples}
386- auto randomUniform = GetRandomUniformReplaceMent(selfContiguous, numsamples, randomParams, uniqueExecutor.get());385+ auto randomUniform = GetRandomUniformReplaceMent(selfContiguous, numsamples, seed, offset, uniqueExecutor.get());
387 CHECK_RET(randomUniform != nullptr, ACLNN_ERR_PARAM_NULLPTR);386 CHECK_RET(randomUniform != nullptr, ACLNN_ERR_PARAM_NULLPTR);
388 multinomialOut=RunMultinomialReplaceMent(selfContiguous,387 multinomialOut=RunMultinomialReplaceMent(selfContiguous,
389 numsamples,388 numsamples,
@@ -74,7 +74,7 @@ static aclnnStatus updateFrom(int64_t& from, op::DataType dtype)
74 if (fromPlusOne < from) {74 if (fromPlusOne < from) {
75 int64_t from_ = std::abs(from + 1);75 int64_t from_ = std::abs(from + 1);
76 int32_t n = 0;76 int32_t n = 0;
77- while (from_ >>= 1) {77+ while ((from_ >>= 1) != 0LL) {
78 ++n;78 ++n;
79 }79 }
80 from = fromPlusOne + (1LL << (n - digits + 1));80 from = fromPlusOne + (1LL << (n - digits + 1));
@@ -116,7 +116,7 @@ static aclnnStatus updateTo(int64_t& to, op::DataType dtype)
116 if (toMinusOne >= to) {116 if (toMinusOne >= to) {
117 int64_t to_ = std::abs(to - 1);117 int64_t to_ = std::abs(to - 1);
118 int32_t n = 0;118 int32_t n = 0;
119- while (to_ >>= 1) {119+ while ((to_ >>= 1) != 0LL) {
120 ++n;120 ++n;
121 }121 }
122 to = toMinusOne - (1LL << (n - digits + 1));122 to = toMinusOne - (1LL << (n - digits + 1));
@@ -93,7 +93,7 @@ ACLNN_API aclnnStatus aclnnInplaceUniformGetWorkspaceSize(
93 * @return aclnnStatus: 返回状态码。93 * @return aclnnStatus: 返回状态码。
94 */94 */
95ACLNN_API aclnnStatus95ACLNN_API aclnnStatus
96-aclnnInplaceUniform(void* workspace, uint64_t workspace_size, aclOpExecutor* executor, const aclrtStream stream);96+aclnnInplaceUniform(void* workspace, uint64_t workspaceSize, aclOpExecutor* executor, const aclrtStream stream);
97 97 
98/**98/**
99 * @brief aclnnInplaceUniformTensor的第一段接口,根据具体的计算流程,计算workspace大小。99 * @brief aclnnInplaceUniformTensor的第一段接口,根据具体的计算流程,计算workspace大小。
@@ -129,7 +129,7 @@ ACLNN_API aclnnStatus aclnnInplaceUniformTensorGetWorkspaceSize(
129 * @return aclnnStatus: 返回状态码。129 * @return aclnnStatus: 返回状态码。
130 */130 */
131ACLNN_API aclnnStatus131ACLNN_API aclnnStatus
132-aclnnInplaceUniformTensor(void* workspace, uint64_t workspace_size, aclOpExecutor* executor, const aclrtStream stream);132+aclnnInplaceUniformTensor(void* workspace, uint64_t workspaceSize, aclOpExecutor* executor, const aclrtStream stream);
133 133 
134#ifdef __cplusplus134#ifdef __cplusplus
135}135}
@@ -16,14 +16,14 @@
16namespace ops {16namespace ops {
17namespace GraphCommon {17namespace GraphCommon {
18ge::graphStatus InferDataTypeByAttr(18ge::graphStatus InferDataTypeByAttr(
19- gert::InferDataTypeContext* context, const int32_t dtypeIndex, ge::DataType& outDtype)19+ gert::InferDataTypeContext* context, const int32_t dtypeIndex, ge::DataType& OutDtype)
20{20{
21 auto* attrs = context->GetAttrs();21 auto* attrs = context->GetAttrs();
22 OP_CHECK_NULL_WITH_CONTEXT(context, attrs);22 OP_CHECK_NULL_WITH_CONTEXT(context, attrs);
23 23 
24 const int64_t* attrDtype = attrs->GetAttrPointer<int64_t>(dtypeIndex);24 const int64_t* attrDtype = attrs->GetAttrPointer<int64_t>(dtypeIndex);
25 OP_CHECK_NULL_WITH_CONTEXT(context, attrDtype);25 OP_CHECK_NULL_WITH_CONTEXT(context, attrDtype);
26- outDtype = static_cast<ge::DataType>(*attrDtype);26+ OutDtype = static_cast<ge::DataType>(*attrDtype);
27 return ge::GRAPH_SUCCESS;27 return ge::GRAPH_SUCCESS;
28}28}
29 29 
@@ -122,7 +122,7 @@ public:
122 totalCombinations_ = 1;122 totalCombinations_ = 1;
123 size_t idx = 0;123 size_t idx = 0;
124 for (auto& item : inputs) {124 for (auto& item : inputs) {
125- if (nameMap_.count(item.name)) {125+ if (nameMap_.count(item.name) != 0U) {
126 throw std::runtime_error("Duplicate input name: " + item.name);126 throw std::runtime_error("Duplicate input name: " + item.name);
127 }127 }
128 nameMap_[item.name] = idx++;128 nameMap_[item.name] = idx++;
@@ -17,12 +17,12 @@
17namespace ops {17namespace ops {
18namespace randomCommon {18namespace randomCommon {
19template <typename T>19template <typename T>
20-ge::graphStatus HandleShapeTensor(gert::Shape& outShape, size_t xShapeSize, const T* xShapeData)20+ge::graphStatus HandleShapeTensor(gert::Shape& outputShape, size_t xShapeSize, const T* xShapeData)
21{21{
22 std::cerr << "[DEBUG] HandleShapeTensor with type: " << typeid(T).name() << ", dims " << xShapeSize << std::endl;22 std::cerr << "[DEBUG] HandleShapeTensor with type: " << typeid(T).name() << ", dims " << xShapeSize << std::endl;
23- outShape.SetDimNum(xShapeSize);23+ outputShape.SetDimNum(xShapeSize);
24 for (size_t i = 0U; i < xShapeSize; i++) {24 for (size_t i = 0U; i < xShapeSize; i++) {
25- outShape.SetDim(i, xShapeData[i]);25+ outputShape.SetDim(i, xShapeData[i]);
26 }26 }
27 return ge::GRAPH_SUCCESS;27 return ge::GRAPH_SUCCESS;
28}28}
@@ -25,7 +25,6 @@
25#include "util/const_util.h"25#include "util/const_util.h"
26#include "op_api/op_util.h"26#include "op_api/op_util.h"
27 27 
28-using namespace ge;
29namespace ops {28namespace ops {
30namespace randomCommon {29namespace randomCommon {
31static constexpr int32_t MODE_DEPENDENCY = 0;30static constexpr int32_t MODE_DEPENDENCY = 0;
@@ -57,7 +57,7 @@ using std::vector;
57 input.push_back(tensor_placeholder##intputIndex); \57 input.push_back(tensor_placeholder##intputIndex); \
58 graph.AddOp(placeholder##intputIndex); \58 graph.AddOp(placeholder##intputIndex); \
59 add1.set_input_##intputName(placeholder##intputIndex); \59 add1.set_input_##intputName(placeholder##intputIndex); \
60- inputs.push_back(placeholder##intputIndex);60+ inputs.push_back(placeholder##intputIndex)
61 61 
62#define ADD_INT_INPUT(intputIndex, intputName, intputDtype, inputShape, value) \62#define ADD_INT_INPUT(intputIndex, intputName, intputDtype, inputShape, value) \
63 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \63 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \
@@ -80,15 +80,15 @@ using std::vector;
80 input.push_back(tensor_placeholder##intputIndex); \80 input.push_back(tensor_placeholder##intputIndex); \
81 graph.AddOp(placeholder##intputIndex); \81 graph.AddOp(placeholder##intputIndex); \
82 add1.set_input_##intputName(placeholder##intputIndex); \82 add1.set_input_##intputName(placeholder##intputIndex); \
83- inputs.push_back(placeholder##intputIndex);83+ inputs.push_back(placeholder##intputIndex)
84 84 
85#define ADD_INPUT_ATTR(attrName, attrValue) \85#define ADD_INPUT_ATTR(attrName, attrValue) \
86- add1.set_attr_##attrName(attrValue);86+ add1.set_attr_##attrName(attrValue)
87 87 
88#define ADD_OUTPUT(outputIndex, outputName, outputDtype, outputShape) \88#define ADD_OUTPUT(outputIndex, outputName, outputDtype, outputShape) \
89 TensorDesc outputName##outputIndex##_desc = \89 TensorDesc outputName##outputIndex##_desc = \
90 TensorDesc(ge::Shape(outputShape), FORMAT_ND, outputDtype); \90 TensorDesc(ge::Shape(outputShape), FORMAT_ND, outputDtype); \
91- add1.update_output_desc_##outputName(outputName##outputIndex##_desc); 91+ add1.update_output_desc_##outputName(outputName##outputIndex##_desc)
92 92 
93#define ADD_CONST_INPUT(intputIndex, intputName, intputDtype, inputShape) \93#define ADD_CONST_INPUT(intputIndex, intputName, intputDtype, inputShape) \
94 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \94 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \
@@ -112,7 +112,7 @@ using std::vector;
112 graph.AddOp(placeholder##intputIndex); \112 graph.AddOp(placeholder##intputIndex); \
113 add1.set_input_##intputName(placeholder##intputIndex); \113 add1.set_input_##intputName(placeholder##intputIndex); \
114 add1.update_input_desc_##intputName(placeholder##intputIndex##_desc); \114 add1.update_input_desc_##intputName(placeholder##intputIndex##_desc); \
115- inputs.push_back(placeholder##intputIndex);115+ inputs.push_back(placeholder##intputIndex)
116 116 
117#define LOG_PRINT(message, ...) \117#define LOG_PRINT(message, ...) \
118 do { \118 do { \
@@ -197,8 +197,7 @@ int32_t GenOnesData(
197 197 
198int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t *inputData)198int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t *inputData)
199{199{
200- FILE *fp;200+ FILE *fp = fopen(bin_file.c_str(), "w");
201- fp = fopen(bin_file.c_str(), "w");
202 fwrite(inputData, sizeof(uint8_t), data_size, fp);201 fwrite(inputData, sizeof(uint8_t), data_size, fp);
203 fclose(fp);202 fclose(fp);
204 return SUCCESS;203 return SUCCESS;
@@ -57,7 +57,7 @@ using std::vector;
57 input.push_back(tensor_placeholder##intputIndex); \57 input.push_back(tensor_placeholder##intputIndex); \
58 graph.AddOp(placeholder##intputIndex); \58 graph.AddOp(placeholder##intputIndex); \
59 add1.set_input_##intputName(placeholder##intputIndex); \59 add1.set_input_##intputName(placeholder##intputIndex); \
60- inputs.push_back(placeholder##intputIndex);60+ inputs.push_back(placeholder##intputIndex)
61 61 
62#define ADD_INT_INPUT(intputIndex, intputName, intputDtype, inputShape, value) \62#define ADD_INT_INPUT(intputIndex, intputName, intputDtype, inputShape, value) \
63 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \63 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \
@@ -80,15 +80,15 @@ using std::vector;
80 input.push_back(tensor_placeholder##intputIndex); \80 input.push_back(tensor_placeholder##intputIndex); \
81 graph.AddOp(placeholder##intputIndex); \81 graph.AddOp(placeholder##intputIndex); \
82 add1.set_input_##intputName(placeholder##intputIndex); \82 add1.set_input_##intputName(placeholder##intputIndex); \
83- inputs.push_back(placeholder##intputIndex);83+ inputs.push_back(placeholder##intputIndex)
84 84 
85#define ADD_INPUT_ATTR(attrName, attrValue) \85#define ADD_INPUT_ATTR(attrName, attrValue) \
86- add1.set_attr_##attrName(attrValue);86+ add1.set_attr_##attrName(attrValue)
87 87 
88#define ADD_OUTPUT(outputIndex, outputName, outputDtype, outputShape) \88#define ADD_OUTPUT(outputIndex, outputName, outputDtype, outputShape) \
89 TensorDesc outputName##outputIndex##_desc = \89 TensorDesc outputName##outputIndex##_desc = \
90 TensorDesc(ge::Shape(outputShape), FORMAT_ND, outputDtype); \90 TensorDesc(ge::Shape(outputShape), FORMAT_ND, outputDtype); \
91- add1.update_output_desc_##outputName(outputName##outputIndex##_desc); 91+ add1.update_output_desc_##outputName(outputName##outputIndex##_desc)
92 92 
93#define ADD_CONST_INPUT(intputIndex, intputName, intputDtype, inputShape) \93#define ADD_CONST_INPUT(intputIndex, intputName, intputDtype, inputShape) \
94 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \94 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \
@@ -112,7 +112,7 @@ using std::vector;
112 graph.AddOp(placeholder##intputIndex); \112 graph.AddOp(placeholder##intputIndex); \
113 add1.set_input_##intputName(placeholder##intputIndex); \113 add1.set_input_##intputName(placeholder##intputIndex); \
114 add1.update_input_desc_##intputName(placeholder##intputIndex##_desc); \114 add1.update_input_desc_##intputName(placeholder##intputIndex##_desc); \
115- inputs.push_back(placeholder##intputIndex);115+ inputs.push_back(placeholder##intputIndex)
116 116 
117#define LOG_PRINT(message, ...) \117#define LOG_PRINT(message, ...) \
118 do { \118 do { \
@@ -191,8 +191,7 @@ int32_t GenOnesData(
191 191 
192int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t *inputData)192int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t *inputData)
193{193{
194- FILE *fp;194+ FILE *fp = fopen(bin_file.c_str(), "w");
195- fp = fopen(bin_file.c_str(), "w");
196 fwrite(inputData, sizeof(uint8_t), data_size, fp);195 fwrite(inputData, sizeof(uint8_t), data_size, fp);
197 fclose(fp);196 fclose(fp);
198 return SUCCESS;197 return SUCCESS;
@@ -57,7 +57,7 @@ using std::vector;
57 input.push_back(tensor_placeholder##intputIndex); \57 input.push_back(tensor_placeholder##intputIndex); \
58 graph.AddOp(placeholder##intputIndex); \58 graph.AddOp(placeholder##intputIndex); \
59 add1.set_input_##intputName(placeholder##intputIndex); \59 add1.set_input_##intputName(placeholder##intputIndex); \
60- inputs.push_back(placeholder##intputIndex);60+ inputs.push_back(placeholder##intputIndex)
61 61 
62#define ADD_INT_INPUT(intputIndex, intputName, intputDtype, inputShape, value) \62#define ADD_INT_INPUT(intputIndex, intputName, intputDtype, inputShape, value) \
63 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \63 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \
@@ -80,15 +80,15 @@ using std::vector;
80 input.push_back(tensor_placeholder##intputIndex); \80 input.push_back(tensor_placeholder##intputIndex); \
81 graph.AddOp(placeholder##intputIndex); \81 graph.AddOp(placeholder##intputIndex); \
82 add1.set_input_##intputName(placeholder##intputIndex); \82 add1.set_input_##intputName(placeholder##intputIndex); \
83- inputs.push_back(placeholder##intputIndex);83+ inputs.push_back(placeholder##intputIndex)
84 84 
85#define ADD_INPUT_ATTR(attrName, attrValue) \85#define ADD_INPUT_ATTR(attrName, attrValue) \
86- add1.set_attr_##attrName(attrValue);86+ add1.set_attr_##attrName(attrValue)
87 87 
88#define ADD_OUTPUT(outputIndex, outputName, outputDtype, outputShape) \88#define ADD_OUTPUT(outputIndex, outputName, outputDtype, outputShape) \
89 TensorDesc outputName##outputIndex##_desc = \89 TensorDesc outputName##outputIndex##_desc = \
90 TensorDesc(ge::Shape(outputShape), FORMAT_ND, outputDtype); \90 TensorDesc(ge::Shape(outputShape), FORMAT_ND, outputDtype); \
91- add1.update_output_desc_##outputName(outputName##outputIndex##_desc); 91+ add1.update_output_desc_##outputName(outputName##outputIndex##_desc)
92 92 
93#define ADD_CONST_INPUT(intputIndex, intputName, intputDtype, inputShape) \93#define ADD_CONST_INPUT(intputIndex, intputName, intputDtype, inputShape) \
94 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \94 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \
@@ -112,7 +112,7 @@ using std::vector;
112 graph.AddOp(placeholder##intputIndex); \112 graph.AddOp(placeholder##intputIndex); \
113 add1.set_input_##intputName(placeholder##intputIndex); \113 add1.set_input_##intputName(placeholder##intputIndex); \
114 add1.update_input_desc_##intputName(placeholder##intputIndex##_desc); \114 add1.update_input_desc_##intputName(placeholder##intputIndex##_desc); \
115- inputs.push_back(placeholder##intputIndex);115+ inputs.push_back(placeholder##intputIndex)
116 116 
117#define LOG_PRINT(message, ...) \117#define LOG_PRINT(message, ...) \
118 do { \118 do { \
@@ -197,8 +197,7 @@ int32_t GenOnesData(
197 197 
198int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t *inputData)198int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t *inputData)
199{199{
200- FILE *fp;200+ FILE *fp = fopen(bin_file.c_str(), "w");
201- fp = fopen(bin_file.c_str(), "w");
202 fwrite(inputData, sizeof(uint8_t), data_size, fp);201 fwrite(inputData, sizeof(uint8_t), data_size, fp);
203 fclose(fp);202 fclose(fp);
204 return SUCCESS;203 return SUCCESS;
@@ -57,7 +57,7 @@ using std::vector;
57 input.push_back(tensor_placeholder##intputIndex); \57 input.push_back(tensor_placeholder##intputIndex); \
58 graph.AddOp(placeholder##intputIndex); \58 graph.AddOp(placeholder##intputIndex); \
59 add1.set_input_##intputName(placeholder##intputIndex); \59 add1.set_input_##intputName(placeholder##intputIndex); \
60- inputs.push_back(placeholder##intputIndex);60+ inputs.push_back(placeholder##intputIndex)
61 61 
62#define ADD_INT_INPUT(intputIndex, intputName, intputDtype, inputShape, value) \62#define ADD_INT_INPUT(intputIndex, intputName, intputDtype, inputShape, value) \
63 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \63 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \
@@ -80,7 +80,7 @@ using std::vector;
80 input.push_back(tensor_placeholder##intputIndex); \80 input.push_back(tensor_placeholder##intputIndex); \
81 graph.AddOp(placeholder##intputIndex); \81 graph.AddOp(placeholder##intputIndex); \
82 add1.set_input_##intputName(placeholder##intputIndex); \82 add1.set_input_##intputName(placeholder##intputIndex); \
83- inputs.push_back(placeholder##intputIndex);83+ inputs.push_back(placeholder##intputIndex)
84 84 
85#define ADD_INPUT_ATTR(attrName, attrValue) \85#define ADD_INPUT_ATTR(attrName, attrValue) \
86 add1.set_attr_##attrName(attrValue);86 add1.set_attr_##attrName(attrValue);
@@ -88,7 +88,7 @@ using std::vector;
88#define ADD_OUTPUT(outputIndex, outputName, outputDtype, outputShape) \88#define ADD_OUTPUT(outputIndex, outputName, outputDtype, outputShape) \
89 TensorDesc outputName##outputIndex##_desc = \89 TensorDesc outputName##outputIndex##_desc = \
90 TensorDesc(ge::Shape(outputShape), FORMAT_ND, outputDtype); \90 TensorDesc(ge::Shape(outputShape), FORMAT_ND, outputDtype); \
91- add1.update_output_desc_##outputName(outputName##outputIndex##_desc); 91+ add1.update_output_desc_##outputName(outputName##outputIndex##_desc)
92 92 
93#define ADD_CONST_INPUT(intputIndex, intputName, intputDtype, inputShape) \93#define ADD_CONST_INPUT(intputIndex, intputName, intputDtype, inputShape) \
94 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \94 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \
@@ -112,7 +112,7 @@ using std::vector;
112 graph.AddOp(placeholder##intputIndex); \112 graph.AddOp(placeholder##intputIndex); \
113 add1.set_input_##intputName(placeholder##intputIndex); \113 add1.set_input_##intputName(placeholder##intputIndex); \
114 add1.update_input_desc_##intputName(placeholder##intputIndex##_desc); \114 add1.update_input_desc_##intputName(placeholder##intputIndex##_desc); \
115- inputs.push_back(placeholder##intputIndex);115+ inputs.push_back(placeholder##intputIndex)
116 116 
117#define LOG_PRINT(message, ...) \117#define LOG_PRINT(message, ...) \
118 do { \118 do { \
@@ -197,8 +197,7 @@ int32_t GenOnesData(
197 197 
198int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t *inputData)198int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t *inputData)
199{199{
200- FILE *fp;200+ FILE *fp = fopen(bin_file.c_str(), "w");
201- fp = fopen(bin_file.c_str(), "w");
202 fwrite(inputData, sizeof(uint8_t), data_size, fp);201 fwrite(inputData, sizeof(uint8_t), data_size, fp);
203 fclose(fp);202 fclose(fp);
204 return SUCCESS;203 return SUCCESS;
@@ -37,7 +37,7 @@ static const std::initializer_list<op::DataType> DTYPE_SUPPORT_LIST = {
37 op::DataType::DT_FLOAT16, op::DataType::DT_FLOAT, op::DataType::DT_DOUBLE};37 op::DataType::DT_FLOAT16, op::DataType::DT_FLOAT, op::DataType::DT_DOUBLE};
38 38 
39/* 查看TensorFloat的Dtype和Shape */39/* 查看TensorFloat的Dtype和Shape */
40-static bool CheckTensorAndFloatDtype(const aclTensor* mean, aclTensor* out)40+static bool CheckTensorAndFloatDtype(const aclTensor* mean, const aclTensor* out)
41{41{
42 // 检查mean的数据类型是否在normal算子的支持列表内42 // 检查mean的数据类型是否在normal算子的支持列表内
43 OP_CHECK_DTYPE_NOT_SUPPORT(mean, DTYPE_SUPPORT_LIST, return false);43 OP_CHECK_DTYPE_NOT_SUPPORT(mean, DTYPE_SUPPORT_LIST, return false);
@@ -46,7 +46,7 @@ static bool CheckTensorAndFloatDtype(const aclTensor* mean, aclTensor* out)
46 return true;46 return true;
47}47}
48 48 
49-static bool CheckTensorAndFloatShapeOfMean(const aclTensor* mean, aclTensor* out)49+static bool CheckTensorAndFloatShapeOfMean(const aclTensor* mean, const aclTensor* out)
50{50{
51 OP_CHECK_MAX_DIM(mean, MAX_DIM_LEN, return false);51 OP_CHECK_MAX_DIM(mean, MAX_DIM_LEN, return false);
52 OP_CHECK_MAX_DIM(out, MAX_DIM_LEN, return false);52 OP_CHECK_MAX_DIM(out, MAX_DIM_LEN, return false);
@@ -71,7 +71,7 @@ static inline bool CheckTensorAndFloatNotNull(const aclTensor* mean, aclTensor*
71}71}
72 72 
73/* 查看FloatTensor的Dtype和Shape */73/* 查看FloatTensor的Dtype和Shape */
74-static bool CheckFloatAndTensorDtype(const aclTensor* std, aclTensor* out)74+static bool CheckFloatAndTensorDtype(const aclTensor* std, const aclTensor* out)
75{75{
76 // 检查std的数据类型是否在normal算子的支持列表内76 // 检查std的数据类型是否在normal算子的支持列表内
77 OP_CHECK_DTYPE_NOT_SUPPORT(std, DTYPE_SUPPORT_LIST, return false);77 OP_CHECK_DTYPE_NOT_SUPPORT(std, DTYPE_SUPPORT_LIST, return false);
@@ -79,7 +79,7 @@ static bool CheckFloatAndTensorDtype(const aclTensor* std, aclTensor* out)
79 return true;79 return true;
80}80}
81 81 
82-static bool CheckFloatAndTensorShapeOfStd(const aclTensor* std, aclTensor* out)82+static bool CheckFloatAndTensorShapeOfStd(const aclTensor* std, const aclTensor* out)
83{83{
84 if (std->IsEmpty()) {84 if (std->IsEmpty()) {
85 OP_LOGE(ACLNN_ERR_PARAM_INVALID, "The std can not be an empty tensor.");85 OP_LOGE(ACLNN_ERR_PARAM_INVALID, "The std can not be an empty tensor.");
@@ -104,7 +104,7 @@ static inline bool CheckFloatAndTensorNotNull(const aclTensor* std, aclTensor* o
104}104}
105 105 
106/* 查看TensorTensor的Dtype和Shape */106/* 查看TensorTensor的Dtype和Shape */
107-static bool CheckTensorAndTensorDtype(const aclTensor* mean, const aclTensor* std, aclTensor* out)107+static bool CheckTensorAndTensorDtype(const aclTensor* mean, const aclTensor* std, const aclTensor* out)
108{108{
109 // 检查std/mean的数据类型是否在normal算子的支持列表内109 // 检查std/mean的数据类型是否在normal算子的支持列表内
110 OP_CHECK_DTYPE_NOT_SUPPORT(mean, DTYPE_SUPPORT_LIST, return false);110 OP_CHECK_DTYPE_NOT_SUPPORT(mean, DTYPE_SUPPORT_LIST, return false);
@@ -114,7 +114,7 @@ static bool CheckTensorAndTensorDtype(const aclTensor* mean, const aclTensor* st
114 return true;114 return true;
115}115}
116 116 
117-static bool CheckTensorAndTensorShape(const aclTensor* mean, const aclTensor* std, aclTensor* out)117+static bool CheckTensorAndTensorShape(const aclTensor* mean, const aclTensor* std, const aclTensor* out)
118{118{
119 // 检查std和mean的维度是否大于8119 // 检查std和mean的维度是否大于8
120 OP_CHECK_MAX_DIM(mean, MAX_DIM_LEN, return false);120 OP_CHECK_MAX_DIM(mean, MAX_DIM_LEN, return false);
@@ -140,7 +140,7 @@ static inline bool CheckTensorAndTensorNotNull(const aclTensor* mean, const aclT
140 return true;140 return true;
141}141}
142 142 
143-static bool CheckPromoteType(const aclTensor* mean, const aclTensor* std, aclTensor* out, op::DataType promoteType)143+static bool CheckPromoteType(const aclTensor* mean, const aclTensor* std, const aclTensor* out, op::DataType promoteType)
144{144{
145 // 检查self和other能否做数据类型推导145 // 检查self和other能否做数据类型推导
146 if (promoteType == DataType::DT_UNDEFINED) {146 if (promoteType == DataType::DT_UNDEFINED) {
@@ -74,7 +74,7 @@ static const aclTensor* StatelessRandomNormalV2AiCpu(
74}74}
75 75 
76const aclTensor* StatelessRandomNormalV2(76const aclTensor* StatelessRandomNormalV2(
77- const aclTensor* result, const aclIntArray* key, const aclIntArray* counter, const aclTensor* algTensor,77+ const aclTensor* result, const aclIntArray* key, const aclIntArray* counter, const aclTensor* alg,
78 aclOpExecutor* executor)78 aclOpExecutor* executor)
79{79{
80 auto outTensor = executor->AllocTensor(result->GetViewShape(), result->GetDataType(), result->GetViewFormat());80 auto outTensor = executor->AllocTensor(result->GetViewShape(), result->GetDataType(), result->GetViewFormat());
@@ -86,11 +86,9 @@ const aclTensor* StatelessRandomNormalV2(
86 auto counterTensor = executor->ConvertToTensor(counter, op::ToOpDataType(ACL_UINT64));86 auto counterTensor = executor->ConvertToTensor(counter, op::ToOpDataType(ACL_UINT64));
87 87 
88 if (IsAiCoreSupport(outTensor->GetDataType())) {88 if (IsAiCoreSupport(outTensor->GetDataType())) {
89- return StatelessRandomNormalV2AiCore(89+ return StatelessRandomNormalV2AiCore(result, shapeTensor, keyTensor, counterTensor, alg, outTensor, executor);
90- result, shapeTensor, keyTensor, counterTensor, algTensor, outTensor, executor);
91 } else {90 } else {
92- return StatelessRandomNormalV2AiCpu(91+ return StatelessRandomNormalV2AiCpu(result, shapeTensor, keyTensor, counterTensor, alg, outTensor, executor);
93- result, shapeTensor, keyTensor, counterTensor, algTensor, outTensor, executor);
94 }92 }
95}93}
96} // namespace l0op94} // namespace l0op
@@ -57,7 +57,7 @@ using std::vector;
57 input.push_back(tensor_placeholder##intputIndex); \57 input.push_back(tensor_placeholder##intputIndex); \
58 graph.AddOp(placeholder##intputIndex); \58 graph.AddOp(placeholder##intputIndex); \
59 add1.set_input_##intputName(placeholder##intputIndex); \59 add1.set_input_##intputName(placeholder##intputIndex); \
60- inputs.push_back(placeholder##intputIndex);60+ inputs.push_back(placeholder##intputIndex)
61 61 
62#define ADD_INT_INPUT(intputIndex, intputName, intputDtype, inputShape, value) \62#define ADD_INT_INPUT(intputIndex, intputName, intputDtype, inputShape, value) \
63 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \63 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \
@@ -80,15 +80,15 @@ using std::vector;
80 input.push_back(tensor_placeholder##intputIndex); \80 input.push_back(tensor_placeholder##intputIndex); \
81 graph.AddOp(placeholder##intputIndex); \81 graph.AddOp(placeholder##intputIndex); \
82 add1.set_input_##intputName(placeholder##intputIndex); \82 add1.set_input_##intputName(placeholder##intputIndex); \
83- inputs.push_back(placeholder##intputIndex);83+ inputs.push_back(placeholder##intputIndex)
84 84 
85#define ADD_INPUT_ATTR(attrName, attrValue) \85#define ADD_INPUT_ATTR(attrName, attrValue) \
86- add1.set_attr_##attrName(attrValue);86+ add1.set_attr_##attrName(attrValue)
87 87 
88#define ADD_OUTPUT(outputIndex, outputName, outputDtype, outputShape) \88#define ADD_OUTPUT(outputIndex, outputName, outputDtype, outputShape) \
89 TensorDesc outputName##outputIndex##_desc = \89 TensorDesc outputName##outputIndex##_desc = \
90 TensorDesc(ge::Shape(outputShape), FORMAT_ND, outputDtype); \90 TensorDesc(ge::Shape(outputShape), FORMAT_ND, outputDtype); \
91- add1.update_output_desc_##outputName(outputName##outputIndex##_desc); 91+ add1.update_output_desc_##outputName(outputName##outputIndex##_desc)
92 92 
93#define ADD_CONST_INPUT(intputIndex, intputName, intputDtype, inputShape) \93#define ADD_CONST_INPUT(intputIndex, intputName, intputDtype, inputShape) \
94 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \94 vector<int64_t> placeholder##intputIndex##_shape = inputShape; \
@@ -112,7 +112,7 @@ using std::vector;
112 graph.AddOp(placeholder##intputIndex); \112 graph.AddOp(placeholder##intputIndex); \
113 add1.set_input_##intputName(placeholder##intputIndex); \113 add1.set_input_##intputName(placeholder##intputIndex); \
114 add1.update_input_desc_##intputName(placeholder##intputIndex##_desc); \114 add1.update_input_desc_##intputName(placeholder##intputIndex##_desc); \
115- inputs.push_back(placeholder##intputIndex);115+ inputs.push_back(placeholder##intputIndex)
116 116 
117#define LOG_PRINT(message, ...) \117#define LOG_PRINT(message, ...) \
118 do { \118 do { \
@@ -197,8 +197,7 @@ int32_t GenOnesData(
197 197 
198int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t *inputData)198int32_t WriteDataToFile(string bin_file, uint64_t data_size, uint8_t *inputData)
199{199{
200- FILE *fp;200+ FILE *fp = fopen(bin_file.c_str(), "w");
201- fp = fopen(bin_file.c_str(), "w");
202 fwrite(inputData, sizeof(uint8_t), data_size, fp);201 fwrite(inputData, sizeof(uint8_t), data_size, fp);
203 fclose(fp);202 fclose(fp);
204 return SUCCESS;203 return SUCCESS;