MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / tensor_round

Function tensor_round

deepspeed/inference/quantization/utils.py:40–45  ·  view source on GitHub ↗
(tensor: Tensor)

Source from the content-addressed store, hash-verified

38
39
40def tensor_round(tensor: Tensor) -> Tensor:
41 if tensor.device.type == 'cpu' and tensor.dtype == torch.float16:
42 # CPU does not support FP16 round
43 return tensor.to(dtype=torch.float32).round_().to(dtype=torch.float16)
44 else:
45 return tensor.round_()
46
47
48class Quantizer:

Callers 1

_quantize_int8Method · 0.85

Calls 1

toMethod · 0.45

Tested by

no test coverage detected