Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exp matcher #65

Merged
merged 80 commits into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
4a6f3ba
Simple BFS Graph Matcher
dboyliao Dec 11, 2018
6daeb73
Add tests (failed)
dboyliao Apr 13, 2019
2d9d193
Fix bug
dboyliao Apr 13, 2019
291f9c7
Syncing develop branch
dboyliao Apr 24, 2019
f15048f
syncing with develop, fix conflicts
dboyliao Apr 30, 2019
725e9d9
Add replace util methods
dboyliao May 1, 2019
ee54a0b
update tests
dboyliao May 1, 2019
53065fd
linear_reorder: wip
neil-tan May 4, 2019
0f802fb
ugraph seems correct, but tf quantization complains
neil-tan May 4, 2019
574f4d7
quantization passed, good until: unsupported op type in uTensor: Quan…
neil-tan May 4, 2019
b046b82
CONV_POOL_Transformer WIP: matcher graph completed
neil-tan May 5, 2019
7870206
fused, but with graph integrity problem
neil-tan May 5, 2019
55fbf77
output graph topologically correct
neil-tan May 5, 2019
eb1a510
attaching op_attribs to the fused-node
neil-tan May 5, 2019
324287c
Merge branch 'f/conv_pool_fusion' into PR69
neil-tan May 7, 2019
d232e02
fix up
neil-tan May 7, 2019
c7687e2
fixing the types
neil-tan May 7, 2019
e66bf54
resolving conflict
neil-tan May 8, 2019
82f5e96
generates some source files, weights file missing
neil-tan May 8, 2019
51641b8
inline transformer enabler hotfix
neil-tan May 8, 2019
428f59c
fixing GatherOpSnippet
neil-tan May 9, 2019
4a2cb98
minor bug fix
dboyliao May 1, 2019
4fc9b14
subgraph view
dboyliao May 6, 2019
1bf33d5
fix bug
dboyliao May 9, 2019
4a07522
merge develope: sync bug fix and resolve conflict
dboyliao May 9, 2019
ad00ee1
null tensor match support
dboyliao May 10, 2019
74a2140
update tests
dboyliao May 11, 2019
654a42f
showing unsupported ops with cli: show subcmd
dboyliao May 11, 2019
4be2c6a
Fix bug and update tests
dboyliao May 19, 2019
403ac64
Merge branch 'develop' into ubit
mbartling May 20, 2019
4aea27e
Add replace method and bugs fixed
dboyliao May 19, 2019
351c061
Add move synmatic to ugraph, op and tensor
dboyliao May 23, 2019
8abc65f
Add first simple replace test
dboyliao May 23, 2019
c250561
fix conflict
dboyliao May 23, 2019
fd525d9
update tests
dboyliao May 23, 2019
c73e9fa
minor refmt
dboyliao May 26, 2019
f0b938e
Fix merge graph bug
dboyliao May 26, 2019
235a529
syncing with develop
dboyliao May 27, 2019
ea059f2
merge ubit and fix conflicts
dboyliao May 27, 2019
c5f8766
linear reorder transformer impl. with matcher
dboyliao May 27, 2019
e5c665e
Add tests for linear reorder transformer
dboyliao May 27, 2019
654b20d
minor fix
dboyliao May 27, 2019
22185fa
remove hardcode graph viz
dboyliao May 31, 2019
5b773e1
Add ConvPool transformer, impl. with matcher api
dboyliao Jun 4, 2019
3736a42
make cli default pipeline using trans impl. with matcher
dboyliao Jun 4, 2019
390bccf
remove incorrect match logic and update tests
dboyliao Jun 5, 2019
5f9c22c
minor fix
dboyliao Jun 5, 2019
6997508
fix bug
dboyliao Jun 7, 2019
89a9c8d
Add tests for convpool transformer (testing against vgg-like graphs)
dboyliao Jun 7, 2019
a0c6ae6
refactor test script a bit
dboyliao Jun 7, 2019
587eadb
minor fix and update Pipfile
dboyliao Jun 8, 2019
0bd9bd8
minor refactor
dboyliao Jun 8, 2019
7aed322
matcher corner case fixed: null tensors
dboyliao Jun 9, 2019
3c03ab0
update README.md
dboyliao Jun 10, 2019
bfb3a12
minor fix and update tests for dropout transformer
dboyliao Jun 10, 2019
7dbd455
clean code
dboyliao Jun 10, 2019
115bfa5
enhance graph viz
dboyliao Jun 10, 2019
7b6502e
Add node fuse image to README.md
dboyliao Jun 10, 2019
ddca306
Add notes to README.md
dboyliao Jun 10, 2019
b797413
update cnn pb file (new dropout api)
dboyliao Jun 11, 2019
fae1129
remove out-dated notebooks
dboyliao Jun 11, 2019
e90771a
Update README and images
dboyliao Jun 11, 2019
2671be1
Add old dropout trans back, update tests and add subcmd
dboyliao Jun 12, 2019
1121d72
minor fix
dboyliao Jun 12, 2019
0e46059
Add lockfile
dboyliao Jun 12, 2019
18a7697
merge develop and resolve conflicts
dboyliao Jun 15, 2019
9d52464
fix bug and make op name pattern as kwarg to dropout tranformer
dboyliao Jun 16, 2019
85c1758
update doc str
dboyliao Jun 16, 2019
3648a27
add flags to show subcmd
dboyliao Jun 20, 2019
5ae22f7
Few bug fixs
dboyliao Jun 23, 2019
8744bb1
Fix bug and update REAME.md
dboyliao Jul 3, 2019
665ecfd
Add explanation to matcher show cases in README.md
dboyliao Jul 7, 2019
f56b40b
Fix typos
dboyliao Jul 7, 2019
40f846f
Fix quant fused conv op snippet bug
dboyliao Jul 11, 2019
9d4153c
remove old experimental matcher and cmsis nn transformer
dboyliao Jul 14, 2019
ca0d37b
update README.md
dboyliao Jul 17, 2019
ea99036
- setup basic doc files
dboyliao Jun 23, 2019
5677dd4
update README
dboyliao Jul 25, 2019
c3af9d3
Fix imgs path
dboyliao Jul 25, 2019
5024724
Add ir chapter
dboyliao Jul 25, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

