mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-28 04:55:25 +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:
@@ -11,13 +11,14 @@ def torch_nn_conv1d(self, input):
|
||||
# at https://pytorch.org/docs/stable/generated/torch.nn.Conv1d.html#torch.nn.Conv1d
|
||||
l_in = input.shape[-1]
|
||||
c_out = self.out_channels
|
||||
l_out = math.floor((l_in + 2 * self.padding[0] - self.dilation[0] *
|
||||
(self.kernel_size[0] - 1) - 1) / self.stride[0] + 1)
|
||||
l_out = math.floor(
|
||||
(l_in + 2 * self.padding[0] - self.dilation[0] * (self.kernel_size[0] - 1) - 1) / self.stride[0] + 1
|
||||
)
|
||||
result_shape = input.shape[:-2] + (
|
||||
c_out,
|
||||
l_out,
|
||||
)
|
||||
return torch.empty(result_shape, device='meta')
|
||||
return torch.empty(result_shape, device="meta")
|
||||
|
||||
|
||||
@meta_patched_module.register(torch.nn.Conv2d)
|
||||
@@ -26,16 +27,18 @@ def torch_nn_conv2d(self, input):
|
||||
# at https://pytorch.org/docs/stable/generated/torch.nn.Conv1d.html#torch.nn.Conv2d
|
||||
h_in, w_in = input.shape[-2:]
|
||||
c_out = self.out_channels
|
||||
h_out = math.floor((h_in + 2 * self.padding[0] - self.dilation[0] *
|
||||
(self.kernel_size[0] - 1) - 1) / self.stride[0] + 1)
|
||||
w_out = math.floor((w_in + 2 * self.padding[1] - self.dilation[1] *
|
||||
(self.kernel_size[1] - 1) - 1) / self.stride[1] + 1)
|
||||
h_out = math.floor(
|
||||
(h_in + 2 * self.padding[0] - self.dilation[0] * (self.kernel_size[0] - 1) - 1) / self.stride[0] + 1
|
||||
)
|
||||
w_out = math.floor(
|
||||
(w_in + 2 * self.padding[1] - self.dilation[1] * (self.kernel_size[1] - 1) - 1) / self.stride[1] + 1
|
||||
)
|
||||
result_shape = input.shape[:-3] + (
|
||||
c_out,
|
||||
h_out,
|
||||
w_out,
|
||||
)
|
||||
return torch.empty(result_shape, device='meta')
|
||||
return torch.empty(result_shape, device="meta")
|
||||
|
||||
|
||||
@meta_patched_module.register(torch.nn.Conv3d)
|
||||
@@ -44,19 +47,22 @@ def torch_nn_conv3d(self, input):
|
||||
# at https://pytorch.org/docs/stable/generated/torch.nn.Conv1d.html#torch.nn.Conv3d
|
||||
d_in, h_in, w_in = input.shape[-3:]
|
||||
c_out = self.out_channels
|
||||
d_out = math.floor((d_in + 2 * self.padding[0] - self.dilation[0] *
|
||||
(self.kernel_size[0] - 1) - 1) / self.stride[0] + 1)
|
||||
h_out = math.floor((h_in + 2 * self.padding[1] - self.dilation[1] *
|
||||
(self.kernel_size[1] - 1) - 1) / self.stride[1] + 1)
|
||||
w_out = math.floor((w_in + 2 * self.padding[2] - self.dilation[2] *
|
||||
(self.kernel_size[2] - 1) - 1) / self.stride[2] + 1)
|
||||
d_out = math.floor(
|
||||
(d_in + 2 * self.padding[0] - self.dilation[0] * (self.kernel_size[0] - 1) - 1) / self.stride[0] + 1
|
||||
)
|
||||
h_out = math.floor(
|
||||
(h_in + 2 * self.padding[1] - self.dilation[1] * (self.kernel_size[1] - 1) - 1) / self.stride[1] + 1
|
||||
)
|
||||
w_out = math.floor(
|
||||
(w_in + 2 * self.padding[2] - self.dilation[2] * (self.kernel_size[2] - 1) - 1) / self.stride[2] + 1
|
||||
)
|
||||
result_shape = input.shape[:-4] + (
|
||||
c_out,
|
||||
d_out,
|
||||
h_out,
|
||||
w_out,
|
||||
)
|
||||
return torch.empty(result_shape, device='meta')
|
||||
return torch.empty(result_shape, device="meta")
|
||||
|
||||
|
||||
@meta_patched_module.register(torch.nn.ConvTranspose1d)
|
||||
@@ -65,13 +71,18 @@ def torch_nn_convtranspose1d(self, input):
|
||||
# at https://pytorch.org/docs/stable/generated/torch.nn.ConvTranspose1d.html
|
||||
l_in = input.shape[-1]
|
||||
c_out = self.out_channels
|
||||
l_out = math.floor((l_in - 1) * self.stride[0] - 2 * self.padding[0] + self.dilation[0] *
|
||||
(self.kernel_size[0] - 1) + self.output_padding[0] + 1)
|
||||
l_out = math.floor(
|
||||
(l_in - 1) * self.stride[0]
|
||||
- 2 * self.padding[0]
|
||||
+ self.dilation[0] * (self.kernel_size[0] - 1)
|
||||
+ self.output_padding[0]
|
||||
+ 1
|
||||
)
|
||||
result_shape = input.shape[:-2] + (
|
||||
c_out,
|
||||
l_out,
|
||||
)
|
||||
return torch.empty(result_shape, device='meta')
|
||||
return torch.empty(result_shape, device="meta")
|
||||
|
||||
|
||||
@meta_patched_module.register(torch.nn.ConvTranspose2d)
|
||||
@@ -80,16 +91,26 @@ def torch_nn_convtranspose2d(self, input):
|
||||
# at https://pytorch.org/docs/stable/generated/torch.nn.ConvTranspose2d.html
|
||||
h_in, w_in = input.shape[-2:]
|
||||
c_out = self.out_channels
|
||||
h_out = math.floor((h_in - 1) * self.stride[0] - 2 * self.padding[0] + self.dilation[0] *
|
||||
(self.kernel_size[0] - 1) + self.output_padding[0] + 1)
|
||||
w_out = math.floor((w_in - 1) * self.stride[1] - 2 * self.padding[1] + self.dilation[1] *
|
||||
(self.kernel_size[1] - 1) + self.output_padding[1] + 1)
|
||||
h_out = math.floor(
|
||||
(h_in - 1) * self.stride[0]
|
||||
- 2 * self.padding[0]
|
||||
+ self.dilation[0] * (self.kernel_size[0] - 1)
|
||||
+ self.output_padding[0]
|
||||
+ 1
|
||||
)
|
||||
w_out = math.floor(
|
||||
(w_in - 1) * self.stride[1]
|
||||
- 2 * self.padding[1]
|
||||
+ self.dilation[1] * (self.kernel_size[1] - 1)
|
||||
+ self.output_padding[1]
|
||||
+ 1
|
||||
)
|
||||
result_shape = input.shape[:-3] + (
|
||||
c_out,
|
||||
h_out,
|
||||
w_out,
|
||||
)
|
||||
return torch.empty(result_shape, device='meta')
|
||||
return torch.empty(result_shape, device="meta")
|
||||
|
||||
|
||||
@meta_patched_module.register(torch.nn.ConvTranspose3d)
|
||||
@@ -98,16 +119,31 @@ def torch_nn_convtranspose3d(self, input):
|
||||
# at https://pytorch.org/docs/stable/generated/torch.nn.ConvTranspose3d.html
|
||||
d_in, h_in, w_in = input.shape[-3:]
|
||||
c_out = self.out_channels
|
||||
d_out = math.floor((d_in - 1) * self.stride[0] - 2 * self.padding[0] + self.dilation[0] *
|
||||
(self.kernel_size[0] - 1) + self.output_padding[0] + 1)
|
||||
h_out = math.floor((h_in - 1) * self.stride[1] - 2 * self.padding[1] + self.dilation[1] *
|
||||
(self.kernel_size[1] - 1) + self.output_padding[1] + 1)
|
||||
w_out = math.floor((w_in - 1) * self.stride[2] - 2 * self.padding[2] + self.dilation[2] *
|
||||
(self.kernel_size[2] - 1) + self.output_padding[2] + 1)
|
||||
d_out = math.floor(
|
||||
(d_in - 1) * self.stride[0]
|
||||
- 2 * self.padding[0]
|
||||
+ self.dilation[0] * (self.kernel_size[0] - 1)
|
||||
+ self.output_padding[0]
|
||||
+ 1
|
||||
)
|
||||
h_out = math.floor(
|
||||
(h_in - 1) * self.stride[1]
|
||||
- 2 * self.padding[1]
|
||||
+ self.dilation[1] * (self.kernel_size[1] - 1)
|
||||
+ self.output_padding[1]
|
||||
+ 1
|
||||
)
|
||||
w_out = math.floor(
|
||||
(w_in - 1) * self.stride[2]
|
||||
- 2 * self.padding[2]
|
||||
+ self.dilation[2] * (self.kernel_size[2] - 1)
|
||||
+ self.output_padding[2]
|
||||
+ 1
|
||||
)
|
||||
result_shape = input.shape[:-4] + (
|
||||
c_out,
|
||||
d_out,
|
||||
h_out,
|
||||
w_out,
|
||||
)
|
||||
return torch.empty(result_shape, device='meta')
|
||||
return torch.empty(result_shape, device="meta")
|
||||
|
Reference in New Issue
Block a user