已合并
Modify aclnnCast 注释 #965
yuanbin_22创建于 1月28日
Modify aclnnCast 注释 #965
已合并
yuanbin_22创建于 1月28日
1 个文件变更+6-4
Mmath/cast/op_api/aclnn_cast.h+6-4
@@ -1,7 +1,7 @@
1/**1/**
2 * Copyright (c) 2025 Huawei Technologies Co., Ltd.2 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 * This program is free software, you can redistribute it and/or modify it under the terms and conditions of3 * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4- * CANN Open Software License Agreement Version 2.0 (the "License")4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5 * Please refer to the License for details. You may not use this file except in compliance with the License.5 * Please refer to the License for details. You may not use this file except in compliance with the License.
6 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,6 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
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.
@@ -25,12 +25,14 @@ extern "C" {
25 * 算子功能:将输入tensor转换为指定的dtype类型。25 * 算子功能:将输入tensor转换为指定的dtype类型。
26 *26 *
27 * @param [in] self: npu27 * @param [in] self: npu
28- * device侧的aclTensor,数据类型支持FLOAT16、FLOAT、FlOAT64、INT8、UINT8、INT16、INT32、INT64、BOOL。28+ * device侧的aclTensor,数据类型支持FLOAT16、FLOAT、DOUBLE、INT8、UINT8、INT16、UINT16、INT32、UINT32、INT64、UINT64、
29+ * BOOL、COMPLEX32、COMPLEX64、COMPLEX128、BFLOAT16、HIFLOAT8、FLOAT8_E5M2、FLOAT8_E4M3FN、FLOAT4_E2M1、FLOAT4_E1M2。
29 * 支持非连续的Tensor,数据格式支持ND。30 * 支持非连续的Tensor,数据格式支持ND。
30 * @param [in] dtype: host侧的aclDataType,输入tensor要转换的目标dtype。31 * @param [in] dtype: host侧的aclDataType,输入tensor要转换的目标dtype。
31 * @param [in] out: npu32 * @param [in] out: npu
32- * device侧的aclTensor,数据类型支持FLOAT16、FLOAT、FlOAT64、INT8、UINT8、INT16、INT32、INT64、BOOL33+ * device侧的aclTensor,数据类型支持FLOAT16、FLOAT、DOUBLE、INT8、UINT8、INT16、UINT16、INT32、UINT32、INT64、UINT64
33- * COMPLEX64、COMPLEX128。数据类型为dtype,shape与self相同,数据格式支持ND,且数据格式需要与self一致。34+ * BOOL、COMPLEX32、COMPLEX64、COMPLEX128、BFLOAT16、HIFLOAT8、FLOAT8_E5M2、FLOAT8_E4M3FN、FLOAT4_E2M1、FLOAT4_E1M2、INT4
CANN-robot
CANN-robotCANN-robot1月28日

代码结构与可维护性: 输出tensor支持的数据类型列表中包含'INT4',但输入tensor支持的数据类型列表中未包含。这可能导致从非INT4类型转换到INT4时,函数行为未在输入约束中明确说明,增加使用困惑。

问题类型: 代码结构与可维护性 文件路径: math/cast/op_api/aclnn_cast.h 行号: 34 问题代码:

BOOL、COMPLEX32、COMPLEX64、COMPLEX128、BFLOAT16、HIFLOAT8、FLOAT8_E5M2、FLOAT8_E4M3FN、FLOAT4_E2M1、FLOAT4_E1M2、INT4。

修改建议:

在输入tensor支持的数据类型列表中也添加'INT4',或明确注释说明INT4仅作为输出目标类型支持,不支持作为输入类型。这有助于用户清晰理解接口能力边界。

此评论由代码审查工具自动生成

likedislike
35+ * 输出tensor的数据类型由输入参数dtype指定,其shape与self相同,数据格式支持ND,且数据格式需要与self一致。
34 * @param [out] workspaceSize: 返回用户需要在npu device侧申请的workspace大小。36 * @param [out] workspaceSize: 返回用户需要在npu device侧申请的workspace大小。
35 * @param [out] executor: 返回op执行器,包含算子计算流程。37 * @param [out] executor: 返回op执行器,包含算子计算流程。
36 * @return aclnnStatus: 返回状态码。38 * @return aclnnStatus: 返回状态码。