Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update cinn flags usage #56896

Merged
merged 10 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,9 @@ if(WITH_CINN)
add_subdirectory(python)
endif()
add_subdirectory(test)
if(NOT WITH_GFLAGS)
add_subdirectory(paddle/utils)
endif()
return()
endif()
endif()
Expand Down
18 changes: 8 additions & 10 deletions cmake/cinn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@ include(cmake/cinn/core.cmake)
include(cmake/cinn/nvrtc.cmake)
include(cmake/cinn/nvtx.cmake)

if(CINN_ONLY)
huangjiyi marked this conversation as resolved.
Show resolved Hide resolved
link_libraries(gflags)
endif()

set(LINK_FLAGS
"-Wl,--version-script ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cinn/export.map"
CACHE INTERNAL "")
Expand Down Expand Up @@ -183,9 +179,9 @@ if(WITH_MKL)
endif()
endif()

if(NOT WITH_GFLAGS)
target_link_libraries(cinnapi gflags)
add_dependencies(cinnapi gflags)
if(CINN_ONLY)
huangjiyi marked this conversation as resolved.
Show resolved Hide resolved
target_link_libraries(cinnapi ${flags_dep})
add_dependencies(cinnapi ${flags_dep})
endif()

if(WITH_GPU)
Expand Down Expand Up @@ -242,9 +238,9 @@ function(gen_cinncore LINKTYPE)
endif()
endif()

if(NOT WITH_GFLAGS)
target_link_libraries(${CINNCORE_TARGET} gflags)
add_dependencies(${CINNCORE_TARGET} gflags)
if(CINN_ONLY)
target_link_libraries(${CINNCORE_TARGET} ${flags_dep})
add_dependencies(${CINNCORE_TARGET} ${flags_dep})
endif()

