MCPcopy Create free account
hub / github.com/pytorch/executorch / from_tensor

Method from_tensor

backends/test/harness/error_statistics.py:30–40  ·  view source on GitHub ↗

Creates a TensorStatistics object from a tensor.

(cls, tensor: torch.Tensor)

Source from the content-addressed store, hash-verified

28
29 @classmethod
30 def from_tensor(cls, tensor: torch.Tensor) -> "TensorStatistics":
31 """Creates a TensorStatistics object from a tensor."""
32 flattened = torch.flatten(tensor)
33 return cls(
34 shape=tensor.shape,
35 numel=tensor.numel(),
36 median=torch.median(flattened).item(),
37 mean=flattened.mean().item(),
38 max=flattened.max().item(),
39 min=flattened.min().item(),
40 )
41
42
43@dataclass

Callers 15

placeholderMethod · 0.45
from_tensorsMethod · 0.45
_create_gru_nodeMethod · 0.45
_create_split_nodeMethod · 0.45
create_concat_nodeMethod · 0.45
_reshape_w_node_to_2dMethod · 0.45
_create_mul_op_nodeMethod · 0.45
_create_mul_data_nodeMethod · 0.45

Calls 4

flattenMethod · 0.80
numelMethod · 0.80
maxMethod · 0.45
minMethod · 0.45