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_cos.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 aclnnCos_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("aclnnCos", "aclnnCos non_contig op fuzz start \n");
    // 合法dtype类型:0-FLOAT 1-FP16 2-INT8 3-INT32 4-UINT8 6-INT16 7-UINT16 8-UINT32 9-INT64 10-UINT64 11-DOUBLE 12-BOOL 16-COMPLEX64 17-COMPLEX128 27-BF16(仅910B) 
    int aiNormal910B[] = { 0, 1, 2, 3, 4, 6, 9, 11, 12, 16, 17 ,27};
    int aiNormal[] = { 0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 16, 17, 27, 33, -1};                    
    int iDtypeNum910B = sizeof(aiNormal910B) / sizeof(aiNormal910B[0]);
    int iDtypeNum = sizeof(aiNormal) / sizeof(aiNormal[0]); 

    aclrtSetOpExecuteTimeOut(1091);
    DT_Set_TimeOut_Second(3000);
        int success_count = 0;
    int faild_count = 0;
DT_FUZZ_START(0, fuzz_num, "aclnnCos" ,0)
    {
        int i=0;
        void* selfDeviceAddr = nullptr;
        void* outDeviceAddr = nullptr;
        aclTensor* self = nullptr;
        aclTensor* out = nullptr;
                            
        uint64_t workspaceSize = 0;
        aclOpExecutor* executor;
        void* workspaceAddr = nullptr;
        bool shape_execeed_flag = false;  

        LOG_PRINT("aclnnCos_non_contig %d\n",fuzzi);
            printf("[FUZZ_LOG] plog_file: aclnnCos_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获取变异数据
            int shape1 = *(int *)DTSetGetNumberRange(&g_Element[i++],4, 1,MAX_SHAPE_SIZE,"i");
            int shape2 = *(int *)DTSetGetNumberRange(&g_Element[i++],2, 1,MAX_SHAPE_SIZE,"i");
            int shape3 = *(int *)DTSetGetNumberRange(&g_Element[i++],2, 1,MAX_SHAPE_SIZE,"i");
            int shape4 = *(int *)DTSetGetNumberRange(&g_Element[i++],2, 1,MAX_SHAPE_SIZE,"i");
            int shape5 = *(int *)DTSetGetNumberRange(&g_Element[i++],2, 1,MAX_SHAPE_SIZE,"i");
            int shape6 = *(int *)DTSetGetNumberRange(&g_Element[i++],2, 1,MAX_SHAPE_SIZE,"i");
            int shape7 = *(int *)DTSetGetNumberRange(&g_Element[i++],2, 1,MAX_SHAPE_SIZE,"i");
            int shape8 = *(int *)DTSetGetNumberRange(&g_Element[i++],2, 1,MAX_SHAPE_SIZE,"i");
            auto inputDtype = (aclDataType)*(int *)DT_SetGetNumberEnumV3(i++, aclDataType::ACL_FLOAT, aiNormal910B, iDtypeNum910B);   

            std::vector<int64_t> selfShape = {};
            int dim_num = *(int *)DTSetGetNumberRange(&g_Element[i++],2, 0,8,"i");
            if (dim_num == 0) { selfShape = {}; } else 
            if(dim_num == 1){
                selfShape = {shape1};
                printf("selfShape:{%d}\n",selfShape[0]);
            } else if(dim_num == 2){
                selfShape = {shape1,shape2};
                printf("selfShape:{%d,%d}\n",selfShape[0],selfShape[1]);
            } else if(dim_num == 3){
                selfShape = {shape1,shape2,shape3};
                printf("selfShape:{%d,%d,%d}\n",selfShape[0],selfShape[1],selfShape[2]);
            } else if(dim_num == 4){
                selfShape = {shape1,shape2,shape3,shape4};
                printf("selfShape:{%d,%d,%d,%d}\n",selfShape[0],selfShape[1],selfShape[2],selfShape[3]);       
            } else if(dim_num == 5){
                selfShape = {shape1,shape2,shape3,shape4,shape5};
                printf("selfShape:{%d,%d,%d,%d,%d}\n",selfShape[0],selfShape[1],selfShape[2],selfShape[3],selfShape[4]);            
            } else if(dim_num == 6){
                selfShape = {shape1,shape2,shape3,shape4,shape5,shape6};
                printf("selfShape:{%d,%d,%d,%d,%d,%d}\n",selfShape[0],selfShape[1],selfShape[2],selfShape[3],selfShape[4],selfShape[5]);            
            } else if(dim_num == 7){
                selfShape = {shape1,shape2,shape3,shape4,shape5,shape6,shape7};
                printf("selfShape:{%d,%d,%d,%d,%d,%d,%d}\n",selfShape[0],selfShape[1],selfShape[2],selfShape[3],selfShape[4],selfShape[5],selfShape[6]); 
            } else if(dim_num == 8){
                selfShape = {shape1,shape2,shape3,shape4,shape5,shape6,shape7,shape8};
                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]); 
            }

            std::vector<int64_t> outShape = selfShape;
            long long shape_size = GetShapeSize(selfShape);
            if(shape_size > SHAPE_SIZE_CTL)
            {
                shape_execeed_flag = true;
                goto ERROR;
            }
            long long shape_size1 = GetShapeSize(outShape);
            if(shape_size1 > SHAPE_SIZE_CTL)
            {
                shape_execeed_flag = true;
                goto ERROR;
            }

            //对input、out进行shape泛化
            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 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 (inputDtype == aclDataType::ACL_FLOAT) {
                std::vector<float> selfHostData(outStorageSize, 1);
                std::vector<float> outHostData(outStorageSize, 1);
                //创建AclTensor

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

                long long totalSize = shape_size + shape_size1 + selfStorageSize + outStorageSize;

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

                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, inputDtype, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS,  goto ERROR);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, inputDtype, ACL_FORMAT_ND, &out);
                printf("inputDtype:ACL_FLOAT\n");
                CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Create Tensor failed. ERROR: %d\n", ret); goto ERROR);
            } else if(inputDtype == aclDataType::ACL_FLOAT16) {
                std::vector<int16_t> selfHostData(outStorageSize, 1);
                std::vector<int16_t> outHostData(outStorageSize, 1);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, inputDtype, ACL_FORMAT_ND, &self);               
                CHECK_RET(ret == ACL_SUCCESS,  goto ERROR);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, inputDtype, ACL_FORMAT_ND, &out);               
                printf("inputDtype:ACL_FLOAT16\n");
                CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Create Tensor failed. ERROR: %d\n", ret); goto ERROR);
            }else if(inputDtype == aclDataType::ACL_BF16) {
                std::vector<int16_t> selfHostData(outStorageSize, 1);
                std::vector<int16_t> outHostData(outStorageSize, 1);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, inputDtype, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS,  goto ERROR);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, inputDtype, ACL_FORMAT_ND, &out);
                printf("inputDtype:ACL_BF16\n");
                CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Create Tensor failed. ERROR: %d\n", ret); goto ERROR);
            }  else if(inputDtype == aclDataType::ACL_INT8) {
                std::vector<float> selfHostData(outStorageSize, 1);
                std::vector<float> outHostData(outStorageSize, 1);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, aclDataType::ACL_FLOAT, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS,  goto ERROR);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, aclDataType::ACL_FLOAT, ACL_FORMAT_ND, &out);
                printf("inputDtype:ACL_INT8\n");
                CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Create Tensor failed. ERROR: %d\n", ret); goto ERROR);
            } else if(inputDtype == aclDataType::ACL_INT32) {
                std::vector<float> selfHostData(outStorageSize, 1);
                std::vector<float> outHostData(outStorageSize, 1);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, aclDataType::ACL_FLOAT, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS,  goto ERROR);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, aclDataType::ACL_FLOAT, ACL_FORMAT_ND, &out);
                printf("inputDtype:ACL_INT32\n");
                CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Create Tensor failed. ERROR: %d\n", ret); goto ERROR);
            } else if(inputDtype == aclDataType::ACL_UINT8) {
                std::vector<float> selfHostData(outStorageSize, 1);
                std::vector<float> outHostData(outStorageSize, 1);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, aclDataType::ACL_FLOAT, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS,  goto ERROR);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, aclDataType::ACL_FLOAT, ACL_FORMAT_ND, &out);
                printf("inputDtype:ACL_UINT8\n");
                CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Create Tensor failed. ERROR: %d\n", ret); goto ERROR);
            } else if(inputDtype == aclDataType::ACL_INT16) {
                std::vector<float> selfHostData(outStorageSize, 1);
                std::vector<float> outHostData(outStorageSize, 1);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, aclDataType::ACL_FLOAT, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS,  goto ERROR);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, aclDataType::ACL_FLOAT, ACL_FORMAT_ND, &out);
                printf("inputDtype:ACL_INT16\n");
                CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Create Tensor failed. ERROR: %d\n", ret); goto ERROR);
            } else if(inputDtype == aclDataType::ACL_INT64) {
                std::vector<float> selfHostData(outStorageSize, 1);
                std::vector<float> outHostData(outStorageSize, 1);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, aclDataType::ACL_FLOAT, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS,  goto ERROR);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, aclDataType::ACL_FLOAT, ACL_FORMAT_ND, &out);
                printf("inputDtype:ACL_INT64\n");
                CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Create Tensor failed. ERROR: %d\n", ret); goto ERROR);
            } else if(inputDtype == aclDataType::ACL_DOUBLE) {
                std::vector<double> selfHostData(outStorageSize, 1);
                std::vector<double> outHostData(outStorageSize, 1);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, inputDtype, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS,  goto ERROR);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, inputDtype, ACL_FORMAT_ND, &out);
                printf("inputDtype:ACL_DOUBLE\n");
                CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Create Tensor failed. ERROR: %d\n", ret); goto ERROR);
            } else if(inputDtype == aclDataType::ACL_BOOL) {
                std::vector<float> selfHostData(outStorageSize, 1);
                std::vector<float> outHostData(outStorageSize, 1);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, aclDataType::ACL_FLOAT, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS,  goto ERROR);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, aclDataType::ACL_FLOAT, ACL_FORMAT_ND, &out);
                printf("inputDtype:ACL_BOOL\n");
                CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Create Tensor failed. ERROR: %d\n", ret); goto ERROR);
            } else if(inputDtype == aclDataType::ACL_COMPLEX64) {
                std::vector<std::complex<float>> selfHostData(shape_size , 1);
                std::vector<std::complex<float>> outHostData(shape_size1 , 1);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, inputDtype, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS,  goto ERROR);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, inputDtype, ACL_FORMAT_ND, &out);
                printf("inputDtype:ACL_BOOL\n");
                CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Create Tensor failed. ERROR: %d\n", ret); goto ERROR);
            } else if(inputDtype == aclDataType::ACL_COMPLEX128) {
                std::vector<std::complex<double>> selfHostData(shape_size , 1);
                std::vector<std::complex<double>> outHostData(shape_size1 , 1);
                ret = CreateAclTensorByScene(selfHostData, ncSelf, &selfDeviceAddr, inputDtype, ACL_FORMAT_ND, &self);
                CHECK_RET(ret == ACL_SUCCESS,  goto ERROR);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, inputDtype, ACL_FORMAT_ND, &out);
                printf("inputDtype:ACL_BOOL\n");
                CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Create Tensor failed. ERROR: %d\n", ret); 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> outHostData(GetShapeSize(ncOut.storageShape), 0);
                ret = CreateAclTensorByScene(outHostData, ncOut, &outDeviceAddr, ACL_FLOAT, ACL_FORMAT_ND, &out);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
            }   

            // 调用aclnnCos第一段接口
            //shape3:%d shape4:%d shape5:%d shape6:%d shape7:%d
            ret = aclnnCosGetWorkspaceSize(self, out, &workspaceSize, &executor);
            CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclnnCosGetWorkspaceSize failed. ERROR: %d\n", ret); goto ERROR);
            printf("aclnnCosGetWorkspaceSize ret=%d\n", ret);

            // // 根据第一段接口计算出的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;);
            }
            // // 调用aclnnCos第二段接口
            ret = aclnnCos(workspaceAddr, workspaceSize, executor, stream);
            CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclnnCos failed. ERROR: %d\n", ret); goto ERROR);
        
            {
        
                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 (out != nullptr) { aclDestroyTensor(out); out = nullptr; }

        if (selfDeviceAddr != nullptr) { aclrtFree(selfDeviceAddr); selfDeviceAddr = nullptr; }
        if (outDeviceAddr != nullptr) { aclrtFree(outDeviceAddr); outDeviceAddr = nullptr; }
        if (workspaceSize > 0) {
            if (workspaceAddr != nullptr) { aclrtFree(workspaceAddr); workspaceAddr = nullptr; }
        }
    }
    DT_FUZZ_END()
    printf("=== aclnnCos_non_contig SUMMARY: total=%d, success=%d, faild=%d ===\n", fuzz_num, success_count, faild_count);
    WriteDTLog("aclnnCos", "aclnnCos 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("aclnnCos", "aclnnCos non_contig op fuzz end \n");
    aclrtDestroyStream(stream);
    aclrtDestroyContext(context);
    aclrtResetDevice(deviceId);
    aclFinalize();   
    return 0;
}
extern "C" int aclnnCos_non_contig_fuzz(int argc, char *argv[]);
int aclnnCos_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("aclnnCos_non_contig :%d \n",aclnnCos_non_contig(fuzz_num));

    return 0;
}