AAlice_zhouupdate
97284875Add on Oct 8History
#include <iostream>
#include <vector>
#include <getopt.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <ctime>
#include <sys/wait.h>
#include <dlfcn.h>
#include <unistd.h>
#include <cstdio>
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <string.h>
#include <time.h>
#include <ctime>
#include <list>
#include <algorithm>
#include <stdarg.h>
#include "acl/acl.h"
#include "aclnn/aclnn_base.h"
#include "acl/acl_base.h"
#include "acl/acl_rt.h"
#include "sec_common.h"
#include "utils.h"
#include <complex>
#include "../fuzzlib/secodeFuzz.h"
#include "aclnnop/aclnn_addcmul.h"

using namespace std;

static const char* GetNonContigSceneName(int scene) {
    switch(scene) {
        case 0: return "CONTINUOUS";
        case 1: return "BROADCAST";
        case 2: return "SLICE";
        case 3: return "ASSTRIDED";
        case 4: return "STORAGE_PADDED";
        case 5: return "TRANSPOSE";
        default: return "UNKNOWN";
    }
}

int aclnnAddcmul_non_contig(int fuzz_num)
{
    auto ret = Init(deviceId, &context, &stream);
    // check根据自己的需要处理
    CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Init acl failed. ERROR: %d\n", ret); return ret);
    WriteDTLog("aclnnAddcmul", "aclnnAddcmul non_contig op fuzz start \n");
    // aclDataType definition at acl/acl_base.h
    int dtype0Enum[] = { 0, 1, 11, 27, 3, 9, 2, 4 };
    int dtype0Num = sizeof(dtype0Enum) / sizeof(dtype0Enum[0]);
    int dim0Enum[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
    int dim0Num = sizeof(dim0Enum) / sizeof(dim0Enum[0]);
    int scalar_dtype0Enum[] = { 0, 1, 11, 27, 3, 9, 2, 4 };
    int scalar_dtype0Num = sizeof(scalar_dtype0Enum) / sizeof(scalar_dtype0Enum[0]);

    aclrtSetOpExecuteTimeOut(1091);
    DT_Set_TimeOut_Second(3000);
        int success_count = 0;
    int faild_count = 0;
DT_FUZZ_START(0, fuzz_num, "aclnnAddcmul_non_contig",0)
    {
        int i=0;
        void* selfDeviceAddr = nullptr;
        void* tensor1DeviceAddr = nullptr;
        void* tensor2DeviceAddr = nullptr;
        void* outDeviceAddr = nullptr;
        aclTensor* self = nullptr;
        aclTensor* tensor1 = nullptr;
        aclTensor* tensor2 = nullptr;
        aclTensor* out = nullptr;
        aclScalar* value = nullptr;
        uint64_t workspaceSize = 0;
        aclOpExecutor* executor;
        void* workspaceAddr = nullptr;
        LOG_PRINT("aclnnAddcmul_non_contig %d\n",fuzzi);
            printf("[FUZZ_LOG] plog_file: aclnnAddcmul_non_contig_plog_case_%d\n", fuzzi);
        try
        {

            // === Tensor Size distribution control ===

            int sizeBucket = *(int *)DTSetGetNumberRange(&g_Element[i++], 1, 0, 3, "i");

            long long totalSizeMin = 0, totalSizeMax = 0;

            switch (sizeBucket) {

                case 0: totalSizeMin = 1;          totalSizeMax = 1000;          break;

                case 1: totalSizeMin = 1001;       totalSizeMax = 1073741824LL;  break;

                case 2: totalSizeMin = 1073741825LL; totalSizeMax = 2147483648LL; break;

                case 3: totalSizeMin = 2147483649LL; totalSizeMax = 4294967296LL; break;

            }

        // 创建调用DT获取变异数据
            auto dtype0 = (aclDataType)*(int *)DT_SetGetNumberEnumV3(i++, aclDataType::ACL_FLOAT, dtype0Enum, dtype0Num);
            printf("dtype0: %d\n",dtype0);
            auto scalar_dtype0 = dtype0;
            printf("scalar_dtype0: %d\n",scalar_dtype0);
            int dim_num0 = *(int *)DT_SetGetNumberEnumV3(i++, 1, dim0Enum, dim0Num);
            int valueValue = *(int *)DTSetGetNumberRange(&g_Element[i++],1,-100,100,"i");;
            printf("value: %d\n", valueValue);
            //创建 value aclScalar
            value = aclCreateScalar(&valueValue, scalar_dtype0);
            CHECK_RET(value != nullptr, goto ERROR);

            std::vector <int64_t> selfShape = {};
            std::vector <int64_t> tensor1Shape = {};
            std::vector <int64_t> tensor2Shape = {};
            std::vector <int64_t> outShape = {};
            for (int64_t index = 0; index < dim_num0; index++){
                int64_t dim_value = *(int * )DTSetGetNumberRange(&g_Element[i++], 5, 1, MAX_SHAPE_SIZE, "i");
                selfShape.push_back(dim_value);
                tensor1Shape.push_back(dim_value);
                tensor2Shape.push_back(dim_value);
                outShape.push_back(dim_value);
            }
            aclFormat format0;
            if(dim_num0 == 1){
                printf("selfShape:{%d}\n",selfShape[0]);
                printf("tensor1Shape:{%d}\n",tensor1Shape[0]);
                printf("tensor2Shape:{%d}\n",tensor2Shape[0]);
                printf("outShape:{%d}\n",outShape[0]);
                format0 = aclFormat::ACL_FORMAT_ND;
            } else if(dim_num0 == 2){
                printf("selfShape:{%d,%d}\n",selfShape[0],selfShape[1]);
                printf("tensor1Shape:{%d,%d}\n",tensor1Shape[0],tensor1Shape[1]);
                printf("tensor2Shape:{%d,%d}\n",tensor2Shape[0],tensor2Shape[1]);
                printf("outShape:{%d,%d}\n",outShape[0],outShape[1]);
                format0 = aclFormat::ACL_FORMAT_ND;
            } else if(dim_num0 == 3){
                printf("selfShape:{%d,%d,%d}\n",selfShape[0],selfShape[1],selfShape[2]);
                printf("tensor1Shape:{%d,%d,%d}\n",tensor1Shape[0],tensor1Shape[1],tensor1Shape[2]);
                printf("tensor2Shape:{%d,%d,%d}\n",tensor2Shape[0],tensor2Shape[1],tensor2Shape[2]);
                printf("outShape:{%d,%d,%d}\n",outShape[0],outShape[1],outShape[2]);
                format0 = aclFormat::ACL_FORMAT_ND;
            } else if(dim_num0 == 4){
                printf("selfShape:{%d,%d,%d,%d}\n",selfShape[0],selfShape[1],selfShape[2],selfShape[3]);
                printf("tensor1Shape:{%d,%d,%d,%d}\n",tensor1Shape[0],tensor1Shape[1],tensor1Shape[2],tensor1Shape[3]);
                printf("tensor2Shape:{%d,%d,%d,%d}\n",tensor2Shape[0],tensor2Shape[1],tensor2Shape[2],tensor2Shape[3]);
                printf("outShape:{%d,%d,%d,%d}\n",outShape[0],outShape[1],outShape[2],outShape[3]);
                format0 = aclFormat::ACL_FORMAT_ND;
            } else if(dim_num0 == 5){
                printf("selfShape:{%d,%d,%d,%d,%d}\n",selfShape[0],selfShape[1],selfShape[2],selfShape[3],selfShape[4]);
                printf("tensor1Shape:{%d,%d,%d,%d,%d}\n",tensor1Shape[0],tensor1Shape[1],tensor1Shape[2],tensor1Shape[3],tensor1Shape[4]);
                printf("tensor2Shape:{%d,%d,%d,%d,%d}\n",tensor2Shape[0],tensor2Shape[1],tensor2Shape[2],tensor2Shape[3],tensor2Shape[4]);
                printf("outShape:{%d,%d,%d,%d,%d}\n",outShape[0],outShape[1],outShape[2],outShape[3],outShape[4]);
                format0 = aclFormat::ACL_FORMAT_ND;
            } else if(dim_num0 == 6){
                printf("selfShape:{%d,%d,%d,%d,%d,%d}\n",selfShape[0],selfShape[1],selfShape[2],selfShape[3],selfShape[4],selfShape[5]);
                printf("tensor1Shape:{%d,%d,%d,%d,%d,%d}\n",tensor1Shape[0],tensor1Shape[1],tensor1Shape[2],tensor1Shape[3],tensor1Shape[4],tensor1Shape[5]);
                printf("tensor2Shape:{%d,%d,%d,%d,%d,%d}\n",tensor2Shape[0],tensor2Shape[1],tensor2Shape[2],tensor2Shape[3],tensor2Shape[4],tensor2Shape[5]);
                printf("outShape:{%d,%d,%d,%d,%d,%d}\n",outShape[0],outShape[1],outShape[2],outShape[3],outShape[4],outShape[5]);
                format0 = aclFormat::ACL_FORMAT_ND;
            } else if(dim_num0 == 7){
                printf("selfShape:{%d,%d,%d,%d,%d,%d,%d}\n",selfShape[0],selfShape[1],selfShape[2],selfShape[3],selfShape[4],selfShape[5],selfShape[6]);
                printf("tensor1Shape:{%d,%d,%d,%d,%d,%d,%d}\n",tensor1Shape[0],tensor1Shape[1],tensor1Shape[2],tensor1Shape[3],tensor1Shape[4],tensor1Shape[5],tensor1Shape[6]);
                printf("tensor2Shape:{%d,%d,%d,%d,%d,%d,%d}\n",tensor2Shape[0],tensor2Shape[1],tensor2Shape[2],tensor2Shape[3],tensor2Shape[4],tensor2Shape[5],tensor2Shape[6]);
                printf("outShape:{%d,%d,%d,%d,%d,%d,%d}\n",outShape[0],outShape[1],outShape[2],outShape[3],outShape[4],outShape[5],outShape[6]);
                format0 = aclFormat::ACL_FORMAT_ND;
            } else if(dim_num0 == 8){
                printf("selfShape:{%d,%d,%d,%d,%d,%d,%d,%d}\n",selfShape[0],selfShape[1],selfShape[2],selfShape[3],selfShape[4],selfShape[5],selfShape[6],selfShape[7]);
                printf("tensor1Shape:{%d,%d,%d,%d,%d,%d,%d,%d}\n",tensor1Shape[0],tensor1Shape[1],tensor1Shape[2],tensor1Shape[3],tensor1Shape[4],tensor1Shape[5],tensor1Shape[6],tensor1Shape[7]);
                printf("tensor2Shape:{%d,%d,%d,%d,%d,%d,%d,%d}\n",tensor2Shape[0],tensor2Shape[1],tensor2Shape[2],tensor2Shape[3],tensor2Shape[4],tensor2Shape[5],tensor2Shape[6],tensor2Shape[7]);
                printf("outShape:{%d,%d,%d,%d,%d,%d,%d,%d}\n",outShape[0],outShape[1],outShape[2],outShape[3],outShape[4],outShape[5],outShape[6],outShape[7]);
                format0 = aclFormat::ACL_FORMAT_ND;
            } 
            long long selfShape_size = GetShapeSize(selfShape);
            if(selfShape_size > SHAPE_SIZE_CTL)
            {
                printf("selfShape_size too big\n");
                goto ERROR;
            }
            long long tensor1Shape_size = GetShapeSize(tensor1Shape);
            if(tensor1Shape_size > SHAPE_SIZE_CTL)
            {
                printf("tensor1Shape_size too big\n");
                goto ERROR;
            }
            long long tensor2Shape_size = GetShapeSize(tensor2Shape);
            if(tensor2Shape_size > SHAPE_SIZE_CTL)
            {
                printf("tensor2Shape_size too big\n");
                goto ERROR;
            }
            long long outShape_size = GetShapeSize(outShape);
            if(outShape_size > SHAPE_SIZE_CTL)
            {
                printf("outShape_size too big\n");
                goto ERROR;
            }
            NonContigParams ncSelf;
            ncSelf.scene = *(int *)DTSetGetNumberRange(&g_Element[i++], 1, 2, 5, "i");
            if (ncSelf.scene < 2) ncSelf.scene = 2;
            ncSelf.viewShape = selfShape;
            ncSelf.sliceStep = *(int64_t *)DTSetGetNumberRangeS64(&g_Element[i++], 2, 2, 5, "i");
            ncSelf.sliceAxis = 0;
            ncSelf.offset = 0;
            ncSelf.pos1 = *(int *)DTSetGetNumberRange(&g_Element[i++], 1, 1, 4, "i");
            ncSelf.pos2 = *(int *)DTSetGetNumberRange(&g_Element[i++], 2, 1, 4, "i");
            ncSelf.strides.resize(selfShape.size());
            for (size_t j = 0; j < selfShape.size(); j++) {
                ncSelf.strides[j] = *(int64_t *)DTSetGetNumberRangeS64(&g_Element[i++], 2, 1, 20, "i");
            }
            CalcNonContiguousParams(ncSelf);
            long long selfStorageSize = GetShapeSize(ncSelf.storageShape);
            printf("[NON_CONTIG] ncSelf scene=%s(%d), originalShape=[", GetNonContigSceneName(ncSelf.scene), ncSelf.scene);
            for (int _i = 0; _i < (int)selfShape.size(); _i++) printf("%lld%s", (long long)selfShape[_i], _i < (int)selfShape.size() - 1 ? "," : "");
            printf("], viewShape=[");
            for (int _i = 0; _i < (int)ncSelf.viewShape.size(); _i++) printf("%lld%s", (long long)ncSelf.viewShape[_i], _i < (int)ncSelf.viewShape.size() - 1 ? "," : "");
            printf("], viewStrides=[");
            for (int _i = 0; _i < (int)ncSelf.strides.size(); _i++) printf("%lld%s", (long long)ncSelf.strides[_i], _i < (int)ncSelf.strides.size() - 1 ? "," : "");
            printf("], storageShape=[");
            for (int _i = 0; _i < (int)ncSelf.storageShape.size(); _i++) printf("%lld%s", (long long)ncSelf.storageShape[_i], _i < (int)ncSelf.storageShape.size() - 1 ? "," : "");
            printf("], offset=%lld\n", (long long)ncSelf.offset);
            NonContigParams ncTensor1;
            ncTensor1.scene = *(int *)DTSetGetNumberRange(&g_Element[i++], 1, 2, 5, "i");
            if (ncTensor1.scene < 2) ncTensor1.scene = 2;
            ncTensor1.viewShape = tensor1Shape;
            ncTensor1.sliceStep = *(int64_t *)DTSetGetNumberRangeS64(&g_Element[i++], 2, 2, 5, "i");
            ncTensor1.sliceAxis = 0;
            ncTensor1.offset = 0;
            ncTensor1.pos1 = *(int *)DTSetGetNumberRange(&g_Element[i++], 1, 1, 4, "i");
            ncTensor1.pos2 = *(int *)DTSetGetNumberRange(&g_Element[i++], 2, 1, 4, "i");
            ncTensor1.strides.resize(tensor1Shape.size());
            for (size_t j = 0; j < tensor1Shape.size(); j++) {
                ncTensor1.strides[j] = *(int64_t *)DTSetGetNumberRangeS64(&g_Element[i++], 2, 1, 20, "i");
            }
            CalcNonContiguousParams(ncTensor1);
            long long tensor1StorageSize = GetShapeSize(ncTensor1.storageShape);
            printf("[NON_CONTIG] ncTensor1 scene=%s(%d), originalShape=[", GetNonContigSceneName(ncTensor1.scene), ncTensor1.scene);
            for (int _i = 0; _i < (int)tensor1Shape.size(); _i++) printf("%lld%s", (long long)tensor1Shape[_i], _i < (int)tensor1Shape.size() - 1 ? "," : "");
            printf("], viewShape=[");
            for (int _i = 0; _i < (int)ncTensor1.viewShape.size(); _i++) printf("%lld%s", (long long)ncTensor1.viewShape[_i], _i < (int)ncTensor1.viewShape.size() - 1 ? "," : "");
            printf("], viewStrides=[");
            for (int _i = 0; _i < (int)ncTensor1.strides.size(); _i++) printf("%lld%s", (long long)ncTensor1.strides[_i], _i < (int)ncTensor1.strides.size() - 1 ? "," : "");
            printf("], storageShape=[");
            for (int _i = 0; _i < (int)ncTensor1.storageShape.size(); _i++) printf("%lld%s", (long long)ncTensor1.storageShape[_i], _i < (int)ncTensor1.storageShape.size() - 1 ? "," : "");
            printf("], offset=%lld\n", (long long)ncTensor1.offset);
            NonContigParams ncTensor2;
            ncTensor2.scene = *(int *)DTSetGetNumberRange(&g_Element[i++], 1, 2, 5, "i");
            if (ncTensor2.scene < 2) ncTensor2.scene = 2;
            ncTensor2.viewShape = tensor2Shape;
            ncTensor2.sliceStep = *(int64_t *)DTSetGetNumberRangeS64(&g_Element[i++], 2, 2, 5, "i");
            ncTensor2.sliceAxis = 0;
            ncTensor2.offset = 0;
            ncTensor2.pos1 = *(int *)DTSetGetNumberRange(&g_Element[i++], 1, 1, 4, "i");
            ncTensor2.pos2 = *(int *)DTSetGetNumberRange(&g_Element[i++], 2, 1, 4, "i");
            ncTensor2.strides.resize(tensor2Shape.size());
            for (size_t j = 0; j < tensor2Shape.size(); j++) {
                ncTensor2.strides[j] = *(int64_t *)DTSetGetNumberRangeS64(&g_Element[i++], 2, 1, 20, "i");
            }
            CalcNonContiguousParams(ncTensor2);
            long long tensor2StorageSize = GetShapeSize(ncTensor2.storageShape);
            printf("[NON_CONTIG] ncTensor2 scene=%s(%d), originalShape=[", GetNonContigSceneName(ncTensor2.scene), ncTensor2.scene);
            for (int _i = 0; _i < (int)tensor2Shape.size(); _i++) printf("%lld%s", (long long)tensor2Shape[_i], _i < (int)tensor2Shape.size() - 1 ? "," : "");
            printf("], viewShape=[");
            for (int _i = 0; _i < (int)ncTensor2.viewShape.size(); _i++) printf("%lld%s", (long long)ncTensor2.viewShape[_i], _i < (int)ncTensor2.viewShape.size() - 1 ? "," : "");
            printf("], viewStrides=[");
            for (int _i = 0; _i < (int)ncTensor2.strides.size(); _i++) printf("%lld%s", (long long)ncTensor2.strides[_i], _i < (int)ncTensor2.strides.size() - 1 ? "," : "");
            printf("], storageShape=[");
            for (int _i = 0; _i < (int)ncTensor2.storageShape.size(); _i++) printf("%lld%s", (long long)ncTensor2.storageShape[_i], _i < (int)ncTensor2.storageShape.size() - 1 ? "," : "");
            printf("], offset=%lld\n", (long long)ncTensor2.offset);
            NonContigParams ncOut;
            ncOut.scene = *(int *)DTSetGetNumberRange(&g_Element[i++], 1, 2, 5, "i");
            if (ncOut.scene < 2) ncOut.scene = 2;
            ncOut.viewShape = outShape;
            ncOut.sliceStep = *(int64_t *)DTSetGetNumberRangeS64(&g_Element[i++], 2, 2, 5, "i");
            ncOut.sliceAxis = 0;
            ncOut.offset = 0;
            ncOut.pos1 = *(int *)DTSetGetNumberRange(&g_Element[i++], 1, 1, 4, "i");
            ncOut.pos2 = *(int *)DTSetGetNumberRange(&g_Element[i++], 2, 1, 4, "i");
            ncOut.strides.resize(outShape.size());
            for (size_t j = 0; j < outShape.size(); j++) {
                ncOut.strides[j] = *(int64_t *)DTSetGetNumberRangeS64(&g_Element[i++], 2, 1, 20, "i");
            }
            CalcNonContiguousParams(ncOut);
            long long outStorageSize = GetShapeSize(ncOut.storageShape);
            printf("[NON_CONTIG] ncOut scene=%s(%d), originalShape=[", GetNonContigSceneName(ncOut.scene), ncOut.scene);
            for (int _i = 0; _i < (int)outShape.size(); _i++) printf("%lld%s", (long long)outShape[_i], _i < (int)outShape.size() - 1 ? "," : "");
            printf("], viewShape=[");
            for (int _i = 0; _i < (int)ncOut.viewShape.size(); _i++) printf("%lld%s", (long long)ncOut.viewShape[_i], _i < (int)ncOut.viewShape.size() - 1 ? "," : "");
            printf("], viewStrides=[");
            for (int _i = 0; _i < (int)ncOut.strides.size(); _i++) printf("%lld%s", (long long)ncOut.strides[_i], _i < (int)ncOut.strides.size() - 1 ? "," : "");
            printf("], storageShape=[");
            for (int _i = 0; _i < (int)ncOut.storageShape.size(); _i++) printf("%lld%s", (long long)ncOut.storageShape[_i], _i < (int)ncOut.storageShape.size() - 1 ? "," : "");
            printf("], offset=%lld\n", (long long)ncOut.offset);
            if (dtype0 == aclDataType::ACL_FLOAT) {
                // 创建self aclTensor
                std::vector<float> selfHostData (selfStorageSize, 1);

                // === Tensor Size distribution check ===

                long long totalSize = selfShape_size + tensor1Shape_size + tensor2Shape_size + outShape_size + selfStorageSize + tensor1StorageSize + tensor2StorageSize + outStorageSize;

                if (totalSize < totalSizeMin || totalSize > totalSizeMax) { goto ERROR; }

                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, dtype0, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor1 aclTensor
                std::vector<float> tensor1HostData (tensor1StorageSize, 1);
                ret = CreateAclTensorByScene(tensor1HostData, ncTensor1, &tensor1DeviceAddr, dtype0, ACL_FORMAT_ND, &tensor1);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor2 aclTensor
                std::vector<float> tensor2HostData (tensor2StorageSize, 1);
                ret = CreateAclTensorByScene(tensor2HostData, ncTensor2, &tensor2DeviceAddr, dtype0, ACL_FORMAT_ND, &tensor2);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建out aclTensor
                std::vector<float> outHostData (outStorageSize, 1);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, dtype0, ACL_FORMAT_ND, &out);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
            } else if (dtype0 == aclDataType::ACL_FLOAT16) {
                // 创建self aclTensor
                std::vector<int16_t> selfHostData (selfStorageSize, 1);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, dtype0, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor1 aclTensor
                std::vector<int16_t> tensor1HostData (tensor1StorageSize, 1);
                ret = CreateAclTensorByScene(tensor1HostData, ncTensor1, &tensor1DeviceAddr, dtype0, ACL_FORMAT_ND, &tensor1);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor2 aclTensor
                std::vector<int16_t> tensor2HostData (tensor2StorageSize, 1);
                ret = CreateAclTensorByScene(tensor2HostData, ncTensor2, &tensor2DeviceAddr, dtype0, ACL_FORMAT_ND, &tensor2);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建out aclTensor
                std::vector<int16_t> outHostData (outStorageSize, 1);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, dtype0, ACL_FORMAT_ND, &out);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
            } else if (dtype0 == aclDataType::ACL_DOUBLE) {
                // 创建self aclTensor
                std::vector<double> selfHostData (selfStorageSize, 1);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, dtype0, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor1 aclTensor
                std::vector<double> tensor1HostData (tensor1StorageSize, 1);
                ret = CreateAclTensorByScene(tensor1HostData, ncTensor1, &tensor1DeviceAddr, dtype0, ACL_FORMAT_ND, &tensor1);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor2 aclTensor
                std::vector<double> tensor2HostData (tensor2StorageSize, 1);
                ret = CreateAclTensorByScene(tensor2HostData, ncTensor2, &tensor2DeviceAddr, dtype0, ACL_FORMAT_ND, &tensor2);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建out aclTensor
                std::vector<double> outHostData (outStorageSize, 1);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, dtype0, ACL_FORMAT_ND, &out);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
            } else if (dtype0 == aclDataType::ACL_BF16) {
                // 创建self aclTensor
                std::vector<int16_t> selfHostData (selfStorageSize, 1);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, dtype0, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor1 aclTensor
                std::vector<int16_t> tensor1HostData (tensor1StorageSize, 1);
                ret = CreateAclTensorByScene(tensor1HostData, ncTensor1, &tensor1DeviceAddr, dtype0, ACL_FORMAT_ND, &tensor1);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor2 aclTensor
                std::vector<int16_t> tensor2HostData (tensor2StorageSize, 1);
                ret = CreateAclTensorByScene(tensor2HostData, ncTensor2, &tensor2DeviceAddr, dtype0, ACL_FORMAT_ND, &tensor2);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建out aclTensor
                std::vector<int16_t> outHostData (outStorageSize, 1);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, dtype0, ACL_FORMAT_ND, &out);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
            } else if (dtype0 == aclDataType::ACL_INT32) {
                // 创建self aclTensor
                std::vector<int32_t> selfHostData (selfStorageSize, 1);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, dtype0, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor1 aclTensor
                std::vector<int32_t> tensor1HostData (tensor1StorageSize, 1);
                ret = CreateAclTensorByScene(tensor1HostData, ncTensor1, &tensor1DeviceAddr, dtype0, ACL_FORMAT_ND, &tensor1);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor2 aclTensor
                std::vector<int32_t> tensor2HostData (tensor2StorageSize, 1);
                ret = CreateAclTensorByScene(tensor2HostData, ncTensor2, &tensor2DeviceAddr, dtype0, ACL_FORMAT_ND, &tensor2);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建out aclTensor
                std::vector<int32_t> outHostData (outStorageSize, 1);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, dtype0, ACL_FORMAT_ND, &out);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
            } else if (dtype0 == aclDataType::ACL_INT64) {
                // 创建self aclTensor
                std::vector<int64_t> selfHostData (selfStorageSize, 1);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, dtype0, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor1 aclTensor
                std::vector<int64_t> tensor1HostData (tensor1StorageSize, 1);
                ret = CreateAclTensorByScene(tensor1HostData, ncTensor1, &tensor1DeviceAddr, dtype0, ACL_FORMAT_ND, &tensor1);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor2 aclTensor
                std::vector<int64_t> tensor2HostData (tensor2StorageSize, 1);
                ret = CreateAclTensorByScene(tensor2HostData, ncTensor2, &tensor2DeviceAddr, dtype0, ACL_FORMAT_ND, &tensor2);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建out aclTensor
                std::vector<int64_t> outHostData (outStorageSize, 1);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, dtype0, ACL_FORMAT_ND, &out);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
            } else if (dtype0 == aclDataType::ACL_INT8) {
                // 创建self aclTensor
                std::vector<int8_t> selfHostData (selfStorageSize, 1);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, dtype0, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor1 aclTensor
                std::vector<int8_t> tensor1HostData (tensor1StorageSize, 1);
                ret = CreateAclTensorByScene(tensor1HostData, ncTensor1, &tensor1DeviceAddr, dtype0, ACL_FORMAT_ND, &tensor1);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor2 aclTensor
                std::vector<int8_t> tensor2HostData (tensor2StorageSize, 1);
                ret = CreateAclTensorByScene(tensor2HostData, ncTensor2, &tensor2DeviceAddr, dtype0, ACL_FORMAT_ND, &tensor2);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建out aclTensor
                std::vector<int8_t> outHostData (outStorageSize, 1);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, dtype0, ACL_FORMAT_ND, &out);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
            } else if (dtype0 == aclDataType::ACL_UINT8) {
                // 创建self aclTensor
                std::vector<uint8_t> selfHostData (selfStorageSize, 1);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, dtype0, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor1 aclTensor
                std::vector<uint8_t> tensor1HostData (tensor1StorageSize, 1);
                ret = CreateAclTensorByScene(tensor1HostData, ncTensor1, &tensor1DeviceAddr, dtype0, ACL_FORMAT_ND, &tensor1);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor2 aclTensor
                std::vector<uint8_t> tensor2HostData (tensor2StorageSize, 1);
                ret = CreateAclTensorByScene(tensor2HostData, ncTensor2, &tensor2DeviceAddr, dtype0, ACL_FORMAT_ND, &tensor2);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建out aclTensor
                std::vector<uint8_t> outHostData (outStorageSize, 1);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, dtype0, ACL_FORMAT_ND, &out);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
             } else {
                std::vector<float> selfHostData(GetShapeSize(ncSelf.storageShape), 0);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, ACL_FLOAT, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                std::vector<float> tensor1HostData(GetShapeSize(ncTensor1.storageShape), 0);
                ret = CreateAclTensorByScene(tensor1HostData, ncTensor1, &tensor1DeviceAddr, ACL_FLOAT, ACL_FORMAT_ND, &tensor1);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                std::vector<float> tensor2HostData(GetShapeSize(ncTensor2.storageShape), 0);
                ret = CreateAclTensorByScene(tensor2HostData, ncTensor2, &tensor2DeviceAddr, ACL_FLOAT, ACL_FORMAT_ND, &tensor2);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                std::vector<float> outHostData(GetShapeSize(ncOut.storageShape), 0);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, ACL_FLOAT, ACL_FORMAT_ND, &out);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
            } 

            //3. 调用aclnnAddcmul执行
            // 调用aclnnAddcmul第一段接口
            ret = aclnnAddcmulGetWorkspaceSize(self, tensor1, tensor2, value, out, &workspaceSize, &executor);
            CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclnnAddcmulGetWorkspaceSize failed. ERROR: %d\n", ret); goto ERROR);
            // 根据第一段接口计算出的workspaceSize申请device内存
            if (workspaceSize > 0) {
                ret = aclrtMalloc(&workspaceAddr, workspaceSize, ACL_MEM_MALLOC_HUGE_FIRST);
                CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("allocate workspace failed. ERROR: %d\n", ret); goto ERROR);
            }
            // 调用aclnnAddcmul第二段接口
            ret = aclnnAddcmul(workspaceAddr, workspaceSize, executor, stream);
            CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclnnAddcmul failed. ERROR: %d\n", ret); goto ERROR);

            // 4. (固定写法)同步等待任务执行结束
            {
                aclError syncRet = aclrtSynchronizeStream(stream);
                (void)syncRet;
            }
            CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSynchronizeStream failed. ERROR: %d\n", ret); goto ERROR);

            LOG_PRINT("aclnn execute success : %d\n", ret);

        }
        catch (std::exception& e)
        {
            printf("catch exception %s\n",e.what());
        }
