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

Method forward

src/fastertransformer/models/decoding/Decoding.cc:265–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263
264template<typename T>
265void Decoding<T>::forward(std::vector<Tensor>* output_tensors,
266 const std::vector<Tensor>* input_tensors,
267 const DecodingWeight<T>* decoding_weights)
268{
269 FT_LOG_DEBUG(__PRETTY_FUNCTION__);
270 // input_tensors:
271 // encoder_output [batch_size * beam, mem_max_seq_len, memory_hidden_dimension]
272 // encoder_sequence_length [batch_size * beam]
273
274 // output_tensors:
275 // output_ids [max_seq_len, batch_size, beam]
276 // parent_ids [max_seq_len, batch_size, beam]
277 // sequence_length [batch_size, beam], record the number of generated token, except the start token
278
279 // Step is from 1 ~ max_seq_len,
280 // When step = k, we put output ids and caches at step k, and the sequence_length would be k - 1 before
281 // complete this step.
282
283 std::unordered_map<std::string, Tensor> input_tensors_map{{"encoder_output", input_tensors->at(0)},
284 {"encoder_sequence_length", input_tensors->at(1)}};
285
286 std::unordered_map<std::string, Tensor> output_tensors_map{{"output_ids", output_tensors->at(0)},
287 {"parent_ids", output_tensors->at(1)},
288 {"sequence_length", output_tensors->at(2)}};
289 forward(&output_tensors_map, &input_tensors_map, decoding_weights);
290}
291
292template<typename T>
293void Decoding<T>::forward(std::unordered_map<std::string, Tensor>* output_tensors,

Callers

nothing calls this directly

Calls 7

invokeGeneralLayerNormFunction · 0.85
atMethod · 0.80
sizeMethod · 0.45
setupMethod · 0.45
GemmMethod · 0.45
isExistMethod · 0.45

Tested by

no test coverage detected