Skip to content

Commit 1ccdbaa

Browse files
committed
update
1 parent 36ec593 commit 1ccdbaa

File tree

8 files changed

+23
-4
lines changed

8 files changed

+23
-4
lines changed

paddle/fluid/framework/ir/graph_viz_pass.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,14 @@ void GraphVizPass::ApplyImpl(ir::Graph* graph) const {
6262
}
6363
}
6464
}
65+
const std::string& optim_cache_dir = Get<std::string>("optim_cache_dir");
6566
std::string program_bytes = program_desc.Proto()->SerializeAsString();
6667
// rename from "17_ir_fc_fuse_pass.dot" to "fc_fuse_pass.pdmodel"
6768
program_path =
6869
graph_viz_path.substr(found1 + 4, found2 - found1 - 4) + ".pdmodel";
70+
if (!optim_cache_dir.empty()) {
71+
program_path = optim_cache_dir + "/" + program_path;
72+
}
6973
std::ofstream file(program_path.c_str(), std::ios::binary);
7074
file.write(program_bytes.c_str(), program_bytes.size());
7175
file.close();

paddle/fluid/inference/analysis/ir_pass_manager.cc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,18 @@ void IRPassManager::CreatePasses(Argument *argument,
5656
auto pass = framework::ir::PassRegistry::Instance().Get(pass_name);
5757

5858
if (pass_name == "graph_viz_pass") {
59-
std::string dot_file_path = std::to_string(pass_num) + "_ir_" +
60-
(pre_pass.empty() ? "origin" : pre_pass) +
61-
".dot";
59+
std::string optim_cache_dir = argument->optim_cache_dir();
60+
std::string dot_file_path;
61+
if (optim_cache_dir.empty()) {
62+
dot_file_path = std::to_string(pass_num) + "_ir_" +
63+
(pre_pass.empty() ? "origin" : pre_pass) + ".dot";
64+
} else {
65+
dot_file_path = optim_cache_dir + "/" + std::to_string(pass_num) +
66+
"_ir_" + (pre_pass.empty() ? "origin" : pre_pass) +
67+
".dot";
68+
}
6269
pass->Set("graph_viz_path", new std::string(std::move(dot_file_path)));
70+
pass->Set("optim_cache_dir", new std::string(std::move(optim_cache_dir)));
6371
pass_num++;
6472
} else if (pass_name == "mkldnn_placement_pass") {
6573
pass->Set("mkldnn_enabled_op_types",

paddle/scripts/paddle_build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,6 +2404,8 @@ function trt_convert_test() {
24042404
if [ "$result_num" != "0" ];then
24052405
exit 11
24062406
fi
2407+
}
2408+
24072409
function build_pr_and_develop() {
24082410
cmake_gen_and_build ${PYTHON_ABI:-""} ${parallel_number}
24092411
mkdir ${PADDLE_ROOT}/build/pr_whl && cp ${PADDLE_ROOT}/build/python/dist/*.whl ${PADDLE_ROOT}/build/pr_whl

python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from trt_layer_auto_scan_test import TrtLayerAutoScanTest, SkipReasons
1616
from program_config import TensorConfig, ProgramConfig
1717
import numpy as np
18+
import unittest
1819
import paddle.inference as paddle_infer
1920
from functools import partial
2021
from typing import Optional, List, Callable, Dict, Any, Set

python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d_transpose.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from trt_layer_auto_scan_test import TrtLayerAutoScanTest, SkipReasons
1616
from program_config import TensorConfig, ProgramConfig
1717
import numpy as np
18+
import unittest
1819
import paddle.inference as paddle_infer
1920
from functools import partial
2021
from typing import Optional, List, Callable, Dict, Any, Set

python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_depthwise_conv2d.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import paddle.inference as paddle_infer
1919
from functools import partial
2020
from typing import Optional, List, Callable, Dict, Any, Set
21+
import unittest
2122

2223

2324
class TrtConvertDepthwiseConv2dTest(TrtLayerAutoScanTest):

python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_depthwise_conv2d_transpose.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import paddle.inference as paddle_infer
1919
from functools import partial
2020
from typing import Optional, List, Callable, Dict, Any, Set
21+
import unittest
2122

2223

2324
class TrtConvertDepthwiseConv2dTransposeTest(TrtLayerAutoScanTest):

python/paddle/fluid/tests/unittests/ir/inference/trt_layer_auto_scan_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ def assert_tensors_near(self,
122122
"Output has diff between GPU and TensorRT. ")
123123

124124
def assert_op_size(self, trt_engine_num, paddle_op_num):
125-
last_passed_program = 'transpose_flatten_concat_fuse_pass.pdmodel'
125+
last_passed_program = os.path.join(
126+
self.trt_cache_dir, 'transpose_flatten_concat_fuse_pass.pdmodel')
126127
model_bytes = paddle.static.load_from_file(last_passed_program)
127128
pg = paddle.static.deserialize_program(model_bytes)
128129
main_block = pg.desc.block(0)

0 commit comments

Comments
 (0)