已合并
[fix] torch.eye API consistency #4256
一只食醉狗创建于 2月12日
[fix] torch.eye API consistency #4256
已合并
共 1 个文件变更+6-3
| @@ -23,7 +23,7 @@ using npu_preparation = at_npu::native::OpPreparation; | |||
| 23 | at::Tensor& eye_out(int64_t n, at::Tensor& out) | 23 | at::Tensor& eye_out(int64_t n, at::Tensor& out) |
| 24 | { | 24 | { |
| 25 | DO_COMPATIBILITY(aclnnEye, acl_op::eye_out(n, out)); | 25 | DO_COMPATIBILITY(aclnnEye, acl_op::eye_out(n, out)); |
| 26 | - TORCH_CHECK(n >= 0, "n must be greater or equal to 0, got ", n, OPS_ERROR(ErrCode::VALUE)); | 26 | + TORCH_CHECK(n >= 0, "n must be greater or equal to 0, got ", n, OPS_ERROR(ErrCode::PARAM)); |
| 27 | out.resize_({n, n}); | 27 | out.resize_({n, n}); |
| 28 | EXEC_NPU_CMD(aclnnEye, n, n, out); | 28 | EXEC_NPU_CMD(aclnnEye, n, n, out); |
| 29 | return out; | 29 | return out; |
| @@ -32,8 +32,8 @@ at::Tensor& eye_out(int64_t n, at::Tensor& out) | |||
| 32 | at::Tensor& eye_out(int64_t n, int64_t m, at::Tensor& out) | 32 | at::Tensor& eye_out(int64_t n, int64_t m, at::Tensor& out) |
| 33 | { | 33 | { |
| 34 | DO_COMPATIBILITY(aclnnEye, acl_op::eye_out(n, m, out)); | 34 | DO_COMPATIBILITY(aclnnEye, acl_op::eye_out(n, m, out)); |
| 35 | - TORCH_CHECK(n >= 0, "n must be greater or equal to 0, got ", n, OPS_ERROR(ErrCode::VALUE)); | 35 | + TORCH_CHECK(n >= 0, "n must be greater or equal to 0, got ", n, OPS_ERROR(ErrCode::PARAM)); |
| 36 | - TORCH_CHECK(m >= 0, "m must be greater or equal to 0, got ", m, OPS_ERROR(ErrCode::VALUE)); | 36 | + TORCH_CHECK(m >= 0, "m must be greater or equal to 0, got ", m, OPS_ERROR(ErrCode::PARAM)); |
| 37 | out.resize_({n, m}); | 37 | out.resize_({n, m}); |
| 38 | EXEC_NPU_CMD(aclnnEye, n, m, out); | 38 | EXEC_NPU_CMD(aclnnEye, n, m, out); |
| 39 | return out; | 39 | return out; |
| @@ -47,6 +47,7 @@ at::Tensor eye( | |||
| 47 | c10::optional<bool> pin_memory) | 47 | c10::optional<bool> pin_memory) |
| 48 | { | 48 | { |
| 49 | DO_COMPATIBILITY(aclnnEye, acl_op::eye(n, dtype, layout, device, pin_memory)); | 49 | DO_COMPATIBILITY(aclnnEye, acl_op::eye(n, dtype, layout, device, pin_memory)); |
| 50 | + TORCH_CHECK(n >= 0, "n must be greater or equal to 0, got ", n, OPS_ERROR(ErrCode::PARAM)); | ||
| 50 | auto device_value = device_or_default(device); | 51 | auto device_value = device_or_default(device); |
| 51 | at::TensorOptions option = option.dtype(dtype) | 52 | at::TensorOptions option = option.dtype(dtype) |
| 52 | .layout(layout) | 53 | .layout(layout) |
| @@ -71,6 +72,8 @@ at::Tensor eye( | |||
| 71 | c10::optional<bool> pin_memory) | 72 | c10::optional<bool> pin_memory) |
| 72 | { | 73 | { |
| 73 | DO_COMPATIBILITY(aclnnEye, acl_op::eye(n, m, dtype, layout, device, pin_memory)); | 74 | DO_COMPATIBILITY(aclnnEye, acl_op::eye(n, m, dtype, layout, device, pin_memory)); |
| 75 | + TORCH_CHECK(n >= 0, "n must be greater or equal to 0, got ", n, OPS_ERROR(ErrCode::PARAM)); | ||
| 76 | + TORCH_CHECK(m >= 0, "m must be greater or equal to 0, got ", m, OPS_ERROR(ErrCode::PARAM)); | ||
| 74 | auto device_value = device_or_default(device); | 77 | auto device_value = device_or_default(device); |
| 75 | at::TensorOptions option = option.dtype(dtype) | 78 | at::TensorOptions option = option.dtype(dtype) |
| 76 | .layout(layout) | 79 | .layout(layout) |