ERROR:
        {
            aclError syncRet = aclrtSynchronizeStream(stream);
            (void)syncRet;
        }
        printf("end \n");
        CheckAndLog(ret);
        if (ret == 0) { success_count++; } else { faild_count++; }
        printf("[FUZZ_RESULT] case_%d: %s, ret=%d\n", fuzzi, ret == 0 ? "success" : "faild", ret);
        pid_t pid = getpid();
        std::string cmd  = "grep -rin 'aicore error' /root/ascend/log/debug/plog/ ";
        printf("system return value %d\n",CheckResult(pid));
        if (self != nullptr) { aclDestroyTensor(self); self = nullptr; }
        if (tensor1 != nullptr) { aclDestroyTensor(tensor1); tensor1 = nullptr; }
        if (tensor2 != nullptr) { aclDestroyTensor(tensor2); tensor2 = nullptr; }
        if (out != nullptr) { aclDestroyTensor(out); out = nullptr; }
        if (selfDeviceAddr != nullptr) { aclrtFree(selfDeviceAddr); selfDeviceAddr = nullptr; }
        if (tensor1DeviceAddr != nullptr) { aclrtFree(tensor1DeviceAddr); tensor1DeviceAddr = nullptr; }
        if (tensor2DeviceAddr != nullptr) { aclrtFree(tensor2DeviceAddr); tensor2DeviceAddr = nullptr; }
        if (outDeviceAddr != nullptr) { aclrtFree(outDeviceAddr); outDeviceAddr = nullptr; }
        if (workspaceSize > 0) {
            if (workspaceAddr != nullptr) { aclrtFree(workspaceAddr); workspaceAddr = nullptr; }
        }
    }
    DT_FUZZ_END()
    printf("=== aclnnAddcmul_non_contig SUMMARY: total=%d, success=%d, faild=%d ===\n", fuzz_num, success_count, faild_count);
    WriteDTLog("aclnnAddcmul", "aclnnAddcmul non_contig op fuzz total number:%u, para error number %u , execute error number %u \n",fuzz_num,aclnn_INVALID_Para ,aclnn_Inner_Error + Runtime_Error);
    WriteDTLog("aclnnAddcmul", "aclnnAddcmul non_contig op fuzz end \n");
    aclrtDestroyStream(stream);
    aclrtDestroyContext(context);
    aclrtResetDevice(deviceId);
    aclFinalize();   
    return 0;
}
extern "C" int aclnnAddcmul_non_contig_fuzz(int argc, char *argv[]);
int aclnnAddcmul_non_contig_fuzz(int argc, char *argv[])
{
    int fuzz_num = MAXFUZZNUMBER ;
    if (argc < 1) {
        cout << "[ERROR] input arg num must be bigger than 1 \n" << endl;
        cout << "The second arg stand for testcase num  \n" << endl;
        return -1;
    }
    else if( argc > 1)
    {
        fuzz_num = atoi(argv[2]);
    }
    if( argc == 4)
    {
        deviceId = atoi(argv[3]);
    }

    printf("fuzz_num : %d \n",fuzz_num);
  
    printf("aclnnAddcmul : %d \n", aclnnAddcmul_non_contig(fuzz_num));

    return 0;
}