You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Source code of custom_op is required **only when** corresponding operator is used in the module, and **no specific format** is required.
53
+
46
54
**Step 1: graph_net.torch.extract**
47
55
56
+
Import and wrap the model with `graph_net.torch.extract(name=model_name, dynamic=dynamic_mode)()` is all you need:
57
+
48
58
```bash
49
59
import graph_net
50
60
51
61
# Instantiate the model (e.g. a torchvision model)
52
62
model = ...
53
63
54
64
# Extract your own model
55
-
model = graph_net.torch.extract(name="model_name")(model)
56
-
57
-
# After running, the extracted graph will be saved to:
58
-
# $GRAPH_NET_EXTRACT_WORKSPACE/model_name/
65
+
model = graph_net.torch.extract(name="model_name", dynamic="True")(model)
59
66
```
60
67
61
-
For details, see docstring of `graph_net.torch.extract` defined in `graph_net/torch/extractor.py`
68
+
After running, the extracted graph will be saved to: `$GRAPH_NET_EXTRACT_WORKSPACE/model_name/`.
69
+
70
+
For more details, see docstring of `graph_net.torch.extract` defined in `graph_net/torch/extractor.py`.
62
71
63
72
**Step 2: graph_net.torch.validate**
73
+
74
+
To verify that the extracted model meets requirements, we use `graph_net.torch.validate` in CI tool and also ask contributors to self-check in advance:
75
+
64
76
```bash
65
-
# Verify that the extracted model meets requirements
All the **construction constraints** will be examined automatically. After passing validation, a unique `graph_hash.txt` will be generated and later checked in CI procedure to avoid redundant.
82
+
70
83
## ⚖️ Compiler Evaluation
71
84
72
85
**Step 1: Benchmark**
73
86
74
-
We use ```graph_net/benchmark_demo.sh``` to benchmark GraphNet computation graph samples:
87
+
We use `graph_net/benchmark_demo.sh` to benchmark GraphNet computation graph samples:
75
88
76
89
```bash
77
90
bash graph_net/benchmark_demo.sh &
78
91
```
79
92
80
-
The script runs ```graph_net.torch.test_compiler``` with specific batch and log configurations.
93
+
The script runs `graph_net.torch.test_compiler` with specific batch and log configurations.
81
94
82
-
Or you can customize and use ```graph_net.torch.test_compiler``` yourself:
95
+
Or you can customize and use `graph_net.torch.test_compiler` yourself:
# Note: if --compiler is omitted, PyTorch’s built-in compiler is used by default
94
107
```
95
108
96
-
After executing, ```graph_net.torch.test_compiler``` will:
109
+
After executing, `graph_net.torch.test_compiler` will:
97
110
1. Running the original model in eager mode to record a baseline.
98
111
2. Compiling the model with the specified backend (e.g., CINN, TVM, Inductor, TensorRT, XLA, BladeDISC).
99
112
3. Executing the compiled model and collecting its runtime and outputs.
100
113
4. Conduct speedup by comparing the compiled results against the baseline.
101
114
102
115
**Step 2: Analysis**
103
116
104
-
After processing, we provide ```graph_net/analysis.py``` to generate [violin plot](https://en.m.wikipedia.org/wiki/Violin_plot) based on the JSON results.
117
+
After processing, we provide `graph_net/analysis.py` to generate [violin plot](https://en.m.wikipedia.org/wiki/Violin_plot) based on the JSON results.
After executing, one summary plot of results on all compilers, as well as multiple sub-plots of results in categories (model tasks, Library...) on a single compiler will be exported.
113
126
114
-
The script is designed to process a file structure as ```/benchmark_path/compiler_name/category_name/``` (for example ```/benchmark_logs/paddle/nlp/```), and items on x-axis are identified by name of the folders. So you can modify ```read_all_speedups``` function to fit the benchmark settings on your demand.
127
+
The script is designed to process a file structure as `/benchmark_path/compiler_name/category_name/` (for example `/benchmark_logs/paddle/nlp/`), and items on x-axis are identified by name of the folders. So you can modify `read_all_speedups` function to fit the benchmark settings on your demand.
115
128
116
129
## 📌 Roadmap
117
130
@@ -120,7 +133,7 @@ The script is designed to process a file structure as ```/benchmark_path/compile
120
133
3. Extract samples from multi-GPU scenarios to support benchmarking and optimization for large-scale, distributed computing.
121
134
4. Enable splitting full graphs into independently optimized subgraphs and operator sequences.
122
135
123
-
**Vision**: GraphNet aims to lay the foundation for [ai4c](https://github.com/PaddlePaddle/ai4c) by enabling large-scale, systematic evaluation of tensor compiler optimizations.
136
+
**Vision**: GraphNet aims to lay the foundation for [ai4c](https://github.com/PaddlePaddle/ai4c) by enabling **large-scale, systematic evaluation** of tensor compiler optimizations, and providing a **dataset for models to learn** and transfer optimization strategies.
0 commit comments