mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-06-19 04:02:17 +00:00
[NFC] polish colossalai/nn/layer/parallel_2d/layers.py code style (#976)
This commit is contained in:
parent
b67eebd20f
commit
18542b47fc
@ -182,7 +182,7 @@ class Linear2D(ParallelLayer):
|
|||||||
def forward(self, x: Tensor) -> Tensor:
|
def forward(self, x: Tensor) -> Tensor:
|
||||||
# input: [m/q, n/q, k/q]
|
# input: [m/q, n/q, k/q]
|
||||||
# output: [m/q, n/q, h/q]
|
# output: [m/q, n/q, h/q]
|
||||||
out_shape = x.shape[:-1] + (self.hidden_size_per_partition, )
|
out_shape = x.shape[:-1] + (self.hidden_size_per_partition,)
|
||||||
|
|
||||||
output = Matmul_AB_2D.apply(x, self.weight, self.summa_dim, out_shape, self.row_rank, self.col_rank,
|
output = Matmul_AB_2D.apply(x, self.weight, self.summa_dim, out_shape, self.row_rank, self.col_rank,
|
||||||
ParallelMode.PARALLEL_2D_ROW, ParallelMode.PARALLEL_2D_COL, self.data_parallel_rank,
|
ParallelMode.PARALLEL_2D_ROW, ParallelMode.PARALLEL_2D_COL, self.data_parallel_rank,
|
||||||
@ -1012,7 +1012,7 @@ class Classifier2D(ParallelLayer):
|
|||||||
destination.update(local_state)
|
destination.update(local_state)
|
||||||
|
|
||||||
def forward(self, input_: Tensor) -> Tensor:
|
def forward(self, input_: Tensor) -> Tensor:
|
||||||
out_shape = input_.shape[:-1] + (self.num_classes, )
|
out_shape = input_.shape[:-1] + (self.num_classes,)
|
||||||
|
|
||||||
return classifier_2d(input_, self.weight, self.bias, self.summa_dim, out_shape, self.row_rank, self.col_rank,
|
return classifier_2d(input_, self.weight, self.bias, self.summa_dim, out_shape, self.row_rank, self.col_rank,
|
||||||
ParallelMode.PARALLEL_2D_ROW, ParallelMode.PARALLEL_2D_COL, self.data_parallel_rank,
|
ParallelMode.PARALLEL_2D_ROW, ParallelMode.PARALLEL_2D_COL, self.data_parallel_rank,
|
||||||
@ -1186,7 +1186,7 @@ class VocabParallelClassifier2D(ParallelLayer):
|
|||||||
def forward(self, x: Tensor) -> Tensor:
|
def forward(self, x: Tensor) -> Tensor:
|
||||||
# input: [m/q, n/q, k/q]
|
# input: [m/q, n/q, k/q]
|
||||||
# output: [m/q, n/q, h/q]
|
# output: [m/q, n/q, h/q]
|
||||||
out_shape = x.shape[:-1] + (self.output_size_per_partition, )
|
out_shape = x.shape[:-1] + (self.output_size_per_partition,)
|
||||||
|
|
||||||
output = Matmul_ABT_2D.apply(x, self.weight, self.summa_dim, out_shape, self.row_rank, self.col_rank,
|
output = Matmul_ABT_2D.apply(x, self.weight, self.summa_dim, out_shape, self.row_rank, self.col_rank,
|
||||||
ParallelMode.PARALLEL_2D_ROW, ParallelMode.PARALLEL_2D_COL,
|
ParallelMode.PARALLEL_2D_ROW, ParallelMode.PARALLEL_2D_COL,
|
||||||
|
Loading…
Reference in New Issue
Block a user