diff --git a/ai/mindspore/BUILD.gn b/ai/mindspore/BUILD.gn index 5849705710379a1b8eff24ea15d69b08d581466e..46403f16e90a26718475c9715c8b3b402f5c8e70 100644 --- a/ai/mindspore/BUILD.gn +++ b/ai/mindspore/BUILD.gn @@ -28,6 +28,7 @@ ohos_moduletest_suite("ActsMindSporeTest") { configs = [ ":mindspore_config" ] + external_deps = [ "c_utils:utils" ] deps = [ "//third_party/googletest:gmock", "//third_party/googletest:gtest", diff --git a/ai/mindspore/src/ohos_c_api_test_mslite.cpp b/ai/mindspore/src/ohos_c_api_test_mslite.cpp index 49573fe347dbff721d4915c7d22a173f7e25d1b9..d86cd2869b8de493a1046b94bf5e65101e7d4c34 100644 --- a/ai/mindspore/src/ohos_c_api_test_mslite.cpp +++ b/ai/mindspore/src/ohos_c_api_test_mslite.cpp @@ -15,6 +15,7 @@ #include #include +#include #include "ohos_common.h" #include "gtest/gtest.h" #include "include/c_api/context_c.h" @@ -90,9 +91,9 @@ void FillInputsData(OH_AI_TensorHandleArray inputs, string model_name, bool is_t const int64_t *shape = OH_AI_TensorGetShape(tensor, &shape_num); auto imageBuf_nhwc = new char[size1]; PackNCHWToNHWCFp32(imageBuf, imageBuf_nhwc, shape[0], shape[1] * shape[2], shape[3]); - memcpy(input_data, imageBuf_nhwc, size1); + memcpy_s(input_data, size1, imageBuf_nhwc, size1); } else { - memcpy(input_data, imageBuf, size1); + memcpy_s(input_data, size1, imageBuf, size1); } printf("input data after filling is: "); for (int j = 0; j < element_num && j <= 20; ++j) { @@ -958,7 +959,7 @@ HWTEST(MSLiteTest, OHOS_Model_GetInputByTensorName_0001, Function | MediumTest | const int64_t *shape = OH_AI_TensorGetShape(tensor, &shape_num); auto imageBuf_nhwc = new char[size1]; PackNCHWToNHWCFp32(imageBuf, imageBuf_nhwc, shape[0], shape[1] * shape[2], shape[3]); - memcpy(input_data, imageBuf_nhwc, size1); + memcpy_s(input_data, size1, imageBuf_nhwc, size1); printf("input data is:"); for (int j = 0; j < element_num && j <= 20; ++j) { printf("%f ", input_data[j]); @@ -1479,7 +1480,7 @@ HWTEST(MSLiteTest, OHOS_Input_0003, Function | MediumTest | Level1) { printf("Tensor name: %s, elements num: %" PRId64 ".\n", OH_AI_TensorGetName(tensor), element_num); void *input_data = OH_AI_TensorGetMutableData(inputs.handle_list[i]); ASSERT_NE(input_data, nullptr); - memcpy(input_data, imageBuf, size1); + memcpy_s(input_data, size1, imageBuf, size1); } printf("==========Model Predict==========\n"); OH_AI_TensorHandleArray outputs;