tests:
rm -f tests_log.txt
make test_utils test_ir test_transformer test_frontend
make test_utils test_ir test_transformer test_frontend test_matcher

test_%:
@if [ -d .venv ]; then \
Expand All @@ -12,4 +12,4 @@ test_%:
fi;

clean:
rm -f tests_log.txt
rm -f tests_log.txt *.pdf
3 changes: 2 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ verify_ssl = true
name = "pypi"

[packages]
"e1839a8" = {path = ".", editable = true}
e1839a8 = {path = ".",editable = true}

[dev-packages]
pylint = "*"
Expand All @@ -14,3 +14,4 @@ rope = "*"
pillow = "*"
scipy = "*"
graphviz = "*"
sphinx = "*"
901 changes: 901 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

34 changes: 26 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,33 @@ In graph theory terminology, they are `leaf` nodes of your graph.

Run `utensor-cli convert --help` for detailed information.

# Example
# Use `utensor_cgen` as Library

## Subgraph Isomorphic Matcher and Nodes Fusion

With `uTensorGraphMatcher`, performing a subgraph isomorphic match, replace or manipulate the matched subgraph is just a few line of code!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With uTensorGraphMatcher, performing common subgraph tasks such as isomorphic matching along with replacing or manipulating the matched subgraph(s) takes just a few line of code!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make a note here that future transforms will be based on our own graph constructor/builder.


### Node Fusion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For these few examples, you might want one or two sentences explaining what they user is looking for.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I'll elaborate it more.


![conv-pool-fuce](images/conv_pool_fuse.png)

- Left: original graph
- Middle: matched convolution layer
- Right: replace the matched layer with specialized `QuantConvPool` node

### Dropout Layer Removal

![cnn-dropout](images/cnn_dropout.png)

- Left: original graph with dropout Layers
- Middle: matched dropout layers
- Right: graph with dropout layers removed

# Examples

- [Deep Multilayer Perceptron](https://github.com/uTensor/utensor_cgen/tree/develop/tests/deep_mlp)
- [End-to-End Convolution NN](https://github.com/uTensor/simple_cnn_tutorial)

Please refer to [tests/deep_mlp](https://github.com/uTensor/utensor_cgen/tree/develop/tests/deep_mlp) for detailed example

# User Guide

Expand All @@ -100,12 +124,6 @@ Following steps are a general guild for user how to porting a `TensorFlow` proto
2. run `make tests`
- Or you can use `pipenv run pytest tests` instead

# Known Limitations

- If you want to use dropout with placeholders for the `keep_prob`, you have to name the `keep_prob` placeholder by any name that starts with "keep_prob".
- You can still use any input tensor with name starts with "keep_prob" as long as it's not the output tensor of a placeholder node.
- You can't wrap `dropout` in any `namescope`

# Philosophy

- [12 Factor CLI App](https://medium.com/@jdxcode/12-factor-cli-apps-dd3c227a0e46?fbclid=IwAR1Gfq0D7oh3b-mXaIMV3RwYu39TAPrPXfz5sBKC4Rz1t-cckvC8WjBVl_w)
Expand Down
Binary file added images/cnn_dropout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/conv_pool_fuse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
]},
install_requires=[
'Jinja2',
'tensorflow',
'tensorflow==1.13.1',
'idx2numpy',
'attrs',
'click',
Expand Down
4 changes: 0 additions & 4 deletions tests/deep_cnn/cifar/__init__.py

This file was deleted.

101 changes: 0 additions & 101 deletions tests/deep_cnn/cifar/_cifar.py

This file was deleted.

42 changes: 0 additions & 42 deletions tests/deep_cnn/cifar/cs231n/data_utils.py

This file was deleted.

128 changes: 0 additions & 128 deletions tests/deep_cnn/cifar/dataset.py

This file was deleted.

Binary file modified tests/deep_cnn/cifar10_cnn.pb
Binary file not shown.
Loading