AAlice_zhouupdate
9d759d93Add on Sep 10History
#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;


/* ========== [CONSISTENT] 一致性压测辅助函数(gen_consistent_from_normal 生成) ========== */
static const int CONSISTENT_MAX_RUN_TIMES = 64; /* hash数组上限,防越界 */
static int CONSISTENT_RUN_TIMES = 2; /* 每用例执行次数:默认2次,对比2次输出是否一致;经环境变量 CONSISTENT_RUN_TIMES 覆盖 */

static const char* ConsistentDtypeStr(aclDataType t) {
    switch (t) {
        case ACL_FLOAT: return "FLOAT"; case ACL_FLOAT16: return "FLOAT16";
        case ACL_BF16: return "BFLOAT16"; case ACL_DOUBLE: return "DOUBLE";
        case ACL_INT8: return "INT8"; case ACL_INT16: return "INT16";
        case ACL_INT32: return "INT32"; case ACL_INT64: return "INT64";
        case ACL_UINT8: return "UINT8"; case ACL_UINT16: return "UINT16";
        case ACL_UINT32: return "UINT32"; case ACL_UINT64: return "UINT64";
        case ACL_BOOL: return "BOOL"; case ACL_COMPLEX64: return "COMPLEX64";
        case ACL_COMPLEX128: return "COMPLEX128";
        default: return "UNKNOWN";
    }
}

static const char* ConsistentFormatStr(aclFormat f) {
    switch (f) {
        case ACL_FORMAT_NCHW: return "NCHW"; case ACL_FORMAT_NHWC: return "NHWC";
        case ACL_FORMAT_ND: return "ND"; case ACL_FORMAT_NC1HWC0: return "NC1HWC0";
        case ACL_FORMAT_FRACTAL_Z: return "FRACTAL_Z"; case ACL_FORMAT_HWCN: return "HWCN";
        case ACL_FORMAT_NDHWC: return "NDHWC"; case ACL_FORMAT_FRACTAL_NZ: return "FRACTAL_NZ";
        case ACL_FORMAT_NCDHW: return "NCDHW"; case ACL_FORMAT_NC: return "NC";
        case ACL_FORMAT_NCL: return "NCL";
        default: return "OTHER";
    }
}

static size_t ConsistentSizeOfDtype(aclDataType dataType) {
    switch (dataType) {
        case ACL_FLOAT: return 4; case ACL_FLOAT16: return 2;
        case ACL_INT8: return 1; case ACL_INT32: return 4;
        case ACL_UINT8: return 1; case ACL_INT16: return 2;
        case ACL_UINT16: return 2; case ACL_UINT32: return 4;
        case ACL_INT64: return 8; case ACL_UINT64: return 8;
        case ACL_DOUBLE: return 8; case ACL_BOOL: return 1;
        case ACL_BF16: return 2; case ACL_COMPLEX64: return 8;
        case ACL_COMPLEX128: return 16;
        /* 以下 dtype 的 sizeof(T)=1(vector<int8_t>),必须显式列出,禁止落入 default:4 */
        case ACL_INT4: return 1;
        case ACL_HIFLOAT8: return 1;
        case ACL_FLOAT8_E5M2: return 1;
        case ACL_FLOAT8_E4M3FN: return 1;
        case ACL_FLOAT8_E8M0: return 1;
        case ACL_FLOAT4_E2M1: return 1;
        case ACL_FLOAT4_E1M2: return 1;
        default: return 0; /* 未知 dtype 返回 0,触发 [FUZZ_CONSISTENT_BYTES] 告警 */
    }
}

static void ConsistentPrintShape(const std::vector<int64_t>& shape) {
    printf("[");
    for (size_t k = 0; k < shape.size(); k++) {
        printf("%lld%s", (long long)shape[k], (k + 1 < shape.size()) ? "," : "");
    }
    printf("]");
}

static uint64_t ConsistentHashBuffer(const void* data, size_t len) {
    const uint8_t* p = (const uint8_t*)data;
    uint64_t hash = 1469598103934665603ULL; /* FNV-1a offset basis */
    for (size_t k = 0; k < len; k++) {
        hash ^= (uint64_t)p[k];
        hash *= 1099511628211ULL; /* FNV-1a prime */
    }
    return hash;
}

static uint64_t ConsistentHashDeviceTensor(void* deviceAddr, size_t bytes) {
    if (deviceAddr == nullptr || bytes == 0) return 0;
    void* hostBuf = malloc(bytes);
    if (hostBuf == nullptr) return 0;
    if (aclrtMemcpy(hostBuf, bytes, deviceAddr, bytes, ACL_MEMCPY_DEVICE_TO_HOST) != ACL_SUCCESS) {
        free(hostBuf);
        return 0;
    }
    uint64_t h = ConsistentHashBuffer(hostBuf, bytes);
    free(hostBuf);
    return h;
}
/* ========== [CONSISTENT] 辅助函数结束 ========== */

