MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / _sha256_tensor

Method _sha256_tensor

lightx2v/disagg/services/decoder.py:213–220  ·  view source on GitHub ↗
(tensor: Optional[torch.Tensor])

Source from the content-addressed store, hash-verified

211 def _buffer_view(buf: torch.Tensor, dtype: torch.dtype, shape: tuple[int, ...]) -> torch.Tensor:
212 view = torch.empty(0, dtype=dtype, device=buf.device)
213 view.set_(buf.untyped_storage(), 0, shape)
214 return view
215
216 def _sha256_tensor(tensor: Optional[torch.Tensor]) -> Optional[str]:
217 if tensor is None:
218 return None
219 data_tensor = tensor.detach()
220 if data_tensor.dtype == torch.bfloat16:
221 data_tensor = data_tensor.to(torch.float32)
222 data = data_tensor.contiguous().cpu().numpy().tobytes()
223 return hashlib.sha256(data).hexdigest()

Callers

nothing calls this directly

Calls 2

cpuMethod · 0.80
toMethod · 0.45

Tested by

no test coverage detected