Skip to content

Commit c4c4480

Browse files
committed
Fixes #17. add JAX support. Changed exception detection algorithm so that it's not just something special about the exception message, but also traps anything triggered within one of the libraries. Update examples.
1 parent c7d3f7c commit c4c4480

5 files changed

Lines changed: 1421 additions & 410 deletions

File tree

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,25 @@ TensorSensor augments the message with more information about which operator cau
3535
Cause: @ on tensor operand W w/shape [764, 100] and operand X.T w/shape [764, 200]
3636
```
3737

38+
You can also get the full computation graph for an expression that includes all of these sub result shapes.
39+
40+
```python
41+
g = tsensor.astviz("b = W@b + (h+3).dot(h) + torch.abs(torch.tensor(34))", sys._getframe()) # eval, highlight vectors
42+
g
43+
```
44+
45+
yields the following abstract syntax tree with shapes:
46+
47+
<img src="images/ast.svg" width="400">
3848

3949
## Install
4050

4151
```
4252
pip install tensor-sensor # This will only install the library for you
4353
pip install tensor-sensor[torch] # install pytorch related dependency
4454
pip install tensor-sensor[tensorflow] # install tensorflow related dependency
45-
pip install tensor-sensor[all] # install both tensorflow and pytorch
55+
pip install tensor-sensor[jax] # install jax, jaxlib
56+
pip install tensor-sensor[all] # install tensorflow, pytorch, jax
4657
```
4758

4859
which gives you module `tsensor`. I developed and tested with the following versions
@@ -56,6 +67,9 @@ numpy 1.18.5
5667
numpydoc 1.1.0
5768
$ pip list | grep -i torch
5869
torch 1.6.0
70+
$ pip list | grep -i jax
71+
jax 0.2.6
72+
jaxlib 0.1.57
5973
```
6074

6175
### Graphviz for tsensor.astviz()
@@ -115,5 +129,3 @@ $ pip install .
115129
### TODO
116130

117131
* can i call pyviz in debugger?
118-
* try on real examples
119-
* `dict(W=[3,0,1,2], b=[1,0])` that would indicate (300, 30, 60, 3) would best be displayed as (30,60,3, 300) and b would be first dimension last and last dimension first

0 commit comments

Comments
 (0)