MCPcopy Create free account
hub / github.com/NVIDIA/FasterTransformer / __init__

Method __init__

examples/pytorch/decoder/utils/ft_decoder.py:120–132  ·  view source on GitHub ↗
(self, head_num, head_size, mem_hidden_dim, layer_num, weights, args)

Source from the content-addressed store, hash-verified

118
119class FTDecoder(nn.Module):
120 def __init__(self, head_num, head_size, mem_hidden_dim, layer_num, weights, args):
121 super().__init__()
122 self.args = args
123 self.is_fp16 = True if self.args.data_type == 'fp16' else False
124 self.layer_num = layer_num
125 self.use_batch_major_op_cache, self.op_cache_dim_x = get_op_cache_config(head_size, self.is_fp16)
126
127 torch.classes.load_library(args.decoder_ths_path)
128 try:
129 self.dec_layer = torch.classes.FasterTransformer.Decoder(*weights.w, head_num, head_size, head_num * head_size * 4, layer_num, mem_hidden_dim)
130 except:
131 # legacy ths for 20.03 image
132 self.dec_layer = torch.classes.FasterTransformerDecoder(*weights.w, head_num, head_size, head_num * head_size * 4, layer_num, mem_hidden_dim)
133
134 def forward(self, inputs, memory, memory_seq_lens, self_cache, mem_cache, sequence_lengths, step):
135 dtype = torch.half if self.is_fp16 else torch.float32

Callers

nothing calls this directly

Calls 3

DecoderMethod · 0.80
get_op_cache_configFunction · 0.70

Tested by

no test coverage detected