|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +GRAPH_NET_ROOT=$(python3 -c "import graph_net; import os; print(os.path.dirname(os.path.dirname(graph_net.__file__)))") |
| 4 | +DECOMPOSE_PATH=$GRAPH_NET_ROOT/decompose_level5_100 |
| 5 | + |
| 6 | +mkdir -p "$DECOMPOSE_PATH" |
| 7 | + |
| 8 | +model_list="$GRAPH_NET_ROOT/graph_net/config/torch_samples_list.txt" |
| 9 | +# model_list="$GRAPH_NET_ROOT/graph_net/test/dev_model_list/tmp_torch_samples_list.txt" |
| 10 | + |
| 11 | +# Split models into sequences |
| 12 | +python3 -m graph_net.torch.typical_sequence_split_points \ |
| 13 | + --model-list "$model_list" \ |
| 14 | + --device "cuda" \ |
| 15 | + --window-size 10 \ |
| 16 | + --fold-policy default \ |
| 17 | + --fold-times 10 \ |
| 18 | + --output-json "$DECOMPOSE_PATH/split_results.json" |
| 19 | + |
| 20 | +# Decompose models |
| 21 | +decompose_config_json_str=$(cat <<EOF |
| 22 | +{ |
| 23 | + "handler_path": "$GRAPH_NET_ROOT/graph_net/torch/graph_decomposer.py", |
| 24 | + "handler_class_name": "RangeDecomposerExtractor", |
| 25 | + "handler_config": { |
| 26 | + "model_path_prefix": "$GRAPH_NET_ROOT", |
| 27 | + "output_dir": "$DECOMPOSE_PATH", |
| 28 | + "split_results_path": "$DECOMPOSE_PATH/split_results.json", |
| 29 | + "group_head_and_tail": true, |
| 30 | + "chain_style": false |
| 31 | + } |
| 32 | +} |
| 33 | +EOF |
| 34 | +) |
| 35 | +DECOMPOSE_CONFIG=$(echo $decompose_config_json_str | base64 -w 0) |
| 36 | + |
| 37 | +python3 -m graph_net.model_path_handler \ |
| 38 | + --model-path-list $model_list \ |
| 39 | + --handler-config=$DECOMPOSE_CONFIG \ |
| 40 | + --use-subprocess |
| 41 | + |
| 42 | +# Rename graph variable |
| 43 | +config_json_str=$(cat <<EOF |
| 44 | +{ |
| 45 | + "handler_path": "$GRAPH_NET_ROOT/graph_net/torch/graph_variable_renamer.py", |
| 46 | + "handler_class_name": "GraphVariableRenamer", |
| 47 | + "handler_config": { |
| 48 | + "model_path_prefix": "", |
| 49 | + "data_input_predicator_filepath": "$GRAPH_NET_ROOT/graph_net/torch/constraint_util.py", |
| 50 | + "data_input_predicator_class_name": "NaiveDataInputPredicator", |
| 51 | + "model_runnable_predicator_filepath": "$GRAPH_NET_ROOT/graph_net/torch/constraint_util.py", |
| 52 | + "model_runnable_predicator_class_name": "ModelRunnablePredicator", |
| 53 | + "output_dir": "$DECOMPOSE_PATH/graph_variable_rename_workspace" |
| 54 | + } |
| 55 | +} |
| 56 | +EOF |
| 57 | +) |
| 58 | +CONFIG=$(echo $config_json_str | base64 -w 0) |
| 59 | + |
| 60 | +python3 -m graph_net.model_path_handler \ |
| 61 | + --model-path $DECOMPOSE_PATH \ |
| 62 | + --handler-config=$CONFIG \ |
| 63 | + --use-subprocess |
0 commit comments