Merged
fix issue,add md doc,add check shape #14221
liuyun_njAdd on 11 days ago
fix issue,add md doc,add check shape #14221
Merged
liuyun_njAdd on 11 days ago
Total: 11 files changed+448-17
@@ -13,6 +13,7 @@
13 * \brief13 * \brief
14 */14 */
15 15 
16+#include <cmath>
16#include <limits>17#include <limits>
17#include "op_host/tiling_util.h"18#include "op_host/tiling_util.h"
18#include "add_rms_norm_tiling.h"19#include "add_rms_norm_tiling.h"
@@ -268,12 +269,24 @@ static bool CheckRstdGammaShapeByMode(const gert::TilingContext* context, const
268 269 
269static bool CheckInputOutputShape(const gert::TilingContext* context)270static bool CheckInputOutputShape(const gert::TilingContext* context)
270{271{
272+ // InplaceAddRmsNorm 的 rstdOut 为必选输出,且资料声明不支持空Tensor。空 rstdOut 会在
273+ // CheckNullptr 的模式推导中被误判为 PRE_RMS_NORM 而跳过 rstd 相关校验,导致第一段
274+ // 静默通过、第二段执行失败(#7407 实测 361001)。此处按算子类型显式拒绝,
275+ // 第一段返回 561002;不影响 AddRmsNorm 以空 rstd 选择 PRE/POST 模式的既有用法。
276+ const gert::StorageShape* rstd_shape = context->GetOutputShape(RMS_OUTPUT_RSTD_INDEX);
277+ if (std::string(context->GetNodeType()) == "InplaceAddRmsNorm" && rstd_shape != nullptr &&
278+ rstd_shape->GetOriginShape().GetShapeSize() <= 0) {
279+ OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context->GetNodeName(), "rstdOut",
280+ Ops::Base::ToString(rstd_shape->GetOriginShape()).c_str(),
281+ "rstdOut cannot be an empty tensor for InplaceAddRmsNorm");
282+ return false;
283+ }
284+ 
271 OP_CHECK_IF(!CheckInputOutputDim(context), OP_LOGE(context, "Input Dim invalid."), return false);285 OP_CHECK_IF(!CheckInputOutputDim(context), OP_LOGE(context, "Input Dim invalid."), return false);
272 const gert::StorageShape* x1_shape = context->GetInputShape(RMS_INPUT_X1_INDEX);286 const gert::StorageShape* x1_shape = context->GetInputShape(RMS_INPUT_X1_INDEX);
273 const gert::StorageShape* x2_shape = context->GetInputShape(RMS_INPUT_X2_INDEX);287 const gert::StorageShape* x2_shape = context->GetInputShape(RMS_INPUT_X2_INDEX);
274 const gert::StorageShape* gamma_shape = context->GetInputShape(RMS_INPUT_GAMMA_INDEX);288 const gert::StorageShape* gamma_shape = context->GetInputShape(RMS_INPUT_GAMMA_INDEX);
275 const gert::StorageShape* y_shape = context->GetOutputShape(RMS_OUTPUT_Y_INDEX);289 const gert::StorageShape* y_shape = context->GetOutputShape(RMS_OUTPUT_Y_INDEX);
276- const gert::StorageShape* rstd_shape = context->GetOutputShape(RMS_OUTPUT_RSTD_INDEX);
277 const gert::StorageShape* x_shape = context->GetOutputShape(RMS_OUTPUT_X_INDEX);290 const gert::StorageShape* x_shape = context->GetOutputShape(RMS_OUTPUT_X_INDEX);
278 291 
279 size_t x1DimNum = x1_shape->GetStorageShape().GetDimNum();292 size_t x1DimNum = x1_shape->GetStorageShape().GetDimNum();
@@ -384,9 +397,11 @@ static ge::graphStatus GetEpsilonParameter(gert::TilingContext* context, float&
384 auto attrs = context->GetAttrs();397 auto attrs = context->GetAttrs();
385 OP_CHECK_NULL_WITH_CONTEXT(context, attrs);398 OP_CHECK_NULL_WITH_CONTEXT(context, attrs);
386 epsilon = *attrs->GetFloat(0);399 epsilon = *attrs->GetFloat(0);
387- OP_CHECK_IF(epsilon < 0,400+ // 用 !std::isfinite(epsilon) || epsilon < 0 而非 epsilon < 0:NaN 与任何比较恒为假,
401+ // 且 +Inf >= 0 为真,二者都会被 epsilon < 0 放行并污染全部输出(issue #7397)。
402+ OP_CHECK_IF(!std::isfinite(epsilon) || epsilon < 0,
388 OP_LOGE_FOR_INVALID_VALUE(context->GetNodeName(), "epsilon", std::to_string(epsilon).c_str(),403 OP_LOGE_FOR_INVALID_VALUE(context->GetNodeName(), "epsilon", std::to_string(epsilon).c_str(),
389- "greater than or equal to zero"),404+ "a finite value greater than or equal to zero"),
390 return ge::GRAPH_FAILED);405 return ge::GRAPH_FAILED);
391 return ge::GRAPH_SUCCESS;406 return ge::GRAPH_SUCCESS;
392}407}
@@ -539,7 +554,8 @@ static ge::graphStatus Tiling4AddRmsNorm(gert::TilingContext* context)
539 554 
540 float epsilon = 0;555 float epsilon = 0;
541 GetEpsilonParameter(context, epsilon);556 GetEpsilonParameter(context, epsilon);
542- if (epsilon < 0) {557+ // 与 GetEpsilonParameter 一致,用 !std::isfinite(epsilon) || epsilon < 0 拦截 NaN/±Inf(issue #7397)。
558+ if (!std::isfinite(epsilon) || epsilon < 0) {
543 return ge::GRAPH_FAILED;559 return ge::GRAPH_FAILED;
544 }560 }
545 561 
@@ -7,6 +7,7 @@
7 * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.7 * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 * See LICENSE in the root of the software repository for the full text of the License.8 * See LICENSE in the root of the software repository for the full text of the License.
9 */9 */
10+#include <cmath>
10#include "aclnn/aclnn_base.h"11#include "aclnn/aclnn_base.h"
11#include "op_api/op_api_def_nn.h"12#include "op_api/op_api_def_nn.h"
12 13 
@@ -194,10 +195,13 @@ static bool CheckShapeDim(AddRmsNormInputTensor& inputTensor, AddRmsNormOutputTe
194 195 
195static bool CheckAttr(double epsilon)196static bool CheckAttr(double epsilon)
196{197{
197- OP_CHECK(198+ // OP_CHECK 为断言式宏(条件为合法条件,不成立即失败,同本文件 137 行用法),
198- epsilon >= 0.0,199+ // 与 OP_CHECK_IF(条件为真即失败)语义相反;此处须写合法性条件:
199- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "The epsilon value must be greater than or equal to 0, but got %lf.", epsilon),200+ // std::isfinite(epsilon) && epsilon >= 0.0,NaN/±Inf/负值全部拒绝(issue #7397)。
200- return false);201+ OP_CHECK(std::isfinite(epsilon) && epsilon >= 0.0,
202+ OP_LOGE(ACLNN_ERR_PARAM_INVALID,
203+ "The epsilon value must be a finite number greater than or equal to 0, but got %lf.", epsilon),
204+ return false);
201 return true;205 return true;
202}206}
203 207 
@@ -2803,3 +2803,182 @@ TEST_F(AddRmsNormTiling, add_rms_norm_regbase_post_mode_rejected)
2803 2803 
2804 EXPECT_EQ(tiling_func(tiling_context), ge::GRAPH_FAILED);2804 EXPECT_EQ(tiling_func(tiling_context), ge::GRAPH_FAILED);
2805}2805}
2806+ 
2807+// InplaceAddRmsNorm 的 rstdOut 为必选输出:空 rstdOut 会被模式推导误判为 PRE_RMS_NORM,
2808+// 导致第一段静默通过、第二段执行失败(#7407)。tiling 须在第一段显式拒绝(561002)。
2809+TEST_F(AddRmsNormTiling, inplace_add_rms_norm_empty_rstd_rejected)
2810+{
2811+ gert::StorageShape input_shape_x1 = {{2, 64}, {2, 64}};
2812+ gert::StorageShape input_shape_x2 = {{2, 64}, {2, 64}};
2813+ gert::StorageShape gamma_shape = {{64}, {64}};
2814+ gert::StorageShape out_shape_y = {{2, 64}, {2, 64}};
2815+ gert::StorageShape rstd_shape = {{0}, {0}};
2816+ gert::StorageShape out_shape_x = {{2, 64}, {2, 64}};
2817+ 
2818+ std::map<std::string, std::string> soc_version_infos = {{"Short_SoC_version", "Ascend950"}, {"NpuArch", "3510"}};
atomgit-bot
atomgit-botatomgit-bot11 days ago

🟡 Medium Priority

变更点:新增用例 inplace_add_rms_norm_empty_rstd_rejected(2813-2818 行设置 gamma=1 维 {64}、rstd={0},并在 2818 行把平台设为 Ascend950/NpuArch 3510),断言 tiling_func(...) == GRAPH_FAILED,注释称其覆盖本次新增的「InplaceAddRmsNorm 空 rstdOut 第一段拒绝」。

失效链:该用例的断言结果与被测新代码无关,两条路径都返回 GRAPH_FAILED:

  1. rstd origin shape {0} 使 norm_key = PRE_RMS_NORM(CheckNullptr,add_rms_norm_tiling.cpp:119-123),若 950 走 regbase 分支,Tiling4AddRmsNorm 会在 add_rms_norm_tiling.cpp:543 以「regbase 不支持 PRE/POST」拒绝;
  2. 若该 UT 的 950 配置被判定为非 regbase,则 PRE 模式要求 gamma 必须 2 维(add_rms_norm_tiling.cpp:207-212),本用例的 gamma 是 1 维 {64},同样返回 GRAPH_FAILED。

也就是说:把新增的 CheckInputOutputShape 里那段 InplaceAddRmsNorm 空 rstd 校验整段删掉,本用例仍然 PASS,本次修复的唯一回归保护实际不存在(这也是 #7407 中该行为在被发现前一直无 UT 覆盖的原因)。

建议:将该用例的平台配置由 Ascend950/NpuArch 3510 改为 Ascend910B(非 regbase),并把 gamma_shape 从 {64} 改为 {1, 64},使用例只有在新增的 InplaceAddRmsNorm 空 rstd 校验生效时才返回 GRAPH_FAILED,否则返回 GRAPH_SUCCESS,从而真正守护本次修改。

likedislike
Incorrect?
2819+ string compile_info_string = R"({
2820+ "hardware_info": {"BT_SIZE": 0, "load3d_constraints": "1",
2821+ "Intrinsic_fix_pipe_l0c2out": false, "Intrinsic_data_move_l12ub": true,
2822+ "Intrinsic_data_move_l0c2ub": true, "Intrinsic_data_move_out2l1_nd2nz": false,
2823+ "UB_SIZE": 196608, "L2_SIZE": 33554432, "L1_SIZE": 524288,
2824+ "L0A_SIZE": 65536, "L0B_SIZE": 65536, "L0C_SIZE": 131072,
2825+ "CORE_NUM": 40}
2826+ })";
2827+ map<string, string> soc_infos;
2828+ map<string, string> aicore_spec;
2829+ map<string, string> intrinsics;
2830+ GetPlatFormInfos(compile_info_string.c_str(), soc_infos, aicore_spec, intrinsics);
2831+ 
2832+ fe::PlatFormInfos platform_info;
2833+ platform_info.Init();
2834+ optiling::AddRmsNormCompileInfo compile_info;
2835+ 
2836+ std::string op_type("InplaceAddRmsNorm");
2837+ ASSERT_NE(gert::OpImplRegistry::GetInstance().GetOpImpl(op_type.c_str()), nullptr);
2838+ auto tiling_func = gert::OpImplRegistry::GetInstance().GetOpImpl(op_type.c_str())->tiling;
2839+ auto tiling_parse_func = gert::OpImplRegistry::GetInstance().GetOpImpl(op_type.c_str())->tiling_parse;
2840+ 
2841+ auto kernel_holder = gert::KernelRunContextFaker()
2842+ .KernelIONum(2, 1)
2843+ .Inputs({const_cast<char*>(compile_info_string.c_str()),
2844+ reinterpret_cast<void*>(&platform_info)})
2845+ .Outputs({&compile_info})
2846+ .Build();
2847+ 
2848+ ASSERT_TRUE(kernel_holder.GetContext<gert::TilingParseContext>()->GetPlatformInfo()->Init());
2849+ kernel_holder.GetContext<gert::TilingParseContext>()->GetPlatformInfo()->SetPlatformRes("SoCInfo", soc_infos);
2850+ kernel_holder.GetContext<gert::TilingParseContext>()->GetPlatformInfo()->SetPlatformRes("AICoreSpec", aicore_spec);
2851+ kernel_holder.GetContext<gert::TilingParseContext>()->GetPlatformInfo()->SetCoreNumByCoreType("AICore");
2852+ kernel_holder.GetContext<gert::TilingParseContext>()->GetPlatformInfo()->SetPlatformRes("AICoreintrinsicDtypeMap",
2853+ intrinsics);
2854+ kernel_holder.GetContext<gert::TilingParseContext>()->GetPlatformInfo()->SetPlatformRes("version",
2855+ soc_version_infos);
2856+ 
2857+ ASSERT_EQ(tiling_parse_func(kernel_holder.GetContext<gert::KernelContext>()), ge::GRAPH_SUCCESS);
2858+ 
2859+ auto param = gert::TilingData::CreateCap(4096);
2860+ auto workspace_size_holder = gert::ContinuousVector::Create<size_t>(4096);
2861+ auto ws_size = reinterpret_cast<gert::ContinuousVector*>(workspace_size_holder.get());
2862+ ASSERT_NE(param, nullptr);
2863+ auto holder = gert::TilingContextFaker()
2864+ .SetOpType("InplaceAddRmsNorm")
2865+ .NodeIoNum(3, 3)
2866+ .IrInstanceNum({1, 1, 1})
2867+ .InputShapes({&input_shape_x1, &input_shape_x2, &gamma_shape})
2868+ .OutputShapes({&out_shape_y, &rstd_shape, &out_shape_x})
2869+ .CompileInfo(&compile_info)
2870+ .PlatformInfo(reinterpret_cast<char*>(&platform_info))
2871+ .NodeInputTd(0, ge::DT_BF16, ge::FORMAT_ND, ge::FORMAT_ND)
2872+ .NodeInputTd(1, ge::DT_BF16, ge::FORMAT_ND, ge::FORMAT_ND)
2873+ .NodeInputTd(2, ge::DT_BF16, ge::FORMAT_ND, ge::FORMAT_ND)
2874+ .NodeOutputTd(0, ge::DT_BF16, ge::FORMAT_ND, ge::FORMAT_ND)
2875+ .NodeOutputTd(1, ge::DT_FLOAT, ge::FORMAT_ND, ge::FORMAT_ND)
2876+ .NodeOutputTd(2, ge::DT_BF16, ge::FORMAT_ND, ge::FORMAT_ND)
2877+ .NodeAttrs({{"epsilon", Ops::NN::AnyValue::CreateFrom<float>(0.01)}})
2878+ .TilingData(param.get())
2879+ .Workspace(ws_size)
2880+ .Build();
2881+ 
2882+ gert::TilingContext* tiling_context = holder.GetContext<gert::TilingContext>();
2883+ ASSERT_NE(tiling_context->GetPlatformInfo(), nullptr);
2884+ holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("SoCInfo", soc_infos);
2885+ holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreSpec", aicore_spec);
2886+ holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetCoreNumByCoreType("AICore");
2887+ holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreintrinsicDtypeMap", intrinsics);
2888+ holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("version", soc_version_infos);
2889+ 
2890+ EXPECT_EQ(tiling_func(tiling_context), ge::GRAPH_FAILED);
2891+}
2892+ 
2893+// epsilon=NaN 与任何比较恒为假,epsilon < 0 拦不住(#7397):legacy tiling 须以
2894+// !(epsilon >= 0) 拒绝,第一段返回 561002。
2895+TEST_F(AddRmsNormTiling, add_rms_norm_epsilon_non_finite_rejected)
2896+{
2897+ gert::StorageShape input_shape_x1 = {{2, 64}, {2, 64}};
2898+ gert::StorageShape input_shape_x2 = {{2, 64}, {2, 64}};
2899+ gert::StorageShape gamma_shape = {{64}, {64}};
2900+ gert::StorageShape out_shape_y = {{2, 64}, {2, 64}};
2901+ gert::StorageShape rstd_shape = {{2, 1}, {2, 1}};
2902+ gert::StorageShape out_shape_x = {{2, 64}, {2, 64}};
2903+ 
2904+ std::map<std::string, std::string> soc_version_infos = {{"Short_SoC_version", "Ascend910B"}, {"NpuArch", "2201"}};
2905+ string compile_info_string = R"({
2906+ "hardware_info": {"BT_SIZE": 0, "load3d_constraints": "1",
2907+ "Intrinsic_fix_pipe_l0c2out": false, "Intrinsic_data_move_l12ub": true,
2908+ "Intrinsic_data_move_l0c2ub": true, "Intrinsic_data_move_out2l1_nd2nz": false,
2909+ "UB_SIZE": 196608, "L2_SIZE": 33554432, "L1_SIZE": 524288,
2910+ "L0A_SIZE": 65536, "L0B_SIZE": 65536, "L0C_SIZE": 131072,
2911+ "CORE_NUM": 40}
2912+ })";
2913+ map<string, string> soc_infos;
2914+ map<string, string> aicore_spec;
2915+ map<string, string> intrinsics;
2916+ GetPlatFormInfos(compile_info_string.c_str(), soc_infos, aicore_spec, intrinsics);
2917+ 
2918+ fe::PlatFormInfos platform_info;
2919+ platform_info.Init();
2920+ optiling::AddRmsNormCompileInfo compile_info;
2921+ 
2922+ std::string op_type("AddRmsNorm");
2923+ ASSERT_NE(gert::OpImplRegistry::GetInstance().GetOpImpl(op_type.c_str()), nullptr);
2924+ auto tiling_func = gert::OpImplRegistry::GetInstance().GetOpImpl(op_type.c_str())->tiling;
2925+ auto tiling_parse_func = gert::OpImplRegistry::GetInstance().GetOpImpl(op_type.c_str())->tiling_parse;
2926+ 
2927+ auto kernel_holder = gert::KernelRunContextFaker()
2928+ .KernelIONum(2, 1)
2929+ .Inputs({const_cast<char*>(compile_info_string.c_str()),
2930+ reinterpret_cast<void*>(&platform_info)})
2931+ .Outputs({&compile_info})
2932+ .Build();
2933+ 
2934+ ASSERT_TRUE(kernel_holder.GetContext<gert::TilingParseContext>()->GetPlatformInfo()->Init());
2935+ kernel_holder.GetContext<gert::TilingParseContext>()->GetPlatformInfo()->SetPlatformRes("SoCInfo", soc_infos);
2936+ kernel_holder.GetContext<gert::TilingParseContext>()->GetPlatformInfo()->SetPlatformRes("AICoreSpec", aicore_spec);
2937+ kernel_holder.GetContext<gert::TilingParseContext>()->GetPlatformInfo()->SetCoreNumByCoreType("AICore");
2938+ kernel_holder.GetContext<gert::TilingParseContext>()->GetPlatformInfo()->SetPlatformRes("AICoreintrinsicDtypeMap",
2939+ intrinsics);
2940+ kernel_holder.GetContext<gert::TilingParseContext>()->GetPlatformInfo()->SetPlatformRes("version",
2941+ soc_version_infos);
2942+ 
2943+ ASSERT_EQ(tiling_parse_func(kernel_holder.GetContext<gert::KernelContext>()), ge::GRAPH_SUCCESS);
2944+ 
2945+ auto param = gert::TilingData::CreateCap(4096);
2946+ auto workspace_size_holder = gert::ContinuousVector::Create<size_t>(4096);
2947+ auto ws_size = reinterpret_cast<gert::ContinuousVector*>(workspace_size_holder.get());
2948+ ASSERT_NE(param, nullptr);
2949+ // NaN/-Inf/+Inf 三种非有限值均须被 !(std::isfinite(epsilon) || epsilon < 0) 拦截:
2950+ // epsilon < 0 拦不住 NaN(比较恒假)与 +Inf(+Inf >= 0 为真)(issue #7397)。
2951+ const float nonFiniteEpsilons[] = {std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::infinity(),
2952+ -std::numeric_limits<float>::infinity()};
2953+ for (float epsilon : nonFiniteEpsilons) {
2954+ auto holder = gert::TilingContextFaker()
2955+ .NodeIoNum(3, 3)
2956+ .IrInstanceNum({1, 1, 1})
2957+ .InputShapes({&input_shape_x1, &input_shape_x2, &gamma_shape})
2958+ .OutputShapes({&out_shape_y, &rstd_shape, &out_shape_x})
2959+ .CompileInfo(&compile_info)
2960+ .PlatformInfo(reinterpret_cast<char*>(&platform_info))
2961+ .NodeInputTd(0, ge::DT_FLOAT16, ge::FORMAT_ND, ge::FORMAT_ND)
2962+ .NodeInputTd(1, ge::DT_FLOAT16, ge::FORMAT_ND, ge::FORMAT_ND)
2963+ .NodeInputTd(2, ge::DT_FLOAT16, ge::FORMAT_ND, ge::FORMAT_ND)
2964+ .NodeOutputTd(0, ge::DT_FLOAT16, ge::FORMAT_ND, ge::FORMAT_ND)
2965+ .NodeOutputTd(1, ge::DT_FLOAT, ge::FORMAT_ND, ge::FORMAT_ND)
2966+ .NodeOutputTd(2, ge::DT_FLOAT16, ge::FORMAT_ND, ge::FORMAT_ND)
2967+ .NodeAttrs({{"epsilon", Ops::NN::AnyValue::CreateFrom<float>(epsilon)}})
2968+ .TilingData(param.get())
2969+ .Workspace(ws_size)
2970+ .Build();
2971+ 
2972+ gert::TilingContext* tiling_context = holder.GetContext<gert::TilingContext>();
2973+ ASSERT_NE(tiling_context->GetPlatformInfo(), nullptr);
2974+ holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("SoCInfo", soc_infos);
2975+ holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreSpec", aicore_spec);
2976+ holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetCoreNumByCoreType("AICore");
2977+ holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreintrinsicDtypeMap",
2978+ intrinsics);
2979+ holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("version", soc_version_infos);
2980+ 
2981+ SCOPED_TRACE(::testing::Message() << "epsilon is non-finite, case " << static_cast<int>(epsilon < 0));
2982+ EXPECT_EQ(tiling_func(tiling_context), ge::GRAPH_FAILED);
2983+ }
2984+}
@@ -225,15 +225,17 @@ aclnnStatus aclnnDeepNorm(
225 <td>如果传入参数是必选输入,输出或者必选属性,且是空指针。</td>225 <td>如果传入参数是必选输入,输出或者必选属性,且是空指针。</td>
226 </tr>226 </tr>
227 <tr>227 <tr>
228- <td rowspan="3">ACLNN_ERR_PARAM_INVALID</td>228+ <td rowspan="2">ACLNN_ERR_PARAM_INVALID</td>
229- <td rowspan="3">161002</td>229+ <td rowspan="2">161002</td>
230 <td>输入或输出的数据类型不在支持的范围之内。</td>230 <td>输入或输出的数据类型不在支持的范围之内。</td>
231 </tr>231 </tr>
232 <tr>232 <tr>
233- <td>输入和输出的shape不匹配或者不在支持的维度范围内。</td>233+ <td>输入和输出的数据类型不满足参数说明中的约束。</td>
234 </tr>234 </tr>
235 <tr>235 <tr>
236- <td>输入和输出的数据类型不满足参数说明中的约束。</td>236+ <td>ACLNN_ERR_INNER_TILING_ERROR</td>
237+ <td>561002</td>
238+ <td>输入和输出的shape不匹配或者不在支持的维度范围内(如x/gx/y的维度数不在[2, 8]、gamma/beta的维度数不在[1, 7]、x的维度数不大于gamma的维度数、meanOut/rstdOut的shape关系不满足参数说明中的约束等)。</td>
237 </tr>239 </tr>
238 </tbody></table>240 </tbody></table>
239 241 
@@ -115,6 +115,14 @@ static bool CheckInputOutputShapeValue(const gert::TilingContext* context)
115 OP_LOGE(context, "Output rstd/mean shape invaild, shape is not equal x first few dim."),115 OP_LOGE(context, "Output rstd/mean shape invaild, shape is not equal x first few dim."),
116 return false);116 return false);
117 }117 }
118+ // 归约维(被 norm 的维度)必须为 1:kernel 按前导维乘积写 mean/rstd,
119+ // 尾维非 1 会导致部分写甚至越界写(issue #7296)。动态维(负数)跳过。
120+ for (uint32_t i = xDimNum - gammaDimNum; i < xDimNum; i++) {
121+ OP_CHECK_IF((rstdShape->GetStorageShape().GetDim(i) >= 0 && rstdShape->GetStorageShape().GetDim(i) != 1) ||
122+ (meanShape->GetStorageShape().GetDim(i) >= 0 && meanShape->GetStorageShape().GetDim(i) != 1),
123+ OP_LOGE(context, "Output rstd/mean shape invaild, the normalized dims of rstd/mean must be 1."),
124+ return false);
125+ }
118 for (uint32_t i = 0; i < gammaDimNum; i++) {126 for (uint32_t i = 0; i < gammaDimNum; i++) {
119 OP_CHECK_IF(127 OP_CHECK_IF(
120 (gammaShape->GetStorageShape().GetDim(i) != xShape->GetStorageShape().GetDim(xDimNum - gammaDimNum + i)) ||128 (gammaShape->GetStorageShape().GetDim(i) != xShape->GetStorageShape().GetDim(xDimNum - gammaDimNum + i)) ||
@@ -132,3 +132,102 @@ TEST_F(DeepNormTiling, Deep_norm_tiling_001)
132 ASSERT_EQ(tiling_key, 1);132 ASSERT_EQ(tiling_key, 1);
133 // dlog_setlevel(0, 3, 0);133 // dlog_setlevel(0, 3, 0);
134}134}
135+ 
136+// mean/rstd 的归约维(尾维)必须为 1:kernel 按前导维乘积写 mean/rstd,
137+// 尾维非 1 会导致部分写甚至越界写(issue #7296)。
138+TEST_F(DeepNormTiling, Deep_norm_tiling_mean_rstd_reduce_dim_mismatch)
139+{
140+ gert::StorageShape input_x_shape = {{24, 1, 2560}, {24, 1, 2560}};
141+ gert::StorageShape input_gx_shape = {{24, 1, 2560}, {24, 1, 2560}};
142+ gert::StorageShape beta_shape = {{
143+ 2560,
144+ },
145+ {
146+ 2560,
147+ }};
148+ gert::StorageShape gamma_shape = {{
149+ 2560,
150+ },
151+ {
152+ 2560,
153+ }};
154+ gert::StorageShape mean_shape = {{24, 1, 2}, {24, 1, 2}};
155+ gert::StorageShape rstd_shape = {{24, 1, 2}, {24, 1, 2}};
156+ gert::StorageShape output_y_shape = {{24, 1, 2560}, {24, 1, 2560}};
157+ 
158+ string compile_info_string = R"({
159+ "hardware_info": {"BT_SIZE": 0, "load3d_constraints": "1",
160+ "Intrinsic_fix_pipe_l0c2out": false, "Intrinsic_data_move_l12ub": true, "Intrinsic_data_move_l0c2ub": true, "Intrinsic_data_move_out2l1_nd2nz": false,
161+ "UB_SIZE": 196608, "L2_SIZE": 33554432, "L1_SIZE": 524288,
162+ "L0A_SIZE": 65536, "L0B_SIZE": 65536, "L0C_SIZE": 131072,
163+ "CORE_NUM": 40}
164+ })";
165+ map<string, string> soc_infos;
166+ map<string, string> aicore_spec;
167+ map<string, string> intrinsics;
168+ GetPlatFormInfos(compile_info_string.c_str(), soc_infos, aicore_spec, intrinsics);
169+ 
170+ // platform info
171+ fe::PlatFormInfos platform_info;
172+ platform_info.Init();
173+ // compile info
174+ struct DeepNormCompileInfo {};
175+ DeepNormCompileInfo compile_info;
176+ 
177+ std::string op_type("DeepNorm");
178+ ASSERT_NE(gert::OpImplRegistry::GetInstance().GetOpImpl(op_type.c_str()), nullptr);
179+ auto tiling_func = gert::OpImplRegistry::GetInstance().GetOpImpl(op_type.c_str())->tiling;
180+ auto tiling_parse_func = gert::OpImplRegistry::GetInstance().GetOpImpl(op_type.c_str())->tiling_parse;
181+ 
182+ // tilingParseFunc simulate
183+ auto kernel_holder = gert::KernelRunContextFaker()
184+ .KernelIONum(2, 1)
185+ .Inputs({const_cast<char*>(compile_info_string.c_str()),
186+ reinterpret_cast<void*>(&platform_info)})
187+ .Outputs({&compile_info})
188+ .Build();
189+ 
190+ ASSERT_TRUE(kernel_holder.GetContext<gert::TilingParseContext>()->GetPlatformInfo()->Init());
191+ kernel_holder.GetContext<gert::TilingParseContext>()->GetPlatformInfo()->SetPlatformRes("SoCInfo", soc_infos);
192+ kernel_holder.GetContext<gert::TilingParseContext>()->GetPlatformInfo()->SetPlatformRes("AICoreSpec", aicore_spec);
193+ kernel_holder.GetContext<gert::TilingParseContext>()->GetPlatformInfo()->SetCoreNumByCoreType("AICore");
194+ kernel_holder.GetContext<gert::TilingParseContext>()->GetPlatformInfo()->SetPlatformRes("AICoreintrinsicDtypeMap",
195+ intrinsics);
196+ 
197+ ASSERT_EQ(tiling_parse_func(kernel_holder.GetContext<gert::KernelContext>()), ge::GRAPH_SUCCESS);
198+ 
199+ // tilingFunc simulate
200+ auto param = gert::TilingData::CreateCap(4096);
201+ auto workspace_size_holer = gert::ContinuousVector::Create<size_t>(4096);
202+ auto ws_size = reinterpret_cast<gert::ContinuousVector*>(workspace_size_holer.get());
203+ ASSERT_NE(param, nullptr);
204+ 
205+ auto holder = gert::TilingContextFaker()
206+ .NodeIoNum(4, 3)
207+ .IrInstanceNum({1, 1, 1, 1})
208+ .InputShapes({&input_x_shape, &input_gx_shape, &beta_shape, &gamma_shape})
209+ .OutputShapes({&mean_shape, &rstd_shape, &output_y_shape})
210+ .CompileInfo(&compile_info)
211+ .PlatformInfo(reinterpret_cast<char*>(&platform_info))
212+ .NodeInputTd(0, ge::DT_FLOAT16, ge::FORMAT_ND, ge::FORMAT_ND)
213+ .NodeInputTd(1, ge::DT_FLOAT16, ge::FORMAT_ND, ge::FORMAT_ND)
214+ .NodeInputTd(2, ge::DT_FLOAT16, ge::FORMAT_ND, ge::FORMAT_ND)
215+ .NodeInputTd(3, ge::DT_FLOAT16, ge::FORMAT_ND, ge::FORMAT_ND)
216+ .NodeOutputTd(0, ge::DT_FLOAT, ge::FORMAT_ND, ge::FORMAT_ND)
217+ .NodeOutputTd(1, ge::DT_FLOAT, ge::FORMAT_ND, ge::FORMAT_ND)
218+ .NodeOutputTd(2, ge::DT_FLOAT16, ge::FORMAT_ND, ge::FORMAT_ND)
219+ .NodeAttrs({{"alpha", Ops::NN::AnyValue::CreateFrom<float>(0.3)},
220+ {"epsilon", Ops::NN::AnyValue::CreateFrom<float>(0.000001)}})
221+ .TilingData(param.get())
222+ .Workspace(ws_size)
223+ .Build();
224+ 
225+ gert::TilingContext* tiling_context = holder.GetContext<gert::TilingContext>();
226+ ASSERT_NE(tiling_context->GetPlatformInfo(), nullptr);
227+ holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("SoCInfo", soc_infos);
228+ holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreSpec", aicore_spec);
229+ holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetCoreNumByCoreType("AICore");
230+ holder.GetContext<gert::TilingContext>()->GetPlatformInfo()->SetPlatformRes("AICoreintrinsicDtypeMap", intrinsics);
231+ 
232+ EXPECT_EQ(tiling_func(tiling_context), ge::GRAPH_FAILED);
233+}
@@ -351,6 +351,14 @@ aclnnStatus aclnnGroupNorm(
351 351 
352## 约束说明352## 约束说明
353 353 
354+- 空Tensor说明:
355+ - 空Tensor指shape中存在0的Tensor,不等同于空指针或标量。
356+ - 满足其余shape、数据类型约束时,支持`self`为空Tensor,此时`out`为空Tensor,不写入数据。
357+ - `meanOut`、`rstdOut`的shape为(N, group),仅由N与group决定:
358+ - 当N=0时,`meanOut`、`rstdOut`为空Tensor;
359+ - 当N>0且C=0或HxW=0时,`meanOut`、`rstdOut`非空,约定`meanOut`输出全0、`rstdOut`输出全NaN(约定值,非计算结果)。
360+ - 必选参数仍须提供Tensor对象。
361+ 
354- 确定性计算:362- 确定性计算:
355 - aclnnGroupNorm默认确定性实现。363 - aclnnGroupNorm默认确定性实现。
356 364 
@@ -191,6 +191,11 @@ aclnnStatus aclnnInplaceAddRmsNorm(
191 <td rowspan="1">161002</td>191 <td rowspan="1">161002</td>
192 <td>输入或输出的数据类型不在支持的范围之内。</td>192 <td>输入或输出的数据类型不在支持的范围之内。</td>
193 </tr>193 </tr>
194+ <tr>
195+ <td>ACLNN_ERR_INNER_TILING_ERROR</td>
196+ <td>561002</td>
197+ <td>输入/输出的维度数(rank)不满足约束说明要求(如gamma与x1Ref需要归一化的维度不一致或rstdOut的维度数/前缀维/尾维与x1Ref、gamma的关系不成立),shape关系不满足约束说明中的要求(如x2Ref与x1Ref的shape不一致), epsilon取值为非有限值/负值,x1Ref、x2Ref、gamma、rstdOut中的部分Tensor为空而其余非空。</td>
198+ </tr>
194 </tbody></table>199 </tbody></table>
195 200 
196## aclnnInplaceAddRmsNorm201## aclnnInplaceAddRmsNorm
@@ -238,6 +243,8 @@ aclnnStatus aclnnInplaceAddRmsNorm(
238 243 
239## 约束说明244## 约束说明
240 245 
246+- 空Tensor说明:
247+ - 支持`x1Ref`、`x2Ref`、`gamma`、`rstdOut`**同时**为空Tensor(shape中存在0,不等同于空指针或标量)的场景:此时两段接口均返回成功且不执行计算(空转),输出不写入数据。
241- 边界值场景说明:248- 边界值场景说明:
242 - 当输入是Inf时,输出为Inf。249 - 当输入是Inf时,输出为Inf。
243 - 当输入是NaN时,输出为NaN。250 - 当输入是NaN时,输出为NaN。
@@ -93,7 +93,7 @@ aclnnStatus aclnnRmsNorm(
93 <td>gamma(aclTensor*)</td>93 <td>gamma(aclTensor*)</td>
94 <td>输入</td>94 <td>输入</td>
95 <td>表示进行归一化计算的缩放因子(权重),对应公式中的`gamma`。</td>95 <td>表示进行归一化计算的缩放因子(权重),对应公式中的`gamma`。</td>
96- <td>shape需要满足gamma_shape = x_shape[n:], n < x_shape.dims()。</td>96+ <td>shape需要满足gamma_shape = x_shape[n:],n的取值范围为[0, x_shape.dims()-1];当n = 0时gamma与x同shape,等价于对全部轴归一化,此时rstdOut的有效元素数为1。</td>
97 <td>FLOAT32、FLOAT16、BFLOAT16</td>97 <td>FLOAT32、FLOAT16、BFLOAT16</td>
98 <td>ND</td>98 <td>ND</td>
99 <td>1-8</td>99 <td>1-8</td>
@@ -487,6 +487,13 @@ aclnnStatus aclnnRmsNormQuantGetWorkspaceSize(const aclTensor* x, const aclTenso
487 return ACLNN_SUCCESS;487 return ACLNN_SUCCESS;
488 }488 }
489 }489 }
490+ if (!isRegbase) {
491+ // 与 regbase 同序:先校验 2 维 gamma/beta 首维必须为 1(issue #7399)。
492+ // 否则 PreDealData 的 Reshape 会以内部错误 561103 失败,而非资料声明的 161002。
493+ CHECK_RET(CheckShapeBeforeReshape(inputTensorOri.gamma, "gamma") &&
494+ CheckShapeBeforeReshape(inputTensorOri.beta, "beta"),
495+ ACLNN_ERR_PARAM_INVALID);
496+ }
490 CHECK_RET(PreDealData(inputTensorOri, uniqueExecutor.get()) == ACLNN_SUCCESS, ACLNN_ERR_INNER_NULLPTR);497 CHECK_RET(PreDealData(inputTensorOri, uniqueExecutor.get()) == ACLNN_SUCCESS, ACLNN_ERR_INNER_NULLPTR);
491 if (!isRegbase) {498 if (!isRegbase) {
492 const auto paramRet = CheckParams(inputTensorOri, y);499 const auto paramRet = CheckParams(inputTensorOri, y);
@@ -194,7 +194,7 @@ TEST_F(l2_rms_norm_quant_test, ascend950_null_gamma_and_beta_remain_param_nullpt
194 EXPECT_EQ(nullBetaUt.TestGetWorkspaceSize(&workspaceSize), ACLNN_ERR_PARAM_NULLPTR);194 EXPECT_EQ(nullBetaUt.TestGetWorkspaceSize(&workspaceSize), ACLNN_ERR_PARAM_NULLPTR);
195}195}
196 196 
197-TEST_F(l2_rms_norm_quant_test, legacy_norm_preprocessing_behavior_is_unchanged)197+TEST_F(l2_rms_norm_quant_test, gamma_beta_2d_first_dim_validation)
198{198{
199 for (auto socVersion : {op::SocVersion::ASCEND910B, op::SocVersion::ASCEND910_93}) {199 for (auto socVersion : {op::SocVersion::ASCEND910B, op::SocVersion::ASCEND910_93}) {
200 op::SocVersionManager versionManager(socVersion);200 op::SocVersionManager versionManager(socVersion);
@@ -202,16 +202,19 @@ TEST_F(l2_rms_norm_quant_test, legacy_norm_preprocessing_behavior_is_unchanged)
202 TensorCase testCase;202 TensorCase testCase;
203 testCase.dtypes[3] = ACL_FLOAT16;203 testCase.dtypes[3] = ACL_FLOAT16;
204 testCase.dtypes[4] = ACL_INT8;204 testCase.dtypes[4] = ACL_INT8;
205+ // gamma/beta = [1, H]:合法形态,第一段返回成功。
205 testCase.shapes[1] = {1, 16};206 testCase.shapes[1] = {1, 16};
206 testCase.shapes[2] = {1, 16};207 testCase.shapes[2] = {1, 16};
207 EXPECT_EQ(RunTensorCase(testCase), ACLNN_SUCCESS);208 EXPECT_EQ(RunTensorCase(testCase), ACLNN_SUCCESS);
208 209 
209- // The new early shape check is RegBase-only; legacy reshape failures keep their previous status.210+ // gamma/beta 2维且首维≠1:资料声明该形态 shape 关系非法,非 regbase 路径
211+ // 已在 PreDealData 前按契约拒绝(#7399),返回 161002,
212+ // 不再走 PreDealData 的 Reshape 内部失败(561103)。
210 testCase.shapes[1] = {2, 16};213 testCase.shapes[1] = {2, 16};
211- EXPECT_EQ(RunTensorCase(testCase), ACLNN_ERR_INNER_NULLPTR);214+ EXPECT_EQ(RunTensorCase(testCase), ACLNN_ERR_PARAM_INVALID);
212 testCase.shapes[1] = {1, 16};215 testCase.shapes[1] = {1, 16};
213 testCase.shapes[2] = {2, 16};216 testCase.shapes[2] = {2, 16};
214- EXPECT_EQ(RunTensorCase(testCase), ACLNN_ERR_INNER_NULLPTR);217+ EXPECT_EQ(RunTensorCase(testCase), ACLNN_ERR_PARAM_INVALID);
215 }218 }
216}219}
217 220 
@@ -325,3 +328,101 @@ TEST_F(l2_rms_norm_quant_test, ascend910b_int4_output_must_be_int32_packed)
325 INPUT(xDesc, gammaDesc, betaDesc, scaleDesc, offsetDesc, 1e-6, yInt32WrongDesc), OUTPUT());328 INPUT(xDesc, gammaDesc, betaDesc, scaleDesc, offsetDesc, 1e-6, yInt32WrongDesc), OUTPUT());
326 EXPECT_EQ(utWrong.TestGetWorkspaceSize(&workspaceSize), ACLNN_ERR_PARAM_INVALID);329 EXPECT_EQ(utWrong.TestGetWorkspaceSize(&workspaceSize), ACLNN_ERR_PARAM_INVALID);
327}330}
331+ 
332+TEST_F(l2_rms_norm_quant_test, ascend910b_dtype_mismatch_returns_param_invalid)
333+{
334+ op::SocVersionManager versionManager(op::SocVersion::ASCEND910B);
335+ uint64_t workspaceSize = 0;
336+ 
337+ // x dtype 不在支持列表(910B 仅支持 FLOAT16/BFLOAT16)→ OP_CHECK_DTYPE_NOT_SUPPORT → 161002。
338+ auto xInt8Desc = TensorDesc({2, 16}, ACL_INT8, ACL_FORMAT_ND);
339+ auto gammaFp16Desc = TensorDesc({16}, ACL_FLOAT16, ACL_FORMAT_ND);
340+ auto betaFp16Desc = TensorDesc({16}, ACL_FLOAT16, ACL_FORMAT_ND);
341+ auto scaleFp16Desc = TensorDesc({1}, ACL_FLOAT16, ACL_FORMAT_ND);
342+ auto offsetInt8Desc = TensorDesc({1}, ACL_INT8, ACL_FORMAT_ND);
343+ auto yInt8Desc = TensorDesc({2, 16}, ACL_INT8, ACL_FORMAT_ND);
344+ auto utX = OP_API_UT(aclnnRmsNormQuant,
345+ INPUT(xInt8Desc, gammaFp16Desc, betaFp16Desc, scaleFp16Desc, offsetInt8Desc, 1e-6, yInt8Desc),
346+ OUTPUT());
347+ EXPECT_EQ(utX.TestGetWorkspaceSize(&workspaceSize), ACLNN_ERR_PARAM_INVALID);
348+ 
349+ // gamma dtype 与 x 不一致(BF16 vs FP16)→ OP_CHECK_DTYPE_NOT_SAME → 161002。
350+ auto xFp16Desc = TensorDesc({2, 16}, ACL_FLOAT16, ACL_FORMAT_ND);
351+ auto gammaBf16Desc = TensorDesc({16}, ACL_BF16, ACL_FORMAT_ND);
352+ auto betaBf16Desc = TensorDesc({16}, ACL_BF16, ACL_FORMAT_ND);
353+ auto utGamma = OP_API_UT(
354+ aclnnRmsNormQuant,
355+ INPUT(xFp16Desc, gammaBf16Desc, betaBf16Desc, scaleFp16Desc, offsetInt8Desc, 1e-6, yInt8Desc), OUTPUT());
356+ EXPECT_EQ(utGamma.TestGetWorkspaceSize(&workspaceSize), ACLNN_ERR_PARAM_INVALID);
357+ 
358+ // 非 regbase 平台 scale dtype 必须与 x 一致(FLOAT vs FP16)→ 161002。
359+ auto scaleFp32Desc = TensorDesc({1}, ACL_FLOAT, ACL_FORMAT_ND);
360+ auto gammaFp16 = TensorDesc({16}, ACL_FLOAT16, ACL_FORMAT_ND);
361+ auto betaFp16 = TensorDesc({16}, ACL_FLOAT16, ACL_FORMAT_ND);
362+ auto utScale = OP_API_UT(aclnnRmsNormQuant,
363+ INPUT(xFp16Desc, gammaFp16, betaFp16, scaleFp32Desc, offsetInt8Desc, 1e-6, yInt8Desc),
364+ OUTPUT());
365+ EXPECT_EQ(utScale.TestGetWorkspaceSize(&workspaceSize), ACLNN_ERR_PARAM_INVALID);
366+ 
367+ // 非 regbase 平台 offset dtype 必须为 INT8(FLOAT vs INT8)→ 161002。
368+ auto scaleFp16 = TensorDesc({1}, ACL_FLOAT16, ACL_FORMAT_ND);
369+ auto offsetFp32Desc = TensorDesc({1}, ACL_FLOAT, ACL_FORMAT_ND);
370+ auto utOffset = OP_API_UT(
371+ aclnnRmsNormQuant, INPUT(xFp16Desc, gammaFp16, betaFp16, scaleFp16, offsetFp32Desc, 1e-6, yInt8Desc), OUTPUT());
372+ EXPECT_EQ(utOffset.TestGetWorkspaceSize(&workspaceSize), ACLNN_ERR_PARAM_INVALID);
373+}
374+ 
375+TEST_F(l2_rms_norm_quant_test, ascend910b_int32_packed_output_returns_success)
376+{
377+ op::SocVersionManager versionManager(op::SocVersion::ASCEND910B);
378+ auto xDesc = TensorDesc({3, 16}, ACL_FLOAT16, ACL_FORMAT_ND);
379+ auto gammaDesc = TensorDesc({1, 16}, ACL_FLOAT16, ACL_FORMAT_ND);
380+ auto betaDesc = TensorDesc({1, 16}, ACL_FLOAT16, ACL_FORMAT_ND);
381+ auto scaleDesc = TensorDesc({1}, ACL_FLOAT16, ACL_FORMAT_ND);
382+ auto offsetDesc = TensorDesc({1}, ACL_INT8, ACL_FORMAT_ND);
383+ auto yInt32Desc = TensorDesc({3, 2}, ACL_INT32, ACL_FORMAT_ND);
384+ 
385+ // INT32 打包形态(y 末维 = x 末维/8)在 A2/A3 上两段均应成功,
386+ // 覆盖 RunRmsNormQuantKernel 的 INT4→INT32 打包分支。
387+ auto ut = OP_API_UT(aclnnRmsNormQuant, INPUT(xDesc, gammaDesc, betaDesc, scaleDesc, offsetDesc, 1e-6, yInt32Desc),
388+ OUTPUT());
389+ uint64_t workspaceSize = 0;
390+ EXPECT_EQ(ut.TestGetWorkspaceSize(&workspaceSize), ACLNN_SUCCESS);
391+}
392+ 
393+TEST_F(l2_rms_norm_quant_test, ascend950_empty_tensor_returns_success)
394+{
395+ op::SocVersionManager versionManager(op::SocVersion::ASCEND950);
396+ auto xDesc = TensorDesc({0, 5}, ACL_FLOAT16, ACL_FORMAT_ND);
397+ auto gammaDesc = TensorDesc({5}, ACL_FLOAT16, ACL_FORMAT_ND);
398+ auto betaDesc = TensorDesc({5}, ACL_FLOAT16, ACL_FORMAT_ND);
399+ auto scaleDesc = TensorDesc({1}, ACL_FLOAT16, ACL_FORMAT_ND);
400+ auto offsetDesc = TensorDesc({1}, ACL_INT8, ACL_FORMAT_ND);
401+ auto yDesc = TensorDesc({0, 5}, ACL_INT8, ACL_FORMAT_ND);
402+ 
403+ // 950 支持 x/y 同时为空 Tensor:第一段返回成功且 workspace 为 0(空转),
404+ // 覆盖 regbase 路径的空 Tensor 早退分支。
405+ auto ut = OP_API_UT(aclnnRmsNormQuant, INPUT(xDesc, gammaDesc, betaDesc, scaleDesc, offsetDesc, 1e-6, yDesc),
406+ OUTPUT());
407+ uint64_t workspaceSize = 0;
408+ EXPECT_EQ(ut.TestGetWorkspaceSize(&workspaceSize), ACLNN_SUCCESS);
409+ EXPECT_EQ(workspaceSize, 0);
410+}
411+ 
412+TEST_F(l2_rms_norm_quant_test, ascend950_int32_packed_output_returns_success)
413+{
414+ op::SocVersionManager versionManager(op::SocVersion::ASCEND950);
415+ auto xDesc = TensorDesc({3, 16}, ACL_FLOAT16, ACL_FORMAT_ND);
416+ auto gammaDesc = TensorDesc({16}, ACL_FLOAT16, ACL_FORMAT_ND);
417+ auto betaDesc = TensorDesc({16}, ACL_FLOAT16, ACL_FORMAT_ND);
418+ auto scaleDesc = TensorDesc({1}, ACL_FLOAT16, ACL_FORMAT_ND);
419+ auto offsetDesc = TensorDesc({1}, ACL_INT8, ACL_FORMAT_ND);
420+ auto yInt32Desc = TensorDesc({3, 2}, ACL_INT32, ACL_FORMAT_ND);
421+ 
422+ // 950 上 INT32 打包形态(y 末维 = x 末维/8)两段均成功,
423+ // 覆盖 regbase INT32 分支的 front-n-1 校验与打包路径。
424+ auto ut = OP_API_UT(aclnnRmsNormQuant, INPUT(xDesc, gammaDesc, betaDesc, scaleDesc, offsetDesc, 1e-6, yInt32Desc),
425+ OUTPUT());
426+ uint64_t workspaceSize = 0;
427+ EXPECT_EQ(ut.TestGetWorkspaceSize(&workspaceSize), ACLNN_SUCCESS);
428+}