Browse Source

!152 Add debug_dir & op_compiler_cache_dir & op_compiler_cache_mode options

Merge pull request !152 from HW_KK/development
tags/v1.1.0
王涛 Gitee 3 years ago
parent
commit
399374a52c
2 changed files with 86 additions and 70 deletions
  1. +14
    -0
      ge/offline/main.cc
  2. +72
    -70
      inc/external/ge/ge_api_types.h

+ 14
- 0
ge/offline/main.cc View File

@@ -194,6 +194,11 @@ DEFINE_int32(op_debug_level, 0, "Optional; configure debug level of compiler. 0(
"1: open TBE compiler, export ccec file and TBE instruction mapping file; 2: open ccec compiler");
DEFINE_string(enable_scope_fusion_passes, "", "Optional; validate the non-general scope fusion pass,"
"multiple names can be set and separated by ','.");
DEFINE_string(debug_dir, "", "Optional; the path to save the intermediate files of operator compilation");

DEFINE_string(op_compiler_cache_dir, "", "Optional; the path to cache operator compilation files");

DEFINE_string(op_compiler_cache_mode, "", "Optional; choose the operator compiler cache mode");

class GFlagUtils {
public:
@@ -999,6 +1004,9 @@ static void SetEnvForSingleOp(std::map<string, string> &options) {
options.emplace(ge::AUTO_TUNE_MODE, FLAGS_auto_tune_mode);
options.emplace(ge::GRAPH_MEMORY_MAX_SIZE, kGraphMemoryManagerMallocMaxSize);
options.emplace(ge::OP_DEBUG_LEVEL, to_string(FLAGS_op_debug_level));
options.emplace(ge::DEBUG_DIR, FLAGS_debug_dir);
options.emplace(ge::OP_COMPILER_CACHE_DIR, FLAGS_op_compiler_cache_dir);
options.emplace(ge::OP_COMPILER_CACHE_MODE, FLAGS_op_compiler_cache_mode);
}

domi::Status GenerateSingleOp(const std::string& json_file_path) {
@@ -1131,6 +1139,12 @@ domi::Status GenerateOmModel() {

options.insert(std::pair<string, string>(string(ge::ENABLE_SINGLE_STREAM), FLAGS_enable_single_stream));

options.insert(std::pair<string, string>(string(ge::DEBUG_DIR), FLAGS_debug_dir));

options.insert(std::pair<string, string>(string(ge::OP_COMPILER_CACHE_DIR), FLAGS_op_compiler_cache_dir));

options.insert(std::pair<string, string>(string(ge::OP_COMPILER_CACHE_MODE), FLAGS_op_compiler_cache_mode));

SetDynamicInputSizeOptions();

if (!FLAGS_save_original_model.empty()) {


+ 72
- 70
inc/external/ge/ge_api_types.h View File

@@ -222,6 +222,18 @@ const char *const OPTION_GE_MAX_DUMP_OP_NUM = "ge.maxDumpOpNum";
// Its value should be "0" or "1", default value is "1"
const char *const ENABLE_PRINT_OP_PASS = "ge.enablePrintOpPass";

// Configure operator compilation path
// Its value should be file path, default value is "./"
const char *const DEBUG_DIR = "ge.debugDir";

// Configure operator compiler cache path
// Its value should be file path, default value is "./"
const char *const OP_COMPILER_CACHE_DIR = "ge.op_compiler_cache_dir";

// Configure operator compiler cache mode
// Its value should be "disable", "enable" or "force", default value is "disable"
const char *const OP_COMPILER_CACHE_MODE = "ge.op_compiler_cache_mode";

// Configure whether to use single stream.
// Its value should be "true" or "false", default value is "false"
const char *const ENABLE_SINGLE_STREAM = "ge.enableSingleStream";
@@ -238,10 +250,10 @@ enum GraphRunMode { PREDICTION = 0, TRAIN };

// Input/Output tensor info
struct InputTensorInfo {
uint32_t data_type; // data type
std::vector<int64_t> dims; // shape description
void *data; // tensor data
int64_t length; // tensor length
uint32_t data_type; // data type
std::vector<int64_t> dims; // shape description
void *data; // tensor data
int64_t length; // tensor length
};

struct OutputTensorInfo {
@@ -250,11 +262,8 @@ struct OutputTensorInfo {
std::unique_ptr<uint8_t[]> data; // tensor data
int64_t length; // tensor length
OutputTensorInfo() : data_type(0), dims({}), data(nullptr), length(0) {}
OutputTensorInfo(OutputTensorInfo &&out) :
data_type(out.data_type),
dims(out.dims),
data(std::move(out.data)),
length(out.length) {}
OutputTensorInfo(OutputTensorInfo &&out)
: data_type(out.data_type), dims(out.dims), data(std::move(out.data)), length(out.length) {}

OutputTensorInfo &operator=(OutputTensorInfo &&out) {
if (this != &out) {
@@ -273,67 +282,60 @@ using Status = uint32_t;
using RunAsyncCallback = std::function<void(Status, std::vector<ge::OutputTensorInfo> &)>;
// for ir build
namespace ir_option {
static const char *const INPUT_FORMAT = "input_format";
static const char *const INPUT_SHAPE = "input_shape";
static const char *const OP_NAME_MAP = "op_name_map";
static const char *const DYNAMIC_BATCH_SIZE = kDynamicBatchSize;
static const char *const DYNAMIC_IMAGE_SIZE = kDynamicImageSize;
static const char *const DYNAMIC_DIMS = kDynamicDims;
static const char *const INSERT_OP_FILE = ge::INSERT_OP_FILE.c_str();
static const char *const PRECISION_MODE = ge::PRECISION_MODE.c_str();
static const char *const EXEC_DISABLE_REUSED_MEMORY = ge::OPTION_EXEC_DISABLE_REUSED_MEMORY;
static const char *const AUTO_TUNE_MODE = ge::AUTO_TUNE_MODE.c_str();
static const char *const CORE_TYPE = ge::CORE_TYPE.c_str();
static const char *const SOC_VERSION = ge::SOC_VERSION.c_str();
static const char *const ENABLE_SINGLE_STREAM = ge::ENABLE_SINGLE_STREAM;
static const char *const AICORE_NUM = ge::AICORE_NUM.c_str();
static const char *const FUSION_SWITCH_FILE = ge::FUSION_SWITCH_FILE.c_str();
static const char *const ENABLE_SMALL_CHANNEL = ge::ENABLE_SMALL_CHANNEL.c_str();
static const char *const OP_SELECT_IMPL_MODE = ge::OP_SELECT_IMPL_MODE.c_str();
static const char *const OUTPUT_TYPE = ge::OUTPUT_DATATYPE.c_str();
static const char *const BUFFER_OPTIMIZE = ge::BUFFER_OPTIMIZE.c_str();
static const char *const ENABLE_COMPRESS_WEIGHT = ge::ENABLE_COMPRESS_WEIGHT.c_str();
static const char *const COMPRESS_WEIGHT_CONF = "compress_weight_conf";
static const char *const OUT_NODES = ge::OUTPUT_NODE_NAME.c_str();
static const char *const INPUT_FP16_NODES = ge::INPUT_FP16_NODES.c_str();
static const char *const LOG_LEVEL = "log";
static const char *const OPTYPELIST_FOR_IMPLMODE = ge::OPTYPELIST_FOR_IMPLMODE.c_str();

// for interface: aclgrphBuildModel
const std::set<std::string> ir_builder_suppported_options = {
INPUT_FORMAT,
INPUT_SHAPE,
OP_NAME_MAP,
DYNAMIC_BATCH_SIZE,
DYNAMIC_IMAGE_SIZE,
DYNAMIC_DIMS,
INSERT_OP_FILE,
PRECISION_MODE,
EXEC_DISABLE_REUSED_MEMORY,
AUTO_TUNE_MODE,
OUTPUT_TYPE,
OUT_NODES,
INPUT_FP16_NODES,
LOG_LEVEL
};
// for interface: aclgrphBuildInitialize
const std::set<std::string> global_options = {
CORE_TYPE,
SOC_VERSION,
BUFFER_OPTIMIZE,
ENABLE_COMPRESS_WEIGHT,
COMPRESS_WEIGHT_CONF,
PRECISION_MODE,
EXEC_DISABLE_REUSED_MEMORY,
AUTO_TUNE_MODE,
ENABLE_SINGLE_STREAM,
AICORE_NUM,
FUSION_SWITCH_FILE,
ENABLE_SMALL_CHANNEL,
OP_SELECT_IMPL_MODE,
OPTYPELIST_FOR_IMPLMODE
};
}
static const char *const INPUT_FORMAT = "input_format";
static const char *const INPUT_SHAPE = "input_shape";
static const char *const OP_NAME_MAP = "op_name_map";
static const char *const DYNAMIC_BATCH_SIZE = kDynamicBatchSize;
static const char *const DYNAMIC_IMAGE_SIZE = kDynamicImageSize;
static const char *const DYNAMIC_DIMS = kDynamicDims;
static const char *const INSERT_OP_FILE = ge::INSERT_OP_FILE.c_str();
static const char *const PRECISION_MODE = ge::PRECISION_MODE.c_str();
static const char *const EXEC_DISABLE_REUSED_MEMORY = ge::OPTION_EXEC_DISABLE_REUSED_MEMORY;
static const char *const AUTO_TUNE_MODE = ge::AUTO_TUNE_MODE.c_str();
static const char *const CORE_TYPE = ge::CORE_TYPE.c_str();
static const char *const SOC_VERSION = ge::SOC_VERSION.c_str();
static const char *const ENABLE_SINGLE_STREAM = ge::ENABLE_SINGLE_STREAM;
static const char *const AICORE_NUM = ge::AICORE_NUM.c_str();
static const char *const FUSION_SWITCH_FILE = ge::FUSION_SWITCH_FILE.c_str();
static const char *const ENABLE_SMALL_CHANNEL = ge::ENABLE_SMALL_CHANNEL.c_str();
static const char *const OP_SELECT_IMPL_MODE = ge::OP_SELECT_IMPL_MODE.c_str();
static const char *const OUTPUT_TYPE = ge::OUTPUT_DATATYPE.c_str();
static const char *const BUFFER_OPTIMIZE = ge::BUFFER_OPTIMIZE.c_str();
static const char *const ENABLE_COMPRESS_WEIGHT = ge::ENABLE_COMPRESS_WEIGHT.c_str();
static const char *const COMPRESS_WEIGHT_CONF = "compress_weight_conf";
static const char *const OUT_NODES = ge::OUTPUT_NODE_NAME.c_str();
static const char *const INPUT_FP16_NODES = ge::INPUT_FP16_NODES.c_str();
static const char *const LOG_LEVEL = "log";
static const char *const OPTYPELIST_FOR_IMPLMODE = ge::OPTYPELIST_FOR_IMPLMODE.c_str();
static const char *const DEBUG_DIR = ge::DEBUG_DIR;
static const char *const OP_COMPILER_CACHE_DIR = ge::OP_COMPILER_CACHE_DIR;
static const char *const OP_COMPILER_CACHE_MODE = ge::OP_COMPILER_CACHE_MODE;
// for interface: aclgrphBuildModel
const std::set<std::string> ir_builder_suppported_options = {
INPUT_FORMAT, INPUT_SHAPE, OP_NAME_MAP,
DYNAMIC_BATCH_SIZE, DYNAMIC_IMAGE_SIZE, DYNAMIC_DIMS,
INSERT_OP_FILE, PRECISION_MODE, EXEC_DISABLE_REUSED_MEMORY,
AUTO_TUNE_MODE, OUTPUT_TYPE, OUT_NODES,
INPUT_FP16_NODES, LOG_LEVEL};
// for interface: aclgrphBuildInitialize
const std::set<std::string> global_options = {CORE_TYPE,
SOC_VERSION,
BUFFER_OPTIMIZE,
ENABLE_COMPRESS_WEIGHT,
COMPRESS_WEIGHT_CONF,
PRECISION_MODE,
EXEC_DISABLE_REUSED_MEMORY,
AUTO_TUNE_MODE,
ENABLE_SINGLE_STREAM,
AICORE_NUM,
FUSION_SWITCH_FILE,
ENABLE_SMALL_CHANNEL,
OP_SELECT_IMPL_MODE,
OPTYPELIST_FOR_IMPLMODE,
DEBUG_DIR,
OP_COMPILER_CACHE_DIR,
OP_COMPILER_CACHE_MODE};
} // namespace ir_option
} // namespace ge

#endif // INC_EXTERNAL_GE_GE_API_TYPES_H_

Loading…
Cancel
Save