已开启
[Bug-Report|缺陷反馈]:使用atk测试以下用例,出现问题 #1
xieshengwei1024创建于  24 天前
xieshengwei1024成员
24 天前 创建

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.

一、问题描述 (必填)

用例名: {"id": 5939, "name": "aclnn.OneHot", "aclnn_name": "OneHot", "triton_name": null, "kernel_name": null, "version": "v2.1", "expected_error_msg": null, "api": "pytorch", "api_type": "executor_torch_nn_functional_one_hot", "aclnn_api_type": "executor_aclnn_one_hot", "triton_api_type": "triton_function", "fusion_api_type": "fusion_function", "fusion_mode": null, "dist_api_type": "dist_function", "kernel_api_type": "kernel_function", "backward": false, "standard": {"acc": "md5", "perf": [0.95, 0.95], "mem": 1.1}, "outputs": null, "inputs": [{"name": "self", "type": "tensor", "required": true, "dtype": "int32", "shape": [19, 16, 15], "range_values": [0, 2049], "backward": true, "align_32B": false, "outlier_values": null}, {"name": "numClasses", "type": "attr", "required": false, "dtype": "int", "shape": null, "range_values": 2048, "backward": false, "align_32B": null, "outlier_values": null}, {"name": "onValue", "type": "tensor", "required": true, "dtype": "int32", "shape": [8, 5], "range_values": [-100, 100], "backward": true, "align_32B": null, "outlier_values": null}, {"name": "offValue", "type": "tensor", "required": true, "dtype": "int32", "shape": [1, 3, 6, 3, 8, 3, 1, 6], "range_values": [-100, 100], "backward": true, "align_32B": null, "outlier_values": null}, {"name": "axis", "type": "attr", "required": false, "dtype": "int", "shape": null, "range_values": 3, "backward": false, "align_32B": null, "outlier_values": null}], "acl_json": "", "method_inputs": null, "tensor_input": null, "compute_times": null, "save_name": null, "uuid": null, "downloaded": false, "is_boundary": false, "xrun_cs_name": null, "xrun_data": null}

下载链接:
https://gitcode.com/Ascend/ATK

二、环境信息 (可选)

三、重现步骤 (可选)

四、预期结果 (可选)

💡 备注(选填)

likedislike
xieshengwei1024成员
24 天前 评论:

import torch
import torch_npu

torch.npu.set_device(0)

IN_SHAPE = (19, 16, 15)
DEPTH = 2048
ON_VALUE = -63
OFF_VALUE = 89
AXIS = 3

for seed in [5939, 1, 42]:
torch.manual_seed(seed)
x = torch.randint(0, 2050, IN_SHAPE, dtype=torch.int32) # [0, 2049],含越界值
oob = int((x >= DEPTH).sum())
x = x.npu()

out = torch_npu.npu_one_hot(x, num_classes=AXIS, depth=DEPTH, on_value=ON_VALUE, off_value=OFF_VALUE)
o = out.cpu()

total = o.numel()
on = int((o == ON_VALUE).sum())
off = int((o == OFF_VALUE).sum())
zero = int((o == 0).sum())
other = total - on - off - zero
expect_on = 19 * 16 * 15 - oob
status = "OK" if (zero == 0 and other == 0 and on == expect_on) else "FAIL"
print(f"seed={seed} oob={oob} total={total} on={on}(expect {expect_on}) off={off} zero={zero} other={other} -> {status}")
likedislike
xieshengwei1024成员
24 天前 评论:

msprof op --kernel-name=OneHot --launch-count=3 --output=/tmp/prof_onehot python3 test_onehot_atk_case.py

likedislike