Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
0e5ed76
tweak compilation add rewrite
AD1024 Nov 4, 2021
e3d1b20
[ add ] cplex ilp extraction
AD1024 Nov 4, 2021
a563bde
save changes
AD1024 Nov 4, 2021
3c50421
cargo fmt
AD1024 Nov 4, 2021
b0836b7
[ draft ] use egg ilp extraction
AD1024 Nov 5, 2021
c84df8d
[ update ] fix accelerator call information propagation
AD1024 Nov 6, 2021
09d6308
[ tweak ] infra + adapt api
AD1024 Nov 7, 2021
d87d844
update ilp extraction
AD1024 Nov 8, 2021
377fb3f
tweak scripts
AD1024 Nov 9, 2021
d49a64c
adapt to new api
AD1024 Nov 9, 2021
b0b0f57
change to use windows operator
AD1024 Nov 10, 2021
9f92b3c
Merge branch '3la-pldi-flexmatch-eval' of github.com:AD1024/flexmatch…
AD1024 Nov 10, 2021
7a2c38b
[ finish ] max pool example
AD1024 Nov 11, 2021
cdafe75
tweak cost model
AD1024 Nov 11, 2021
caedff0
[ add ] flexmatch end-to-end
AD1024 Nov 11, 2021
78091bd
[ add ] more of end-to-end evaluation of flexible matching
AD1024 Nov 11, 2021
82160d2
add readme for e2e tool
AD1024 Nov 11, 2021
30d5807
add example
AD1024 Nov 11, 2021
926a3d7
tweak
AD1024 Nov 11, 2021
043b97a
add quantization for vta
AD1024 Nov 13, 2021
9e7565c
add model import
AD1024 Nov 13, 2021
9665e3e
[ impl ] quantization for vta
AD1024 Nov 15, 2021
2c0c3ac
attempt to fix
AD1024 Nov 15, 2021
40fec63
[ fix ] model
AD1024 Nov 15, 2021
121142c
update dep
AD1024 Nov 15, 2021
d8459a8
disable ilp
AD1024 Nov 16, 2021
1c4495e
Propagate cplex dependency to Glenside so it's configurable
slyubomirsky Nov 16, 2021
6aec7f2
use relay quantization
AD1024 Nov 16, 2021
fd48e38
add BERT
AD1024 Nov 16, 2021
bc3cb65
setting matches the paper; stats scripts
AD1024 Nov 16, 2021
b98b559
Merge pull request #3 from slyubomirsky/configurable-cplex
AD1024 Nov 16, 2021
1a7f888
update quantization
AD1024 Nov 17, 2021
b26685f
Merge branch '3la-pldi-flexmatch-eval' of github.com:AD1024/flexmatch…
AD1024 Nov 17, 2021
56720f2
quant fix
AD1024 Nov 17, 2021
17010fd
add calibration back
AD1024 Nov 17, 2021
d6a28f6
add layerwise analysis
AD1024 Nov 17, 2021
012ba43
add mobilenet quantized
AD1024 Nov 17, 2021
9ab9044
add model
AD1024 Nov 17, 2021
227b4b3
add lstm support
AD1024 Nov 18, 2021
84c7e8f
Merge branch '3la-pldi-flexmatch-eval' of github.com:AD1024/flexmatch…
AD1024 Nov 18, 2021
94dc0c1
update eval for lstm
AD1024 Nov 18, 2021
be5896f
add quantized dense test
AD1024 Nov 18, 2021
9c6f821
add models
AD1024 Nov 19, 2021
2b23413
update glenside and tvm
gussmith23 Nov 19, 2021
cd06ddb
Update glenside to point to transofrmer branch
gussmith23 Nov 19, 2021
5576ed9
Get transformer flexmatch numbers
gussmith23 Nov 19, 2021
bd720c8
Need to simplify inference and simplify lets to --debug on transformer
gussmith23 Nov 19, 2021
ec6245f
Match more linear layers for flexasr
gussmith23 Nov 19, 2021
57ed9dd
Make ResMLP depth 5 the main ResMLP
gussmith23 Nov 19, 2021
7d421af
Update Glenside with bug fix
gussmith23 Nov 19, 2021
59ed6f3
Reorder passes and add note
gussmith23 Nov 19, 2021
3cf38b8
Switch to mobilenet v2
gussmith23 Nov 19, 2021
912816a
Merge pull request #7 from AD1024/gus-updates
AD1024 Nov 19, 2021
ad34f05
Disable rplex/cplex by default
gussmith23 Nov 19, 2021
da0fc8d
Update TVM and glenside
gussmith23 Dec 16, 2021
c1fb172
Update glenside
gussmith23 Dec 17, 2021
e3ebc77
Update tvm
gussmith23 Dec 17, 2021
dc333ca
Update tvm and glenside
gussmith23 Dec 17, 2021
9494c40
update tvm and glenside
gussmith23 Dec 18, 2021
7af09ca
update tvm and glenside
gussmith23 Dec 20, 2021
134919d
update glenside
gussmith23 Dec 20, 2021
8b4fd82
update glenside
gussmith23 Dec 22, 2021
9bb5bff
update TVM and glenside
gussmith23 Jan 31, 2022
3f8a7be
Update glenside after rebase
gussmith23 Feb 23, 2022
7e9ad9e
Update glenside
gussmith23 Feb 23, 2022
e7b8f70
Relay API update
gussmith23 Apr 28, 2022
484dfbd
Add new resnet50s
gussmith23 Jun 28, 2022
a8a117b
Add models accidentally ignored
gussmith23 Jul 5, 2022
25e45d3
Remove troublesome lines from gitignore
gussmith23 Jul 5, 2022
954f18d
Update glenside, fix filenames
gussmith23 Jul 5, 2022
dff31e0
Copy over models
gussmith23 Jul 5, 2022
e6a63b8
fix onnx add ops
AD1024 Jul 7, 2022
eed0079
fix padding dim compute
AD1024 Jul 7, 2022
273511d
fix maxpool2d
AD1024 Jul 7, 2022
44995b5
fix model
AD1024 Jul 7, 2022
209c733
fix bug
AD1024 Jul 7, 2022
3ea97dd
eval result
AD1024 Jul 7, 2022
654862d
update result
AD1024 Jul 7, 2022
026c7d4
Fix glenside dep
gussmith23 Aug 30, 2022
b29ecae
update glenside
gussmith23 Sep 28, 2022
aec8b26
add perf profiling
AD1024 Oct 26, 2022
1bbff9f
adopt tsim dense from vta benchmark
AD1024 Nov 7, 2022
f799faa
performance eval code
AD1024 Nov 9, 2022
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
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
__pycache__
*.json
!configs/*.json
*.relay
!tests/models
tests/params/
.pkl_memoize_py3
.pkl_memoize_py3
tests/data
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,27 @@ Flexible Matching via Equality Saturation
- Takes the **relay source file**, the output model and eclass analysis data json from EqSat
- Compiles the rewritten model back to a relay executable model and saves to a file
- Optional argument: `--debug`; instead of inserting accelerator calls, if this argument is passed, the equivalent relay function will be generated
- Example: `python3 compile_model.py models/resmlp.relay resmlp-rewritten.relay resmlp-rewritten.json resmlp-data.json linear-rewrites im2col-rewrites --debug`
- Example: `python3 compile_model.py models/resmlp.relay resmlp-rewritten.relay resmlp-rewritten.json resmlp-data.json linear-rewrites im2col-rewrites --debug`

# End-to-end compilation validation
```bash
python3 validate_compilation.py model ([--configs CONFIGS+] | [--defaults]) [--use-ilp] [--debug]
```
- `model`: resnet18; efficientnet; max_pool2d; mobilenet; resmlp
- `configs`: hlscnn-conv2d; flexasr-maxpool; im2col; vta-dense; linear-rewrites
- hlscnn-conv2d: `Conv2D` to HLSCNN
- flexasr-maxpool: `Max_pool2D` to FlexASR
- im2col: Convolutions to matmuls
- linear-rewrites: `nn.Linear` to FlexASR
- `--defaults`: if turned oon, use default configs
- `--use-ilp`: Use CPLEX ILP Solver to extract the rewritten model
- `--debug`: Use debug functions to replace accelerator calls for debug purposes

Example: `python3 validate_compilation.py resnet18 --configs im2col vta-dense --debug`

# Rewrite Config Structure
- rewrites :: `Dict[String, Array[Integer]]`. rewrite rules to apply
- composites :: `Dict[String (accelerator func names), String]`. Compiler composite region annotations
- compiler :: `Dict[String (accelerator func names), String]`. which compiler to use
- debug_functions :: `Dict[String (accelerator func names), String]`. debug functions for corresponding accelerator calls
- out_dtypes :: `Dict[String (accelerator func names), String (dtype names)]`. Output data type of the accelerator function.
17 changes: 17 additions & 0 deletions configs/flexasr-lstm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"rewrites": {
"flex-lstm": []
},
"composites": {
"flex-lstm": "ilaflex.lstm"
},
"compilers": {
"flex-lstm": "ilaflex"
},
"debug_functions": {
"flex-lstm": "lambda *inputs: tvm.parser.fromtext(open('./models/lstm-for-pldi-pattern.relay').read())['main'](*inputs)"
},
"out_dtypes": {
"flex-lstm": "float32"
}
}
9 changes: 6 additions & 3 deletions configs/flexasr-maxpool.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
"simplify-reduce-max": []
},
"composites": {
"flexasr-maxpool": "ilaflex.max_pool"
"flex-maxpool": "ilaflex.max_pool"
},
"compilers": {
"flexasr-maxpool": "ilaflex"
"flex-maxpool": "ilaflex"
},
"debug_functions": {
"flexasr-maxpool": "nn.max_pool2d"
"flex-maxpool": "lambda x: relay.expand_dims(relay.max(x, axis=0), axis=0)"
},
"out_dtypes": {
"flex-maxpool": "float32"
}
}
5 changes: 4 additions & 1 deletion configs/hlscnn-conv2d.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"hlscnn-conv2d": "ilacnn"
},
"debug_functions": {
"hlscnn-conv2d": "nn.conv2d"
"hlscnn-conv2d": "RelayOperators.RelayConv2D"
},
"out_dtypes": {
"hlscnn-conv2d": "float32"
}
}
12 changes: 12 additions & 0 deletions configs/im2col.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"rewrites": {
"flatten-unflatten-all-accesses": [],
"bubble-reshape-through-cartesian-product": [],
"bubble-reshape-through-compute-dot-product": [],
"access-reshape-to-relay": []
},
"composites": {},
"compilers": {},
"debug_functions": {},
"out_dtypes": {}
}
7 changes: 6 additions & 1 deletion configs/linear-rewrites.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"rewrites": {
"linear-rewrites": [],
"access-reshape-to-relay": [],
"flex-linear-rewrite": []
"flex-linear-rewrite": [],
"add_bias_add_to_dense": [],
"glenside_matmul_to_relay_dense": []
},
"composites": {
"flex-linear": "ilaflex.linear"
Expand All @@ -12,5 +14,8 @@
},
"debug_functions": {
"flex-linear": "lambda x, w, b: nn.bias_add(nn.dense(x, w), b)"
},
"out_dtypes": {
"flex-linear": "float32"
}
}
17 changes: 17 additions & 0 deletions configs/qnn-vta-dense.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"rewrites": {
"vta-dense-rewrite": []
},
"composites": {
"vta-dense": "ilavta.dense"
},
"compilers": {
"vta-dense": "ilavata"
},
"debug_functions": {
"vta-dense": "lambda x,w: nn.dense(x, w, out_dtype='int32')"
},
"out_dtypes": {
"vta-dense": "int32"
}
}
7 changes: 3 additions & 4 deletions configs/im2col-rewrites.json → configs/vta-dense.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"rewrites": {
"flatten-unflatten-all-accesses": [],
"bubble-reshape-through-cartesian-product": [],
"bubble-reshape-through-compute-dot-product": [],
"access-reshape-to-relay": [],
"vta-dense-rewrite": []
},
"composites": {
Expand All @@ -14,5 +10,8 @@
},
"debug_functions": {
"vta-dense": "nn.dense"
},
"out_dtypes": {
"vta-dense": "float32"
}
}
Binary file not shown.
Loading