int aclnnAddcmul_consistent(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);
    // [CONSISTENT] md文档标注默认确定性实现,无需打开确定性计算开关
    printf("[FUZZ_DETERMINISTIC] api=aclnnAddcmul, enable_deterministic=0, reason=md文档标注:aclnnAddcmul&aclnnInplaceAddcmul默认确定性实现。\n");
    WriteDTLog("aclnnAddcmul", "aclnnAddcmul consistent 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);
    DT_FUZZ_START(0, fuzz_num, "aclnnAddcmul_consistent",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;
        // [CONSISTENT] 一致性压测:固定输入重复执行 + hash 对比用变量
        char curTilingKey[64];
        snprintf(curTilingKey, sizeof(curTilingKey), "N/A");
        int cstRunCount = 0;
        bool cstAllOk = true;
        bool cstResultPrinted = false;  // 判定路径是否已打印 FUZZ_RESULT(去重 ERROR 标签处打印)
        uint64_t cstSelfShapeSz = 0;  // 创建语句处捕获的 shape size(作用域安全)
        int cstSelfDtype = 0;  // 创建语句处捕获的 dtype(作用域安全)
        size_t cstSelfBytes = 0;
        void* cstSelfSaveBuf = nullptr;
        uint64_t cstSelfHashArr[CONSISTENT_MAX_RUN_TIMES];
        memset(cstSelfHashArr, 0, sizeof(cstSelfHashArr));
        uint64_t cstTensor1ShapeSz = 0;  // 创建语句处捕获的 shape size(作用域安全)
        int cstTensor1Dtype = 0;  // 创建语句处捕获的 dtype(作用域安全)
        size_t cstTensor1Bytes = 0;
        void* cstTensor1SaveBuf = nullptr;
        uint64_t cstTensor1HashArr[CONSISTENT_MAX_RUN_TIMES];
        memset(cstTensor1HashArr, 0, sizeof(cstTensor1HashArr));
        uint64_t cstTensor2ShapeSz = 0;  // 创建语句处捕获的 shape size(作用域安全)
        int cstTensor2Dtype = 0;  // 创建语句处捕获的 dtype(作用域安全)
        size_t cstTensor2Bytes = 0;
        void* cstTensor2SaveBuf = nullptr;
        uint64_t cstTensor2HashArr[CONSISTENT_MAX_RUN_TIMES];
        memset(cstTensor2HashArr, 0, sizeof(cstTensor2HashArr));
        uint64_t cstOutShapeSz = 0;  // 创建语句处捕获的 shape size(作用域安全)
        int cstOutDtype = 0;  // 创建语句处捕获的 dtype(作用域安全)
        size_t cstOutBytes = 0;
        void* cstOutSaveBuf = nullptr;
        uint64_t cstOutHashArr[CONSISTENT_MAX_RUN_TIMES];
        memset(cstOutHashArr, 0, sizeof(cstOutHashArr));
        long long cstValueVal = 0;  // aclCreateScalar 处捕获的值(作用域安全)

        printf("[FUZZ_LOG] plog_file: aclnnAddcmul_consistent_plog_case_%d\n", fuzzi);
        LOG_PRINT("aclnnAddcmul_consistent %d\n",fuzzi);
        try
        {

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

            int sizeBucket = *(int *)DTSetGetNumberRange(&g_Element[i++], 1, 0, 1, "i");  // [CONSISTENT] 收紧size档位(仅小/中规模), 避免大shape快照导致host OOM

            long long totalSizeMin = 0, totalSizeMax = 0;

            switch (sizeBucket) {

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

                case 1: totalSizeMin = 1001;       totalSizeMax = 67108864LL;  break;  // [CONSISTENT] 中档上限收紧至64M元素(快照双份内存峰值约3GB)

                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);
            cstValueVal = (long long)(valueValue);
            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;
            }
            if (dtype0 == aclDataType::ACL_FLOAT) {
                // 创建self aclTensor
                std::vector<float> selfHostData (selfShape_size , 1);

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

                long long totalSize = selfShape_size + tensor1Shape_size + tensor2Shape_size + outShape_size;

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

                ret = CreateAclTensor_New(selfHostData , selfShape, &selfDeviceAddr, dtype0, format0, &self);
                cstSelfShapeSz = (uint64_t)GetShapeSize(selfShape);
                cstSelfDtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor1 aclTensor
                std::vector<float> tensor1HostData (tensor1Shape_size , 1);
                ret = CreateAclTensor_New(tensor1HostData , tensor1Shape, &tensor1DeviceAddr, dtype0, format0, &tensor1);
                cstTensor1ShapeSz = (uint64_t)GetShapeSize(tensor1Shape);
                cstTensor1Dtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor2 aclTensor
                std::vector<float> tensor2HostData (tensor2Shape_size , 1);
                ret = CreateAclTensor_New(tensor2HostData , tensor2Shape, &tensor2DeviceAddr, dtype0, format0, &tensor2);
                cstTensor2ShapeSz = (uint64_t)GetShapeSize(tensor2Shape);
                cstTensor2Dtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建out aclTensor
                std::vector<float> outHostData (outShape_size , 1);
                ret = CreateAclTensor_New(outHostData , outShape, &outDeviceAddr, dtype0, format0, &out);
                cstOutShapeSz = (uint64_t)GetShapeSize(outShape);
                cstOutDtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
            } else if (dtype0 == aclDataType::ACL_FLOAT16) {
                // 创建self aclTensor
                std::vector<int16_t> selfHostData (selfShape_size , 1);
                ret = CreateAclTensor_New(selfHostData , selfShape, &selfDeviceAddr, dtype0, format0, &self);
                cstSelfShapeSz = (uint64_t)GetShapeSize(selfShape);
                cstSelfDtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor1 aclTensor
                std::vector<int16_t> tensor1HostData (tensor1Shape_size , 1);
                ret = CreateAclTensor_New(tensor1HostData , tensor1Shape, &tensor1DeviceAddr, dtype0, format0, &tensor1);
                cstTensor1ShapeSz = (uint64_t)GetShapeSize(tensor1Shape);
                cstTensor1Dtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor2 aclTensor
                std::vector<int16_t> tensor2HostData (tensor2Shape_size , 1);
                ret = CreateAclTensor_New(tensor2HostData , tensor2Shape, &tensor2DeviceAddr, dtype0, format0, &tensor2);
                cstTensor2ShapeSz = (uint64_t)GetShapeSize(tensor2Shape);
                cstTensor2Dtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建out aclTensor
                std::vector<int16_t> outHostData (outShape_size , 1);
                ret = CreateAclTensor_New(outHostData , outShape, &outDeviceAddr, dtype0, format0, &out);
                cstOutShapeSz = (uint64_t)GetShapeSize(outShape);
                cstOutDtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
            } else if (dtype0 == aclDataType::ACL_DOUBLE) {
                // 创建self aclTensor
                std::vector<double> selfHostData (selfShape_size , 1);
                ret = CreateAclTensor_New(selfHostData , selfShape, &selfDeviceAddr, dtype0, format0, &self);
                cstSelfShapeSz = (uint64_t)GetShapeSize(selfShape);
                cstSelfDtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor1 aclTensor
                std::vector<double> tensor1HostData (tensor1Shape_size , 1);
                ret = CreateAclTensor_New(tensor1HostData , tensor1Shape, &tensor1DeviceAddr, dtype0, format0, &tensor1);
                cstTensor1ShapeSz = (uint64_t)GetShapeSize(tensor1Shape);
                cstTensor1Dtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor2 aclTensor
                std::vector<double> tensor2HostData (tensor2Shape_size , 1);
                ret = CreateAclTensor_New(tensor2HostData , tensor2Shape, &tensor2DeviceAddr, dtype0, format0, &tensor2);
                cstTensor2ShapeSz = (uint64_t)GetShapeSize(tensor2Shape);
                cstTensor2Dtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建out aclTensor
                std::vector<double> outHostData (outShape_size , 1);
                ret = CreateAclTensor_New(outHostData , outShape, &outDeviceAddr, dtype0, format0, &out);
                cstOutShapeSz = (uint64_t)GetShapeSize(outShape);
                cstOutDtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
            } else if (dtype0 == aclDataType::ACL_BF16) {
                // 创建self aclTensor
                std::vector<int16_t> selfHostData (selfShape_size , 1);
                ret = CreateAclTensor_New(selfHostData , selfShape, &selfDeviceAddr, dtype0, format0, &self);
                cstSelfShapeSz = (uint64_t)GetShapeSize(selfShape);
                cstSelfDtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor1 aclTensor
                std::vector<int16_t> tensor1HostData (tensor1Shape_size , 1);
                ret = CreateAclTensor_New(tensor1HostData , tensor1Shape, &tensor1DeviceAddr, dtype0, format0, &tensor1);
                cstTensor1ShapeSz = (uint64_t)GetShapeSize(tensor1Shape);
                cstTensor1Dtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor2 aclTensor
                std::vector<int16_t> tensor2HostData (tensor2Shape_size , 1);
                ret = CreateAclTensor_New(tensor2HostData , tensor2Shape, &tensor2DeviceAddr, dtype0, format0, &tensor2);
                cstTensor2ShapeSz = (uint64_t)GetShapeSize(tensor2Shape);
                cstTensor2Dtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建out aclTensor
                std::vector<int16_t> outHostData (outShape_size , 1);
                ret = CreateAclTensor_New(outHostData , outShape, &outDeviceAddr, dtype0, format0, &out);
                cstOutShapeSz = (uint64_t)GetShapeSize(outShape);
                cstOutDtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
            } else if (dtype0 == aclDataType::ACL_INT32) {
                // 创建self aclTensor
                std::vector<int32_t> selfHostData (selfShape_size , 1);
                ret = CreateAclTensor_New(selfHostData , selfShape, &selfDeviceAddr, dtype0, format0, &self);
                cstSelfShapeSz = (uint64_t)GetShapeSize(selfShape);
                cstSelfDtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor1 aclTensor
                std::vector<int32_t> tensor1HostData (tensor1Shape_size , 1);
                ret = CreateAclTensor_New(tensor1HostData , tensor1Shape, &tensor1DeviceAddr, dtype0, format0, &tensor1);
                cstTensor1ShapeSz = (uint64_t)GetShapeSize(tensor1Shape);
                cstTensor1Dtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor2 aclTensor
                std::vector<int32_t> tensor2HostData (tensor2Shape_size , 1);
                ret = CreateAclTensor_New(tensor2HostData , tensor2Shape, &tensor2DeviceAddr, dtype0, format0, &tensor2);
                cstTensor2ShapeSz = (uint64_t)GetShapeSize(tensor2Shape);
                cstTensor2Dtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建out aclTensor
                std::vector<int32_t> outHostData (outShape_size , 1);
                ret = CreateAclTensor_New(outHostData , outShape, &outDeviceAddr, dtype0, format0, &out);
                cstOutShapeSz = (uint64_t)GetShapeSize(outShape);
                cstOutDtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
            } else if (dtype0 == aclDataType::ACL_INT64) {
                // 创建self aclTensor
                std::vector<int64_t> selfHostData (selfShape_size , 1);
                ret = CreateAclTensor_New(selfHostData , selfShape, &selfDeviceAddr, dtype0, format0, &self);
                cstSelfShapeSz = (uint64_t)GetShapeSize(selfShape);
                cstSelfDtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor1 aclTensor
                std::vector<int64_t> tensor1HostData (tensor1Shape_size , 1);
                ret = CreateAclTensor_New(tensor1HostData , tensor1Shape, &tensor1DeviceAddr, dtype0, format0, &tensor1);
                cstTensor1ShapeSz = (uint64_t)GetShapeSize(tensor1Shape);
                cstTensor1Dtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor2 aclTensor
                std::vector<int64_t> tensor2HostData (tensor2Shape_size , 1);
                ret = CreateAclTensor_New(tensor2HostData , tensor2Shape, &tensor2DeviceAddr, dtype0, format0, &tensor2);
                cstTensor2ShapeSz = (uint64_t)GetShapeSize(tensor2Shape);
                cstTensor2Dtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建out aclTensor
                std::vector<int64_t> outHostData (outShape_size , 1);
                ret = CreateAclTensor_New(outHostData , outShape, &outDeviceAddr, dtype0, format0, &out);
                cstOutShapeSz = (uint64_t)GetShapeSize(outShape);
                cstOutDtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
            } else if (dtype0 == aclDataType::ACL_INT8) {
                // 创建self aclTensor
                std::vector<int8_t> selfHostData (selfShape_size , 1);
                ret = CreateAclTensor_New(selfHostData , selfShape, &selfDeviceAddr, dtype0, format0, &self);
                cstSelfShapeSz = (uint64_t)GetShapeSize(selfShape);
                cstSelfDtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor1 aclTensor
                std::vector<int8_t> tensor1HostData (tensor1Shape_size , 1);
                ret = CreateAclTensor_New(tensor1HostData , tensor1Shape, &tensor1DeviceAddr, dtype0, format0, &tensor1);
                cstTensor1ShapeSz = (uint64_t)GetShapeSize(tensor1Shape);
                cstTensor1Dtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor2 aclTensor
                std::vector<int8_t> tensor2HostData (tensor2Shape_size , 1);
                ret = CreateAclTensor_New(tensor2HostData , tensor2Shape, &tensor2DeviceAddr, dtype0, format0, &tensor2);
                cstTensor2ShapeSz = (uint64_t)GetShapeSize(tensor2Shape);
                cstTensor2Dtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建out aclTensor
                std::vector<int8_t> outHostData (outShape_size , 1);
                ret = CreateAclTensor_New(outHostData , outShape, &outDeviceAddr, dtype0, format0, &out);
                cstOutShapeSz = (uint64_t)GetShapeSize(outShape);
                cstOutDtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
            } else if (dtype0 == aclDataType::ACL_UINT8) {
                // 创建self aclTensor
                std::vector<uint8_t> selfHostData (selfShape_size , 1);
                ret = CreateAclTensor_New(selfHostData , selfShape, &selfDeviceAddr, dtype0, format0, &self);
                cstSelfShapeSz = (uint64_t)GetShapeSize(selfShape);
                cstSelfDtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor1 aclTensor
                std::vector<uint8_t> tensor1HostData (tensor1Shape_size , 1);
                ret = CreateAclTensor_New(tensor1HostData , tensor1Shape, &tensor1DeviceAddr, dtype0, format0, &tensor1);
                cstTensor1ShapeSz = (uint64_t)GetShapeSize(tensor1Shape);
                cstTensor1Dtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建tensor2 aclTensor
                std::vector<uint8_t> tensor2HostData (tensor2Shape_size , 1);
                ret = CreateAclTensor_New(tensor2HostData , tensor2Shape, &tensor2DeviceAddr, dtype0, format0, &tensor2);
                cstTensor2ShapeSz = (uint64_t)GetShapeSize(tensor2Shape);
                cstTensor2Dtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
                // 创建out aclTensor
                std::vector<uint8_t> outHostData (outShape_size , 1);
                ret = CreateAclTensor_New(outHostData , outShape, &outDeviceAddr, dtype0, format0, &out);
                cstOutShapeSz = (uint64_t)GetShapeSize(outShape);
                cstOutDtype = (int)(dtype0);
                CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
            } 

            //3. 调用aclnnAddcmul执行
            // 调用aclnnAddcmul第一段接口
                        // ===== [CONSISTENT] 保存全部 tensor 设备侧初始内容(固定输入,含输入tensor的值) =====
            cstSelfBytes = (selfDeviceAddr != nullptr) ? (size_t)cstSelfShapeSz * (size_t)ConsistentSizeOfDtype((aclDataType)cstSelfDtype) : 0;
            printf("[FUZZ_CONSISTENT_BYTES] case_%d: tensor=self, dtype=%d(%s), shapeSize=%llu, cstBytes=%zu, ConsistentSizeOfDtype=%zu\n", fuzzi, (int)cstSelfDtype, ConsistentDtypeStr((aclDataType)cstSelfDtype), (unsigned long long)cstSelfShapeSz, cstSelfBytes, ConsistentSizeOfDtype((aclDataType)cstSelfDtype));
            if (cstSelfBytes == 0 && selfDeviceAddr != nullptr) {
                printf("[FUZZ_CONSISTENT_BYTES] case_%d: WARN tensor=self addr!=nullptr but cstBytes=0, dtype may be uncovered by ConsistentSizeOfDtype\n", fuzzi);
            }
            cstSelfSaveBuf = (cstSelfBytes > 0) ? malloc(cstSelfBytes) : nullptr;
            if (cstSelfSaveBuf != nullptr && selfDeviceAddr != nullptr) {
                aclrtMemcpy(cstSelfSaveBuf, cstSelfBytes, selfDeviceAddr, cstSelfBytes, ACL_MEMCPY_DEVICE_TO_HOST);
            }
            cstTensor1Bytes = (tensor1DeviceAddr != nullptr) ? (size_t)cstTensor1ShapeSz * (size_t)ConsistentSizeOfDtype((aclDataType)cstTensor1Dtype) : 0;
            printf("[FUZZ_CONSISTENT_BYTES] case_%d: tensor=tensor1, dtype=%d(%s), shapeSize=%llu, cstBytes=%zu, ConsistentSizeOfDtype=%zu\n", fuzzi, (int)cstTensor1Dtype, ConsistentDtypeStr((aclDataType)cstTensor1Dtype), (unsigned long long)cstTensor1ShapeSz, cstTensor1Bytes, ConsistentSizeOfDtype((aclDataType)cstTensor1Dtype));
            if (cstTensor1Bytes == 0 && tensor1DeviceAddr != nullptr) {
                printf("[FUZZ_CONSISTENT_BYTES] case_%d: WARN tensor=tensor1 addr!=nullptr but cstBytes=0, dtype may be uncovered by ConsistentSizeOfDtype\n", fuzzi);
            }
            cstTensor1SaveBuf = (cstTensor1Bytes > 0) ? malloc(cstTensor1Bytes) : nullptr;
            if (cstTensor1SaveBuf != nullptr && tensor1DeviceAddr != nullptr) {
                aclrtMemcpy(cstTensor1SaveBuf, cstTensor1Bytes, tensor1DeviceAddr, cstTensor1Bytes, ACL_MEMCPY_DEVICE_TO_HOST);
            }
            cstTensor2Bytes = (tensor2DeviceAddr != nullptr) ? (size_t)cstTensor2ShapeSz * (size_t)ConsistentSizeOfDtype((aclDataType)cstTensor2Dtype) : 0;
            printf("[FUZZ_CONSISTENT_BYTES] case_%d: tensor=tensor2, dtype=%d(%s), shapeSize=%llu, cstBytes=%zu, ConsistentSizeOfDtype=%zu\n", fuzzi, (int)cstTensor2Dtype, ConsistentDtypeStr((aclDataType)cstTensor2Dtype), (unsigned long long)cstTensor2ShapeSz, cstTensor2Bytes, ConsistentSizeOfDtype((aclDataType)cstTensor2Dtype));
            if (cstTensor2Bytes == 0 && tensor2DeviceAddr != nullptr) {
                printf("[FUZZ_CONSISTENT_BYTES] case_%d: WARN tensor=tensor2 addr!=nullptr but cstBytes=0, dtype may be uncovered by ConsistentSizeOfDtype\n", fuzzi);
            }
            cstTensor2SaveBuf = (cstTensor2Bytes > 0) ? malloc(cstTensor2Bytes) : nullptr;
            if (cstTensor2SaveBuf != nullptr && tensor2DeviceAddr != nullptr) {
                aclrtMemcpy(cstTensor2SaveBuf, cstTensor2Bytes, tensor2DeviceAddr, cstTensor2Bytes, ACL_MEMCPY_DEVICE_TO_HOST);
            }
            cstOutBytes = (outDeviceAddr != nullptr) ? (size_t)cstOutShapeSz * (size_t)ConsistentSizeOfDtype((aclDataType)cstOutDtype) : 0;
            printf("[FUZZ_CONSISTENT_BYTES] case_%d: tensor=out, dtype=%d(%s), shapeSize=%llu, cstBytes=%zu, ConsistentSizeOfDtype=%zu\n", fuzzi, (int)cstOutDtype, ConsistentDtypeStr((aclDataType)cstOutDtype), (unsigned long long)cstOutShapeSz, cstOutBytes, ConsistentSizeOfDtype((aclDataType)cstOutDtype));
            if (cstOutBytes == 0 && outDeviceAddr != nullptr) {
                printf("[FUZZ_CONSISTENT_BYTES] case_%d: WARN tensor=out addr!=nullptr but cstBytes=0, dtype may be uncovered by ConsistentSizeOfDtype\n", fuzzi);
            }
            cstOutSaveBuf = (cstOutBytes > 0) ? malloc(cstOutBytes) : nullptr;
            if (cstOutSaveBuf != nullptr && outDeviceAddr != nullptr) {
                aclrtMemcpy(cstOutSaveBuf, cstOutBytes, outDeviceAddr, cstOutBytes, ACL_MEMCPY_DEVICE_TO_HOST);
            }

            // ===== [CONSISTENT] 固定输入重复执行 CONSISTENT_RUN_TIMES 次,逐轮对全部 tensor 计算 hash =====
            cstRunCount = 0;
            cstAllOk = true;
            for (int cstRun = 0; cstRun < CONSISTENT_RUN_TIMES; cstRun++) {
                // [CONSISTENT] 恢复固定输入(输出 tensor 同时恢复初始值,覆盖 inplace/累加类算子)
                if (cstSelfSaveBuf != nullptr && selfDeviceAddr != nullptr) {
                    aclrtMemcpy(selfDeviceAddr, cstSelfBytes, cstSelfSaveBuf, cstSelfBytes, ACL_MEMCPY_HOST_TO_DEVICE);
                }
                if (cstTensor1SaveBuf != nullptr && tensor1DeviceAddr != nullptr) {
                    aclrtMemcpy(tensor1DeviceAddr, cstTensor1Bytes, cstTensor1SaveBuf, cstTensor1Bytes, ACL_MEMCPY_HOST_TO_DEVICE);
                }
                if (cstTensor2SaveBuf != nullptr && tensor2DeviceAddr != nullptr) {
                    aclrtMemcpy(tensor2DeviceAddr, cstTensor2Bytes, cstTensor2SaveBuf, cstTensor2Bytes, ACL_MEMCPY_HOST_TO_DEVICE);
                }
                if (cstOutSaveBuf != nullptr && outDeviceAddr != nullptr) {
                    aclrtMemcpy(outDeviceAddr, cstOutBytes, cstOutSaveBuf, cstOutBytes, ACL_MEMCPY_HOST_TO_DEVICE);
                }
                ret = aclnnAddcmulGetWorkspaceSize(self, tensor1, tensor2, value, out, &workspaceSize, &executor);
                if (ret != ACL_SUCCESS) {
                    printf("aclnnAddcmul execute failed :%d\n", (int)ret);
                    printf("[FUZZ_CONSISTENT] case_%d: faild, type=execute_error, stage=GetWorkspaceSize, run=%d/%d, ret=%d\n", fuzzi, cstRun + 1, CONSISTENT_RUN_TIMES, (int)ret);
                    cstAllOk = false;
                    break;
                }
                if (workspaceSize > 0) {
                    if (workspaceAddr != nullptr) { aclrtFree(workspaceAddr); workspaceAddr = nullptr; }
                    ret = aclrtMalloc(&workspaceAddr, workspaceSize, ACL_MEM_MALLOC_HUGE_FIRST);
                    if (ret != ACL_SUCCESS) {
                        printf("[FUZZ_CONSISTENT] case_%d: faild, type=execute_error, stage=workspace_malloc, run=%d/%d, ret=%d\n", fuzzi, cstRun + 1, CONSISTENT_RUN_TIMES, (int)ret);
                        cstAllOk = false;
                        break;
                    }
                }
                ret = aclnnAddcmul(workspaceAddr, workspaceSize, executor, stream);
                if (ret != ACL_SUCCESS) {
                    printf("aclnnAddcmul execute failed :%d\n", (int)ret);
                    printf("[FUZZ_CONSISTENT] case_%d: faild, type=execute_error, stage=execute, run=%d/%d, ret=%d\n", fuzzi, cstRun + 1, CONSISTENT_RUN_TIMES, (int)ret);
                    cstAllOk = false;
                    break;
                }
                ret = aclrtSynchronizeStream(stream);
                if (ret != ACL_SUCCESS) {
                    printf("[FUZZ_CONSISTENT] case_%d: faild, type=execute_error, stage=sync, run=%d/%d, ret=%d\n", fuzzi, cstRun + 1, CONSISTENT_RUN_TIMES, (int)ret);
                    cstAllOk = false;
                    break;
                }
                // [CONSISTENT] 本轮执行结果 hash
                if (selfDeviceAddr != nullptr && cstSelfBytes > 0) {
                    cstSelfHashArr[cstRun] = ConsistentHashDeviceTensor(selfDeviceAddr, cstSelfBytes);
                }
                if (tensor1DeviceAddr != nullptr && cstTensor1Bytes > 0) {
                    cstTensor1HashArr[cstRun] = ConsistentHashDeviceTensor(tensor1DeviceAddr, cstTensor1Bytes);
                }
                if (tensor2DeviceAddr != nullptr && cstTensor2Bytes > 0) {
                    cstTensor2HashArr[cstRun] = ConsistentHashDeviceTensor(tensor2DeviceAddr, cstTensor2Bytes);
                }
                if (outDeviceAddr != nullptr && cstOutBytes > 0) {
                    cstOutHashArr[cstRun] = ConsistentHashDeviceTensor(outDeviceAddr, cstOutBytes);
                }
                cstRunCount++;
                printf("aclnnAddcmul execute success :%d\n", (int)ret);
            }

            // ===== [CONSISTENT] 对比 2 轮 hash,判定一致性(2次执行输出一致即为确定性) =====
            if (cstAllOk && cstRunCount == CONSISTENT_RUN_TIMES) {
                bool cstSelfSame = true;
                for (int cstR = 1; cstR < CONSISTENT_RUN_TIMES; cstR++) {
                    if (cstSelfHashArr[cstR] != cstSelfHashArr[0]) { cstSelfSame = false; break; }
                }
                bool cstTensor1Same = true;
                for (int cstR = 1; cstR < CONSISTENT_RUN_TIMES; cstR++) {
                    if (cstTensor1HashArr[cstR] != cstTensor1HashArr[0]) { cstTensor1Same = false; break; }
                }
                bool cstTensor2Same = true;
                for (int cstR = 1; cstR < CONSISTENT_RUN_TIMES; cstR++) {
                    if (cstTensor2HashArr[cstR] != cstTensor2HashArr[0]) { cstTensor2Same = false; break; }
                }
                bool cstOutSame = true;
                for (int cstR = 1; cstR < CONSISTENT_RUN_TIMES; cstR++) {
                    if (cstOutHashArr[cstR] != cstOutHashArr[0]) { cstOutSame = false; break; }
                }
                bool cstAllSame = cstSelfSame && cstTensor1Same && cstTensor2Same && cstOutSame;
                if (cstAllSame) {
                    printf("[FUZZ_CONSISTENT] case_%d: success, type=consistent, runs=%d, hash_consistent=all\n", fuzzi, CONSISTENT_RUN_TIMES);
                    printf("[FUZZ_RESULT] case_%d: success, ret=%d\n", fuzzi, (int)ret);
                    cstResultPrinted = true;
                } else {
                    printf("[FUZZ_CONSISTENT] case_%d: faild, type=hash_mismatch, runs=%d, inconsistent=", fuzzi, CONSISTENT_RUN_TIMES);
                    if (!cstSelfSame) printf("self ");
                    if (!cstTensor1Same) printf("tensor1 ");
                    if (!cstTensor2Same) printf("tensor2 ");
                    if (!cstOutSame) printf("out ");
                    printf("\n");
                    printf("[FUZZ_CONSISTENT_DETAIL] case_%d: self hash:", fuzzi);
                    for (int cstR = 0; cstR < CONSISTENT_RUN_TIMES; cstR++) printf(" run%d=%llu", cstR, (unsigned long long)cstSelfHashArr[cstR]);
                    printf("\n");
                    printf("[FUZZ_CONSISTENT_DETAIL] case_%d: tensor1 hash:", fuzzi);
                    for (int cstR = 0; cstR < CONSISTENT_RUN_TIMES; cstR++) printf(" run%d=%llu", cstR, (unsigned long long)cstTensor1HashArr[cstR]);
                    printf("\n");
                    printf("[FUZZ_CONSISTENT_DETAIL] case_%d: tensor2 hash:", fuzzi);
                    for (int cstR = 0; cstR < CONSISTENT_RUN_TIMES; cstR++) printf(" run%d=%llu", cstR, (unsigned long long)cstTensor2HashArr[cstR]);
                    printf("\n");
                    printf("[FUZZ_CONSISTENT_DETAIL] case_%d: out hash:", fuzzi);
                    for (int cstR = 0; cstR < CONSISTENT_RUN_TIMES; cstR++) printf(" run%d=%llu", cstR, (unsigned long long)cstOutHashArr[cstR]);
                    printf("\n");
                    // [CONSISTENT] 失败时打印全部入参信息(dtype/format/shape/attr/tiling_key)
                    printf("[FUZZ_PARAM] ");
                    printf("self: dtype=%s, format=%s, ", ConsistentDtypeStr((aclDataType)cstSelfDtype), ConsistentFormatStr(format0)); printf("shapeSize=%llu", (unsigned long long)cstSelfShapeSz); printf("; ");
                    printf("tensor1: dtype=%s, format=%s, ", ConsistentDtypeStr((aclDataType)cstTensor1Dtype), ConsistentFormatStr(format0)); printf("shapeSize=%llu", (unsigned long long)cstTensor1ShapeSz); printf("; ");
                    printf("tensor2: dtype=%s, format=%s, ", ConsistentDtypeStr((aclDataType)cstTensor2Dtype), ConsistentFormatStr(format0)); printf("shapeSize=%llu", (unsigned long long)cstTensor2ShapeSz); printf("; ");
                    printf("out: dtype=%s, format=%s, ", ConsistentDtypeStr((aclDataType)cstOutDtype), ConsistentFormatStr(format0)); printf("shapeSize=%llu", (unsigned long long)cstOutShapeSz); printf("; ");
                    printf("value=%d; ", (int)cstValueVal);
                    printf("tiling_key=%s\n", curTilingKey);
                    // ret=-2 为 hash_mismatch 专用标记(非 aclnn 错误码:执行成功但输出不确定)
                    printf("[FUZZ_RESULT] case_%d: faild, ret=%d\n", fuzzi, -2);
                    cstResultPrinted = true;
                }
            } else if (!cstAllOk) {
                // [CONSISTENT] 执行失败也打印全部入参信息
                printf("[FUZZ_PARAM] ");
                printf("self: dtype=%s, format=%s, ", ConsistentDtypeStr((aclDataType)cstSelfDtype), ConsistentFormatStr(format0)); printf("shapeSize=%llu", (unsigned long long)cstSelfShapeSz); printf("; ");
                printf("tensor1: dtype=%s, format=%s, ", ConsistentDtypeStr((aclDataType)cstTensor1Dtype), ConsistentFormatStr(format0)); printf("shapeSize=%llu", (unsigned long long)cstTensor1ShapeSz); printf("; ");
                printf("tensor2: dtype=%s, format=%s, ", ConsistentDtypeStr((aclDataType)cstTensor2Dtype), ConsistentFormatStr(format0)); printf("shapeSize=%llu", (unsigned long long)cstTensor2ShapeSz); printf("; ");
                printf("out: dtype=%s, format=%s, ", ConsistentDtypeStr((aclDataType)cstOutDtype), ConsistentFormatStr(format0)); printf("shapeSize=%llu", (unsigned long long)cstOutShapeSz); printf("; ");
                printf("value=%d; ", (int)cstValueVal);
                printf("tiling_key=%s\n", curTilingKey);
                printf("[FUZZ_RESULT] case_%d: faild, ret=%d\n", fuzzi, (int)ret);
                cstResultPrinted = true;
            }
        }
        catch (std::exception& e)
        {
            printf("catch exception %s\n",e.what());
            printf("[FUZZ_CONSISTENT] case_%d: faild, type=exception, ret=%d\n", fuzzi, (int)ret);
            printf("[FUZZ_RESULT] case_%d: faild, ret=%d\n", fuzzi, (int)ret);
            cstResultPrinted = true;
        }
ERROR:
        printf("end \n");
        CheckAndLog(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));
        // [CONSISTENT] 释放固定输入快照
        if (cstSelfSaveBuf != nullptr) { free(cstSelfSaveBuf); cstSelfSaveBuf = nullptr; }
        if (cstTensor1SaveBuf != nullptr) { free(cstTensor1SaveBuf); cstTensor1SaveBuf = nullptr; }
        if (cstTensor2SaveBuf != nullptr) { free(cstTensor2SaveBuf); cstTensor2SaveBuf = nullptr; }
        if (cstOutSaveBuf != nullptr) { free(cstOutSaveBuf); cstOutSaveBuf = nullptr; }
        aclDestroyTensor(self);
        aclDestroyTensor(tensor1);
        aclDestroyTensor(tensor2);
        aclDestroyTensor(out);
        aclrtFree(selfDeviceAddr);
        aclrtFree(tensor1DeviceAddr);
        aclrtFree(tensor2DeviceAddr);
        aclrtFree(outDeviceAddr);
        if (workspaceSize > 0) {
            aclrtFree(workspaceAddr);
        }
    }
    DT_FUZZ_END()
    WriteDTLog("aclnnAddcmul", "aclnnAddcmul consistent 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 consistent op fuzz end \n");
    aclrtDestroyStream(stream);
    aclrtDestroyContext(context);
    aclrtResetDevice(deviceId);
    aclFinalize();   
    return 0;
}
extern "C" int aclnnAddcmul_consistent_fuzz(int argc, char *argv[]);
int aclnnAddcmul_consistent_fuzz(int argc, char *argv[])
{
    // [CONSISTENT] 运行时覆盖每用例执行次数(环境变量 CONSISTENT_RUN_TIMES:默认2次,可按需覆盖)
    const char* cstRunEnv = getenv("CONSISTENT_RUN_TIMES");
    if (cstRunEnv != nullptr) {
        int cstRunV = atoi(cstRunEnv);
        if (cstRunV > 0 && cstRunV <= CONSISTENT_MAX_RUN_TIMES) { CONSISTENT_RUN_TIMES = cstRunV; }
    }
    printf("[FUZZ_CONSISTENT_RUNTIMES] run_times=%d\n", CONSISTENT_RUN_TIMES);
    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_consistent(fuzz_num));

    return 0;
}