MCPcopy
hub / github.com/NVIDIA/TensorRT-LLM / numpy_to_torch

Function numpy_to_torch

tensorrt_llm/_utils.py:67–73  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

65
66
67def numpy_to_torch(x):
68 if x.dtype == np_bfloat16:
69 return torch.from_numpy(x.view(np.int16)).view(torch.bfloat16)
70 elif x.dtype == np_float8:
71 return torch.from_numpy(x.view(np.int8)).view(torch.float8_e4m3fn)
72 else:
73 return torch.from_numpy(x)
74
75
76def numpy_to_dtype(x, dtype: str):

Callers 15

covert_and_saveFunction · 0.90
add_trt_llm_weightFunction · 0.90
walkMethod · 0.90
add_trt_llm_weightFunction · 0.90
quantizeFunction · 0.90
from_hugging_faceMethod · 0.90
numpy_to_dtypeFunction · 0.85
save_checkpointMethod · 0.85
fuse_gate_mlpFunction · 0.85

Calls 1

viewMethod · 0.45

Tested by

no test coverage detected