mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-26 20:23:26 +00:00
[misc] update pre-commit and run all files (#4752)
* [misc] update pre-commit * [misc] run pre-commit * [misc] remove useless configuration files * [misc] ignore cuda for clang-format
This commit is contained in:
@@ -8,7 +8,7 @@ from ...registry import meta_patched_module
|
||||
@meta_patched_module.register(torch.nn.AvgPool1d)
|
||||
def torch_nn_avgpool1d(self, input):
|
||||
num_dim = input.dim()
|
||||
assert num_dim in [2, 3], f'expected the input to have 2 or 3 dimensions, but got {num_dim} dimensions'
|
||||
assert num_dim in [2, 3], f"expected the input to have 2 or 3 dimensions, but got {num_dim} dimensions"
|
||||
|
||||
l_in = input.shape[-1]
|
||||
|
||||
@@ -25,13 +25,13 @@ def torch_nn_avgpool1d(self, input):
|
||||
l_out = math.floor((l_in + 2 * padding[0] - kernel_size[0]) / stride[0] + 1)
|
||||
|
||||
result_shape = tuple(input.shape[:-1]) + (l_out,)
|
||||
return torch.empty(result_shape, device='meta')
|
||||
return torch.empty(result_shape, device="meta")
|
||||
|
||||
|
||||
@meta_patched_module.register(torch.nn.AvgPool2d)
|
||||
def torch_nn_avgpool2d(self, input):
|
||||
num_dim = input.dim()
|
||||
assert num_dim in [3, 4], f'expected the input to have 3 or 4 dimensions, but got {num_dim} dimensions'
|
||||
assert num_dim in [3, 4], f"expected the input to have 3 or 4 dimensions, but got {num_dim} dimensions"
|
||||
|
||||
h_in, w_in = input.shape[-2:]
|
||||
|
||||
@@ -52,13 +52,13 @@ def torch_nn_avgpool2d(self, input):
|
||||
h_out,
|
||||
w_out,
|
||||
)
|
||||
return torch.empty(result_shape, device='meta')
|
||||
return torch.empty(result_shape, device="meta")
|
||||
|
||||
|
||||
@meta_patched_module.register(torch.nn.AvgPool3d)
|
||||
def torch_nn_avgpool3d(self, input):
|
||||
num_dim = input.dim()
|
||||
assert num_dim in [4, 5], f'expected the input to have 4 or 5 dimensions, but got {num_dim} dimensions'
|
||||
assert num_dim in [4, 5], f"expected the input to have 4 or 5 dimensions, but got {num_dim} dimensions"
|
||||
|
||||
d_in, h_in, w_in = input.shape[-3:]
|
||||
|
||||
@@ -81,13 +81,13 @@ def torch_nn_avgpool3d(self, input):
|
||||
h_out,
|
||||
w_out,
|
||||
)
|
||||
return torch.empty(result_shape, device='meta')
|
||||
return torch.empty(result_shape, device="meta")
|
||||
|
||||
|
||||
@meta_patched_module.register(torch.nn.MaxPool1d)
|
||||
def torch_nn_maxpool1d(self, input):
|
||||
num_dim = input.dim()
|
||||
assert num_dim in [2, 3], f'expected the input to have 2 or 3 dimensions, but got {num_dim} dimensions'
|
||||
assert num_dim in [2, 3], f"expected the input to have 2 or 3 dimensions, but got {num_dim} dimensions"
|
||||
|
||||
l_in = input.shape[-1]
|
||||
|
||||
@@ -105,13 +105,13 @@ def torch_nn_maxpool1d(self, input):
|
||||
l_out = math.floor((l_in + 2 * padding[0] - dilation[0] * (kernel_size[0] - 1) - 1) / stride[0] + 1)
|
||||
|
||||
result_shape = tuple(input.shape[:-1]) + (l_out,)
|
||||
return torch.empty(result_shape, device='meta')
|
||||
return torch.empty(result_shape, device="meta")
|
||||
|
||||
|
||||
@meta_patched_module.register(torch.nn.MaxPool2d)
|
||||
def torch_nn_maxpool2d(self, input):
|
||||
num_dim = input.dim()
|
||||
assert num_dim in [3, 4], f'expected the input to have 3 or 4 dimensions, but got {num_dim} dimensions'
|
||||
assert num_dim in [3, 4], f"expected the input to have 3 or 4 dimensions, but got {num_dim} dimensions"
|
||||
|
||||
h_in, w_in = input.shape[-2:]
|
||||
|
||||
@@ -133,13 +133,13 @@ def torch_nn_maxpool2d(self, input):
|
||||
h_out,
|
||||
w_out,
|
||||
)
|
||||
return torch.empty(result_shape, device='meta')
|
||||
return torch.empty(result_shape, device="meta")
|
||||
|
||||
|
||||
@meta_patched_module.register(torch.nn.MaxPool3d)
|
||||
def torch_nn_maxpool3d(self, input):
|
||||
num_dim = input.dim()
|
||||
assert num_dim in [4, 5], f'expected the input to have 4 or 5 dimensions, but got {num_dim} dimensions'
|
||||
assert num_dim in [4, 5], f"expected the input to have 4 or 5 dimensions, but got {num_dim} dimensions"
|
||||
|
||||
d_in, h_in, w_in = input.shape[-3:]
|
||||
|
||||
@@ -163,7 +163,7 @@ def torch_nn_maxpool3d(self, input):
|
||||
h_out,
|
||||
w_out,
|
||||
)
|
||||
return torch.empty(result_shape, device='meta')
|
||||
return torch.empty(result_shape, device="meta")
|
||||
|
||||
|
||||
@meta_patched_module.register(torch.nn.AdaptiveAvgPool1d)
|
||||
@@ -175,7 +175,7 @@ def torch_nn_adapative_pooling_1d(self, input):
|
||||
else:
|
||||
output_size = self.output_size
|
||||
result_shape = tuple(input.shape[:-1]) + output_size
|
||||
return torch.empty(result_shape, device='meta')
|
||||
return torch.empty(result_shape, device="meta")
|
||||
|
||||
|
||||
@meta_patched_module.register(torch.nn.AdaptiveAvgPool2d)
|
||||
@@ -187,7 +187,7 @@ def torch_nn_adapative_pooling_2d(self, input):
|
||||
else:
|
||||
output_size = self.output_size
|
||||
result_shape = tuple(input.shape[:-2]) + output_size
|
||||
return torch.empty(result_shape, device='meta')
|
||||
return torch.empty(result_shape, device="meta")
|
||||
|
||||
|
||||
@meta_patched_module.register(torch.nn.AdaptiveAvgPool3d)
|
||||
@@ -199,4 +199,4 @@ def torch_nn_adapative_pooling_3d(self, input):
|
||||
else:
|
||||
output_size = self.output_size
|
||||
result_shape = tuple(input.shape[:-3]) + output_size
|
||||
return torch.empty(result_shape, device='meta')
|
||||
return torch.empty(result_shape, device="meta")
|
||||
|
Reference in New Issue
Block a user