From 68c3e2cba77946750d18cb5274b7686bb6184fc4 Mon Sep 17 00:00:00 2001 From: Zhen Wang Date: Sat, 6 Nov 2021 23:02:32 +0800 Subject: [PATCH] Update the batch size used in test_resnet50_with_cinn.py. (#37013) * Update the batch size used in test_resnet50_with_cinn.py. * Enable more debug info. --- cmake/external/cinn.cmake | 2 +- paddle/fluid/framework/paddle2cinn/cinn_compiler.cc | 4 ++-- .../fluid/tests/unittests/test_resnet50_with_cinn.py | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmake/external/cinn.cmake b/cmake/external/cinn.cmake index 18a523346cf..3e9114a35d0 100644 --- a/cmake/external/cinn.cmake +++ b/cmake/external/cinn.cmake @@ -27,7 +27,7 @@ add_definitions(-w) include(ExternalProject) set(CINN_SOURCE_DIR ${THIRD_PARTY_PATH}/CINN) # TODO(zhhsplendid): Modify git tag after we have release tag -set(CINN_GIT_TAG 2122413fc74f4020ff4397b54488a793529d581b) +set(CINN_GIT_TAG develop) set(CINN_OPTIONAL_ARGS -DPY_VERSION=${PY_VERSION} -DWITH_CUDA=${WITH_GPU} -DWITH_CUDNN=${WITH_GPU} -DPUBLISH_LIBS=ON -DWITH_TESTING=ON) set(CINN_BUILD_COMMAND $(MAKE) cinnapi -j) ExternalProject_Add( diff --git a/paddle/fluid/framework/paddle2cinn/cinn_compiler.cc b/paddle/fluid/framework/paddle2cinn/cinn_compiler.cc index 96c052ef505..97cb7a558d5 100644 --- a/paddle/fluid/framework/paddle2cinn/cinn_compiler.cc +++ b/paddle/fluid/framework/paddle2cinn/cinn_compiler.cc @@ -67,7 +67,7 @@ const CinnCompiledObject& CinnCompiler::Compile( const Graph& graph, const std::map& input_tensors, const Target& target) { - VLOG(4) << "-- The graph to be compiled is:\n" << VizGraph(graph); + VLOG(1) << "-- The graph to be compiled is:\n" << VizGraph(graph); CinnCacheKey cur_key(graph, input_tensors, target.arch_str()); bool exist = false; { @@ -195,7 +195,7 @@ std::unique_ptr CinnCompiler::CompileGraph( ProgramPass::Apply(&frontend_program, target, {"Decomposer"}); auto cinn_graph = std::make_shared<::cinn::hlir::framework::Graph>( frontend_program, target); - VLOG(4) << "-- The " << compiled_num << "-th compilation (" + VLOG(1) << "-- The " << compiled_num << "-th compilation (" << target.arch_str() << "), and its related graph:\n" << cinn_graph->Visualize(); ApplyPass(cinn_graph.get(), "OpFusion"); diff --git a/python/paddle/fluid/tests/unittests/test_resnet50_with_cinn.py b/python/paddle/fluid/tests/unittests/test_resnet50_with_cinn.py index 58c080fc0cc..7f865f55878 100644 --- a/python/paddle/fluid/tests/unittests/test_resnet50_with_cinn.py +++ b/python/paddle/fluid/tests/unittests/test_resnet50_with_cinn.py @@ -40,8 +40,8 @@ def set_cinn_flag(val): class TestResnet50Accuracy(unittest.TestCase): def reader(self, limit): for _ in range(limit): - yield np.random.randint(0, 256, size=[1, 3, 224, 224]).astype('float32'), \ - np.random.randint(0, 1000, size=[1]).astype('int64') + yield np.random.randint(0, 256, size=[32, 3, 224, 224]).astype('float32'), \ + np.random.randint(0, 1000, size=[32]).astype('int64') def generate_random_data(self, loop_num=10): feed = [] @@ -54,8 +54,8 @@ class TestResnet50Accuracy(unittest.TestCase): def build_program(self, main_program, startup_program): with paddle.static.program_guard(main_program, startup_program): image = paddle.static.data( - name='image', shape=[1, 3, 224, 224], dtype='float32') - label = paddle.static.data(name='label', shape=[1], dtype='int64') + name='image', shape=[32, 3, 224, 224], dtype='float32') + label = paddle.static.data(name='label', shape=[32], dtype='int64') model = paddle.vision.models.resnet50() prediction = model(image) @@ -80,7 +80,7 @@ class TestResnet50Accuracy(unittest.TestCase): loss = self.build_program(main_program, startup_program) exe = paddle.static.Executor(place) - parallel_exec = paddle.static.CompiledProgram( + compiled_prog = paddle.static.CompiledProgram( main_program).with_data_parallel(loss_name=loss.name) loss_vals = [] scope = paddle.static.Scope() @@ -88,7 +88,7 @@ class TestResnet50Accuracy(unittest.TestCase): with paddle.static.scope_guard(scope): exe.run(startup_program) for step in range(iters): - loss_v = exe.run(parallel_exec, + loss_v = exe.run(compiled_prog, feed=feed[step], fetch_list=[loss], return_numpy=True) -- GitLab