MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Create

Method Create

serving/processor/serving/model_config.cc:51–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51Status ModelConfigFactory::Create(const char* model_config, ModelConfig** config) {
52 if (strlen(model_config) <= 0) {
53 return Status(error::Code::INVALID_ARGUMENT,
54 "[TensorFlow] Invalid ModelConfig json.");
55 }
56
57 // Enable INFERENCE_MODE by default
58 if (setenv("INFERENCE_MODE", "1", 1) != 0) {
59 LOG(WARNING) << "Set env INFERENCE_MODE=1 error.";
60 }
61
62 Json::Reader reader;
63 Json::Value json_config;
64 if (!reader.parse(model_config, json_config)) {
65 return Status(error::Code::INVALID_ARGUMENT,
66 "[TensorFlow] Parse ModelConfig json failed.");
67 }
68
69 int64 schedule_threads;
70 ReadInt64FromEnvVar("SCHEDULABLE_CPUS", DEFAULT_CPUS, &schedule_threads);
71
72 *config = new ModelConfig;
73
74 // User set session group cpuset,
75 // Usage: "0-10;11-20;21-30" or
76 // "0,1,2,3;4,5,6,7;8,9,10"
77 if (!json_config["cpusets"].isNull()) {
78 (*config)->cpusets =
79 json_config["cpusets"].asString();
80 }
81
82 if (!json_config["session_num"].isNull()) {
83 (*config)->session_num =
84 json_config["session_num"].asInt();
85 } else {
86 (*config)->session_num = 1;
87 }
88
89 if (!json_config["gpu_ids_list"].isNull()) {
90 std::string gpu_ids_list =
91 json_config["gpu_ids_list"].asString();
92 ParseGPUIds(gpu_ids_list, &((*config)->gpu_ids));
93 }
94
95 bool use_multi_stream = false;
96 if (!json_config["use_multi_stream"].isNull()) {
97 use_multi_stream = json_config["use_multi_stream"].asBool();
98 }
99 (*config)->use_multi_stream = use_multi_stream;
100
101 (*config)->select_session_policy = "MOD";
102 if (!json_config["select_session_policy"].isNull()) {
103 (*config)->select_session_policy =
104 json_config["select_session_policy"].asString();
105 }
106 if ((*config)->select_session_policy != "MOD" &&
107 (*config)->select_session_policy != "RR") {
108 return Status(error::Code::INVALID_ARGUMENT,

Callers 2

CreateSessionMethod · 0.45
CreateSessionGroupMethod · 0.45

Calls 13

ReadInt64FromEnvVarFunction · 0.85
ParseGPUIdsFunction · 0.85
AddOSSAccessPrefixFunction · 0.85
c_strMethod · 0.80
SetParamsMethod · 0.80
StatusClass · 0.50
setenvFunction · 0.50
parseMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected