From 9376a35dd32fa3f10e6991100409a065bcc9074c Mon Sep 17 00:00:00 2001 From: Honglei-Qiu <1044497581@qq.com> Date: Fri, 23 Jan 2026 02:33:54 +0000 Subject: [PATCH 1/4] fix graph_net/tools/generate_subgraph_dataset --- graph_net/tools/generate_subgraph_dataset.sh | 209 +++++++++++++++++-- 1 file changed, 197 insertions(+), 12 deletions(-) diff --git a/graph_net/tools/generate_subgraph_dataset.sh b/graph_net/tools/generate_subgraph_dataset.sh index a56ecaaf6f..8a2156d284 100755 --- a/graph_net/tools/generate_subgraph_dataset.sh +++ b/graph_net/tools/generate_subgraph_dataset.sh @@ -4,6 +4,7 @@ set -x MIN_SEQ_OPS=${1:-16} MAX_SEQ_OPS=${2:-64} GPU_ID=${3:-0} +LIMITS_HANDLED_MODELS=${4:-40} OP_RANGE=$MIN_SEQ_OPS-$MAX_SEQ_OPS @@ -24,15 +25,38 @@ FUSIBLE_SUBGRAPH_SAMPLES_DIR=$DECOMPOSE_WORKSPACE/fusible_subgraph_samples RENAMED_FUSIBLE_SUBGRAPH_DIR=$DECOMPOSE_WORKSPACE/renamed_fusible_subgraphs DEDUPLICATED_FUSIBLE_SUBGRAPH_DIR=$DECOMPOSE_WORKSPACE/deduplicated_fusible_subgraphs UNITTESTS_OUTPUT_DIR=$DECOMPOSE_WORKSPACE/unittests +DIMENSION_GENERALIZER_OUTPUT_DIR=/tmp/dimension_generalized_samples mkdir -p "$DECOMPOSE_WORKSPACE" -model_list="$GRAPH_NET_ROOT/graph_net/config/small100_torch_samples_list.txt" +model_list="$GRAPH_NET_ROOT/graph_net/config/small10_torch_samples_list.txt" #改成10测试 range_decomposed_subgraph_list=${DECOMPOSE_WORKSPACE}/range_decomposed_subgraph_sample_list.txt deduplicated_subgraph_list=${DECOMPOSE_WORKSPACE}/deduplicated_subgraph_sample_list.txt device_rewrited_subgraph_list=${DECOMPOSE_WORKSPACE}/device_rewrited_subgraph_sample_list.txt fusible_subgraph_list=${DECOMPOSE_WORKSPACE}/fusible_subgraph_sample_list.txt deduplicated_fusible_subgraphs_list=${DECOMPOSE_WORKSPACE}/deduplicated_fusible_subgraph_sample_list.txt +dimension_generalizer_samples_list=dimension_generalizer_sample_list.txt +model_runnable_predicator=ModelRunnablePredicator + + +function generate_subgraph_list_by_index() { + local target_dir="$1" + local sample_list_name="$2" + local max_index="$3" + echo ">>> Generate subgraph_sample_list for samples under ${target_dir} with index 0-${max_index}." + echo ">>>" + for index in $(seq 0 $max_index); do + local sample_list="${target_dir}/${index}/${sample_list_name}" + echo ">>> Generating list for index ${index}" + + find ${target_dir}/${index} -name "model.py" \ + | xargs dirname \ + | xargs realpath --relative-to=${target_dir}/${index} \ + | tee $sample_list + + echo "Generated: $sample_list" + done +} function generate_subgraph_list() { local target_dir="$1" @@ -47,9 +71,107 @@ function generate_subgraph_list() { | tee $sample_list } +function dimension_generalizer(){ + echo ">>> dimension_generalizer" + echo ">>>" + python3 -m graph_net.model_path_handler \ + --use-subprocess \ + --model-path-list $model_list \ + --handler-config=$(base64 -w 0 <>> Propagate shapes for all dimension variants (0-8)" + echo ">>>" + for index in {0..8}; do + echo ">>> Processing dimension variant ${index}" + local variant_output_dir="${DIMENSION_GENERALIZER_OUTPUT_DIR}/${index}" + local variant_sample_list="${DIMENSION_GENERALIZER_OUTPUT_DIR}/${index}/${dimension_generalizer_samples_list}" + if [ ! -f "$variant_sample_list" ] || [ ! -s "$variant_sample_list" ]; then + echo ">>> Skip variant ${index}: sample list not found or empty" + continue + fi + + python3 -m graph_net.apply_sample_pass \ + --model-path-list "$variant_sample_list" \ + --sample-pass-file-path "$GRAPH_NET_ROOT/graph_net/torch/sample_pass/shape_propagator.py" \ + --sample-pass-class-name ShapePropagator \ + --sample-pass-config $(base64 -w 0 <>> [1] Generate op_names.txt for samples in ${model_list}." - echo ">>>" + echo ">>>" python3 -m graph_net.model_path_handler \ --model-path-list $model_list \ --handler-config=$(base64 -w 0 <>> [7] Generate fusible subgraphs for subgraph samples under ${DEVICE_REWRITED_OUTPUT_DIR}." + echo ">>> [7] Generate fusible subgraphs for subgraph samples under ${GRAPH_NET_ROOT}." echo ">>>" python3 -m graph_net.model_path_handler \ --use-subprocess \ - --model-path-list "$device_rewrited_subgraph_list" \ + --model-path-list "$model_list" \ --handler-config $(base64 -w 0 <>> [6] Group ranges from subgraph sources." + python3 -m graph_net.apply_sample_pass \ + --model-path-list ${deduplicated_fusible_subgraphs_list} \ + --sample-pass-file-path "$GRAPH_NET_ROOT/graph_net/sample_pass/group_ranges_from_subgraph_sources.py" \ + --sample-pass-class-name GroupRangesFromSubgraphSources \ + --sample-pass-config $(base64 -w 0 <>> [8.5] Rewrite subgraph input shapes for each dimension variant (0-8)" + echo ">>>" + + for index in {0..8}; do + echo ">>> Processing dimension variant index: ${index}" + python3 -m graph_net.apply_sample_pass \ + --model-path-list ${deduplicated_fusible_subgraphs_list} \ + --sample-pass-file-path "$GRAPH_NET_ROOT/graph_net/sample_pass/subgraph_input_shapes_naive_rewriter.py" \ + --sample-pass-class-name SubgraphInputShapesNaiveRewriter \ + --sample-pass-config $(base64 -w 0 <>> [10] Generate unittests for subgraph samples under ${DEDUPLICATED_FUSIBLE_SUBGRAPH_DIR}." echo ">>>" @@ -287,7 +464,11 @@ EOF main() { timestamp=`date +%Y%m%d_%H%M` suffix="${OP_RANGE}ops_${timestamp}" - + + dimension_generalizer 2>&1 | tee ${DIMENSION_GENERALIZER_OUTPUT_DIR}/log_dimension_generalizer_${suffix}.txt + generate_subgraph_list_by_index ${DIMENSION_GENERALIZER_OUTPUT_DIR} ${dimension_generalizer_samples_list} 8 + propagate_shapes_for_all_variants 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_propagate_shapes_${suffix}.txt + generate_op_names 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_op_names_${suffix}.txt generate_split_point 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_split_point_${suffix}.txt range_decompose 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_range_decompose_${suffix}.txt @@ -298,15 +479,19 @@ main() { generate_subgraph_list ${DEDUPLICATED_OUTPUT_DIR} ${deduplicated_subgraph_list} rewrite_device 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_rewrite_device_${suffix}.txt - generate_subgraph_list ${DEVICE_REWRITED_OUTPUT_DIR} ${device_rewrited_subgraph_list} - gen_fusible_subgraphs 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_fusible_subgraphs_${suffix}.txt + gen_fusible_subgraphs 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_fusible_subgraphs_${suffix}.txt generate_subgraph_list ${FUSIBLE_SUBGRAPH_SAMPLES_DIR} ${fusible_subgraph_list} + rename_fusible_subgraph 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_rename_fusible_subgraph_${suffix}.txt remove_duplicate_fusible_graphs 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_remove_duplicate_fusible_graphs_${suffix}.txt - generate_subgraph_list ${DEDUPLICATED_FUSIBLE_SUBGRAPH_DIR} ${deduplicated_fusible_subgraphs_list} + + group_subgraph_sources 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_group_subgraph_sources_${suffix}.txt + analyze_subgraph_dependences 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_subgraph_dependencies_${suffix}.txt + rewrite_subgraph_shapes_per_index 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_rewrite_subgraph_shapes_${suffix}.txt + generate_unittests 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_unittests_${suffix}.txt } From 4d2226f4b815e0194c304746d3199d5a2a06ed29 Mon Sep 17 00:00:00 2001 From: Honglei-Qiu <1044497581@qq.com> Date: Fri, 23 Jan 2026 02:47:23 +0000 Subject: [PATCH 2/4] fix graph_net/tools/generate_subgraph_dataset --- graph_net/tools/generate_subgraph_dataset.sh | 30 +++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/graph_net/tools/generate_subgraph_dataset.sh b/graph_net/tools/generate_subgraph_dataset.sh index 8a2156d284..b505397083 100755 --- a/graph_net/tools/generate_subgraph_dataset.sh +++ b/graph_net/tools/generate_subgraph_dataset.sh @@ -72,7 +72,7 @@ function generate_subgraph_list() { } function dimension_generalizer(){ - echo ">>> dimension_generalizer" + echo ">>> [1] dimension generalize for samoles under ${model_list}." echo ">>>" python3 -m graph_net.model_path_handler \ --use-subprocess \ @@ -144,7 +144,7 @@ EOF } function propagate_shapes_for_all_variants() { - echo ">>> Propagate shapes for all dimension variants (0-8)" + echo ">>> [2] Propagate shapes for all dimension variants (0-8)" echo ">>>" for index in {0..8}; do echo ">>> Processing dimension variant ${index}" @@ -170,7 +170,7 @@ EOF } function generate_op_names() { - echo ">>> [1] Generate op_names.txt for samples in ${model_list}." + echo ">>> [3] Generate op_names.txt for samples in ${model_list}." echo ">>>" python3 -m graph_net.model_path_handler \ --model-path-list $model_list \ @@ -189,7 +189,7 @@ EOF } function generate_split_point() { - echo ">>> [2] Generate split points for samples in ${model_list}." + echo ">>> [4] Generate split points for samples in ${model_list}." echo ">>> MIN_SEQ_OPS: ${MIN_SEQ_OPS}, MAX_SEQ_OPS: ${MAX_SEQ_OPS}" echo ">>>" python3 -m graph_net.apply_sample_pass \ @@ -216,7 +216,7 @@ EOF } function range_decompose() { - echo ">>> [3] Decompose according to split_results.json for samples in ${model_list}." + echo ">>> [5] Decompose according to split_results.json for samples in ${model_list}." echo ">>>" python3 -m graph_net.model_path_handler \ --model-path-list "$model_list" \ @@ -239,7 +239,7 @@ EOF } function rename_decomposed_subgraph() { - echo ">>> [4] Rename subgraph samples under ${RANGE_DECOMPOSE_OUTPUT_DIR}." + echo ">>> [6] Rename subgraph samples under ${RANGE_DECOMPOSE_OUTPUT_DIR}." echo ">>>" python3 -m graph_net.model_path_handler \ --model-path-list ${range_decomposed_subgraph_list} \ @@ -264,7 +264,7 @@ EOF } function remove_duplicate_renamed_graphs() { - echo ">>> [5] Remove duplicated subgraph samples under ${GRAPH_VAR_RENAME_OUTPUT_DIR}." + echo ">>> [7] Remove duplicated subgraph samples under ${GRAPH_VAR_RENAME_OUTPUT_DIR}." echo ">>>" python3 -m graph_net.tools.deduplicated \ --samples-dir ${GRAPH_VAR_RENAME_OUTPUT_DIR} \ @@ -272,7 +272,7 @@ function remove_duplicate_renamed_graphs() { } function rewrite_device() { - echo ">>> [6] Rewrite devices for subgraph samples under ${DEDUPLICATED_OUTPUT_DIR}." + echo ">>> [8] Rewrite devices for subgraph samples under ${DEDUPLICATED_OUTPUT_DIR}." echo ">>>" python3 -m graph_net.model_path_handler \ --model-path-list ${deduplicated_subgraph_list} \ @@ -292,7 +292,7 @@ EOF } function gen_fusible_subgraphs() { - echo ">>> [7] Generate fusible subgraphs for subgraph samples under ${GRAPH_NET_ROOT}." + echo ">>> [9] Generate fusible subgraphs for subgraph samples under ${GRAPH_NET_ROOT}." echo ">>>" python3 -m graph_net.model_path_handler \ --use-subprocess \ @@ -349,7 +349,7 @@ EOF } function rename_fusible_subgraph() { - echo ">>> [8] Rename subgraph samples under ${FUSIBLE_SUBGRAPH_SAMPLES_DIR}." + echo ">>> [10] Rename subgraph samples under ${FUSIBLE_SUBGRAPH_SAMPLES_DIR}." echo ">>>" python3 -m graph_net.model_path_handler \ --model-path-list ${fusible_subgraph_list} \ @@ -374,7 +374,7 @@ EOF } function remove_duplicate_fusible_graphs() { - echo ">>> [9] Remove duplicated subgraph samples under ${RENAMED_FUSIBLE_SUBGRAPH_DIR}." + echo ">>> [11] Remove duplicated subgraph samples under ${RENAMED_FUSIBLE_SUBGRAPH_DIR}." echo ">>>" python3 -m graph_net.tools.deduplicated \ --samples-dir ${RENAMED_FUSIBLE_SUBGRAPH_DIR} \ @@ -382,7 +382,8 @@ function remove_duplicate_fusible_graphs() { } function group_subgraph_sources() { - echo ">>> [6] Group ranges from subgraph sources." + echo ">>> [12] Group ranges from subgraph sources under ${DEDUPLICATED_FUSIBLE_SUBGRAPH_DIR}." + echo ">>>" python3 -m graph_net.apply_sample_pass \ --model-path-list ${deduplicated_fusible_subgraphs_list} \ --sample-pass-file-path "$GRAPH_NET_ROOT/graph_net/sample_pass/group_ranges_from_subgraph_sources.py" \ @@ -397,6 +398,7 @@ EOF } function analyze_subgraph_dependences(){ + echo ">>> [13] Analyze subgraph dependences for samples under ${model_list}." python3 -m graph_net.apply_sample_pass \ --model-path-list $model_list \ --sample-pass-file-path "$GRAPH_NET_ROOT/graph_net/torch/sample_pass/subgraph_input_producer_indexes_generator.py" \ @@ -414,7 +416,7 @@ EOF } function rewrite_subgraph_shapes_per_index() { - echo ">>> [8.5] Rewrite subgraph input shapes for each dimension variant (0-8)" + echo ">>> [14] Rewrite subgraph input shapes for each dimension variant (0-8)" echo ">>>" for index in {0..8}; do @@ -437,7 +439,7 @@ EOF } function generate_unittests() { - echo ">>> [10] Generate unittests for subgraph samples under ${DEDUPLICATED_FUSIBLE_SUBGRAPH_DIR}." + echo ">>> [15] Generate unittests for subgraph samples under ${DEDUPLICATED_FUSIBLE_SUBGRAPH_DIR}." echo ">>>" python3 -m graph_net.model_path_handler \ --model-path-list ${deduplicated_fusible_subgraphs_list} \ From b32363a9ba4e5bda7fcb63e4fefc95765112cc87 Mon Sep 17 00:00:00 2001 From: Honglei-Qiu <1044497581@qq.com> Date: Fri, 23 Jan 2026 02:48:39 +0000 Subject: [PATCH 3/4] fix graph_net/tools/generate_subgraph_dataset --- graph_net/tools/generate_subgraph_dataset.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graph_net/tools/generate_subgraph_dataset.sh b/graph_net/tools/generate_subgraph_dataset.sh index b505397083..383cd2e957 100755 --- a/graph_net/tools/generate_subgraph_dataset.sh +++ b/graph_net/tools/generate_subgraph_dataset.sh @@ -29,7 +29,7 @@ DIMENSION_GENERALIZER_OUTPUT_DIR=/tmp/dimension_generalized_samples mkdir -p "$DECOMPOSE_WORKSPACE" -model_list="$GRAPH_NET_ROOT/graph_net/config/small10_torch_samples_list.txt" #改成10测试 +model_list="$GRAPH_NET_ROOT/graph_net/config/small100_torch_samples_list.txt" range_decomposed_subgraph_list=${DECOMPOSE_WORKSPACE}/range_decomposed_subgraph_sample_list.txt deduplicated_subgraph_list=${DECOMPOSE_WORKSPACE}/deduplicated_subgraph_sample_list.txt device_rewrited_subgraph_list=${DECOMPOSE_WORKSPACE}/device_rewrited_subgraph_sample_list.txt From 98fd62a9d84b2bcb2b27277e29561922cf7850e1 Mon Sep 17 00:00:00 2001 From: Honglei-Qiu <1044497581@qq.com> Date: Mon, 2 Feb 2026 08:59:51 +0000 Subject: [PATCH 4/4] fix generate_subgraph_dataset.sh --- graph_net/tools/generate_subgraph_dataset.sh | 269 ++++++------------- 1 file changed, 88 insertions(+), 181 deletions(-) diff --git a/graph_net/tools/generate_subgraph_dataset.sh b/graph_net/tools/generate_subgraph_dataset.sh index 383cd2e957..4105abbf92 100755 --- a/graph_net/tools/generate_subgraph_dataset.sh +++ b/graph_net/tools/generate_subgraph_dataset.sh @@ -14,18 +14,20 @@ GRAPH_NET_ROOT=$(python3 -c "import graph_net; import os; print(os.path.dirname( RESUME="true" DECOMPOSE_WORKSPACE=/tmp/subgraph_dataset_workspace +DEVICE_REWRITED_OUTPUT_DIR=$DECOMPOSE_WORKSPACE/device_rewrited +DIMENSION_GENERALIZER_OUTPUT_DIR=$DECOMPOSE_WORKSPACE/dimension_generalized_samples OP_NAMES_OUTPUT_DIR=$DECOMPOSE_WORKSPACE/sample_op_names RANGE_DECOMPOSE_OUTPUT_DIR=$DECOMPOSE_WORKSPACE/range_decompose GRAPH_VAR_RENAME_OUTPUT_DIR=$DECOMPOSE_WORKSPACE/graph_var_renamed DEDUPLICATED_OUTPUT_DIR=$DECOMPOSE_WORKSPACE/deduplicated -DEVICE_REWRITED_OUTPUT_DIR=$DECOMPOSE_WORKSPACE/device_rewrited CUMSUM_NUM_KERNELS_DIR=$DECOMPOSE_WORKSPACE/cumsum_num_kernels FUSIBLE_SUBGRAPH_RANGES_DIR=$DECOMPOSE_WORKSPACE/fusible_subgraph_ranges +GROUPED_FUSIBLE_SUBGRAPH_RANGES_DIR=$DECOMPOSE_WORKSPACE/grouped_fusible_subgraph_ranges FUSIBLE_SUBGRAPH_SAMPLES_DIR=$DECOMPOSE_WORKSPACE/fusible_subgraph_samples RENAMED_FUSIBLE_SUBGRAPH_DIR=$DECOMPOSE_WORKSPACE/renamed_fusible_subgraphs DEDUPLICATED_FUSIBLE_SUBGRAPH_DIR=$DECOMPOSE_WORKSPACE/deduplicated_fusible_subgraphs +DIMENSION_SUBGRAPH_SAMPLES_OUTPUT_DIR=$DECOMPOSE_WORKSPACE/workspace_dimension_subgraph_samples UNITTESTS_OUTPUT_DIR=$DECOMPOSE_WORKSPACE/unittests -DIMENSION_GENERALIZER_OUTPUT_DIR=/tmp/dimension_generalized_samples mkdir -p "$DECOMPOSE_WORKSPACE" @@ -35,10 +37,10 @@ deduplicated_subgraph_list=${DECOMPOSE_WORKSPACE}/deduplicated_subgraph_sample_l device_rewrited_subgraph_list=${DECOMPOSE_WORKSPACE}/device_rewrited_subgraph_sample_list.txt fusible_subgraph_list=${DECOMPOSE_WORKSPACE}/fusible_subgraph_sample_list.txt deduplicated_fusible_subgraphs_list=${DECOMPOSE_WORKSPACE}/deduplicated_fusible_subgraph_sample_list.txt +group_subgraph_sources_list=${DECOMPOSE_WORKSPACE}/group_subgraph_sources_sample_list.txt dimension_generalizer_samples_list=dimension_generalizer_sample_list.txt model_runnable_predicator=ModelRunnablePredicator - function generate_subgraph_list_by_index() { local target_dir="$1" local sample_list_name="$2" @@ -71,69 +73,37 @@ function generate_subgraph_list() { | tee $sample_list } -function dimension_generalizer(){ - echo ">>> [1] dimension generalize for samoles under ${model_list}." +function rewrite_device() { + echo ">>> [1] Rewrite devices for subgraph samples under ${GRAPH_NET_ROOT}." echo ">>>" python3 -m graph_net.model_path_handler \ - --use-subprocess \ - --model-path-list $model_list \ + --model-path-list ${model_list} \ --handler-config=$(base64 -w 0 <>> [2] dimension generalize for samoles under ${device_rewrited_subgraph_list}." + echo ">>>" python3 -m graph_net.apply_sample_pass \ - --model-path-list $model_list \ + --model-path-list $device_rewrited_subgraph_list \ --sample-pass-file-path "$GRAPH_NET_ROOT/graph_net/dimension_generalizer.py" \ --sample-pass-class-name "ApplyDimGenPasses" \ --sample-pass-config $(base64 -w 0 <>> [2] Propagate shapes for all dimension variants (0-8)" - echo ">>>" - for index in {0..8}; do - echo ">>> Processing dimension variant ${index}" - local variant_output_dir="${DIMENSION_GENERALIZER_OUTPUT_DIR}/${index}" - local variant_sample_list="${DIMENSION_GENERALIZER_OUTPUT_DIR}/${index}/${dimension_generalizer_samples_list}" - if [ ! -f "$variant_sample_list" ] || [ ! -s "$variant_sample_list" ]; then - echo ">>> Skip variant ${index}: sample list not found or empty" - continue - fi - - python3 -m graph_net.apply_sample_pass \ - --model-path-list "$variant_sample_list" \ - --sample-pass-file-path "$GRAPH_NET_ROOT/graph_net/torch/sample_pass/shape_propagator.py" \ - --sample-pass-class-name ShapePropagator \ - --sample-pass-config $(base64 -w 0 <>> [3] Generate op_names.txt for samples in ${model_list}." + echo ">>> [3] Generate op_names.txt for samples in ${device_rewrited_subgraph_list}." echo ">>>" python3 -m graph_net.model_path_handler \ - --model-path-list $model_list \ + --model-path-list $device_rewrited_subgraph_list \ --handler-config=$(base64 -w 0 <>> [4] Generate split points for samples in ${model_list}." + echo ">>> [4] Generate split points for samples in ${device_rewrited_subgraph_list}." echo ">>> MIN_SEQ_OPS: ${MIN_SEQ_OPS}, MAX_SEQ_OPS: ${MAX_SEQ_OPS}" echo ">>>" python3 -m graph_net.apply_sample_pass \ - --model-path-list $model_list \ + --model-path-list $device_rewrited_subgraph_list \ --sample-pass-file-path $GRAPH_NET_ROOT/graph_net/torch/sample_pass/typical_sequence_split_points.py \ --sample-pass-class-name TypicalSequenceSplitPointsGenerator \ --sample-pass-config=$(base64 -w 0 <>> [5] Decompose according to split_results.json for samples in ${model_list}." + echo ">>> [5] Decompose according to split_results.json for samples in ${device_rewrited_subgraph_list}." echo ">>>" python3 -m graph_net.model_path_handler \ - --model-path-list "$model_list" \ + --model-path-list "$device_rewrited_subgraph_list" \ --handler-config=$(base64 -w 0 <>> [8] Rewrite devices for subgraph samples under ${DEDUPLICATED_OUTPUT_DIR}." - echo ">>>" - python3 -m graph_net.model_path_handler \ - --model-path-list ${deduplicated_subgraph_list} \ - --handler-config=$(base64 -w 0 <>> [9] Generate fusible subgraphs for subgraph samples under ${GRAPH_NET_ROOT}." + echo ">>> [8] Generate fusible subgraphs for subgraph samples under ${DEVICE_REWRITED_OUTPUT_DIR}." echo ">>>" python3 -m graph_net.model_path_handler \ --use-subprocess \ - --model-path-list "$model_list" \ + --model-path-list "$deduplicated_subgraph_list" \ --handler-config $(base64 -w 0 <>> [10] Rename subgraph samples under ${FUSIBLE_SUBGRAPH_SAMPLES_DIR}." + echo ">>> [9] Rename subgraph samples under ${FUSIBLE_SUBGRAPH_SAMPLES_DIR}." echo ">>>" python3 -m graph_net.model_path_handler \ --model-path-list ${fusible_subgraph_list} \ @@ -374,64 +313,31 @@ EOF } function remove_duplicate_fusible_graphs() { - echo ">>> [11] Remove duplicated subgraph samples under ${RENAMED_FUSIBLE_SUBGRAPH_DIR}." + echo ">>> [10] Remove duplicated subgraph samples under ${RENAMED_FUSIBLE_SUBGRAPH_DIR}." echo ">>>" python3 -m graph_net.tools.deduplicated \ --samples-dir ${RENAMED_FUSIBLE_SUBGRAPH_DIR} \ --target-dir ${DEDUPLICATED_FUSIBLE_SUBGRAPH_DIR} } -function group_subgraph_sources() { - echo ">>> [12] Group ranges from subgraph sources under ${DEDUPLICATED_FUSIBLE_SUBGRAPH_DIR}." - echo ">>>" - python3 -m graph_net.apply_sample_pass \ - --model-path-list ${deduplicated_fusible_subgraphs_list} \ - --sample-pass-file-path "$GRAPH_NET_ROOT/graph_net/sample_pass/group_ranges_from_subgraph_sources.py" \ - --sample-pass-class-name GroupRangesFromSubgraphSources \ - --sample-pass-config $(base64 -w 0 <>> [13] Analyze subgraph dependences for samples under ${model_list}." - python3 -m graph_net.apply_sample_pass \ - --model-path-list $model_list \ - --sample-pass-file-path "$GRAPH_NET_ROOT/graph_net/torch/sample_pass/subgraph_input_producer_indexes_generator.py" \ - --sample-pass-class-name SubgraphInputProducerIndexesGenerator \ - --sample-pass-config $(base64 -w 0 <>> [14] Rewrite subgraph input shapes for each dimension variant (0-8)" - echo ">>>" - +function get_dimension_subgraph(){ + echo ">>> [11] Generating dimension_subgraph samples under ${DIMENSION_GENERALIZER_OUTPUT_DIR}." for index in {0..8}; do - echo ">>> Processing dimension variant index: ${index}" - python3 -m graph_net.apply_sample_pass \ - --model-path-list ${deduplicated_fusible_subgraphs_list} \ - --sample-pass-file-path "$GRAPH_NET_ROOT/graph_net/sample_pass/subgraph_input_shapes_naive_rewriter.py" \ - --sample-pass-class-name SubgraphInputShapesNaiveRewriter \ - --sample-pass-config $(base64 -w 0 <>> Generating dimension_subgraph variant index: ${index}" + python3 -m graph_net.model_path_handler \ + --model-path-list "${DIMENSION_GENERALIZER_OUTPUT_DIR}/${index}/${dimension_generalizer_samples_list}" \ + --handler-config $(base64 -w 0 <>> [15] Generate unittests for subgraph samples under ${DEDUPLICATED_FUSIBLE_SUBGRAPH_DIR}." + echo ">>> [12] Generate unittests for subgraph samples under ${DIMENSION_SUBGRAPH_SAMPLES_OUTPUT_DIR}. " echo ">>>" - python3 -m graph_net.model_path_handler \ - --model-path-list ${deduplicated_fusible_subgraphs_list} \ - --handler-config=$(base64 -w 0 <>> Generating unittests variant index: ${index}" + python3 -m graph_net.model_path_handler \ + --model-path-list "${DIMENSION_SUBGRAPH_SAMPLES_OUTPUT_DIR}/${index}/dimension_subgraph_list.txt" \ + --handler-config=$(base64 -w 0 <&1 | tee ${DECOMPOSE_WORKSPACE}/log_rewrite_device_${suffix}.txt + generate_subgraph_list ${DEVICE_REWRITED_OUTPUT_DIR} ${device_rewrited_subgraph_list} + dimension_generalizer 2>&1 | tee ${DIMENSION_GENERALIZER_OUTPUT_DIR}/log_dimension_generalizer_${suffix}.txt generate_subgraph_list_by_index ${DIMENSION_GENERALIZER_OUTPUT_DIR} ${dimension_generalizer_samples_list} 8 - propagate_shapes_for_all_variants 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_propagate_shapes_${suffix}.txt - + generate_op_names 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_op_names_${suffix}.txt generate_split_point 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_split_point_${suffix}.txt range_decompose 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_range_decompose_${suffix}.txt - generate_subgraph_list ${RANGE_DECOMPOSE_OUTPUT_DIR} ${range_decomposed_subgraph_list} + rename_decomposed_subgraph 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_rename_decomposed_subgraph_${suffix}.txt remove_duplicate_renamed_graphs 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_remove_duplicate_renamed_graphs_${suffix}.txt - generate_subgraph_list ${DEDUPLICATED_OUTPUT_DIR} ${deduplicated_subgraph_list} - rewrite_device 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_rewrite_device_${suffix}.txt - generate_subgraph_list ${DEVICE_REWRITED_OUTPUT_DIR} ${device_rewrited_subgraph_list} gen_fusible_subgraphs 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_fusible_subgraphs_${suffix}.txt generate_subgraph_list ${FUSIBLE_SUBGRAPH_SAMPLES_DIR} ${fusible_subgraph_list} @@ -489,11 +397,10 @@ main() { rename_fusible_subgraph 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_rename_fusible_subgraph_${suffix}.txt remove_duplicate_fusible_graphs 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_remove_duplicate_fusible_graphs_${suffix}.txt generate_subgraph_list ${DEDUPLICATED_FUSIBLE_SUBGRAPH_DIR} ${deduplicated_fusible_subgraphs_list} - - group_subgraph_sources 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_group_subgraph_sources_${suffix}.txt - analyze_subgraph_dependences 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_subgraph_dependencies_${suffix}.txt - rewrite_subgraph_shapes_per_index 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_rewrite_subgraph_shapes_${suffix}.txt - + + get_dimension_subgraph 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_get_dimension_subgraph_${suffix}.txt + generate_subgraph_list_by_index ${DIMENSION_SUBGRAPH_SAMPLES_OUTPUT_DIR} dimension_subgraph_list.txt 8 + generate_unittests 2>&1 | tee ${DECOMPOSE_WORKSPACE}/log_unittests_${suffix}.txt }