if(WITH_GPU)
Expand Down Expand Up @@ -272,6 +268,8 @@ set(PUBLISH_LIBS ON)
if(PUBLISH_LIBS)
set(core_includes
"${core_includes};paddle/cinn/runtime/cuda/cinn_cuda_runtime_source.cuh")
set(core_includes
"${core_includes};paddle/utils/flags.h;paddle/utils/flags_native.h")
foreach(header ${core_includes})
get_filename_component(prefix ${header} DIRECTORY)
file(COPY ${header}
Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if(WITH_TESTING)
cinn_cc_library(cinn_gtest_main SRCS gtest_main.cc DEPS gtest gflags)
cinn_cc_library(cinn_gtest_main SRCS gtest_main.cc DEPS gtest ${flags_dep})
endif()

add_subdirectory(api)
Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/auto_schedule/auto_tuner_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "paddle/cinn/ir/ir_base.h"
#include "paddle/cinn/runtime/flags.h"

DECLARE_bool(auto_schedule_use_cost_model);
PD_DECLARE_bool(auto_schedule_use_cost_model);

namespace cinn {
namespace auto_schedule {
Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/auto_schedule/search_space/search_space.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "paddle/cinn/ir/utils/ir_copy.h"
#include "paddle/cinn/runtime/flags.h"

DECLARE_bool(auto_schedule_use_cost_model);
PD_DECLARE_bool(auto_schedule_use_cost_model);

namespace cinn {
namespace auto_schedule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "paddle/cinn/utils/sized_multi_set.h"
#include "paddle/cinn/utils/string.h"

DECLARE_bool(auto_schedule_use_cost_model);
PD_DECLARE_bool(auto_schedule_use_cost_model);

namespace cinn {
namespace auto_schedule {
Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/auto_schedule/task/task_optimizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include "paddle/cinn/backends/cuda_util.h"
#endif

DECLARE_bool(auto_schedule_use_cost_model);
PD_DECLARE_bool(auto_schedule_use_cost_model);

namespace cinn {
namespace auto_schedule {
Expand Down
3 changes: 1 addition & 2 deletions paddle/cinn/auto_schedule/task/task_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@

#pragma once

#include <gflags/gflags.h>

#include <mutex>
#include <string>

#include "paddle/cinn/ir/schedule/ir_schedule.h"
#include "paddle/cinn/ir/utils/ir_copy.h"
#include "paddle/cinn/utils/registry.h"
#include "paddle/utils/flags.h"

namespace cinn {

Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/auto_schedule/task/task_registry_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "paddle/cinn/utils/string.h"
#include "paddle/cinn/utils/type_defs.h"

DECLARE_bool(auto_schedule_use_cost_model);
PD_DECLARE_bool(auto_schedule_use_cost_model);

namespace cinn {
namespace auto_schedule {
Expand Down
14 changes: 7 additions & 7 deletions paddle/cinn/auto_schedule/tests/performance_comparison_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@
* parameters for more detail.
*/

DEFINE_string(resnet50_model_dir,
"./ResNet50",
"the path to paddle model resnet50.");
PD_DEFINE_string(resnet50_model_dir,
"./ResNet50",
"the path to paddle model resnet50.");
// Flags that control which schedule tests will be run.
// Bit with index 0 controls no schedule test, means options = 1 = "001" will
// run no schedule test. Bit with index 1 controls manual schedule test, means
// options = 2 = "010" will run manual schedule test. Bit with index 2 controls
// auto schedule test, means options = 4 = "100" will run auto schedule test.
// The default value is -1, which means that this flag is disabled to set the
// options
DEFINE_int32(evaluate_knobs,
-1,
"the options to control which schedule tests will be run.");
DECLARE_double(cinn_infer_model_version);
PD_DEFINE_int32(evaluate_knobs,
-1,
"the options to control which schedule tests will be run.");
PD_DECLARE_double(cinn_infer_model_version);

namespace cinn {
namespace auto_schedule {
Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/backends/codegen_c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "paddle/cinn/utils/string.h"

//! Root of the builtin code.
DECLARE_string(cinn_x86_builtin_code_root);
PD_DECLARE_string(cinn_x86_builtin_code_root);

namespace cinn {
namespace backends {
Expand Down
3 changes: 1 addition & 2 deletions paddle/cinn/backends/codegen_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#pragma once

#include <gflags/gflags.h>

#include <string>
#include <vector>

Expand All @@ -27,6 +25,7 @@
#include "paddle/cinn/ir/utils/ir_printer.h"
#include "paddle/cinn/lang/packed_func.h"
#include "paddle/cinn/runtime/cinn_runtime.h"
#include "paddle/utils/flags.h"

namespace cinn {

Expand Down
10 changes: 5 additions & 5 deletions paddle/cinn/backends/compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
#include "paddle/cinn/runtime/flags.h"
#endif

DECLARE_string(cinn_source_code_save_path);
DECLARE_string(cinn_dump_group_lowered_func);
DECLARE_string(cinn_dump_group_source_code);
DECLARE_string(cinn_dump_group_ptx);
DECLARE_string(cinn_dump_group_instruction);
PD_DECLARE_string(cinn_source_code_save_path);
PD_DECLARE_string(cinn_dump_group_lowered_func);
PD_DECLARE_string(cinn_dump_group_source_code);
PD_DECLARE_string(cinn_dump_group_ptx);
PD_DECLARE_string(cinn_dump_group_instruction);

namespace cinn {
namespace backends {
Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/backends/extern_func_emitter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "paddle/cinn/runtime/flags.h"
#include "paddle/cinn/utils/string.h"

DECLARE_bool(verbose_function_register);
PD_DECLARE_bool(verbose_function_register);

namespace cinn {
namespace backends {
Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/backends/function_prototype.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "paddle/cinn/ir/tensor.h"
#include "paddle/cinn/runtime/flags.h"

DECLARE_bool(verbose_function_register);
PD_DECLARE_bool(verbose_function_register);

namespace cinn {
namespace backends {
Expand Down
4 changes: 2 additions & 2 deletions paddle/cinn/backends/llvm/runtime_symbol_registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

#include <iostream>

#include "gflags/gflags_declare.h"
#include "paddle/cinn/runtime/flags.h"
#include "paddle/utils/flags.h"

DECLARE_bool(verbose_function_register);
PD_DECLARE_bool(verbose_function_register);

namespace cinn {
namespace backends {
Expand Down
4 changes: 2 additions & 2 deletions paddle/cinn/backends/nvrtc/nvrtc_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#include "paddle/cinn/runtime/flags.h"
#include "paddle/cinn/utils/string.h"

DECLARE_string(cinn_nvcc_cmd_path);
DECLARE_bool(nvrtc_compile_to_cubin);
PD_DECLARE_string(cinn_nvcc_cmd_path);
PD_DECLARE_bool(nvrtc_compile_to_cubin);

namespace cinn {
namespace backends {
Expand Down
6 changes: 3 additions & 3 deletions paddle/cinn/common/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ std::string NameGenerator::New(const std::string& name_hint) {

} // namespace common

DEFINE_bool(cinn_runtime_display_debug_info,
false,
"Whether to display debug information in runtime");
PD_DEFINE_bool(cinn_runtime_display_debug_info,
false,
"Whether to display debug information in runtime");
} // namespace cinn
4 changes: 2 additions & 2 deletions paddle/cinn/common/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#pragma once
#include <absl/types/any.h>
#include <gflags/gflags.h>
#include <isl/cpp.h>

#include <mutex>
Expand All @@ -25,10 +24,11 @@
#include "paddle/cinn/common/debug_manager.h"
#include "paddle/cinn/common/info_registry.h"
#include "paddle/cinn/common/target.h"
#include "paddle/utils/flags.h"

namespace cinn {

DECLARE_bool(cinn_runtime_display_debug_info);
PD_DECLARE_bool(cinn_runtime_display_debug_info);

namespace ir {
class Expr;
Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/frontend/computation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "paddle/cinn/frontend/pass/use_program_pass.h"
#include "paddle/cinn/frontend/program_pass.h"

DEFINE_string(model_dir, "", "");
PD_DEFINE_string(model_dir, "", "");

namespace cinn {
namespace frontend {
Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/frontend/interpreter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "paddle/cinn/hlir/pass/use_pass.h"
#include "paddle/cinn/runtime/flags.h"

DECLARE_bool(enable_auto_tuner);
PD_DECLARE_bool(enable_auto_tuner);

namespace cinn::frontend {

Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/frontend/interpreter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "paddle/cinn/runtime/use_extern_funcs.h"

DEFINE_string(model_dir, "", "");
PD_DEFINE_string(model_dir, "", "");

namespace cinn::frontend {

Expand Down
18 changes: 9 additions & 9 deletions paddle/cinn/frontend/optimize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
#include "paddle/cinn/hlir/pass/use_pass.h"
#include "paddle/cinn/runtime/flags.h"

DECLARE_bool(cinn_use_fill_constant_folding);
DECLARE_bool(cinn_use_op_fusion);
DECLARE_bool(cinn_use_common_subexpression_elimination);
DECLARE_string(cinn_check_fusion_accuracy_pass);
DECLARE_bool(cinn_use_custom_call);
DECLARE_bool(use_reduce_split_pass);
DECLARE_bool(cinn_use_dense_merge_pass);
DECLARE_string(cinn_custom_call_deny_ops);
DECLARE_bool(general_fusion_merge_pass);
PD_DECLARE_bool(cinn_use_fill_constant_folding);
PD_DECLARE_bool(cinn_use_op_fusion);
PD_DECLARE_bool(cinn_use_common_subexpression_elimination);
PD_DECLARE_string(cinn_check_fusion_accuracy_pass);
PD_DECLARE_bool(cinn_use_custom_call);
PD_DECLARE_bool(use_reduce_split_pass);
PD_DECLARE_bool(cinn_use_dense_merge_pass);
PD_DECLARE_string(cinn_custom_call_deny_ops);
PD_DECLARE_bool(general_fusion_merge_pass);

namespace cinn {
namespace frontend {
Expand Down
4 changes: 2 additions & 2 deletions paddle/cinn/frontend/paddle/model_parser_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

#include "paddle/cinn/frontend/paddle/model_parser.h"

#include <gflags/gflags.h>
#include <gtest/gtest.h>
#include "paddle/utils/flags.h"

DEFINE_string(model_dir, "<NOTEXIST>", "model directory path");
PD_DEFINE_string(model_dir, "<NOTEXIST>", "model directory path");

namespace cinn::frontend::paddle {

Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/frontend/paddle_model_convertor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "paddle/cinn/frontend/var_type_utils.h"
#include "paddle/cinn/hlir/op/use_ops.h"

DECLARE_double(cinn_infer_model_version);
PD_DECLARE_double(cinn_infer_model_version);

namespace cinn {
namespace frontend {
Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/frontend/paddle_model_convertor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "paddle/cinn/frontend/decomposer/test_helper.h"
#include "paddle/cinn/runtime/use_extern_funcs.h"

DEFINE_string(model_dir, "", "");
PD_DEFINE_string(model_dir, "", "");

namespace cinn {
namespace frontend {
Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/frontend/paddle_model_to_program.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "paddle/cinn/frontend/paddle/pb/program_desc.h"
#include "paddle/cinn/hlir/framework/node.h"

DECLARE_double(cinn_infer_model_version);
PD_DECLARE_double(cinn_infer_model_version);

namespace cinn {
namespace frontend {
Expand Down
4 changes: 2 additions & 2 deletions paddle/cinn/frontend/pass/pass_test_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#pragma once

#include <gflags/gflags.h>
#include <gtest/gtest.h>

#include <algorithm>
Expand Down Expand Up @@ -42,8 +41,9 @@
#include "paddle/cinn/hlir/op/use_ops.h"
#include "paddle/cinn/hlir/pass/use_pass.h"
#include "paddle/cinn/utils/data_util.h"
#include "paddle/utils/flags.h"

DECLARE_bool(cinn_use_op_fusion);
PD_DECLARE_bool(cinn_use_op_fusion);

namespace cinn {
namespace frontend {
Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/frontend/syntax_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "paddle/cinn/hlir/pass/use_pass.h"
#include "paddle/cinn/utils/data_util.h"

DEFINE_string(model_dir, "", "");
PD_DEFINE_string(model_dir, "", "");

namespace cinn {
namespace frontend {
Expand Down
Loading