#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 <sys/wait.h>
#include <dlfcn.h>
#include <cstdio>
#include <string>
#include <iomanip>
#include <string.h>
#include <list>
#include <algorithm>
#include <stdarg.h>
#include <fstream>
#include <sstream>
#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 "../fuzzlib/secodeFuzz.h"
#include "aclnnop/aclnn_apply_adam_w_v2.h"
using namespace std;
static const char* GetDtypeName(aclDataType dt) {
switch (dt) {
case ACL_FLOAT: return "FLOAT";
case ACL_FLOAT16: return "FLOAT16";
case ACL_INT8: return "INT8";
case ACL_INT32: return "INT32";
case ACL_UINT8: return "UINT8";
case ACL_INT16: return "INT16";
case ACL_UINT16: return "UINT16";
case ACL_UINT32: return "UINT32";
case ACL_INT64: return "INT64";
case ACL_UINT64: return "UINT64";
case ACL_DOUBLE: return "DOUBLE";
case ACL_BOOL: return "BOOL";
case ACL_BF16: return "BFLOAT16";
case ACL_COMPLEX64: return "COMPLEX64";
case ACL_COMPLEX128: return "COMPLEX128";
default: return "UNKNOWN";
}
}
static const char* FormatName(aclFormat fmt) {
switch (fmt) {
case ACL_FORMAT_ND: return "ND";
case ACL_FORMAT_NCHW: return "NCHW";
case ACL_FORMAT_NHWC: return "NHWC";
case ACL_FORMAT_NDHWC: return "NDHWC";
case ACL_FORMAT_NCL: return "NCL";
case ACL_FORMAT_FRACTAL_NZ: return "FRACTAL_NZ";
default: return "FMT?";
}
}
static std::string ShapeToStr(const std::vector<int64_t>& s) {
std::string r = "[";
for (size_t k = 0; k < s.size(); k++) {
if (k) r += ",";
r += std::to_string(s[k]);
}
return r + "]";
}
static std::string IntArrayToStr(const std::vector<int64_t>& s) {
std::string r = "[";
for (size_t k = 0; k < s.size(); k++) {
if (k) r += ",";
r += std::to_string(s[k]);
}
return r + "]";
}
static std::string FloatArrayToStr(const std::vector<float>& s) {
std::string r = "[";
for (size_t k = 0; k < s.size(); k++) {
if (k) r += ",";
r += std::to_string(s[k]);
}
return r + "]";
}
struct ScenarioResult {
int scenarioId;
int retCode;
std::string desc;
std::string violation;
std::string category;
std::string errorType;
std::string aclErrMsg;
};
static std::vector<ScenarioResult> g_allResults;
static int g_stdoutFd = -1;
void RedirectStdoutToScenarioFile(int scenarioId) {
const std::string baseDir = "./opfuzz/scenario_logs";
mkdir(baseDir.c_str(), 0755);
std::string logFile = baseDir + "/scenario_" + std::to_string(scenarioId) + ".log";
fflush(stdout);
g_stdoutFd = dup(fileno(stdout));
freopen(logFile.c_str(), "w", stdout);
setvbuf(stdout, NULL, _IONBF, 0);
}
void RestoreStdout() {
if (g_stdoutFd < 0) return;
fflush(stdout);
dup2(g_stdoutFd, fileno(stdout));
close(g_stdoutFd);
g_stdoutFd = -1;
clearerr(stdout);
}
void GenerateFinalSummary() {
const std::string baseDir = "./opfuzz/scenario_logs";
std::string summaryFile = baseDir + "/summary.txt";
std::ofstream sf(summaryFile);
int paramErr = 0, innerErr = 0, runtimeErr = 0, otherErr = 0, unexpectedOk = 0, ezPass = 0;
for (const auto& r : g_allResults) {
if (r.errorType == "UNEXPECTED_SUCCESS") unexpectedOk++;
else if (r.errorType == "PARAM_ERROR") paramErr++;
else if (r.errorType == "INNER_ERROR") innerErr++;
else if (r.errorType == "RUNTIME_ERROR") runtimeErr++;
else otherErr++;
if (r.aclErrMsg.find("should") != std::string::npos ||
r.aclErrMsg.find("must") != std::string::npos ||
r.aclErrMsg.find("expected") != std::string::npos ||
r.aclErrMsg.find("supported") != std::string::npos) {
ezPass++;
}
}
int total = (int)g_allResults.size();
int detected = paramErr + innerErr + runtimeErr + otherErr;
int rate = (total > 0) ? detected * 100 / total : 0;
int ezRate = (total > 0) ? ezPass * 100 / total : 0;
sf << "==============================================" << std::endl;
sf << " ERROR SCENARIO TEST SUMMARY: aclnnApplyAdamWV2" << std::endl;
sf << "==============================================" << std::endl;
sf << " Total Scenarios: " << total << std::endl;
sf << " Error Detected: " << detected << " / " << total << " (" << rate << "%)" << std::endl;
sf << " PARAM_ERROR: " << paramErr << std::endl;
sf << " INNER_ERROR: " << innerErr << std::endl;
sf << " RUNTIME_ERROR: " << runtimeErr << std::endl;
sf << " OTHER_ERROR: " << otherErr << std::endl;
sf << " Unexpected Success: " << unexpectedOk << std::endl;
sf << " EZ Compliance: " << ezPass << " / " << total << " (" << ezRate << "% have corrective hints)" << std::endl;
sf << "==============================================" << std::endl;
sf << std::endl;
sf << std::string(120, '-') << std::endl;
sf << " Id | RetCode | Type | EZ | desc" << std::endl;
sf << std::string(120, '-') << std::endl;
for (const auto& r : g_allResults) {
bool ez = (r.aclErrMsg.find("should") != std::string::npos ||
r.aclErrMsg.find("must") != std::string::npos ||
r.aclErrMsg.find("expected") != std::string::npos);
sf << " " << std::setw(2) << r.scenarioId
<< " | " << std::setw(9) << r.retCode
<< " | " << std::setw(13) << r.errorType
<< " | " << (ez ? "OK " : "NO ")
<< " | " << r.desc << std::endl;
}
sf << std::string(120, '-') << std::endl;
sf << std::endl;
for (const auto& r : g_allResults) {
std::string logPath = baseDir + "/scenario_" + std::to_string(r.scenarioId) + ".log";
sf << std::endl << "===== Scenario " << r.scenarioId << " (" << r.errorType << ") ====" << std::endl;
std::ifstream lf(logPath);
if (lf.is_open()) {
std::string line;
while (std::getline(lf, line)) sf << line << std::endl;
lf.close();
} else {
sf << " (log file not found)" << std::endl;
}
}
sf.close();
printf("\n====== FINAL SUMMARY ======\n");
{
std::string catCmd = "cat " + summaryFile + " 2>/dev/null";
system(catCmd.c_str());
}
printf("====== END SUMMARY ======\n\n");
WriteDTLog("aclnnApplyAdamWV2", "FINAL: total=%d detected=%d param=%d inner=%d runtime=%d unexpected=%d rate=%d%%\n",
total, detected, paramErr, innerErr, runtimeErr, unexpectedOk, rate);
}
int aclnnApplyAdamWV2_Normal(int fuzz_num)
{
auto ret = Init(deviceId, &context, &stream);
CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Init acl failed. ERROR: %d\n", ret); return ret);
WriteDTLog("aclnnApplyAdamWV2", "aclnnApplyAdamWV2 error scenario test start\n");
aclrtSetOpExecuteTimeOut(1091);
DT_Set_TimeOut_Second(3000);
DT_FUZZ_START(0, fuzz_num, "aclnnApplyAdamWV2", 0)
{
int i = 0;
void* varRefDeviceAddr = nullptr;
aclTensor* varRef = nullptr;
void* mRefDeviceAddr = nullptr;
aclTensor* mRef = nullptr;
void* vRefDeviceAddr = nullptr;
aclTensor* vRef = nullptr;
void* maxGradNormOptionalRefDeviceAddr = nullptr;
aclTensor* maxGradNormOptionalRef = nullptr;
void* gradDeviceAddr = nullptr;
aclTensor* grad = nullptr;
void* stepDeviceAddr = nullptr;
aclTensor* step = nullptr;
float lr = 0.5;
float beta1 = 0.5;
float beta2 = 0.5;
float weightDecay = 0.5;
float eps = 0.000001;
bool amsgrad = false;
bool maximize = false;
uint64_t workspaceSize = 0;
aclOpExecutor* executor;
void* workspaceAddr = nullptr;
int scenario = 0;
int caseRet = -1;
std::string scenarioDesc, violationDetail, errorCategory, savedErrMsg;
int expectedErrorCode = 0;
std::string expectedErrorName, errorTypeStr, errorTargetStr, verifyRequirement;
LOG_PRINT("aclnnApplyAdamWV2 error test %d\n", fuzzi);
RedirectStdoutToScenarioFile(fuzzi);
try
{
scenario = *(int *)DTSetGetNumberRange(&g_Element[i++], 0, 0, 37, "i");
std::vector<int64_t> varRefShape = {2, 4, 16};
std::vector<int64_t> mRefShape = {2, 4, 16};
std::vector<int64_t> vRefShape = {2, 4, 16};
std::vector<int64_t> maxGradNormOptionalRefShape = {2, 4, 16};
std::vector<int64_t> gradShape = {2, 4, 16};
std::vector<int64_t> stepShape = {1};
aclDataType varRefDtype = ACL_FLOAT16;
aclDataType mRefDtype = ACL_FLOAT16;
aclDataType vRefDtype = ACL_FLOAT16;
aclDataType maxGradNormOptionalRefDtype = ACL_FLOAT16;
aclDataType gradDtype = ACL_FLOAT16;
aclDataType stepDtype = ACL_INT64;
aclFormat varRefFormat = ACL_FORMAT_ND;
aclFormat mRefFormat = ACL_FORMAT_ND;
aclFormat vRefFormat = ACL_FORMAT_ND;
aclFormat maxGradNormOptionalRefFormat = ACL_FORMAT_ND;
aclFormat gradFormat = ACL_FORMAT_ND;
aclFormat stepFormat = ACL_FORMAT_ND;
bool nullVarRef = false, nullMRef = false, nullVRef = false, nullMaxGradNormOptionalRef = false, nullGrad = false, nullStep = false;
if (scenario == 0) {
scenarioDesc = "base config sanity check: no violation injected, expect success";
violationDetail = "base config sanity check: no violation injected, expect success";
errorCategory = "BASE";
expectedErrorCode = 0;
expectedErrorName = "ACL_SUCCESS";
errorTypeStr = "BASE_CHECK";
errorTargetStr = "";
verifyRequirement = "基线自检:base配置应执行成功(ret==0);若失败则基线污染,所有异常场景报错不可信,需重构造base";
LOG_PRINT("[BASE_CHECK] base config sanity check: no violation injected, expect success\n");
}
else if (scenario == 1) {
scenarioDesc = "varRef dtype=ACL_INT8 not in supported list [FLOAT16,BF16,FLOAT]";
violationDetail = "varRef=ACL_INT8";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "varRef";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT8不支持或invalid dtype相关提示";
varRefDtype = ACL_INT8;
LOG_PRINT("[A1_varRef_ACL_INT8] varRef dtype=ACL_INT8 not in supported list [FLOAT16,BF16,FLOAT]\n");
}
else if (scenario == 2) {
scenarioDesc = "varRef dtype=ACL_INT32 not in supported list [FLOAT16,BF16,FLOAT]";
violationDetail = "varRef=ACL_INT32";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "varRef";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT32不支持或invalid dtype相关提示";
varRefDtype = ACL_INT32;
LOG_PRINT("[A1_varRef_ACL_INT32] varRef dtype=ACL_INT32 not in supported list [FLOAT16,BF16,FLOAT]\n");
}
else if (scenario == 3) {
scenarioDesc = "varRef dim=9D exceeds max=8D";
violationDetail = "varRef dim=9D exceeds max=8D";
errorCategory = "B1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DIM_ILLEGAL";
errorTargetStr = "varRef";
verifyRequirement = "返回码应为161001或161002,错误信息应提示维度数超限";
varRefShape = {1, 1, 1, 1, 1, 1, 1, 1, 1};
LOG_PRINT("[B1_varRef_dim_above_8] varRef dim=9D exceeds max=8D\n");
}
else if (scenario == 4) {
scenarioDesc = "varRef shape has zero dimension: [0, 4, 16]";
violationDetail = "varRef shape has zero dimension: [0, 4, 16]";
errorCategory = "B4";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "SHAPE_ILLEGAL";
errorTargetStr = "varRef";
verifyRequirement = "空tensor可能合法也可能非法,需根据md文档确认;若非法应返回161001或161002";
varRefShape = {0, 4, 16};
LOG_PRINT("[B4_varRef_zero_dim] varRef shape has zero dimension: [0, 4, 16]\n");
}
else if (scenario == 5) {
scenarioDesc = "varRef format=ACL_FORMAT_NCHW (only ND supported)";
violationDetail = "varRef format=ACL_FORMAT_NCHW (only ND supported)";
errorCategory = "C1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "FORMAT_UNSUPPORTED";
errorTargetStr = "varRef";
verifyRequirement = "返回码应为161001或161002,错误信息应提示format不支持";
varRefFormat = ACL_FORMAT_NCHW;
LOG_PRINT("[C1_varRef_NCHW] varRef format=ACL_FORMAT_NCHW (only ND supported)\n");
}
else if (scenario == 6) {
scenarioDesc = "varRef tensor is nullptr (input pointer is null)";
violationDetail = "varRef tensor is nullptr (input pointer is null)";
errorCategory = "D3";
expectedErrorCode = 161001;
expectedErrorName = "ACLNN_ERR_PARAM_NULLPTR";
errorTypeStr = "NULLPTR_INPUT";
errorTargetStr = "varRef";
verifyRequirement = "返回码应为161001,错误信息应包含null或nullptr相关提示";
nullVarRef = true;
LOG_PRINT("[D3_varRef_nullptr] varRef tensor is nullptr (input pointer is null)\n");
}
else if (scenario == 7) {
scenarioDesc = "mRef dtype=ACL_INT8 not in supported list [FLOAT16,BF16,FLOAT]";
violationDetail = "mRef=ACL_INT8";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "mRef";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT8不支持或invalid dtype相关提示";
mRefDtype = ACL_INT8;
LOG_PRINT("[A1_mRef_ACL_INT8] mRef dtype=ACL_INT8 not in supported list [FLOAT16,BF16,FLOAT]\n");
}
else if (scenario == 8) {
scenarioDesc = "mRef dtype=ACL_INT32 not in supported list [FLOAT16,BF16,FLOAT]";
violationDetail = "mRef=ACL_INT32";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "mRef";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT32不支持或invalid dtype相关提示";
mRefDtype = ACL_INT32;
LOG_PRINT("[A1_mRef_ACL_INT32] mRef dtype=ACL_INT32 not in supported list [FLOAT16,BF16,FLOAT]\n");
}
else if (scenario == 9) {
scenarioDesc = "mRef dim=9D exceeds max=8D";
violationDetail = "mRef dim=9D exceeds max=8D";
errorCategory = "B1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DIM_ILLEGAL";
errorTargetStr = "mRef";
verifyRequirement = "返回码应为161001或161002,错误信息应提示维度数超限";
mRefShape = {1, 1, 1, 1, 1, 1, 1, 1, 1};
LOG_PRINT("[B1_mRef_dim_above_8] mRef dim=9D exceeds max=8D\n");
}
else if (scenario == 10) {
scenarioDesc = "mRef shape has zero dimension: [0, 4, 16]";
violationDetail = "mRef shape has zero dimension: [0, 4, 16]";
errorCategory = "B4";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "SHAPE_ILLEGAL";
errorTargetStr = "mRef";
verifyRequirement = "空tensor可能合法也可能非法,需根据md文档确认;若非法应返回161001或161002";
mRefShape = {0, 4, 16};
LOG_PRINT("[B4_mRef_zero_dim] mRef shape has zero dimension: [0, 4, 16]\n");
}
else if (scenario == 11) {
scenarioDesc = "mRef format=ACL_FORMAT_NCHW (only ND supported)";
violationDetail = "mRef format=ACL_FORMAT_NCHW (only ND supported)";
errorCategory = "C1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "FORMAT_UNSUPPORTED";
errorTargetStr = "mRef";
verifyRequirement = "返回码应为161001或161002,错误信息应提示format不支持";
mRefFormat = ACL_FORMAT_NCHW;
LOG_PRINT("[C1_mRef_NCHW] mRef format=ACL_FORMAT_NCHW (only ND supported)\n");
}
else if (scenario == 12) {
scenarioDesc = "mRef tensor is nullptr (input pointer is null)";
violationDetail = "mRef tensor is nullptr (input pointer is null)";
errorCategory = "D3";
expectedErrorCode = 161001;
expectedErrorName = "ACLNN_ERR_PARAM_NULLPTR";
errorTypeStr = "NULLPTR_INPUT";
errorTargetStr = "mRef";
verifyRequirement = "返回码应为161001,错误信息应包含null或nullptr相关提示";
nullMRef = true;
LOG_PRINT("[D3_mRef_nullptr] mRef tensor is nullptr (input pointer is null)\n");
}
else if (scenario == 13) {
scenarioDesc = "vRef dtype=ACL_INT8 not in supported list [FLOAT16,BF16,FLOAT]";
violationDetail = "vRef=ACL_INT8";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "vRef";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT8不支持或invalid dtype相关提示";
vRefDtype = ACL_INT8;
LOG_PRINT("[A1_vRef_ACL_INT8] vRef dtype=ACL_INT8 not in supported list [FLOAT16,BF16,FLOAT]\n");
}
else if (scenario == 14) {
scenarioDesc = "vRef dtype=ACL_INT32 not in supported list [FLOAT16,BF16,FLOAT]";
violationDetail = "vRef=ACL_INT32";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "vRef";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT32不支持或invalid dtype相关提示";
vRefDtype = ACL_INT32;
LOG_PRINT("[A1_vRef_ACL_INT32] vRef dtype=ACL_INT32 not in supported list [FLOAT16,BF16,FLOAT]\n");
}
else if (scenario == 15) {
scenarioDesc = "vRef dim=9D exceeds max=8D";
violationDetail = "vRef dim=9D exceeds max=8D";
errorCategory = "B1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DIM_ILLEGAL";
errorTargetStr = "vRef";
verifyRequirement = "返回码应为161001或161002,错误信息应提示维度数超限";
vRefShape = {1, 1, 1, 1, 1, 1, 1, 1, 1};
LOG_PRINT("[B1_vRef_dim_above_8] vRef dim=9D exceeds max=8D\n");
}
else if (scenario == 16) {
scenarioDesc = "vRef shape has zero dimension: [0, 4, 16]";
violationDetail = "vRef shape has zero dimension: [0, 4, 16]";
errorCategory = "B4";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "SHAPE_ILLEGAL";
errorTargetStr = "vRef";
verifyRequirement = "空tensor可能合法也可能非法,需根据md文档确认;若非法应返回161001或161002";
vRefShape = {0, 4, 16};
LOG_PRINT("[B4_vRef_zero_dim] vRef shape has zero dimension: [0, 4, 16]\n");
}
else if (scenario == 17) {
scenarioDesc = "vRef format=ACL_FORMAT_NCHW (only ND supported)";
violationDetail = "vRef format=ACL_FORMAT_NCHW (only ND supported)";
errorCategory = "C1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "FORMAT_UNSUPPORTED";
errorTargetStr = "vRef";
verifyRequirement = "返回码应为161001或161002,错误信息应提示format不支持";
vRefFormat = ACL_FORMAT_NCHW;
LOG_PRINT("[C1_vRef_NCHW] vRef format=ACL_FORMAT_NCHW (only ND supported)\n");
}
else if (scenario == 18) {
scenarioDesc = "vRef tensor is nullptr (input pointer is null)";
violationDetail = "vRef tensor is nullptr (input pointer is null)";
errorCategory = "D3";
expectedErrorCode = 161001;
expectedErrorName = "ACLNN_ERR_PARAM_NULLPTR";
errorTypeStr = "NULLPTR_INPUT";
errorTargetStr = "vRef";
verifyRequirement = "返回码应为161001,错误信息应包含null或nullptr相关提示";
nullVRef = true;
LOG_PRINT("[D3_vRef_nullptr] vRef tensor is nullptr (input pointer is null)\n");
}
else if (scenario == 19) {
scenarioDesc = "maxGradNormOptionalRef dtype=ACL_INT8 not in supported list [FLOAT16,BF16,FLOAT]";
violationDetail = "maxGradNormOptionalRef=ACL_INT8";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "maxGradNormOptionalRef";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT8不支持或invalid dtype相关提示";
maxGradNormOptionalRefDtype = ACL_INT8;
LOG_PRINT("[A1_maxGradNormOptionalRef_ACL_INT8] maxGradNormOptionalRef dtype=ACL_INT8 not in supported list [FLOAT16,BF16,FLOAT]\n");
}
else if (scenario == 20) {
scenarioDesc = "maxGradNormOptionalRef dtype=ACL_INT32 not in supported list [FLOAT16,BF16,FLOAT";
violationDetail = "maxGradNormOptionalRef=ACL_INT32";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "maxGradNormOptionalRef";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT32不支持或invalid dtype相关提示";
maxGradNormOptionalRefDtype = ACL_INT32;
LOG_PRINT("[A1_maxGradNormOptionalRef_ACL_INT32] maxGradNormOptionalRef dtype=ACL_INT32 not in supported list [FLOAT16,BF16,FLOAT\n");
}
else if (scenario == 21) {
scenarioDesc = "maxGradNormOptionalRef dim=9D exceeds max=8D";
violationDetail = "maxGradNormOptionalRef dim=9D exceeds max=8D";
errorCategory = "B1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DIM_ILLEGAL";
errorTargetStr = "maxGradNormOptionalRef";
verifyRequirement = "返回码应为161001或161002,错误信息应提示维度数超限";
maxGradNormOptionalRefShape = {1, 1, 1, 1, 1, 1, 1, 1, 1};
LOG_PRINT("[B1_maxGradNormOptionalRef_dim_above_8] maxGradNormOptionalRef dim=9D exceeds max=8D\n");
}
else if (scenario == 22) {
scenarioDesc = "maxGradNormOptionalRef shape has zero dimension: [0, 4, 16]";
violationDetail = "maxGradNormOptionalRef shape has zero dimension: [0, 4, 16]";
errorCategory = "B4";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "SHAPE_ILLEGAL";
errorTargetStr = "maxGradNormOptionalRef";
verifyRequirement = "空tensor可能合法也可能非法,需根据md文档确认;若非法应返回161001或161002";
maxGradNormOptionalRefShape = {0, 4, 16};
LOG_PRINT("[B4_maxGradNormOptionalRef_zero_dim] maxGradNormOptionalRef shape has zero dimension: [0, 4, 16]\n");
}
else if (scenario == 23) {
scenarioDesc = "maxGradNormOptionalRef format=ACL_FORMAT_NCHW (only ND supported)";
violationDetail = "maxGradNormOptionalRef format=ACL_FORMAT_NCHW (only ND supported)";
errorCategory = "C1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "FORMAT_UNSUPPORTED";
errorTargetStr = "maxGradNormOptionalRef";
verifyRequirement = "返回码应为161001或161002,错误信息应提示format不支持";
maxGradNormOptionalRefFormat = ACL_FORMAT_NCHW;
LOG_PRINT("[C1_maxGradNormOptionalRef_NCHW] maxGradNormOptionalRef format=ACL_FORMAT_NCHW (only ND supported)\n");
}
else if (scenario == 24) {
scenarioDesc = "maxGradNormOptionalRef tensor is nullptr (input pointer is null)";
violationDetail = "maxGradNormOptionalRef tensor is nullptr (input pointer is null)";
errorCategory = "D3";
expectedErrorCode = 161001;
expectedErrorName = "ACLNN_ERR_PARAM_NULLPTR";
errorTypeStr = "NULLPTR_INPUT";
errorTargetStr = "maxGradNormOptionalRef";
verifyRequirement = "返回码应为161001,错误信息应包含null或nullptr相关提示";
nullMaxGradNormOptionalRef = true;
LOG_PRINT("[D3_maxGradNormOptionalRef_nullptr] maxGradNormOptionalRef tensor is nullptr (input pointer is null)\n");
}
else if (scenario == 25) {
scenarioDesc = "grad dtype=ACL_INT8 not in supported list [FLOAT16,BF16,FLOAT]";
violationDetail = "grad=ACL_INT8";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "grad";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT8不支持或invalid dtype相关提示";
gradDtype = ACL_INT8;
LOG_PRINT("[A1_grad_ACL_INT8] grad dtype=ACL_INT8 not in supported list [FLOAT16,BF16,FLOAT]\n");
}
else if (scenario == 26) {
scenarioDesc = "grad dtype=ACL_INT32 not in supported list [FLOAT16,BF16,FLOAT]";
violationDetail = "grad=ACL_INT32";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "grad";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT32不支持或invalid dtype相关提示";
gradDtype = ACL_INT32;
LOG_PRINT("[A1_grad_ACL_INT32] grad dtype=ACL_INT32 not in supported list [FLOAT16,BF16,FLOAT]\n");
}
else if (scenario == 27) {
scenarioDesc = "grad dim=9D exceeds max=8D";
violationDetail = "grad dim=9D exceeds max=8D";
errorCategory = "B1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DIM_ILLEGAL";
errorTargetStr = "grad";
verifyRequirement = "返回码应为161001或161002,错误信息应提示维度数超限";
gradShape = {1, 1, 1, 1, 1, 1, 1, 1, 1};
LOG_PRINT("[B1_grad_dim_above_8] grad dim=9D exceeds max=8D\n");
}
else if (scenario == 28) {
scenarioDesc = "grad shape has zero dimension: [0, 4, 16]";
violationDetail = "grad shape has zero dimension: [0, 4, 16]";
errorCategory = "B4";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "SHAPE_ILLEGAL";
errorTargetStr = "grad";
verifyRequirement = "空tensor可能合法也可能非法,需根据md文档确认;若非法应返回161001或161002";
gradShape = {0, 4, 16};
LOG_PRINT("[B4_grad_zero_dim] grad shape has zero dimension: [0, 4, 16]\n");
}
else if (scenario == 29) {
scenarioDesc = "grad format=ACL_FORMAT_NCHW (only ND supported)";
violationDetail = "grad format=ACL_FORMAT_NCHW (only ND supported)";
errorCategory = "C1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "FORMAT_UNSUPPORTED";
errorTargetStr = "grad";
verifyRequirement = "返回码应为161001或161002,错误信息应提示format不支持";
gradFormat = ACL_FORMAT_NCHW;
LOG_PRINT("[C1_grad_NCHW] grad format=ACL_FORMAT_NCHW (only ND supported)\n");
}
else if (scenario == 30) {
scenarioDesc = "grad tensor is nullptr (input pointer is null)";
violationDetail = "grad tensor is nullptr (input pointer is null)";
errorCategory = "D3";
expectedErrorCode = 161001;
expectedErrorName = "ACLNN_ERR_PARAM_NULLPTR";
errorTypeStr = "NULLPTR_INPUT";
errorTargetStr = "grad";
verifyRequirement = "返回码应为161001,错误信息应包含null或nullptr相关提示";
nullGrad = true;
LOG_PRINT("[D3_grad_nullptr] grad tensor is nullptr (input pointer is null)\n");
}
else if (scenario == 31) {
scenarioDesc = "step dtype=ACL_INT8 not in supported list [INT64,FLOAT]";
violationDetail = "step=ACL_INT8";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "step";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT8不支持或invalid dtype相关提示";
stepDtype = ACL_INT8;
LOG_PRINT("[A1_step_ACL_INT8] step dtype=ACL_INT8 not in supported list [INT64,FLOAT]\n");
}
else if (scenario == 32) {
scenarioDesc = "step dtype=ACL_INT32 not in supported list [INT64,FLOAT]";
violationDetail = "step=ACL_INT32";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "step";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT32不支持或invalid dtype相关提示";
stepDtype = ACL_INT32;
LOG_PRINT("[A1_step_ACL_INT32] step dtype=ACL_INT32 not in supported list [INT64,FLOAT]\n");
}
else if (scenario == 33) {
scenarioDesc = "step dim=9D exceeds max=8D";
violationDetail = "step dim=9D exceeds max=8D";
errorCategory = "B1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DIM_ILLEGAL";
errorTargetStr = "step";
verifyRequirement = "返回码应为161001或161002,错误信息应提示维度数超限";
stepShape = {1, 1, 1, 1, 1, 1, 1, 1, 1};
LOG_PRINT("[B1_step_dim_above_8] step dim=9D exceeds max=8D\n");
}
else if (scenario == 34) {
scenarioDesc = "step format=ACL_FORMAT_NCHW (only ND supported)";
violationDetail = "step format=ACL_FORMAT_NCHW (only ND supported)";
errorCategory = "C1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "FORMAT_UNSUPPORTED";
errorTargetStr = "step";
verifyRequirement = "返回码应为161001或161002,错误信息应提示format不支持";
stepFormat = ACL_FORMAT_NCHW;
LOG_PRINT("[C1_step_NCHW] step format=ACL_FORMAT_NCHW (only ND supported)\n");
}
else if (scenario == 35) {
scenarioDesc = "step tensor is nullptr (input pointer is null)";
violationDetail = "step tensor is nullptr (input pointer is null)";
errorCategory = "D3";
expectedErrorCode = 161001;
expectedErrorName = "ACLNN_ERR_PARAM_NULLPTR";
errorTypeStr = "NULLPTR_INPUT";
errorTargetStr = "step";
verifyRequirement = "返回码应为161001,错误信息应包含null或nullptr相关提示";
nullStep = true;
LOG_PRINT("[D3_step_nullptr] step tensor is nullptr (input pointer is null)\n");
}
else if (scenario == 36) {
scenarioDesc = "varRef=ACL_FLOAT16 but mRef=ACL_INT8 (pair requires same)";
violationDetail = "mRef=ACL_INT8";
errorCategory = "A2";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_MISMATCH";
errorTargetStr = "mRef+varRef";
verifyRequirement = "返回码应为161001或161002,错误信息应提示dtype不匹配";
mRefDtype = ACL_INT8;
LOG_PRINT("[A2_mRef_vs_varRef_dtype_mismatch] varRef=ACL_FLOAT16 but mRef=ACL_INT8 (pair requires same)\n");
}
else if (scenario == 37) {
scenarioDesc = "mRef.shape=[2, 4, 33] mismatch with varRef.shape=[2, 4, 16]";
violationDetail = "mRef.shape=[2, 4, 33] mismatch with varRef.shape=[2, 4, 16]";
errorCategory = "B2";
expectedErrorCode = 561002;
expectedErrorName = "ACLNN_ERR_INNER_SHAPE_MISMATCH";
errorTypeStr = "SHAPE_MISMATCH";
errorTargetStr = "mRef+varRef";
verifyRequirement = "返回码可能为561001或561002,错误信息应提示shape不匹配";
mRefShape = {2, 4, 33};
LOG_PRINT("[B2_mRef_vs_varRef_mismatch] mRef.shape=[2, 4, 33] mismatch with varRef.shape=[2, 4, 16]\n");
}
else {
scenarioDesc = "OUT_OF_RANGE";
violationDetail = "scenario index exceeds total";
errorCategory = "SKIP";
LOG_PRINT("Scenario %d out of range (0-37), skipping\n", scenario);
}
if (!nullVarRef) {
long long varRef_sz = GetShapeSize(varRefShape);
if (varRef_sz > 0 && varRef_sz <= 1073741824) {
if (varRefDtype == ACL_FLOAT) {
std::vector<float> varRef_host(varRef_sz, 1);
ret = CreateAclTensor_New(varRef_host, varRefShape, &varRefDeviceAddr, varRefDtype, varRefFormat, &varRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (varRefDtype == ACL_FLOAT16) {
std::vector<int16_t> varRef_host(varRef_sz, 1);
ret = CreateAclTensor_New(varRef_host, varRefShape, &varRefDeviceAddr, varRefDtype, varRefFormat, &varRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (varRefDtype == ACL_INT8) {
std::vector<int8_t> varRef_host(varRef_sz, 1);
ret = CreateAclTensor_New(varRef_host, varRefShape, &varRefDeviceAddr, varRefDtype, varRefFormat, &varRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (varRefDtype == ACL_INT32) {
std::vector<int32_t> varRef_host(varRef_sz, 1);
ret = CreateAclTensor_New(varRef_host, varRefShape, &varRefDeviceAddr, varRefDtype, varRefFormat, &varRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (varRefDtype == ACL_UINT8) {
std::vector<uint8_t> varRef_host(varRef_sz, 1);
ret = CreateAclTensor_New(varRef_host, varRefShape, &varRefDeviceAddr, varRefDtype, varRefFormat, &varRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (varRefDtype == ACL_INT16) {
std::vector<int16_t> varRef_host(varRef_sz, 1);
ret = CreateAclTensor_New(varRef_host, varRefShape, &varRefDeviceAddr, varRefDtype, varRefFormat, &varRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (varRefDtype == ACL_UINT16) {
std::vector<uint16_t> varRef_host(varRef_sz, 1);
ret = CreateAclTensor_New(varRef_host, varRefShape, &varRefDeviceAddr, varRefDtype, varRefFormat, &varRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (varRefDtype == ACL_UINT32) {
std::vector<uint32_t> varRef_host(varRef_sz, 1);
ret = CreateAclTensor_New(varRef_host, varRefShape, &varRefDeviceAddr, varRefDtype, varRefFormat, &varRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (varRefDtype == ACL_INT64) {
std::vector<int64_t> varRef_host(varRef_sz, 1);
ret = CreateAclTensor_New(varRef_host, varRefShape, &varRefDeviceAddr, varRefDtype, varRefFormat, &varRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (varRefDtype == ACL_UINT64) {
std::vector<uint64_t> varRef_host(varRef_sz, 1);
ret = CreateAclTensor_New(varRef_host, varRefShape, &varRefDeviceAddr, varRefDtype, varRefFormat, &varRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (varRefDtype == ACL_DOUBLE) {
std::vector<double> varRef_host(varRef_sz, 1);
ret = CreateAclTensor_New(varRef_host, varRefShape, &varRefDeviceAddr, varRefDtype, varRefFormat, &varRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (varRefDtype == ACL_BOOL) {
std::vector<int8_t> varRef_host(varRef_sz, 1);
ret = CreateAclTensor_New(varRef_host, varRefShape, &varRefDeviceAddr, varRefDtype, varRefFormat, &varRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (varRefDtype == ACL_BF16) {
std::vector<int16_t> varRef_host(varRef_sz, 1);
ret = CreateAclTensor_New(varRef_host, varRefShape, &varRefDeviceAddr, varRefDtype, varRefFormat, &varRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (varRefDtype == ACL_COMPLEX64) {
std::vector<float> varRef_host((varRef_sz * 2), 1);
ret = CreateAclTensor_New(varRef_host, varRefShape, &varRefDeviceAddr, varRefDtype, varRefFormat, &varRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (varRefDtype == ACL_COMPLEX128) {
std::vector<double> varRef_host((varRef_sz * 2), 1);
ret = CreateAclTensor_New(varRef_host, varRefShape, &varRefDeviceAddr, varRefDtype, varRefFormat, &varRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else {
std::vector<float> varRef_host(varRef_sz, 1);
ret = CreateAclTensor_New(varRef_host, varRefShape, &varRefDeviceAddr, varRefDtype, varRefFormat, &varRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
}
}
} else {
varRef = nullptr;
}
if (!nullMRef) {
long long mRef_sz = GetShapeSize(mRefShape);
if (mRef_sz > 0 && mRef_sz <= 1073741824) {
if (mRefDtype == ACL_FLOAT) {
std::vector<float> mRef_host(mRef_sz, 1);
ret = CreateAclTensor_New(mRef_host, mRefShape, &mRefDeviceAddr, mRefDtype, mRefFormat, &mRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (mRefDtype == ACL_FLOAT16) {
std::vector<int16_t> mRef_host(mRef_sz, 1);
ret = CreateAclTensor_New(mRef_host, mRefShape, &mRefDeviceAddr, mRefDtype, mRefFormat, &mRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (mRefDtype == ACL_INT8) {
std::vector<int8_t> mRef_host(mRef_sz, 1);
ret = CreateAclTensor_New(mRef_host, mRefShape, &mRefDeviceAddr, mRefDtype, mRefFormat, &mRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (mRefDtype == ACL_INT32) {
std::vector<int32_t> mRef_host(mRef_sz, 1);
ret = CreateAclTensor_New(mRef_host, mRefShape, &mRefDeviceAddr, mRefDtype, mRefFormat, &mRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (mRefDtype == ACL_UINT8) {
std::vector<uint8_t> mRef_host(mRef_sz, 1);
ret = CreateAclTensor_New(mRef_host, mRefShape, &mRefDeviceAddr, mRefDtype, mRefFormat, &mRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (mRefDtype == ACL_INT16) {
std::vector<int16_t> mRef_host(mRef_sz, 1);
ret = CreateAclTensor_New(mRef_host, mRefShape, &mRefDeviceAddr, mRefDtype, mRefFormat, &mRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (mRefDtype == ACL_UINT16) {
std::vector<uint16_t> mRef_host(mRef_sz, 1);
ret = CreateAclTensor_New(mRef_host, mRefShape, &mRefDeviceAddr, mRefDtype, mRefFormat, &mRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (mRefDtype == ACL_UINT32) {
std::vector<uint32_t> mRef_host(mRef_sz, 1);
ret = CreateAclTensor_New(mRef_host, mRefShape, &mRefDeviceAddr, mRefDtype, mRefFormat, &mRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (mRefDtype == ACL_INT64) {
std::vector<int64_t> mRef_host(mRef_sz, 1);
ret = CreateAclTensor_New(mRef_host, mRefShape, &mRefDeviceAddr, mRefDtype, mRefFormat, &mRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (mRefDtype == ACL_UINT64) {
std::vector<uint64_t> mRef_host(mRef_sz, 1);
ret = CreateAclTensor_New(mRef_host, mRefShape, &mRefDeviceAddr, mRefDtype, mRefFormat, &mRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (mRefDtype == ACL_DOUBLE) {
std::vector<double> mRef_host(mRef_sz, 1);
ret = CreateAclTensor_New(mRef_host, mRefShape, &mRefDeviceAddr, mRefDtype, mRefFormat, &mRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (mRefDtype == ACL_BOOL) {
std::vector<int8_t> mRef_host(mRef_sz, 1);
ret = CreateAclTensor_New(mRef_host, mRefShape, &mRefDeviceAddr, mRefDtype, mRefFormat, &mRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (mRefDtype == ACL_BF16) {
std::vector<int16_t> mRef_host(mRef_sz, 1);
ret = CreateAclTensor_New(mRef_host, mRefShape, &mRefDeviceAddr, mRefDtype, mRefFormat, &mRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (mRefDtype == ACL_COMPLEX64) {
std::vector<float> mRef_host((mRef_sz * 2), 1);
ret = CreateAclTensor_New(mRef_host, mRefShape, &mRefDeviceAddr, mRefDtype, mRefFormat, &mRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (mRefDtype == ACL_COMPLEX128) {
std::vector<double> mRef_host((mRef_sz * 2), 1);
ret = CreateAclTensor_New(mRef_host, mRefShape, &mRefDeviceAddr, mRefDtype, mRefFormat, &mRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else {
std::vector<float> mRef_host(mRef_sz, 1);
ret = CreateAclTensor_New(mRef_host, mRefShape, &mRefDeviceAddr, mRefDtype, mRefFormat, &mRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
}
}
} else {
mRef = nullptr;
}
if (!nullVRef) {
long long vRef_sz = GetShapeSize(vRefShape);
if (vRef_sz > 0 && vRef_sz <= 1073741824) {
if (vRefDtype == ACL_FLOAT) {
std::vector<float> vRef_host(vRef_sz, 1);
ret = CreateAclTensor_New(vRef_host, vRefShape, &vRefDeviceAddr, vRefDtype, vRefFormat, &vRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (vRefDtype == ACL_FLOAT16) {
std::vector<int16_t> vRef_host(vRef_sz, 1);
ret = CreateAclTensor_New(vRef_host, vRefShape, &vRefDeviceAddr, vRefDtype, vRefFormat, &vRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (vRefDtype == ACL_INT8) {
std::vector<int8_t> vRef_host(vRef_sz, 1);
ret = CreateAclTensor_New(vRef_host, vRefShape, &vRefDeviceAddr, vRefDtype, vRefFormat, &vRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (vRefDtype == ACL_INT32) {
std::vector<int32_t> vRef_host(vRef_sz, 1);
ret = CreateAclTensor_New(vRef_host, vRefShape, &vRefDeviceAddr, vRefDtype, vRefFormat, &vRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (vRefDtype == ACL_UINT8) {
std::vector<uint8_t> vRef_host(vRef_sz, 1);
ret = CreateAclTensor_New(vRef_host, vRefShape, &vRefDeviceAddr, vRefDtype, vRefFormat, &vRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (vRefDtype == ACL_INT16) {
std::vector<int16_t> vRef_host(vRef_sz, 1);
ret = CreateAclTensor_New(vRef_host, vRefShape, &vRefDeviceAddr, vRefDtype, vRefFormat, &vRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (vRefDtype == ACL_UINT16) {
std::vector<uint16_t> vRef_host(vRef_sz, 1);
ret = CreateAclTensor_New(vRef_host, vRefShape, &vRefDeviceAddr, vRefDtype, vRefFormat, &vRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (vRefDtype == ACL_UINT32) {
std::vector<uint32_t> vRef_host(vRef_sz, 1);
ret = CreateAclTensor_New(vRef_host, vRefShape, &vRefDeviceAddr, vRefDtype, vRefFormat, &vRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (vRefDtype == ACL_INT64) {
std::vector<int64_t> vRef_host(vRef_sz, 1);
ret = CreateAclTensor_New(vRef_host, vRefShape, &vRefDeviceAddr, vRefDtype, vRefFormat, &vRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (vRefDtype == ACL_UINT64) {
std::vector<uint64_t> vRef_host(vRef_sz, 1);
ret = CreateAclTensor_New(vRef_host, vRefShape, &vRefDeviceAddr, vRefDtype, vRefFormat, &vRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (vRefDtype == ACL_DOUBLE) {
std::vector<double> vRef_host(vRef_sz, 1);
ret = CreateAclTensor_New(vRef_host, vRefShape, &vRefDeviceAddr, vRefDtype, vRefFormat, &vRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (vRefDtype == ACL_BOOL) {
std::vector<int8_t> vRef_host(vRef_sz, 1);
ret = CreateAclTensor_New(vRef_host, vRefShape, &vRefDeviceAddr, vRefDtype, vRefFormat, &vRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (vRefDtype == ACL_BF16) {
std::vector<int16_t> vRef_host(vRef_sz, 1);
ret = CreateAclTensor_New(vRef_host, vRefShape, &vRefDeviceAddr, vRefDtype, vRefFormat, &vRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (vRefDtype == ACL_COMPLEX64) {
std::vector<float> vRef_host((vRef_sz * 2), 1);
ret = CreateAclTensor_New(vRef_host, vRefShape, &vRefDeviceAddr, vRefDtype, vRefFormat, &vRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (vRefDtype == ACL_COMPLEX128) {
std::vector<double> vRef_host((vRef_sz * 2), 1);
ret = CreateAclTensor_New(vRef_host, vRefShape, &vRefDeviceAddr, vRefDtype, vRefFormat, &vRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else {
std::vector<float> vRef_host(vRef_sz, 1);
ret = CreateAclTensor_New(vRef_host, vRefShape, &vRefDeviceAddr, vRefDtype, vRefFormat, &vRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
}
}
} else {
vRef = nullptr;
}
if (!nullMaxGradNormOptionalRef) {
long long maxGradNormOptionalRef_sz = GetShapeSize(maxGradNormOptionalRefShape);
if (maxGradNormOptionalRef_sz > 0 && maxGradNormOptionalRef_sz <= 1073741824) {
if (maxGradNormOptionalRefDtype == ACL_FLOAT) {
std::vector<float> maxGradNormOptionalRef_host(maxGradNormOptionalRef_sz, 1);
ret = CreateAclTensor_New(maxGradNormOptionalRef_host, maxGradNormOptionalRefShape, &maxGradNormOptionalRefDeviceAddr, maxGradNormOptionalRefDtype, maxGradNormOptionalRefFormat, &maxGradNormOptionalRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (maxGradNormOptionalRefDtype == ACL_FLOAT16) {
std::vector<int16_t> maxGradNormOptionalRef_host(maxGradNormOptionalRef_sz, 1);
ret = CreateAclTensor_New(maxGradNormOptionalRef_host, maxGradNormOptionalRefShape, &maxGradNormOptionalRefDeviceAddr, maxGradNormOptionalRefDtype, maxGradNormOptionalRefFormat, &maxGradNormOptionalRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (maxGradNormOptionalRefDtype == ACL_INT8) {
std::vector<int8_t> maxGradNormOptionalRef_host(maxGradNormOptionalRef_sz, 1);
ret = CreateAclTensor_New(maxGradNormOptionalRef_host, maxGradNormOptionalRefShape, &maxGradNormOptionalRefDeviceAddr, maxGradNormOptionalRefDtype, maxGradNormOptionalRefFormat, &maxGradNormOptionalRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (maxGradNormOptionalRefDtype == ACL_INT32) {
std::vector<int32_t> maxGradNormOptionalRef_host(maxGradNormOptionalRef_sz, 1);
ret = CreateAclTensor_New(maxGradNormOptionalRef_host, maxGradNormOptionalRefShape, &maxGradNormOptionalRefDeviceAddr, maxGradNormOptionalRefDtype, maxGradNormOptionalRefFormat, &maxGradNormOptionalRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (maxGradNormOptionalRefDtype == ACL_UINT8) {
std::vector<uint8_t> maxGradNormOptionalRef_host(maxGradNormOptionalRef_sz, 1);
ret = CreateAclTensor_New(maxGradNormOptionalRef_host, maxGradNormOptionalRefShape, &maxGradNormOptionalRefDeviceAddr, maxGradNormOptionalRefDtype, maxGradNormOptionalRefFormat, &maxGradNormOptionalRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (maxGradNormOptionalRefDtype == ACL_INT16) {
std::vector<int16_t> maxGradNormOptionalRef_host(maxGradNormOptionalRef_sz, 1);
ret = CreateAclTensor_New(maxGradNormOptionalRef_host, maxGradNormOptionalRefShape, &maxGradNormOptionalRefDeviceAddr, maxGradNormOptionalRefDtype, maxGradNormOptionalRefFormat, &maxGradNormOptionalRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (maxGradNormOptionalRefDtype == ACL_UINT16) {
std::vector<uint16_t> maxGradNormOptionalRef_host(maxGradNormOptionalRef_sz, 1);
ret = CreateAclTensor_New(maxGradNormOptionalRef_host, maxGradNormOptionalRefShape, &maxGradNormOptionalRefDeviceAddr, maxGradNormOptionalRefDtype, maxGradNormOptionalRefFormat, &maxGradNormOptionalRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (maxGradNormOptionalRefDtype == ACL_UINT32) {
std::vector<uint32_t> maxGradNormOptionalRef_host(maxGradNormOptionalRef_sz, 1);
ret = CreateAclTensor_New(maxGradNormOptionalRef_host, maxGradNormOptionalRefShape, &maxGradNormOptionalRefDeviceAddr, maxGradNormOptionalRefDtype, maxGradNormOptionalRefFormat, &maxGradNormOptionalRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (maxGradNormOptionalRefDtype == ACL_INT64) {
std::vector<int64_t> maxGradNormOptionalRef_host(maxGradNormOptionalRef_sz, 1);
ret = CreateAclTensor_New(maxGradNormOptionalRef_host, maxGradNormOptionalRefShape, &maxGradNormOptionalRefDeviceAddr, maxGradNormOptionalRefDtype, maxGradNormOptionalRefFormat, &maxGradNormOptionalRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (maxGradNormOptionalRefDtype == ACL_UINT64) {
std::vector<uint64_t> maxGradNormOptionalRef_host(maxGradNormOptionalRef_sz, 1);
ret = CreateAclTensor_New(maxGradNormOptionalRef_host, maxGradNormOptionalRefShape, &maxGradNormOptionalRefDeviceAddr, maxGradNormOptionalRefDtype, maxGradNormOptionalRefFormat, &maxGradNormOptionalRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (maxGradNormOptionalRefDtype == ACL_DOUBLE) {
std::vector<double> maxGradNormOptionalRef_host(maxGradNormOptionalRef_sz, 1);
ret = CreateAclTensor_New(maxGradNormOptionalRef_host, maxGradNormOptionalRefShape, &maxGradNormOptionalRefDeviceAddr, maxGradNormOptionalRefDtype, maxGradNormOptionalRefFormat, &maxGradNormOptionalRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (maxGradNormOptionalRefDtype == ACL_BOOL) {
std::vector<int8_t> maxGradNormOptionalRef_host(maxGradNormOptionalRef_sz, 1);
ret = CreateAclTensor_New(maxGradNormOptionalRef_host, maxGradNormOptionalRefShape, &maxGradNormOptionalRefDeviceAddr, maxGradNormOptionalRefDtype, maxGradNormOptionalRefFormat, &maxGradNormOptionalRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (maxGradNormOptionalRefDtype == ACL_BF16) {
std::vector<int16_t> maxGradNormOptionalRef_host(maxGradNormOptionalRef_sz, 1);
ret = CreateAclTensor_New(maxGradNormOptionalRef_host, maxGradNormOptionalRefShape, &maxGradNormOptionalRefDeviceAddr, maxGradNormOptionalRefDtype, maxGradNormOptionalRefFormat, &maxGradNormOptionalRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (maxGradNormOptionalRefDtype == ACL_COMPLEX64) {
std::vector<float> maxGradNormOptionalRef_host((maxGradNormOptionalRef_sz * 2), 1);
ret = CreateAclTensor_New(maxGradNormOptionalRef_host, maxGradNormOptionalRefShape, &maxGradNormOptionalRefDeviceAddr, maxGradNormOptionalRefDtype, maxGradNormOptionalRefFormat, &maxGradNormOptionalRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (maxGradNormOptionalRefDtype == ACL_COMPLEX128) {
std::vector<double> maxGradNormOptionalRef_host((maxGradNormOptionalRef_sz * 2), 1);
ret = CreateAclTensor_New(maxGradNormOptionalRef_host, maxGradNormOptionalRefShape, &maxGradNormOptionalRefDeviceAddr, maxGradNormOptionalRefDtype, maxGradNormOptionalRefFormat, &maxGradNormOptionalRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else {
std::vector<float> maxGradNormOptionalRef_host(maxGradNormOptionalRef_sz, 1);
ret = CreateAclTensor_New(maxGradNormOptionalRef_host, maxGradNormOptionalRefShape, &maxGradNormOptionalRefDeviceAddr, maxGradNormOptionalRefDtype, maxGradNormOptionalRefFormat, &maxGradNormOptionalRef);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
}
}
} else {
maxGradNormOptionalRef = nullptr;
}
if (!nullGrad) {
long long grad_sz = GetShapeSize(gradShape);
if (grad_sz > 0 && grad_sz <= 1073741824) {
if (gradDtype == ACL_FLOAT) {
std::vector<float> grad_host(grad_sz, 1);
ret = CreateAclTensor_New(grad_host, gradShape, &gradDeviceAddr, gradDtype, gradFormat, &grad);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (gradDtype == ACL_FLOAT16) {
std::vector<int16_t> grad_host(grad_sz, 1);
ret = CreateAclTensor_New(grad_host, gradShape, &gradDeviceAddr, gradDtype, gradFormat, &grad);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (gradDtype == ACL_INT8) {
std::vector<int8_t> grad_host(grad_sz, 1);
ret = CreateAclTensor_New(grad_host, gradShape, &gradDeviceAddr, gradDtype, gradFormat, &grad);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (gradDtype == ACL_INT32) {
std::vector<int32_t> grad_host(grad_sz, 1);
ret = CreateAclTensor_New(grad_host, gradShape, &gradDeviceAddr, gradDtype, gradFormat, &grad);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (gradDtype == ACL_UINT8) {
std::vector<uint8_t> grad_host(grad_sz, 1);
ret = CreateAclTensor_New(grad_host, gradShape, &gradDeviceAddr, gradDtype, gradFormat, &grad);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (gradDtype == ACL_INT16) {
std::vector<int16_t> grad_host(grad_sz, 1);
ret = CreateAclTensor_New(grad_host, gradShape, &gradDeviceAddr, gradDtype, gradFormat, &grad);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (gradDtype == ACL_UINT16) {
std::vector<uint16_t> grad_host(grad_sz, 1);
ret = CreateAclTensor_New(grad_host, gradShape, &gradDeviceAddr, gradDtype, gradFormat, &grad);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (gradDtype == ACL_UINT32) {
std::vector<uint32_t> grad_host(grad_sz, 1);
ret = CreateAclTensor_New(grad_host, gradShape, &gradDeviceAddr, gradDtype, gradFormat, &grad);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (gradDtype == ACL_INT64) {
std::vector<int64_t> grad_host(grad_sz, 1);
ret = CreateAclTensor_New(grad_host, gradShape, &gradDeviceAddr, gradDtype, gradFormat, &grad);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (gradDtype == ACL_UINT64) {
std::vector<uint64_t> grad_host(grad_sz, 1);
ret = CreateAclTensor_New(grad_host, gradShape, &gradDeviceAddr, gradDtype, gradFormat, &grad);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (gradDtype == ACL_DOUBLE) {
std::vector<double> grad_host(grad_sz, 1);
ret = CreateAclTensor_New(grad_host, gradShape, &gradDeviceAddr, gradDtype, gradFormat, &grad);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (gradDtype == ACL_BOOL) {
std::vector<int8_t> grad_host(grad_sz, 1);
ret = CreateAclTensor_New(grad_host, gradShape, &gradDeviceAddr, gradDtype, gradFormat, &grad);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (gradDtype == ACL_BF16) {
std::vector<int16_t> grad_host(grad_sz, 1);
ret = CreateAclTensor_New(grad_host, gradShape, &gradDeviceAddr, gradDtype, gradFormat, &grad);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (gradDtype == ACL_COMPLEX64) {
std::vector<float> grad_host((grad_sz * 2), 1);
ret = CreateAclTensor_New(grad_host, gradShape, &gradDeviceAddr, gradDtype, gradFormat, &grad);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (gradDtype == ACL_COMPLEX128) {
std::vector<double> grad_host((grad_sz * 2), 1);
ret = CreateAclTensor_New(grad_host, gradShape, &gradDeviceAddr, gradDtype, gradFormat, &grad);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else {
std::vector<float> grad_host(grad_sz, 1);
ret = CreateAclTensor_New(grad_host, gradShape, &gradDeviceAddr, gradDtype, gradFormat, &grad);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
}
}
} else {
grad = nullptr;
}
if (!nullStep) {
long long step_sz = GetShapeSize(stepShape);
if (step_sz > 0 && step_sz <= 1073741824) {
if (stepDtype == ACL_FLOAT) {
std::vector<float> step_host(step_sz, 1);
ret = CreateAclTensor_New(step_host, stepShape, &stepDeviceAddr, stepDtype, stepFormat, &step);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (stepDtype == ACL_FLOAT16) {
std::vector<int16_t> step_host(step_sz, 1);
ret = CreateAclTensor_New(step_host, stepShape, &stepDeviceAddr, stepDtype, stepFormat, &step);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (stepDtype == ACL_INT8) {
std::vector<int8_t> step_host(step_sz, 1);
ret = CreateAclTensor_New(step_host, stepShape, &stepDeviceAddr, stepDtype, stepFormat, &step);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (stepDtype == ACL_INT32) {
std::vector<int32_t> step_host(step_sz, 1);
ret = CreateAclTensor_New(step_host, stepShape, &stepDeviceAddr, stepDtype, stepFormat, &step);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (stepDtype == ACL_UINT8) {
std::vector<uint8_t> step_host(step_sz, 1);
ret = CreateAclTensor_New(step_host, stepShape, &stepDeviceAddr, stepDtype, stepFormat, &step);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (stepDtype == ACL_INT16) {
std::vector<int16_t> step_host(step_sz, 1);
ret = CreateAclTensor_New(step_host, stepShape, &stepDeviceAddr, stepDtype, stepFormat, &step);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (stepDtype == ACL_UINT16) {
std::vector<uint16_t> step_host(step_sz, 1);
ret = CreateAclTensor_New(step_host, stepShape, &stepDeviceAddr, stepDtype, stepFormat, &step);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (stepDtype == ACL_UINT32) {
std::vector<uint32_t> step_host(step_sz, 1);
ret = CreateAclTensor_New(step_host, stepShape, &stepDeviceAddr, stepDtype, stepFormat, &step);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (stepDtype == ACL_INT64) {
std::vector<int64_t> step_host(step_sz, 1);
ret = CreateAclTensor_New(step_host, stepShape, &stepDeviceAddr, stepDtype, stepFormat, &step);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (stepDtype == ACL_UINT64) {
std::vector<uint64_t> step_host(step_sz, 1);
ret = CreateAclTensor_New(step_host, stepShape, &stepDeviceAddr, stepDtype, stepFormat, &step);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (stepDtype == ACL_DOUBLE) {
std::vector<double> step_host(step_sz, 1);
ret = CreateAclTensor_New(step_host, stepShape, &stepDeviceAddr, stepDtype, stepFormat, &step);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (stepDtype == ACL_BOOL) {
std::vector<int8_t> step_host(step_sz, 1);
ret = CreateAclTensor_New(step_host, stepShape, &stepDeviceAddr, stepDtype, stepFormat, &step);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (stepDtype == ACL_BF16) {
std::vector<int16_t> step_host(step_sz, 1);
ret = CreateAclTensor_New(step_host, stepShape, &stepDeviceAddr, stepDtype, stepFormat, &step);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (stepDtype == ACL_COMPLEX64) {
std::vector<float> step_host((step_sz * 2), 1);
ret = CreateAclTensor_New(step_host, stepShape, &stepDeviceAddr, stepDtype, stepFormat, &step);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (stepDtype == ACL_COMPLEX128) {
std::vector<double> step_host((step_sz * 2), 1);
ret = CreateAclTensor_New(step_host, stepShape, &stepDeviceAddr, stepDtype, stepFormat, &step);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else {
std::vector<float> step_host(step_sz, 1);
ret = CreateAclTensor_New(step_host, stepShape, &stepDeviceAddr, stepDtype, stepFormat, &step);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
}
}
} else {
step = nullptr;
}
printf("[FUZZ_LOG] plog_file: aclnnApplyAdamWV2_error_plog_case_%d.log\n", scenario);
printf("[FUZZ_PARAM] varRef=%s, varRefShape=%s, mRef=%s, mRefShape=%s, vRef=%s, vRefShape=%s, maxGradNormOptionalRef=%s, maxGradNormOptionalRefShape=%s, grad=%s, gradShape=%s, step=%s, stepShape=%s, lr=%f, beta1=%f, beta2=%f, weightDecay=%f, eps=%f, amsgrad=%d, maximize=%d, varRefFmt=%s, mRefFmt=%s, vRefFmt=%s, maxGradNormOptionalRefFmt=%s, gradFmt=%s, stepFmt=%s\n", GetDtypeName(varRefDtype), ShapeToStr(varRefShape).c_str(), GetDtypeName(mRefDtype), ShapeToStr(mRefShape).c_str(), GetDtypeName(vRefDtype), ShapeToStr(vRefShape).c_str(), GetDtypeName(maxGradNormOptionalRefDtype), ShapeToStr(maxGradNormOptionalRefShape).c_str(), GetDtypeName(gradDtype), ShapeToStr(gradShape).c_str(), GetDtypeName(stepDtype), ShapeToStr(stepShape).c_str(), (double)lr, (double)beta1, (double)beta2, (double)weightDecay, (double)eps, (int)amsgrad, (int)maximize, FormatName(varRefFormat), FormatName(mRefFormat), FormatName(vRefFormat), FormatName(maxGradNormOptionalRefFormat), FormatName(gradFormat), FormatName(stepFormat));
printf("[FUZZ_ERROR_POINT] case_%d: errorType=%s, errorTarget=%s, description=%s\n", scenario, errorTypeStr.c_str(), errorTargetStr.c_str(), scenarioDesc.c_str());
ret = aclnnApplyAdamWV2GetWorkspaceSize(varRef, mRef, vRef, maxGradNormOptionalRef, grad, step, lr, beta1, beta2, weightDecay, eps, amsgrad, maximize, &workspaceSize, &executor);
caseRet = (int)ret;
LOG_PRINT("aclnnApplyAdamWV2GetWorkspaceSize ret=%d, scenario=%d\n", ret, scenario);
const char* rawErrMsg = aclGetRecentErrMsg();
savedErrMsg = (rawErrMsg && rawErrMsg[0] != '\0') ? std::string(rawErrMsg) : "";
LOG_PRINT("aclGetRecentErrMsg: %s\n", savedErrMsg.c_str());
printf("[FUZZ_VERIFY] case_%d: expected_code=%d, actual_code=%d, expected_name=%s, match=%s\n",
scenario, expectedErrorCode, caseRet, expectedErrorName.c_str(),
(caseRet == expectedErrorCode || (expectedErrorCode == 161001 && caseRet == 161002) || (expectedErrorCode == 161002 && caseRet == 161001)) ? "YES" : "NO");
printf("[FUZZ_VERIFY] verify_requirement: %s\n", verifyRequirement.c_str());
if (ret == 0) {
if (workspaceSize > 8589934592ULL) {
LOG_PRINT("workspaceSize %llu exceeds 8G cap, skip phase-2 execution\n", (unsigned long long)workspaceSize);
} else {
if (workspaceSize > 0) {
ret = aclrtMalloc(&workspaceAddr, workspaceSize, ACL_MEM_MALLOC_HUGE_FIRST);
if (ret != ACL_SUCCESS) { caseRet = (int)ret; LOG_PRINT("aclrtMalloc failed. ERROR: %d\n", ret); goto ERROR; }
}
ret = aclnnApplyAdamWV2(workspaceAddr, workspaceSize, executor, stream);
if (ret != ACL_SUCCESS) { caseRet = (int)ret; LOG_PRINT("aclnnApplyAdamWV2 execute failed : %d\n", ret); goto ERROR; }
caseRet = (int)ret;
LOG_PRINT("aclnnApplyAdamWV2 execute success : %d\n", ret);
ret = aclrtSynchronizeStream(stream);
if (ret != ACL_SUCCESS) { caseRet = (int)ret; LOG_PRINT("aclrtSynchronizeStream failed. ERROR: %d\n", ret); goto ERROR; }
}
}
}
catch (std::exception& e)
{
printf("catch exception %s\n", e.what());
}
ERROR:
ret = aclrtSynchronizeStream(stream);
printf("end \n");
CheckAndLog(ret);
fflush(stdout);
RestoreStdout();
{
std::string fromPath = "./opfuzz/scenario_logs/scenario_" + std::to_string(fuzzi) + ".log";
std::string toPath = "./opfuzz/scenario_logs/scenario_" + std::to_string(scenario) + ".log";
rename(fromPath.c_str(), toPath.c_str());
}
std::string aclErrMsg = savedErrMsg.empty() ? "(no aclnn error msg)" : savedErrMsg;
std::string errType;
if (caseRet == -1) errType = "SETUP_ERROR";
else if (expectedErrorCode == 0) errType = (caseRet == 0) ? "BASE_CHECK_OK" : "BASE_INVALID";
else if (caseRet == 0) errType = "UNEXPECTED_SUCCESS";
else if (caseRet == 161001 || caseRet == 161002) errType = "PARAM_ERROR";
else if (caseRet > 561001 && caseRet < 561119) errType = "INNER_ERROR";
else if (caseRet > 507000 && caseRet < 507901) errType = "RUNTIME_ERROR";
else errType = "OTHER_ERROR";
bool hasHint = (aclErrMsg.find("should") != std::string::npos ||
aclErrMsg.find("must") != std::string::npos ||
aclErrMsg.find("expected") != std::string::npos ||
aclErrMsg.find("supported") != std::string::npos ||
aclErrMsg.find("range") != std::string::npos ||
aclErrMsg.find("invalid") != std::string::npos ||
aclErrMsg.find("mismatch") != std::string::npos);
std::string ezVerdict = hasHint ? "PASS" : "FAIL";
printf("== Scenario %3d | ret=%-8d | %-16s | EZ:%-4s | %s ==\n", scenario, caseRet, errType.c_str(), ezVerdict.c_str(), scenarioDesc.c_str());
printf(" aclnn error msg: %s\n", aclErrMsg.c_str());
ScenarioResult sr;
sr.scenarioId = scenario;
sr.retCode = caseRet;
sr.desc = scenarioDesc;
sr.violation = violationDetail;
sr.category = errorCategory;
sr.errorType = errType;
sr.aclErrMsg = aclErrMsg;
g_allResults.push_back(sr);
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 (varRef != nullptr) { aclDestroyTensor(varRef); varRef = nullptr; }
if (mRef != nullptr) { aclDestroyTensor(mRef); mRef = nullptr; }
if (vRef != nullptr) { aclDestroyTensor(vRef); vRef = nullptr; }
if (maxGradNormOptionalRef != nullptr) { aclDestroyTensor(maxGradNormOptionalRef); maxGradNormOptionalRef = nullptr; }
if (grad != nullptr) { aclDestroyTensor(grad); grad = nullptr; }
if (step != nullptr) { aclDestroyTensor(step); step = nullptr; }
if (varRefDeviceAddr != nullptr) { aclrtFree(varRefDeviceAddr); varRefDeviceAddr = nullptr; }
if (mRefDeviceAddr != nullptr) { aclrtFree(mRefDeviceAddr); mRefDeviceAddr = nullptr; }
if (vRefDeviceAddr != nullptr) { aclrtFree(vRefDeviceAddr); vRefDeviceAddr = nullptr; }
if (maxGradNormOptionalRefDeviceAddr != nullptr) { aclrtFree(maxGradNormOptionalRefDeviceAddr); maxGradNormOptionalRefDeviceAddr = nullptr; }
if (gradDeviceAddr != nullptr) { aclrtFree(gradDeviceAddr); gradDeviceAddr = nullptr; }
if (stepDeviceAddr != nullptr) { aclrtFree(stepDeviceAddr); stepDeviceAddr = nullptr; }
if (workspaceSize > 0) { aclrtFree(workspaceAddr); }
}
DT_FUZZ_END()
GenerateFinalSummary();
WriteDTLog("aclnnApplyAdamWV2", "aclnnApplyAdamWV2 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("aclnnApplyAdamWV2", "aclnnApplyAdamWV2 op fuzz end\n");
aclrtDestroyStream(stream);
aclrtDestroyContext(context);
aclrtResetDevice(deviceId);
aclFinalize();
return 0;
}
extern "C" int aclnnApplyAdamWV2_error_fuzz(int argc, char *argv[]);
int aclnnApplyAdamWV2_error_fuzz(int argc, char *argv[])
{
int fuzz_num = MAXFUZZNUMBER;
if (argc < 2) {
cout << "[ERROR] input arg num must be bigger than 1 " << endl;
return -1;
} else if (argc > 2 && argv[2] != nullptr) {
fuzz_num = atoi(argv[2]);
}
if (argc == 4) { deviceId = atoi(argv[3]); }
printf("fuzz_num %d \n", fuzz_num);
printf("aclnnApplyAdamWV2_Normal :%d \n", aclnnApplyAdamWV2_Normal(fuzz_num));
return 0;
}