已合并
[Inductor] fix AOTI update_constant_buffer bug #41499
zhucehw创建于 7月13日
[Inductor] fix AOTI update_constant_buffer bug #41499
已合并
共 2 个文件变更+5-5
| @@ -80,7 +80,7 @@ def activation_min_max(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor: | |||
| 80 | class Model(torch.nn.Module): | 80 | class Model(torch.nn.Module): |
| 81 | def __init__(self, dim=32): | 81 | def __init__(self, dim=32): |
| 82 | super().__init__() | 82 | super().__init__() |
| 83 | - self.fc1 = torch.nn.Linear(dim, dim, dtype=torch.float16) | 83 | + self.fc1 = torch.nn.Linear(dim, dim, dtype=torch.float32) |
| 84 | self.sigmoid = torch.nn.Sigmoid() | 84 | self.sigmoid = torch.nn.Sigmoid() |
| 85 | 85 | ||
| 86 | def forward(self, x, y, z): | 86 | def forward(self, x, y, z): |
| @@ -117,11 +117,11 @@ class Model(torch.nn.Module): | |||
| 117 | class TestAotiUserDefinedOp(TestUtils): | 117 | class TestAotiUserDefinedOp(TestUtils): |
| 118 | def generate_input_tensor(self, batch_size=8, dim=32, device="npu"): | 118 | def generate_input_tensor(self, batch_size=8, dim=32, device="npu"): |
| 119 | x_input = torch.arange(0, batch_size * dim, 1, device=device).reshape([batch_size, dim]) | 119 | x_input = torch.arange(0, batch_size * dim, 1, device=device).reshape([batch_size, dim]) |
| 120 | - x_input = 1.0 / x_input.to(torch.float16) | 120 | + x_input = 1.0 / x_input.to(torch.float32) |
| 121 | y_input = torch.arange(batch_size * dim, 0, -1, device=device).reshape([batch_size, dim]) | 121 | y_input = torch.arange(batch_size * dim, 0, -1, device=device).reshape([batch_size, dim]) |
| 122 | - y_input = 1.0 / y_input.to(torch.float16) | 122 | + y_input = 1.0 / y_input.to(torch.float32) |
| 123 | # z_input is a cpu input tensor | 123 | # z_input is a cpu input tensor |
| 124 | - z_input = torch.ones(batch_size * dim, device="cpu", dtype=torch.float16).reshape([batch_size, dim]) | 124 | + z_input = torch.ones(batch_size * dim, device="cpu", dtype=torch.float32).reshape([batch_size, dim]) |
| 125 | return x_input, y_input, z_input | 125 | return x_input, y_input, z_input |
| 126 | 126 | ||
| 127 | 127 | ||
| @@ -442,7 +442,7 @@ public: | |||
| 442 | aoti_torch_get_storage_size(tensor, &constant_size); | 442 | aoti_torch_get_storage_size(tensor, &constant_size); |
| 443 | 443 | ||
| 444 | AOTI_RUNTIME_DEVICE_CHECK(aclrtMemcpy(internal_constants_ptr, constant_size, user_constant_ptr, | 444 | AOTI_RUNTIME_DEVICE_CHECK(aclrtMemcpy(internal_constants_ptr, constant_size, user_constant_ptr, |
| 445 | - constant_size, ACL_MEMCPY_HOST_TO_DEVICE)); | 445 | + constant_size, ACL_MEMCPY_DEFAULT)); |
| 446 | 446 | ||
| 447 | memcpy(internal_constants_ptr, user_constant_ptr, constant_size); | 447 | memcpy(internal_constants_ptr, user_constant_ptr, constant_size); |
| 448 | 448 | ||