#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_advance_step.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 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: aclnnAdvanceStep" << 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("aclnnAdvanceStep", "FINAL: total=%d detected=%d param=%d inner=%d runtime=%d unexpected=%d rate=%d%%\n",
total, detected, paramErr, innerErr, runtimeErr, unexpectedOk, rate);
}
int aclnnAdvanceStep_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("aclnnAdvanceStep", "aclnnAdvanceStep error scenario test start\n");
aclrtSetOpExecuteTimeOut(1091);
DT_Set_TimeOut_Second(3000);
DT_FUZZ_START(0, fuzz_num, "aclnnAdvanceStep", 0)
{
int i = 0;
void* inputTokensDeviceAddr = nullptr;
aclTensor* inputTokens = nullptr;
void* sampledTokenIdsDeviceAddr = nullptr;
aclTensor* sampledTokenIds = nullptr;
void* inputPositionsDeviceAddr = nullptr;
aclTensor* inputPositions = nullptr;
void* seqLensDeviceAddr = nullptr;
aclTensor* seqLens = nullptr;
void* slotMappingDeviceAddr = nullptr;
aclTensor* slotMapping = nullptr;
void* blockTablesDeviceAddr = nullptr;
aclTensor* blockTables = nullptr;
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("aclnnAdvanceStep error test %d\n", fuzzi);
RedirectStdoutToScenarioFile(fuzzi);
try
{
scenario = *(int *)DTSetGetNumberRange(&g_Element[i++], 0, 0, 42, "i");
std::vector<int64_t> inputTokensShape = {2};
std::vector<int64_t> sampledTokenIdsShape = {1, 1};
std::vector<int64_t> inputPositionsShape = {2};
std::vector<int64_t> seqLensShape = {2};
std::vector<int64_t> slotMappingShape = {2};
std::vector<int64_t> blockTablesShape = {2, 4};
aclDataType inputTokensDtype = ACL_INT64;
aclDataType sampledTokenIdsDtype = ACL_INT64;
aclDataType inputPositionsDtype = ACL_INT64;
aclDataType seqLensDtype = ACL_INT64;
aclDataType slotMappingDtype = ACL_INT64;
aclDataType blockTablesDtype = ACL_INT64;
aclFormat tensorFormat = ACL_FORMAT_ND;
bool nullInputTokens = false, nullSampledTokenIds = false, nullInputPositions = false, nullSeqLens = false, nullSlotMapping = false, nullBlockTables = 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 = "inputTokens dtype=ACL_INT8 not in supported list [INT64]";
violationDetail = "inputTokens=ACL_INT8";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "inputTokens";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT8不支持或invalid dtype相关提示";
inputTokensDtype = ACL_INT8;
LOG_PRINT("[A1_inputTokens_ACL_INT8] inputTokens dtype=ACL_INT8 not in supported list [INT64]\n");
}
else if (scenario == 2) {
scenarioDesc = "inputTokens dtype=ACL_INT32 not in supported list [INT64]";
violationDetail = "inputTokens=ACL_INT32";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "inputTokens";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT32不支持或invalid dtype相关提示";
inputTokensDtype = ACL_INT32;
LOG_PRINT("[A1_inputTokens_ACL_INT32] inputTokens dtype=ACL_INT32 not in supported list [INT64]\n");
}
else if (scenario == 3) {
scenarioDesc = "inputTokens must be ACL_INT64, set to ACL_FLOAT16";
violationDetail = "inputTokens=ACL_FLOAT16";
errorCategory = "A3";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "inputTokens";
verifyRequirement = "返回码应为161001或161002,错误信息应提示ACL_FLOAT16不支持";
inputTokensDtype = ACL_FLOAT16;
LOG_PRINT("[A3_inputTokens_ACL_FLOAT16] inputTokens must be ACL_INT64, set to ACL_FLOAT16\n");
}
else if (scenario == 4) {
scenarioDesc = "inputTokens dim=2D exceeds max=1D";
violationDetail = "inputTokens dim=2D exceeds max=1D";
errorCategory = "B1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DIM_ILLEGAL";
errorTargetStr = "inputTokens";
verifyRequirement = "返回码应为161001或161002,错误信息应提示维度数超限";
inputTokensShape = {1, 1};
LOG_PRINT("[B1_inputTokens_dim_above_1] inputTokens dim=2D exceeds max=1D\n");
}
else if (scenario == 5) {
scenarioDesc = "inputTokens format=ACL_FORMAT_NCHW (only ND supported)";
violationDetail = "inputTokens format=ACL_FORMAT_NCHW (only ND supported)";
errorCategory = "C1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "FORMAT_UNSUPPORTED";
errorTargetStr = "inputTokens";
verifyRequirement = "返回码应为161001或161002,错误信息应提示format不支持";
tensorFormat = ACL_FORMAT_NCHW;
LOG_PRINT("[C1_inputTokens_NCHW] inputTokens format=ACL_FORMAT_NCHW (only ND supported)\n");
}
else if (scenario == 6) {
scenarioDesc = "inputTokens tensor is nullptr (input pointer is null)";
violationDetail = "inputTokens tensor is nullptr (input pointer is null)";
errorCategory = "D3";
expectedErrorCode = 161001;
expectedErrorName = "ACLNN_ERR_PARAM_NULLPTR";
errorTypeStr = "NULLPTR_INPUT";
errorTargetStr = "inputTokens";
verifyRequirement = "返回码应为161001,错误信息应包含null或nullptr相关提示";
nullInputTokens = true;
LOG_PRINT("[D3_inputTokens_nullptr] inputTokens tensor is nullptr (input pointer is null)\n");
}
else if (scenario == 7) {
scenarioDesc = "sampledTokenIds dtype=ACL_INT8 not in supported list [INT64]";
violationDetail = "sampledTokenIds=ACL_INT8";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "sampledTokenIds";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT8不支持或invalid dtype相关提示";
sampledTokenIdsDtype = ACL_INT8;
LOG_PRINT("[A1_sampledTokenIds_ACL_INT8] sampledTokenIds dtype=ACL_INT8 not in supported list [INT64]\n");
}
else if (scenario == 8) {
scenarioDesc = "sampledTokenIds dtype=ACL_INT32 not in supported list [INT64]";
violationDetail = "sampledTokenIds=ACL_INT32";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "sampledTokenIds";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT32不支持或invalid dtype相关提示";
sampledTokenIdsDtype = ACL_INT32;
LOG_PRINT("[A1_sampledTokenIds_ACL_INT32] sampledTokenIds dtype=ACL_INT32 not in supported list [INT64]\n");
}
else if (scenario == 9) {
scenarioDesc = "sampledTokenIds must be ACL_INT64, set to ACL_FLOAT16";
violationDetail = "sampledTokenIds=ACL_FLOAT16";
errorCategory = "A3";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "sampledTokenIds";
verifyRequirement = "返回码应为161001或161002,错误信息应提示ACL_FLOAT16不支持";
sampledTokenIdsDtype = ACL_FLOAT16;
LOG_PRINT("[A3_sampledTokenIds_ACL_FLOAT16] sampledTokenIds must be ACL_INT64, set to ACL_FLOAT16\n");
}
else if (scenario == 10) {
scenarioDesc = "sampledTokenIds dim=3D exceeds max=2D";
violationDetail = "sampledTokenIds dim=3D exceeds max=2D";
errorCategory = "B1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DIM_ILLEGAL";
errorTargetStr = "sampledTokenIds";
verifyRequirement = "返回码应为161001或161002,错误信息应提示维度数超限";
sampledTokenIdsShape = {1, 1, 1};
LOG_PRINT("[B1_sampledTokenIds_dim_above_2] sampledTokenIds dim=3D exceeds max=2D\n");
}
else if (scenario == 11) {
scenarioDesc = "sampledTokenIds dim=1D below min=2D";
violationDetail = "sampledTokenIds dim=1D below min=2D";
errorCategory = "B1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DIM_ILLEGAL";
errorTargetStr = "sampledTokenIds";
verifyRequirement = "返回码应为161001或161002,错误信息应提示维度数不足";
sampledTokenIdsShape = {1};
LOG_PRINT("[B1_sampledTokenIds_dim_below_2] sampledTokenIds dim=1D below min=2D\n");
}
else if (scenario == 12) {
scenarioDesc = "sampledTokenIds shape has zero dimension: [0, 4]";
violationDetail = "sampledTokenIds shape has zero dimension: [0, 4]";
errorCategory = "B4";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "SHAPE_ILLEGAL";
errorTargetStr = "sampledTokenIds";
verifyRequirement = "空tensor可能合法也可能非法,需根据md文档确认;若非法应返回161001或161002";
sampledTokenIdsShape = {0, 4};
LOG_PRINT("[B4_sampledTokenIds_zero_dim] sampledTokenIds shape has zero dimension: [0, 4]\n");
}
else if (scenario == 13) {
scenarioDesc = "sampledTokenIds format=ACL_FORMAT_NCHW (only ND supported)";
violationDetail = "sampledTokenIds format=ACL_FORMAT_NCHW (only ND supported)";
errorCategory = "C1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "FORMAT_UNSUPPORTED";
errorTargetStr = "sampledTokenIds";
verifyRequirement = "返回码应为161001或161002,错误信息应提示format不支持";
tensorFormat = ACL_FORMAT_NCHW;
LOG_PRINT("[C1_sampledTokenIds_NCHW] sampledTokenIds format=ACL_FORMAT_NCHW (only ND supported)\n");
}
else if (scenario == 14) {
scenarioDesc = "sampledTokenIds tensor is nullptr (input pointer is null)";
violationDetail = "sampledTokenIds tensor is nullptr (input pointer is null)";
errorCategory = "D3";
expectedErrorCode = 161001;
expectedErrorName = "ACLNN_ERR_PARAM_NULLPTR";
errorTypeStr = "NULLPTR_INPUT";
errorTargetStr = "sampledTokenIds";
verifyRequirement = "返回码应为161001,错误信息应包含null或nullptr相关提示";
nullSampledTokenIds = true;
LOG_PRINT("[D3_sampledTokenIds_nullptr] sampledTokenIds tensor is nullptr (input pointer is null)\n");
}
else if (scenario == 15) {
scenarioDesc = "inputPositions dtype=ACL_INT8 not in supported list [INT64]";
violationDetail = "inputPositions=ACL_INT8";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "inputPositions";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT8不支持或invalid dtype相关提示";
inputPositionsDtype = ACL_INT8;
LOG_PRINT("[A1_inputPositions_ACL_INT8] inputPositions dtype=ACL_INT8 not in supported list [INT64]\n");
}
else if (scenario == 16) {
scenarioDesc = "inputPositions dtype=ACL_INT32 not in supported list [INT64]";
violationDetail = "inputPositions=ACL_INT32";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "inputPositions";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT32不支持或invalid dtype相关提示";
inputPositionsDtype = ACL_INT32;
LOG_PRINT("[A1_inputPositions_ACL_INT32] inputPositions dtype=ACL_INT32 not in supported list [INT64]\n");
}
else if (scenario == 17) {
scenarioDesc = "inputPositions must be ACL_INT64, set to ACL_FLOAT16";
violationDetail = "inputPositions=ACL_FLOAT16";
errorCategory = "A3";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "inputPositions";
verifyRequirement = "返回码应为161001或161002,错误信息应提示ACL_FLOAT16不支持";
inputPositionsDtype = ACL_FLOAT16;
LOG_PRINT("[A3_inputPositions_ACL_FLOAT16] inputPositions must be ACL_INT64, set to ACL_FLOAT16\n");
}
else if (scenario == 18) {
scenarioDesc = "inputPositions dim=2D exceeds max=1D";
violationDetail = "inputPositions dim=2D exceeds max=1D";
errorCategory = "B1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DIM_ILLEGAL";
errorTargetStr = "inputPositions";
verifyRequirement = "返回码应为161001或161002,错误信息应提示维度数超限";
inputPositionsShape = {1, 1};
LOG_PRINT("[B1_inputPositions_dim_above_1] inputPositions dim=2D exceeds max=1D\n");
}
else if (scenario == 19) {
scenarioDesc = "inputPositions format=ACL_FORMAT_NCHW (only ND supported)";
violationDetail = "inputPositions format=ACL_FORMAT_NCHW (only ND supported)";
errorCategory = "C1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "FORMAT_UNSUPPORTED";
errorTargetStr = "inputPositions";
verifyRequirement = "返回码应为161001或161002,错误信息应提示format不支持";
tensorFormat = ACL_FORMAT_NCHW;
LOG_PRINT("[C1_inputPositions_NCHW] inputPositions format=ACL_FORMAT_NCHW (only ND supported)\n");
}
else if (scenario == 20) {
scenarioDesc = "inputPositions tensor is nullptr (input pointer is null)";
violationDetail = "inputPositions tensor is nullptr (input pointer is null)";
errorCategory = "D3";
expectedErrorCode = 161001;
expectedErrorName = "ACLNN_ERR_PARAM_NULLPTR";
errorTypeStr = "NULLPTR_INPUT";
errorTargetStr = "inputPositions";
verifyRequirement = "返回码应为161001,错误信息应包含null或nullptr相关提示";
nullInputPositions = true;
LOG_PRINT("[D3_inputPositions_nullptr] inputPositions tensor is nullptr (input pointer is null)\n");
}
else if (scenario == 21) {
scenarioDesc = "seqLens dtype=ACL_INT8 not in supported list [INT64]";
violationDetail = "seqLens=ACL_INT8";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "seqLens";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT8不支持或invalid dtype相关提示";
seqLensDtype = ACL_INT8;
LOG_PRINT("[A1_seqLens_ACL_INT8] seqLens dtype=ACL_INT8 not in supported list [INT64]\n");
}
else if (scenario == 22) {
scenarioDesc = "seqLens dtype=ACL_INT32 not in supported list [INT64]";
violationDetail = "seqLens=ACL_INT32";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "seqLens";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT32不支持或invalid dtype相关提示";
seqLensDtype = ACL_INT32;
LOG_PRINT("[A1_seqLens_ACL_INT32] seqLens dtype=ACL_INT32 not in supported list [INT64]\n");
}
else if (scenario == 23) {
scenarioDesc = "seqLens must be ACL_INT64, set to ACL_FLOAT16";
violationDetail = "seqLens=ACL_FLOAT16";
errorCategory = "A3";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "seqLens";
verifyRequirement = "返回码应为161001或161002,错误信息应提示ACL_FLOAT16不支持";
seqLensDtype = ACL_FLOAT16;
LOG_PRINT("[A3_seqLens_ACL_FLOAT16] seqLens must be ACL_INT64, set to ACL_FLOAT16\n");
}
else if (scenario == 24) {
scenarioDesc = "seqLens dim=2D exceeds max=1D";
violationDetail = "seqLens dim=2D exceeds max=1D";
errorCategory = "B1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DIM_ILLEGAL";
errorTargetStr = "seqLens";
verifyRequirement = "返回码应为161001或161002,错误信息应提示维度数超限";
seqLensShape = {1, 1};
LOG_PRINT("[B1_seqLens_dim_above_1] seqLens dim=2D exceeds max=1D\n");
}
else if (scenario == 25) {
scenarioDesc = "seqLens format=ACL_FORMAT_NCHW (only ND supported)";
violationDetail = "seqLens format=ACL_FORMAT_NCHW (only ND supported)";
errorCategory = "C1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "FORMAT_UNSUPPORTED";
errorTargetStr = "seqLens";
verifyRequirement = "返回码应为161001或161002,错误信息应提示format不支持";
tensorFormat = ACL_FORMAT_NCHW;
LOG_PRINT("[C1_seqLens_NCHW] seqLens format=ACL_FORMAT_NCHW (only ND supported)\n");
}
else if (scenario == 26) {
scenarioDesc = "seqLens tensor is nullptr (input pointer is null)";
violationDetail = "seqLens tensor is nullptr (input pointer is null)";
errorCategory = "D3";
expectedErrorCode = 161001;
expectedErrorName = "ACLNN_ERR_PARAM_NULLPTR";
errorTypeStr = "NULLPTR_INPUT";
errorTargetStr = "seqLens";
verifyRequirement = "返回码应为161001,错误信息应包含null或nullptr相关提示";
nullSeqLens = true;
LOG_PRINT("[D3_seqLens_nullptr] seqLens tensor is nullptr (input pointer is null)\n");
}
else if (scenario == 27) {
scenarioDesc = "slotMapping dtype=ACL_INT8 not in supported list [INT64]";
violationDetail = "slotMapping=ACL_INT8";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "slotMapping";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT8不支持或invalid dtype相关提示";
slotMappingDtype = ACL_INT8;
LOG_PRINT("[A1_slotMapping_ACL_INT8] slotMapping dtype=ACL_INT8 not in supported list [INT64]\n");
}
else if (scenario == 28) {
scenarioDesc = "slotMapping dtype=ACL_INT32 not in supported list [INT64]";
violationDetail = "slotMapping=ACL_INT32";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "slotMapping";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT32不支持或invalid dtype相关提示";
slotMappingDtype = ACL_INT32;
LOG_PRINT("[A1_slotMapping_ACL_INT32] slotMapping dtype=ACL_INT32 not in supported list [INT64]\n");
}
else if (scenario == 29) {
scenarioDesc = "slotMapping must be ACL_INT64, set to ACL_FLOAT16";
violationDetail = "slotMapping=ACL_FLOAT16";
errorCategory = "A3";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "slotMapping";
verifyRequirement = "返回码应为161001或161002,错误信息应提示ACL_FLOAT16不支持";
slotMappingDtype = ACL_FLOAT16;
LOG_PRINT("[A3_slotMapping_ACL_FLOAT16] slotMapping must be ACL_INT64, set to ACL_FLOAT16\n");
}
else if (scenario == 30) {
scenarioDesc = "slotMapping dim=2D exceeds max=1D";
violationDetail = "slotMapping dim=2D exceeds max=1D";
errorCategory = "B1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DIM_ILLEGAL";
errorTargetStr = "slotMapping";
verifyRequirement = "返回码应为161001或161002,错误信息应提示维度数超限";
slotMappingShape = {1, 1};
LOG_PRINT("[B1_slotMapping_dim_above_1] slotMapping dim=2D exceeds max=1D\n");
}
else if (scenario == 31) {
scenarioDesc = "slotMapping format=ACL_FORMAT_NCHW (only ND supported)";
violationDetail = "slotMapping format=ACL_FORMAT_NCHW (only ND supported)";
errorCategory = "C1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "FORMAT_UNSUPPORTED";
errorTargetStr = "slotMapping";
verifyRequirement = "返回码应为161001或161002,错误信息应提示format不支持";
tensorFormat = ACL_FORMAT_NCHW;
LOG_PRINT("[C1_slotMapping_NCHW] slotMapping format=ACL_FORMAT_NCHW (only ND supported)\n");
}
else if (scenario == 32) {
scenarioDesc = "slotMapping tensor is nullptr (input pointer is null)";
violationDetail = "slotMapping tensor is nullptr (input pointer is null)";
errorCategory = "D3";
expectedErrorCode = 161001;
expectedErrorName = "ACLNN_ERR_PARAM_NULLPTR";
errorTypeStr = "NULLPTR_INPUT";
errorTargetStr = "slotMapping";
verifyRequirement = "返回码应为161001,错误信息应包含null或nullptr相关提示";
nullSlotMapping = true;
LOG_PRINT("[D3_slotMapping_nullptr] slotMapping tensor is nullptr (input pointer is null)\n");
}
else if (scenario == 33) {
scenarioDesc = "blockTables dtype=ACL_INT8 not in supported list [INT64]";
violationDetail = "blockTables=ACL_INT8";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "blockTables";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT8不支持或invalid dtype相关提示";
blockTablesDtype = ACL_INT8;
LOG_PRINT("[A1_blockTables_ACL_INT8] blockTables dtype=ACL_INT8 not in supported list [INT64]\n");
}
else if (scenario == 34) {
scenarioDesc = "blockTables dtype=ACL_INT32 not in supported list [INT64]";
violationDetail = "blockTables=ACL_INT32";
errorCategory = "A1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "blockTables";
verifyRequirement = "返回码应为161001或161002,错误信息应包含ACL_INT32不支持或invalid dtype相关提示";
blockTablesDtype = ACL_INT32;
LOG_PRINT("[A1_blockTables_ACL_INT32] blockTables dtype=ACL_INT32 not in supported list [INT64]\n");
}
else if (scenario == 35) {
scenarioDesc = "blockTables must be ACL_INT64, set to ACL_FLOAT16";
violationDetail = "blockTables=ACL_FLOAT16";
errorCategory = "A3";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_UNSUPPORTED";
errorTargetStr = "blockTables";
verifyRequirement = "返回码应为161001或161002,错误信息应提示ACL_FLOAT16不支持";
blockTablesDtype = ACL_FLOAT16;
LOG_PRINT("[A3_blockTables_ACL_FLOAT16] blockTables must be ACL_INT64, set to ACL_FLOAT16\n");
}
else if (scenario == 36) {
scenarioDesc = "blockTables dim=3D exceeds max=2D";
violationDetail = "blockTables dim=3D exceeds max=2D";
errorCategory = "B1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DIM_ILLEGAL";
errorTargetStr = "blockTables";
verifyRequirement = "返回码应为161001或161002,错误信息应提示维度数超限";
blockTablesShape = {1, 1, 1};
LOG_PRINT("[B1_blockTables_dim_above_2] blockTables dim=3D exceeds max=2D\n");
}
else if (scenario == 37) {
scenarioDesc = "blockTables dim=1D below min=2D";
violationDetail = "blockTables dim=1D below min=2D";
errorCategory = "B1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DIM_ILLEGAL";
errorTargetStr = "blockTables";
verifyRequirement = "返回码应为161001或161002,错误信息应提示维度数不足";
blockTablesShape = {1};
LOG_PRINT("[B1_blockTables_dim_below_2] blockTables dim=1D below min=2D\n");
}
else if (scenario == 38) {
scenarioDesc = "blockTables shape has zero dimension: [0, 4]";
violationDetail = "blockTables shape has zero dimension: [0, 4]";
errorCategory = "B4";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "SHAPE_ILLEGAL";
errorTargetStr = "blockTables";
verifyRequirement = "空tensor可能合法也可能非法,需根据md文档确认;若非法应返回161001或161002";
blockTablesShape = {0, 4};
LOG_PRINT("[B4_blockTables_zero_dim] blockTables shape has zero dimension: [0, 4]\n");
}
else if (scenario == 39) {
scenarioDesc = "blockTables format=ACL_FORMAT_NCHW (only ND supported)";
violationDetail = "blockTables format=ACL_FORMAT_NCHW (only ND supported)";
errorCategory = "C1";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "FORMAT_UNSUPPORTED";
errorTargetStr = "blockTables";
verifyRequirement = "返回码应为161001或161002,错误信息应提示format不支持";
tensorFormat = ACL_FORMAT_NCHW;
LOG_PRINT("[C1_blockTables_NCHW] blockTables format=ACL_FORMAT_NCHW (only ND supported)\n");
}
else if (scenario == 40) {
scenarioDesc = "blockTables tensor is nullptr (input pointer is null)";
violationDetail = "blockTables tensor is nullptr (input pointer is null)";
errorCategory = "D3";
expectedErrorCode = 161001;
expectedErrorName = "ACLNN_ERR_PARAM_NULLPTR";
errorTypeStr = "NULLPTR_INPUT";
errorTargetStr = "blockTables";
verifyRequirement = "返回码应为161001,错误信息应包含null或nullptr相关提示";
nullBlockTables = true;
LOG_PRINT("[D3_blockTables_nullptr] blockTables tensor is nullptr (input pointer is null)\n");
}
else if (scenario == 41) {
scenarioDesc = "inputTokens=ACL_INT64 but sampledTokenIds=ACL_INT8 (pair requires same)";
violationDetail = "sampledTokenIds=ACL_INT8";
errorCategory = "A2";
expectedErrorCode = 161002;
expectedErrorName = "ACLNN_ERR_PARAM_INVALID";
errorTypeStr = "DTYPE_MISMATCH";
errorTargetStr = "sampledTokenIds+inputTokens";
verifyRequirement = "返回码应为161001或161002,错误信息应提示dtype不匹配";
sampledTokenIdsDtype = ACL_INT8;
LOG_PRINT("[A2_sampledTokenIds_vs_inputTokens_dtype_mismatch] inputTokens=ACL_INT64 but sampledTokenIds=ACL_INT8 (pair requires same)\n");
}
else if (scenario == 42) {
scenarioDesc = "sampledTokenIds.shape=[5] mismatch with inputTokens.shape=[2]";
violationDetail = "sampledTokenIds.shape=[5] mismatch with inputTokens.shape=[2]";
errorCategory = "B2";
expectedErrorCode = 561002;
expectedErrorName = "ACLNN_ERR_INNER_SHAPE_MISMATCH";
errorTypeStr = "SHAPE_MISMATCH";
errorTargetStr = "sampledTokenIds+inputTokens";
verifyRequirement = "返回码可能为561001或561002,错误信息应提示shape不匹配";
sampledTokenIdsShape = {5};
LOG_PRINT("[B2_sampledTokenIds_vs_inputTokens_mismatch] sampledTokenIds.shape=[5] mismatch with inputTokens.shape=[2]\n");
}
else {
scenarioDesc = "OUT_OF_RANGE";
violationDetail = "scenario index exceeds total";
errorCategory = "SKIP";
LOG_PRINT("Scenario %d out of range (0-42), skipping\n", scenario);
}
if (!nullInputTokens) {
long long inputTokens_sz = GetShapeSize(inputTokensShape);
if (inputTokens_sz > 0 && inputTokens_sz <= 1073741824) {
if (inputTokensDtype == ACL_FLOAT) {
std::vector<float> itH(inputTokens_sz, 1);
ret = CreateAclTensor(itH, inputTokensShape, &inputTokensDeviceAddr, inputTokensDtype, &inputTokens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputTokensDtype == ACL_FLOAT16) {
std::vector<int16_t> itH(inputTokens_sz, 1);
ret = CreateAclTensor(itH, inputTokensShape, &inputTokensDeviceAddr, inputTokensDtype, &inputTokens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputTokensDtype == ACL_INT8) {
std::vector<int8_t> itH(inputTokens_sz, 1);
ret = CreateAclTensor(itH, inputTokensShape, &inputTokensDeviceAddr, inputTokensDtype, &inputTokens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputTokensDtype == ACL_INT32) {
std::vector<int32_t> itH(inputTokens_sz, 1);
ret = CreateAclTensor(itH, inputTokensShape, &inputTokensDeviceAddr, inputTokensDtype, &inputTokens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputTokensDtype == ACL_UINT8) {
std::vector<uint8_t> itH(inputTokens_sz, 1);
ret = CreateAclTensor(itH, inputTokensShape, &inputTokensDeviceAddr, inputTokensDtype, &inputTokens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputTokensDtype == ACL_INT16) {
std::vector<int16_t> itH(inputTokens_sz, 1);
ret = CreateAclTensor(itH, inputTokensShape, &inputTokensDeviceAddr, inputTokensDtype, &inputTokens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputTokensDtype == ACL_UINT16) {
std::vector<uint16_t> itH(inputTokens_sz, 1);
ret = CreateAclTensor(itH, inputTokensShape, &inputTokensDeviceAddr, inputTokensDtype, &inputTokens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputTokensDtype == ACL_UINT32) {
std::vector<uint32_t> itH(inputTokens_sz, 1);
ret = CreateAclTensor(itH, inputTokensShape, &inputTokensDeviceAddr, inputTokensDtype, &inputTokens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputTokensDtype == ACL_INT64) {
std::vector<int64_t> itH(inputTokens_sz, 1);
ret = CreateAclTensor(itH, inputTokensShape, &inputTokensDeviceAddr, inputTokensDtype, &inputTokens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputTokensDtype == ACL_UINT64) {
std::vector<uint64_t> itH(inputTokens_sz, 1);
ret = CreateAclTensor(itH, inputTokensShape, &inputTokensDeviceAddr, inputTokensDtype, &inputTokens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputTokensDtype == ACL_DOUBLE) {
std::vector<double> itH(inputTokens_sz, 1);
ret = CreateAclTensor(itH, inputTokensShape, &inputTokensDeviceAddr, inputTokensDtype, &inputTokens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputTokensDtype == ACL_BOOL) {
std::vector<int8_t> itH(inputTokens_sz, 1);
ret = CreateAclTensor(itH, inputTokensShape, &inputTokensDeviceAddr, inputTokensDtype, &inputTokens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputTokensDtype == ACL_BF16) {
std::vector<int16_t> itH(inputTokens_sz, 1);
ret = CreateAclTensor(itH, inputTokensShape, &inputTokensDeviceAddr, inputTokensDtype, &inputTokens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputTokensDtype == ACL_COMPLEX64) {
std::vector<float> itH(inputTokens_sz, 1);
ret = CreateAclTensor(itH, inputTokensShape, &inputTokensDeviceAddr, inputTokensDtype, &inputTokens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputTokensDtype == ACL_COMPLEX128) {
std::vector<double> itH(inputTokens_sz, 1);
ret = CreateAclTensor(itH, inputTokensShape, &inputTokensDeviceAddr, inputTokensDtype, &inputTokens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else {
std::vector<float> itH(inputTokens_sz, 1);
ret = CreateAclTensor(itH, inputTokensShape, &inputTokensDeviceAddr, inputTokensDtype, &inputTokens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
}
}
} else {
inputTokens = nullptr;
}
if (!nullSampledTokenIds) {
long long sampledTokenIds_sz = GetShapeSize(sampledTokenIdsShape);
if (sampledTokenIds_sz > 0 && sampledTokenIds_sz <= 1073741824) {
if (sampledTokenIdsDtype == ACL_FLOAT) {
std::vector<float> stiH(sampledTokenIds_sz, 1);
ret = CreateAclTensor(stiH, sampledTokenIdsShape, &sampledTokenIdsDeviceAddr, sampledTokenIdsDtype, &sampledTokenIds);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (sampledTokenIdsDtype == ACL_FLOAT16) {
std::vector<int16_t> stiH(sampledTokenIds_sz, 1);
ret = CreateAclTensor(stiH, sampledTokenIdsShape, &sampledTokenIdsDeviceAddr, sampledTokenIdsDtype, &sampledTokenIds);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (sampledTokenIdsDtype == ACL_INT8) {
std::vector<int8_t> stiH(sampledTokenIds_sz, 1);
ret = CreateAclTensor(stiH, sampledTokenIdsShape, &sampledTokenIdsDeviceAddr, sampledTokenIdsDtype, &sampledTokenIds);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (sampledTokenIdsDtype == ACL_INT32) {
std::vector<int32_t> stiH(sampledTokenIds_sz, 1);
ret = CreateAclTensor(stiH, sampledTokenIdsShape, &sampledTokenIdsDeviceAddr, sampledTokenIdsDtype, &sampledTokenIds);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (sampledTokenIdsDtype == ACL_UINT8) {
std::vector<uint8_t> stiH(sampledTokenIds_sz, 1);
ret = CreateAclTensor(stiH, sampledTokenIdsShape, &sampledTokenIdsDeviceAddr, sampledTokenIdsDtype, &sampledTokenIds);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (sampledTokenIdsDtype == ACL_INT16) {
std::vector<int16_t> stiH(sampledTokenIds_sz, 1);
ret = CreateAclTensor(stiH, sampledTokenIdsShape, &sampledTokenIdsDeviceAddr, sampledTokenIdsDtype, &sampledTokenIds);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (sampledTokenIdsDtype == ACL_UINT16) {
std::vector<uint16_t> stiH(sampledTokenIds_sz, 1);
ret = CreateAclTensor(stiH, sampledTokenIdsShape, &sampledTokenIdsDeviceAddr, sampledTokenIdsDtype, &sampledTokenIds);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (sampledTokenIdsDtype == ACL_UINT32) {
std::vector<uint32_t> stiH(sampledTokenIds_sz, 1);
ret = CreateAclTensor(stiH, sampledTokenIdsShape, &sampledTokenIdsDeviceAddr, sampledTokenIdsDtype, &sampledTokenIds);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (sampledTokenIdsDtype == ACL_INT64) {
std::vector<int64_t> stiH(sampledTokenIds_sz, 1);
ret = CreateAclTensor(stiH, sampledTokenIdsShape, &sampledTokenIdsDeviceAddr, sampledTokenIdsDtype, &sampledTokenIds);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (sampledTokenIdsDtype == ACL_UINT64) {
std::vector<uint64_t> stiH(sampledTokenIds_sz, 1);
ret = CreateAclTensor(stiH, sampledTokenIdsShape, &sampledTokenIdsDeviceAddr, sampledTokenIdsDtype, &sampledTokenIds);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (sampledTokenIdsDtype == ACL_DOUBLE) {
std::vector<double> stiH(sampledTokenIds_sz, 1);
ret = CreateAclTensor(stiH, sampledTokenIdsShape, &sampledTokenIdsDeviceAddr, sampledTokenIdsDtype, &sampledTokenIds);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (sampledTokenIdsDtype == ACL_BOOL) {
std::vector<int8_t> stiH(sampledTokenIds_sz, 1);
ret = CreateAclTensor(stiH, sampledTokenIdsShape, &sampledTokenIdsDeviceAddr, sampledTokenIdsDtype, &sampledTokenIds);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (sampledTokenIdsDtype == ACL_BF16) {
std::vector<int16_t> stiH(sampledTokenIds_sz, 1);
ret = CreateAclTensor(stiH, sampledTokenIdsShape, &sampledTokenIdsDeviceAddr, sampledTokenIdsDtype, &sampledTokenIds);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (sampledTokenIdsDtype == ACL_COMPLEX64) {
std::vector<float> stiH(sampledTokenIds_sz, 1);
ret = CreateAclTensor(stiH, sampledTokenIdsShape, &sampledTokenIdsDeviceAddr, sampledTokenIdsDtype, &sampledTokenIds);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (sampledTokenIdsDtype == ACL_COMPLEX128) {
std::vector<double> stiH(sampledTokenIds_sz, 1);
ret = CreateAclTensor(stiH, sampledTokenIdsShape, &sampledTokenIdsDeviceAddr, sampledTokenIdsDtype, &sampledTokenIds);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else {
std::vector<float> stiH(sampledTokenIds_sz, 1);
ret = CreateAclTensor(stiH, sampledTokenIdsShape, &sampledTokenIdsDeviceAddr, sampledTokenIdsDtype, &sampledTokenIds);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
}
}
} else {
sampledTokenIds = nullptr;
}
if (!nullInputPositions) {
long long inputPositions_sz = GetShapeSize(inputPositionsShape);
if (inputPositions_sz > 0 && inputPositions_sz <= 1073741824) {
if (inputPositionsDtype == ACL_FLOAT) {
std::vector<float> ipH(inputPositions_sz, 1);
ret = CreateAclTensor(ipH, inputPositionsShape, &inputPositionsDeviceAddr, inputPositionsDtype, &inputPositions);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputPositionsDtype == ACL_FLOAT16) {
std::vector<int16_t> ipH(inputPositions_sz, 1);
ret = CreateAclTensor(ipH, inputPositionsShape, &inputPositionsDeviceAddr, inputPositionsDtype, &inputPositions);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputPositionsDtype == ACL_INT8) {
std::vector<int8_t> ipH(inputPositions_sz, 1);
ret = CreateAclTensor(ipH, inputPositionsShape, &inputPositionsDeviceAddr, inputPositionsDtype, &inputPositions);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputPositionsDtype == ACL_INT32) {
std::vector<int32_t> ipH(inputPositions_sz, 1);
ret = CreateAclTensor(ipH, inputPositionsShape, &inputPositionsDeviceAddr, inputPositionsDtype, &inputPositions);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputPositionsDtype == ACL_UINT8) {
std::vector<uint8_t> ipH(inputPositions_sz, 1);
ret = CreateAclTensor(ipH, inputPositionsShape, &inputPositionsDeviceAddr, inputPositionsDtype, &inputPositions);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputPositionsDtype == ACL_INT16) {
std::vector<int16_t> ipH(inputPositions_sz, 1);
ret = CreateAclTensor(ipH, inputPositionsShape, &inputPositionsDeviceAddr, inputPositionsDtype, &inputPositions);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputPositionsDtype == ACL_UINT16) {
std::vector<uint16_t> ipH(inputPositions_sz, 1);
ret = CreateAclTensor(ipH, inputPositionsShape, &inputPositionsDeviceAddr, inputPositionsDtype, &inputPositions);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputPositionsDtype == ACL_UINT32) {
std::vector<uint32_t> ipH(inputPositions_sz, 1);
ret = CreateAclTensor(ipH, inputPositionsShape, &inputPositionsDeviceAddr, inputPositionsDtype, &inputPositions);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputPositionsDtype == ACL_INT64) {
std::vector<int64_t> ipH(inputPositions_sz, 1);
ret = CreateAclTensor(ipH, inputPositionsShape, &inputPositionsDeviceAddr, inputPositionsDtype, &inputPositions);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputPositionsDtype == ACL_UINT64) {
std::vector<uint64_t> ipH(inputPositions_sz, 1);
ret = CreateAclTensor(ipH, inputPositionsShape, &inputPositionsDeviceAddr, inputPositionsDtype, &inputPositions);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputPositionsDtype == ACL_DOUBLE) {
std::vector<double> ipH(inputPositions_sz, 1);
ret = CreateAclTensor(ipH, inputPositionsShape, &inputPositionsDeviceAddr, inputPositionsDtype, &inputPositions);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputPositionsDtype == ACL_BOOL) {
std::vector<int8_t> ipH(inputPositions_sz, 1);
ret = CreateAclTensor(ipH, inputPositionsShape, &inputPositionsDeviceAddr, inputPositionsDtype, &inputPositions);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputPositionsDtype == ACL_BF16) {
std::vector<int16_t> ipH(inputPositions_sz, 1);
ret = CreateAclTensor(ipH, inputPositionsShape, &inputPositionsDeviceAddr, inputPositionsDtype, &inputPositions);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputPositionsDtype == ACL_COMPLEX64) {
std::vector<float> ipH(inputPositions_sz, 1);
ret = CreateAclTensor(ipH, inputPositionsShape, &inputPositionsDeviceAddr, inputPositionsDtype, &inputPositions);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (inputPositionsDtype == ACL_COMPLEX128) {
std::vector<double> ipH(inputPositions_sz, 1);
ret = CreateAclTensor(ipH, inputPositionsShape, &inputPositionsDeviceAddr, inputPositionsDtype, &inputPositions);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else {
std::vector<float> ipH(inputPositions_sz, 1);
ret = CreateAclTensor(ipH, inputPositionsShape, &inputPositionsDeviceAddr, inputPositionsDtype, &inputPositions);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
}
}
} else {
inputPositions = nullptr;
}
if (!nullSeqLens) {
long long seqLens_sz = GetShapeSize(seqLensShape);
if (seqLens_sz > 0 && seqLens_sz <= 1073741824) {
if (seqLensDtype == ACL_FLOAT) {
std::vector<float> slH(seqLens_sz, 1);
ret = CreateAclTensor(slH, seqLensShape, &seqLensDeviceAddr, seqLensDtype, &seqLens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (seqLensDtype == ACL_FLOAT16) {
std::vector<int16_t> slH(seqLens_sz, 1);
ret = CreateAclTensor(slH, seqLensShape, &seqLensDeviceAddr, seqLensDtype, &seqLens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (seqLensDtype == ACL_INT8) {
std::vector<int8_t> slH(seqLens_sz, 1);
ret = CreateAclTensor(slH, seqLensShape, &seqLensDeviceAddr, seqLensDtype, &seqLens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (seqLensDtype == ACL_INT32) {
std::vector<int32_t> slH(seqLens_sz, 1);
ret = CreateAclTensor(slH, seqLensShape, &seqLensDeviceAddr, seqLensDtype, &seqLens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (seqLensDtype == ACL_UINT8) {
std::vector<uint8_t> slH(seqLens_sz, 1);
ret = CreateAclTensor(slH, seqLensShape, &seqLensDeviceAddr, seqLensDtype, &seqLens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (seqLensDtype == ACL_INT16) {
std::vector<int16_t> slH(seqLens_sz, 1);
ret = CreateAclTensor(slH, seqLensShape, &seqLensDeviceAddr, seqLensDtype, &seqLens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (seqLensDtype == ACL_UINT16) {
std::vector<uint16_t> slH(seqLens_sz, 1);
ret = CreateAclTensor(slH, seqLensShape, &seqLensDeviceAddr, seqLensDtype, &seqLens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (seqLensDtype == ACL_UINT32) {
std::vector<uint32_t> slH(seqLens_sz, 1);
ret = CreateAclTensor(slH, seqLensShape, &seqLensDeviceAddr, seqLensDtype, &seqLens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (seqLensDtype == ACL_INT64) {
std::vector<int64_t> slH(seqLens_sz, 1);
ret = CreateAclTensor(slH, seqLensShape, &seqLensDeviceAddr, seqLensDtype, &seqLens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (seqLensDtype == ACL_UINT64) {
std::vector<uint64_t> slH(seqLens_sz, 1);
ret = CreateAclTensor(slH, seqLensShape, &seqLensDeviceAddr, seqLensDtype, &seqLens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (seqLensDtype == ACL_DOUBLE) {
std::vector<double> slH(seqLens_sz, 1);
ret = CreateAclTensor(slH, seqLensShape, &seqLensDeviceAddr, seqLensDtype, &seqLens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (seqLensDtype == ACL_BOOL) {
std::vector<int8_t> slH(seqLens_sz, 1);
ret = CreateAclTensor(slH, seqLensShape, &seqLensDeviceAddr, seqLensDtype, &seqLens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (seqLensDtype == ACL_BF16) {
std::vector<int16_t> slH(seqLens_sz, 1);
ret = CreateAclTensor(slH, seqLensShape, &seqLensDeviceAddr, seqLensDtype, &seqLens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (seqLensDtype == ACL_COMPLEX64) {
std::vector<float> slH(seqLens_sz, 1);
ret = CreateAclTensor(slH, seqLensShape, &seqLensDeviceAddr, seqLensDtype, &seqLens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (seqLensDtype == ACL_COMPLEX128) {
std::vector<double> slH(seqLens_sz, 1);
ret = CreateAclTensor(slH, seqLensShape, &seqLensDeviceAddr, seqLensDtype, &seqLens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else {
std::vector<float> slH(seqLens_sz, 1);
ret = CreateAclTensor(slH, seqLensShape, &seqLensDeviceAddr, seqLensDtype, &seqLens);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
}
}
} else {
seqLens = nullptr;
}
if (!nullSlotMapping) {
long long slotMapping_sz = GetShapeSize(slotMappingShape);
if (slotMapping_sz > 0 && slotMapping_sz <= 1073741824) {
if (slotMappingDtype == ACL_FLOAT) {
std::vector<float> smH(slotMapping_sz, 1);
ret = CreateAclTensor(smH, slotMappingShape, &slotMappingDeviceAddr, slotMappingDtype, &slotMapping);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (slotMappingDtype == ACL_FLOAT16) {
std::vector<int16_t> smH(slotMapping_sz, 1);
ret = CreateAclTensor(smH, slotMappingShape, &slotMappingDeviceAddr, slotMappingDtype, &slotMapping);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (slotMappingDtype == ACL_INT8) {
std::vector<int8_t> smH(slotMapping_sz, 1);
ret = CreateAclTensor(smH, slotMappingShape, &slotMappingDeviceAddr, slotMappingDtype, &slotMapping);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (slotMappingDtype == ACL_INT32) {
std::vector<int32_t> smH(slotMapping_sz, 1);
ret = CreateAclTensor(smH, slotMappingShape, &slotMappingDeviceAddr, slotMappingDtype, &slotMapping);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (slotMappingDtype == ACL_UINT8) {
std::vector<uint8_t> smH(slotMapping_sz, 1);
ret = CreateAclTensor(smH, slotMappingShape, &slotMappingDeviceAddr, slotMappingDtype, &slotMapping);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (slotMappingDtype == ACL_INT16) {
std::vector<int16_t> smH(slotMapping_sz, 1);
ret = CreateAclTensor(smH, slotMappingShape, &slotMappingDeviceAddr, slotMappingDtype, &slotMapping);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (slotMappingDtype == ACL_UINT16) {
std::vector<uint16_t> smH(slotMapping_sz, 1);
ret = CreateAclTensor(smH, slotMappingShape, &slotMappingDeviceAddr, slotMappingDtype, &slotMapping);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (slotMappingDtype == ACL_UINT32) {
std::vector<uint32_t> smH(slotMapping_sz, 1);
ret = CreateAclTensor(smH, slotMappingShape, &slotMappingDeviceAddr, slotMappingDtype, &slotMapping);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (slotMappingDtype == ACL_INT64) {
std::vector<int64_t> smH(slotMapping_sz, 1);
ret = CreateAclTensor(smH, slotMappingShape, &slotMappingDeviceAddr, slotMappingDtype, &slotMapping);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (slotMappingDtype == ACL_UINT64) {
std::vector<uint64_t> smH(slotMapping_sz, 1);
ret = CreateAclTensor(smH, slotMappingShape, &slotMappingDeviceAddr, slotMappingDtype, &slotMapping);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (slotMappingDtype == ACL_DOUBLE) {
std::vector<double> smH(slotMapping_sz, 1);
ret = CreateAclTensor(smH, slotMappingShape, &slotMappingDeviceAddr, slotMappingDtype, &slotMapping);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (slotMappingDtype == ACL_BOOL) {
std::vector<int8_t> smH(slotMapping_sz, 1);
ret = CreateAclTensor(smH, slotMappingShape, &slotMappingDeviceAddr, slotMappingDtype, &slotMapping);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (slotMappingDtype == ACL_BF16) {
std::vector<int16_t> smH(slotMapping_sz, 1);
ret = CreateAclTensor(smH, slotMappingShape, &slotMappingDeviceAddr, slotMappingDtype, &slotMapping);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (slotMappingDtype == ACL_COMPLEX64) {
std::vector<float> smH(slotMapping_sz, 1);
ret = CreateAclTensor(smH, slotMappingShape, &slotMappingDeviceAddr, slotMappingDtype, &slotMapping);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (slotMappingDtype == ACL_COMPLEX128) {
std::vector<double> smH(slotMapping_sz, 1);
ret = CreateAclTensor(smH, slotMappingShape, &slotMappingDeviceAddr, slotMappingDtype, &slotMapping);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else {
std::vector<float> smH(slotMapping_sz, 1);
ret = CreateAclTensor(smH, slotMappingShape, &slotMappingDeviceAddr, slotMappingDtype, &slotMapping);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
}
}
} else {
slotMapping = nullptr;
}
if (!nullBlockTables) {
long long blockTables_sz = GetShapeSize(blockTablesShape);
if (blockTables_sz > 0 && blockTables_sz <= 1073741824) {
if (blockTablesDtype == ACL_FLOAT) {
std::vector<float> btH(blockTables_sz, 1);
ret = CreateAclTensor(btH, blockTablesShape, &blockTablesDeviceAddr, blockTablesDtype, &blockTables);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (blockTablesDtype == ACL_FLOAT16) {
std::vector<int16_t> btH(blockTables_sz, 1);
ret = CreateAclTensor(btH, blockTablesShape, &blockTablesDeviceAddr, blockTablesDtype, &blockTables);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (blockTablesDtype == ACL_INT8) {
std::vector<int8_t> btH(blockTables_sz, 1);
ret = CreateAclTensor(btH, blockTablesShape, &blockTablesDeviceAddr, blockTablesDtype, &blockTables);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (blockTablesDtype == ACL_INT32) {
std::vector<int32_t> btH(blockTables_sz, 1);
ret = CreateAclTensor(btH, blockTablesShape, &blockTablesDeviceAddr, blockTablesDtype, &blockTables);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (blockTablesDtype == ACL_UINT8) {
std::vector<uint8_t> btH(blockTables_sz, 1);
ret = CreateAclTensor(btH, blockTablesShape, &blockTablesDeviceAddr, blockTablesDtype, &blockTables);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (blockTablesDtype == ACL_INT16) {
std::vector<int16_t> btH(blockTables_sz, 1);
ret = CreateAclTensor(btH, blockTablesShape, &blockTablesDeviceAddr, blockTablesDtype, &blockTables);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (blockTablesDtype == ACL_UINT16) {
std::vector<uint16_t> btH(blockTables_sz, 1);
ret = CreateAclTensor(btH, blockTablesShape, &blockTablesDeviceAddr, blockTablesDtype, &blockTables);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (blockTablesDtype == ACL_UINT32) {
std::vector<uint32_t> btH(blockTables_sz, 1);
ret = CreateAclTensor(btH, blockTablesShape, &blockTablesDeviceAddr, blockTablesDtype, &blockTables);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (blockTablesDtype == ACL_INT64) {
std::vector<int64_t> btH(blockTables_sz, 1);
ret = CreateAclTensor(btH, blockTablesShape, &blockTablesDeviceAddr, blockTablesDtype, &blockTables);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (blockTablesDtype == ACL_UINT64) {
std::vector<uint64_t> btH(blockTables_sz, 1);
ret = CreateAclTensor(btH, blockTablesShape, &blockTablesDeviceAddr, blockTablesDtype, &blockTables);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (blockTablesDtype == ACL_DOUBLE) {
std::vector<double> btH(blockTables_sz, 1);
ret = CreateAclTensor(btH, blockTablesShape, &blockTablesDeviceAddr, blockTablesDtype, &blockTables);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (blockTablesDtype == ACL_BOOL) {
std::vector<int8_t> btH(blockTables_sz, 1);
ret = CreateAclTensor(btH, blockTablesShape, &blockTablesDeviceAddr, blockTablesDtype, &blockTables);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (blockTablesDtype == ACL_BF16) {
std::vector<int16_t> btH(blockTables_sz, 1);
ret = CreateAclTensor(btH, blockTablesShape, &blockTablesDeviceAddr, blockTablesDtype, &blockTables);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (blockTablesDtype == ACL_COMPLEX64) {
std::vector<float> btH(blockTables_sz, 1);
ret = CreateAclTensor(btH, blockTablesShape, &blockTablesDeviceAddr, blockTablesDtype, &blockTables);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else if (blockTablesDtype == ACL_COMPLEX128) {
std::vector<double> btH(blockTables_sz, 1);
ret = CreateAclTensor(btH, blockTablesShape, &blockTablesDeviceAddr, blockTablesDtype, &blockTables);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
} else {
std::vector<float> btH(blockTables_sz, 1);
ret = CreateAclTensor(btH, blockTablesShape, &blockTablesDeviceAddr, blockTablesDtype, &blockTables);
CHECK_RET(ret == ACL_SUCCESS, goto ERROR);
}
}
} else {
blockTables = nullptr;
}
printf("[FUZZ_LOG] plog_file: aclnnAdvanceStep_error_plog_case_%d.log\n", scenario);
printf("[FUZZ_PARAM] inputTokens=%s, inputTokensShape=%s, sampledTokenIds=%s, sampledTokenIdsShape=%s, inputPositions=%s, inputPositionsShape=%s, seqLens=%s, seqLensShape=%s, slotMapping=%s, slotMappingShape=%s, blockTables=%s, blockTablesShape=%s, format=ND\n", GetDtypeName(inputTokensDtype), ShapeToStr(inputTokensShape).c_str(), GetDtypeName(sampledTokenIdsDtype), ShapeToStr(sampledTokenIdsShape).c_str(), GetDtypeName(inputPositionsDtype), ShapeToStr(inputPositionsShape).c_str(), GetDtypeName(seqLensDtype), ShapeToStr(seqLensShape).c_str(), GetDtypeName(slotMappingDtype), ShapeToStr(slotMappingShape).c_str(), GetDtypeName(blockTablesDtype), ShapeToStr(blockTablesShape).c_str());
printf("[FUZZ_ERROR_POINT] case_%d: errorType=%s, errorTarget=%s, description=%s\n", scenario, errorTypeStr.c_str(), errorTargetStr.c_str(), scenarioDesc.c_str());
int64_t vNumSeqs = (inputTokens != nullptr) ? (int64_t)inputTokensShape[0] : 2;
int64_t vNumQueries = (sampledTokenIds != nullptr) ? (int64_t)sampledTokenIdsShape[0] : 1;
int64_t vBlockSize = 2;
ret = aclnnAdvanceStepGetWorkspaceSize(inputTokens, sampledTokenIds, inputPositions, seqLens, slotMapping, blockTables, vNumSeqs, vNumQueries, vBlockSize, &workspaceSize, &executor);
caseRet = (int)ret;
LOG_PRINT("aclnnAdvanceStepGetWorkspaceSize 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 = aclnnAdvanceStep(workspaceAddr, workspaceSize, executor, stream);
if (ret != ACL_SUCCESS) { caseRet = (int)ret; LOG_PRINT("aclnnAdvanceStep execute failed : %d\n", ret); goto ERROR; }
caseRet = (int)ret;
LOG_PRINT("aclnnAdvanceStep 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 -rinE 'ai(vec|core) error' /root/ascend/log/debug/plog/ ";
printf("system return value %d\n", CheckResult(pid));
if (inputTokens != nullptr) { aclDestroyTensor(inputTokens); inputTokens = nullptr; }
if (sampledTokenIds != nullptr) { aclDestroyTensor(sampledTokenIds); sampledTokenIds = nullptr; }
if (inputPositions != nullptr) { aclDestroyTensor(inputPositions); inputPositions = nullptr; }
if (seqLens != nullptr) { aclDestroyTensor(seqLens); seqLens = nullptr; }
if (slotMapping != nullptr) { aclDestroyTensor(slotMapping); slotMapping = nullptr; }
if (blockTables != nullptr) { aclDestroyTensor(blockTables); blockTables = nullptr; }
if (inputTokensDeviceAddr != nullptr) { aclrtFree(inputTokensDeviceAddr); inputTokensDeviceAddr = nullptr; }
if (sampledTokenIdsDeviceAddr != nullptr) { aclrtFree(sampledTokenIdsDeviceAddr); sampledTokenIdsDeviceAddr = nullptr; }
if (inputPositionsDeviceAddr != nullptr) { aclrtFree(inputPositionsDeviceAddr); inputPositionsDeviceAddr = nullptr; }
if (seqLensDeviceAddr != nullptr) { aclrtFree(seqLensDeviceAddr); seqLensDeviceAddr = nullptr; }
if (slotMappingDeviceAddr != nullptr) { aclrtFree(slotMappingDeviceAddr); slotMappingDeviceAddr = nullptr; }
if (blockTablesDeviceAddr != nullptr) { aclrtFree(blockTablesDeviceAddr); blockTablesDeviceAddr = nullptr; }
if (workspaceSize > 0) { aclrtFree(workspaceAddr); }
}
DT_FUZZ_END()
GenerateFinalSummary();
WriteDTLog("aclnnAdvanceStep", "aclnnAdvanceStep 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("aclnnAdvanceStep", "aclnnAdvanceStep op fuzz end\n");
aclrtDestroyStream(stream);
aclrtDestroyContext(context);
aclrtResetDevice(deviceId);
aclFinalize();
return 0;
}
extern "C" int aclnnAdvanceStep_error_fuzz(int argc, char *argv[]);
int aclnnAdvanceStep_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("aclnnAdvanceStep_Normal :%d \n", aclnnAdvanceStep_Normal(fuzz_num));
return 0;
}