Skip to content

Commit 0c63b54

Browse files
authored
add a test script for fx graph module Unserialization (#450)
* init 'symbolic_dimension_reifier' field in graph_net.json * remove unused files * add fx_graph_module_unserialize_test.sh
1 parent 3af85cf commit 0c63b54

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
set -x
3+
4+
GRAPH_NET_ROOT=$(python3 -c "import graph_net; import os; print(os.path.dirname(os.path.dirname(graph_net.__file__)))")
5+
DECOMPOSE_PATH=/tmp/decompose_workspace
6+
# DECOMPOSE_PATH=$GRAPH_NET_ROOT/decompose_test_level5_100
7+
8+
mkdir -p "$DECOMPOSE_PATH"
9+
10+
model_list="$GRAPH_NET_ROOT/graph_net/config/torch_samples_list.txt"
11+
# model_list="$GRAPH_NET_ROOT/graph_net/test/dev_model_list/validation_error_model_list.txt"
12+
13+
python3 -m graph_net.model_path_handler \
14+
--model-path-list $model_list \
15+
--handler-config=$(base64 -w 0 <<EOF
16+
{
17+
"handler_path": "$GRAPH_NET_ROOT/graph_net/torch/graph_decomposer.py",
18+
"handler_class_name": "NaiveDecomposerExtractor",
19+
"handler_config": {
20+
"resume": true,
21+
"model_path_prefix": "$GRAPH_NET_ROOT",
22+
"output_dir": "$DECOMPOSE_PATH",
23+
"split_positions": [],
24+
"chain_style": false,
25+
"group_head_and_tail": true
26+
}
27+
}
28+
EOF
29+
)
30+
31+
device_rewrite_sample_list=$DECOMPOSE_PATH/device_rewrite_sample_list.txt
32+
cat $model_list \
33+
| grep -v '# ' \
34+
| xargs -I {} find $DECOMPOSE_PATH/{} -name "model.py" \
35+
| xargs dirname \
36+
| xargs realpath --relative-to=$DECOMPOSE_PATH \
37+
| tee $device_rewrite_sample_list
38+
39+
DEVICE_REWRITE_WORKSPACE=$DECOMPOSE_PATH/device_rewrite
40+
41+
python3 -m graph_net.model_path_handler \
42+
--model-path-list $device_rewrite_sample_list \
43+
--handler-config $(base64 -w 0 <<EOF
44+
{
45+
"handler_path": "$GRAPH_NET_ROOT/graph_net/torch/sample_passes/device_rewrite_sample_pass.py",
46+
"handler_class_name": "DeviceRewriteSamplePass",
47+
"handler_config": {
48+
"device": "cuda",
49+
"resume": false,
50+
"model_path_prefix": "$DECOMPOSE_PATH",
51+
"output_dir": "$DEVICE_REWRITE_WORKSPACE"
52+
}
53+
}
54+
EOF
55+
)
56+
57+
58+
python3 -m graph_net.torch.test_compiler \
59+
--model-path-prefix $GRAPH_NET_ROOT \
60+
--allow-list $model_list \
61+
--compiler range_decomposer_validator \
62+
--device cuda \
63+
--config $(base64 -w 0 <<EOF
64+
{
65+
"model_path_prefix": "$GRAPH_NET_ROOT",
66+
"decomposed_root": "$DEVICE_REWRITE_WORKSPACE"
67+
}
68+
EOF
69+
) \
70+
2>&1 | tee "$DECOMPOSE_PATH/validation.log"
71+
72+
python3 -m graph_net.plot_ESt \
73+
--benchmark-path "$DECOMPOSE_PATH/validation.log" \
74+
--output-dir "$DECOMPOSE_PATH"

0 commit comments

Comments
 (0)