MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / decoder_inference

Function decoder_inference

demo/HuggingFace/T5/measurements.py:33–50  ·  view source on GitHub ↗
(
    t5_decoder, input_ids, encoder_last_hidden_state, timing_profile, use_cuda=True, use_cache=False, past_key_values=None
)

Source from the content-addressed store, hash-verified

31
32@use_cuda
33def decoder_inference(
34 t5_decoder, input_ids, encoder_last_hidden_state, timing_profile, use_cuda=True, use_cache=False, past_key_values=None
35):
36 # This implementation is a bit ugly. Moving implementation of the model to check HFRunner would be cleaner.
37 if isinstance(t5_decoder, TRTNativeRunner):
38 # Function is technically in T5TRTDecoder however due to circular import, TRTNativeRunner in this module scope
39 # implies the existence of this function.
40 t5_decoder.set_return_device("cuda" if use_cuda else "cpu")
41
42 def decoder_stmt():
43 t5_decoder(
44 input_ids=input_ids, encoder_hidden_states=encoder_last_hidden_state, use_cache=use_cache,
45 past_key_values=past_key_values
46 )
47
48 decoder_e2e_time = measure_python_inference_code(decoder_stmt, timing_profile)
49
50 return (decoder_stmt(), decoder_e2e_time)
51
52
53@use_cuda

Callers 3

execute_inferenceMethod · 0.90
execute_inferenceMethod · 0.90
execute_inferenceMethod · 0.90

Calls 3

decoder_stmtFunction · 0.70
set_return_deviceMethod · 0.45

Tested by

no test coverage detected