A tool to control checking sparse tensor invariants.
The following options exists to manage sparsr tensor invariants checking in sparse tensor construction:
Using a context manager:
with torch.sparse.check_sparse_tensor_invariants(): run_my_model()
Using a procedural approach:
prev_checks_enabled = torch.sparse.check_sparse_tensor_invariants.is_enabled() torch.sparse.check_sparse_tensor_invariants.enable() run_my_model() if not prev_checks_enabled: torch.sparse.check_sparse_tensor_invariants.disable()
Using function decoration:
@torch.sparse.check_sparse_tensor_invariants() def run_my_model(): ... run_my_model()
Using check_invariants
keyword argument in sparse tensor constructor call. For example:
>>> torch.sparse_csr_tensor([0, 1, 3], [0, 1], [1, 2], check_invariants=True) Traceback (most recent call last): File "<stdin>", line 1, in <module> RuntimeError: `crow_indices[..., -1] == nnz` is not satisfied.
Disable sparse tensor invariants checking in sparse tensor constructors.
See torch.sparse.check_sparse_tensor_invariants.enable()
for more information.
Enable sparse tensor invariants checking in sparse tensor constructors.
Note
The sparse tensor invariants check flag is effective to all sparse tensor constructors, both in Python and ATen.
The flag can be locally overridden by the check_invariants
optional argument of the sparse tensor constructor functions.
Return True if the sparse tensor invariants checking is enabled.
Access comprehensive developer documentation for PyTorch
View Docs TutorialsGet in-depth tutorials for beginners and advanced developers
View Tutorials ResourcesFind development resources and get your questions answered
View ResourcesRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4