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
Copy file name to clipboardExpand all lines: model/POSET-RL/README.md
+16-8
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,14 @@
1
1
# POSET-RL
2
2
3
-
POSET-RL uses a reinforcement learning approach as the search space of optimization sequences is too big to enumerate. For a compiler with m optimization passes, if the sequence length is fixed as n, then there can be potentially mn combinations, allowing repetitions. The reinforcement learning model is trained and evaluated on programs that are represented using IR2Vec embeddings. The action space contains the subsequences created using the Oz dependence graph (ODG). Sequences are constructed from this graph by finding walks that start and end at critical nodes (with degree greater than a value k).[slides](https://llvm.org/devmtg/2022-04-03/slides/POSET-RL.Phase.ordering.for.Optimizing.Size.and.Execution.Time.using.Reinforcement.Learning.pdf)
3
+
# POSET-RL
4
+
POSET-RL uses a reinforcement learning approach to find pass sequence (for optimal code size + execution time), as the search space of optimization sequences is too big to enumerate. For a compiler with `m` optimization passes, if the sequence length is fixed as `n`, then there can be potentially `mxn` combinations, allowing repetitions.
5
+
6
+
This repo contains the source code and relevant information described in the [paper](https://ieeexplore.ieee.org/abstract/document/9804673) ([arXiv](https://arxiv.org/abs/2208.04238), [slides](https://llvm.org/devmtg/2022-04-03/slides/POSET-RL.Phase.ordering.for.Optimizing.Size.and.Execution.Time.using.Reinforcement.Learning.pdf)).
7
+
Please see [here](https://compilers.cse.iith.ac.in/projects/posetrl) for more details.
8
+
4
9
> POSET-RL: Phase ordering for Optimizing Size and Execution Time using Reinforcement Learning: Shalini Jain, Yashas Andaluri, S. VenkataKeerthy and Ramakrishna Upadrasta
5
10
11
+
6
12
## Environment Setup
7
13
8
14
- Copy the environment `.yml` files from `/path/to/ml-llvm-project/model/POSET-RL/posetrl_env.yml` to the home directory
@@ -28,25 +34,27 @@ POSET-RL uses a reinforcement learning approach as the search space of optimizat
28
34
```bash
29
35
cd ml-llvm-project/model/POSET_RL/src
30
36
31
-
python experiment.py --llvm_dir=<ml-llvm-project/build> --train_dir=<path_to_training_data> --train_iterations=<no.ofiterations in training> --use_grpc
37
+
python experiment.py --llvm_dir=<ml-llvm-project/build> --train_dir=<path_to_training_data> --train_iterations=<no.ofiterations in training> --use_grpc
38
+
39
+
#The --train_dir option must specify a path to a directory of .ll files
32
40
```
33
41
### Pipes
34
42
```bash
35
43
cd ml-llvm-project/model/POSET_RL/src
36
44
37
-
python experiment.py --llvm_dir=<ml-llvm-project/build> --train_dir=<path_to_training_data> --train_iterations=<no.ofiterations in training>--use_pipe --data_format=<json or bytes>
45
+
python experiment.py --llvm_dir=<ml-llvm-project/build> --train_dir=<path_to_training_data> --train_iterations=<no.ofiterations in training> --use_pipe --data_format=<json or bytes>
38
46
47
+
#The --train_dir option must specify a path to a directory of .ll files
39
48
#Model will be generated as a pytorch checkpoint in ml-llvm-project/model/checkpoint_dir after every 10 epochs
40
49
#The output of the above generates the training logs
41
50
```
42
51
### ONNX
43
-
The -export_onnx option in inference.py is responsible for dumping the onnx model
44
52
45
53
```bash
46
54
cd ml-llvm-project/model/POSET_RL/src
47
55
48
-
python inference.py --test-dir=<Path to the test directory> --use_grpc --server_address=<loopback_address:port_no> --model=<path_to_the_model_in_config_in_main_project> --export_onnx
56
+
python inference.py --test-dir=<Path to the test directory> --use_grpc --server_address=<loopback_address:port_no> --model=<path_to_the_model_in_config_in_main_project>
57
+
58
+
```
49
59
50
-
# The model will be dumped inside the onnx-model directory residing inside /path/to/ml-llvm-project/model/POSET-RL/
51
-
# Copy the generated onnx model from the above mentioned directory into /path/to/ml-llvm-project/config/posetrl
52
-
```
60
+
### Model Inference: [Refer to Model Training](../llvm/lib/Transforms/IPO/PosetRL/README.md)
0 commit comments