Skip to content

A library for complex tensor operations not contained in pytorch

Notifications You must be signed in to change notification settings

fleonce/torchcheck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TorchCheck

A simple PyTorch library written in c++ to add assert statements for shapes:

import torch
from torchcheck import assert_shape

x = torch.randn((30, 30))
# will not fail
assert_shape(x, (30, 30))
# will fail:
assert_shape(x, (60, 30))

The benefit of writing the code in c++ is that stacktraces in python then reference to the location where the function has been called, not where the actual shape verification has failed:

File "test.py", line 9, in <module>
    assert_shape(x, (60, 30))
RuntimeError: Expected shape of tensor to be: [60, 30] but got: [30, 30]

Installation:

Make sure to install torch first

pip install torch
pip install git+https://github.com/fleonce/torchcheck.git

About

A library for complex tensor operations not contained in pytorch

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages