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

Function check_spec

exir/tensor.py:403–415  ·  view source on GitHub ↗
(tensor: torch.Tensor, spec: TensorSpec)

Source from the content-addressed store, hash-verified

401
402
403def check_spec(tensor: torch.Tensor, spec: TensorSpec) -> None:
404 internal_assert(
405 tensor.is_sparse == spec.is_sparse,
406 f"Tensor attribute 'is_sparse' is expected to be equal to '{spec.is_sparse}', actually got: '{tensor.is_sparse}'",
407 )
408 internal_assert(
409 tensor.shape == spec.shape,
410 f"Tensor attribute 'shape' is expected to be equal to '{spec.shape}', actually got: '{tensor.shape}'",
411 )
412 internal_assert(
413 tensor.dtype == spec.dtype,
414 f"Tensor attribute 'dtype' is expected to be equal to '{spec.dtype}', actually got: '{tensor.dtype}'",
415 )

Callers

nothing calls this directly

Calls 1

internal_assertFunction · 0.90

Tested by

no test coverage detected