(self, encoder_weight_list, lib_path, head_num, head_size, inter_size, d_model, is_remove_padding,
num_layer, num_bucket=32, max_distance=128, sparse=False, q_scaling=1.0, tensor_para_size=1, pipeline_para_size=1,
bart_with_bias=True, mbart=False, position_embedding_type=1, activation_type="gelu", layernorm_type="post_layernorm")
| 218 | |
| 219 | class FTBartEncoder(nn.Module): |
| 220 | def __init__(self, encoder_weight_list, lib_path, head_num, head_size, inter_size, d_model, is_remove_padding, |
| 221 | num_layer, num_bucket=32, max_distance=128, sparse=False, q_scaling=1.0, tensor_para_size=1, pipeline_para_size=1, |
| 222 | bart_with_bias=True, mbart=False, position_embedding_type=1, activation_type="gelu", layernorm_type="post_layernorm"): |
| 223 | super().__init__() |
| 224 | |
| 225 | self.use_mpi = dist.is_mpi_available() |
| 226 | |
| 227 | if self.use_mpi: |
| 228 | try: |
| 229 | dist.init_process_group(backend='mpi') |
| 230 | except: |
| 231 | print("[INFO] WARNING: Exception occurred in dist.init_process_group(backend = 'mpi'). Maybe the process group has been initialized somewhere else.") |
| 232 | else: |
| 233 | print("[INFO] MPI is not available in this PyTorch build.") |
| 234 | assert tensor_para_size == 1, "[FATAL] MPI is required for tensor_para_size > 1." |
| 235 | assert pipeline_para_size == 1, "[FATAL] MPI is required for pipeline_para_size > 1." |
| 236 | |
| 237 | torch.classes.load_library(lib_path) |
| 238 | try: |
| 239 | self.encoder = torch.classes.FasterTransformer.BartEncoder(*encoder_weight_list, head_num, head_size, inter_size, d_model, |
| 240 | is_remove_padding, num_layer, num_bucket, max_distance, sparse, q_scaling, tensor_para_size, pipeline_para_size, |
| 241 | bart_with_bias, mbart, position_embedding_type, activation_type, layernorm_type) |
| 242 | except: |
| 243 | self.encoder = torch.classes.FasterTransformerBartEncoder(*encoder_weight_list, head_num, head_size, inter_size, d_model, |
| 244 | is_remove_padding, num_layer, num_bucket, max_distance, sparse, q_scaling, tensor_para_size, pipeline_para_size, |
| 245 | bart_with_bias, mbart, position_embedding_type, activation_type, layernorm_type) |
| 246 | |
| 247 | def forward(self, input, seq_len, inputs_embeds=None): |
| 248 | output = self.encoder.forward(input, seq_len, inputs_embeds) |
nothing calls this directly
no test coverage detected