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

Function tensor_round

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

Source from the content-addressed store, hash-verified

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

Callers 1

_quantize_int8Method · 0.85

Calls 1

toMethod · 0.45

Tested by

no test coverage detected