MCPcopy Create free account
hub / github.com/cactus-compute/cactus / execute

Method execute

cactus/graph/graph_execute.cpp:251–716  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249}
250
251void CactusGraph::execute(const std::string& profile_file) {
252 std::vector<size_t> last_use(nodes_.size(), 0);
253 for (size_t i = 0; i < nodes_.size(); ++i) {
254 for (size_t input_id : nodes_[i]->input_ids) {
255 auto it = node_index_map_.find(input_id);
256 if (it != node_index_map_.end()) {
257 last_use[it->second] = std::max(last_use[it->second], i);
258 }
259 }
260 }
261
262 BufferPool& pool = buffer_pool_;
263
264 auto get_env_int = [](const char* name, int fallback) -> int {
265 const char* val = std::getenv(name);
266 return val ? std::atoi(val) : fallback;
267 };
268
269 auto get_env_str = [](const char* name) -> std::string {
270 const char* val = std::getenv(name);
271 return val ? std::string(val) : std::string();
272 };
273
274 bool capture_to_stdout = get_env_int("CACTUS_CAPTURE_STDOUT", 0) != 0;
275 std::string capture_file_path = get_env_str("CACTUS_CAPTURE_FILE");
276 bool capture_requested = get_env_int("CACTUS_CAPTURE_ENABLE", 0) != 0;
277 std::string capture_dir = get_env_str("CACTUS_CAPTURE_DIR");
278
279 if (!capture_requested) {
280 capture_requested = capture_to_stdout || !capture_file_path.empty() || !capture_dir.empty();
281 } else if (capture_file_path.empty() && !capture_to_stdout && capture_dir.empty()) {
282 capture_to_stdout = true;
283 }
284
285 size_t capture_preview_count = static_cast<size_t>(get_env_int("CACTUS_CAPTURE_PREVIEW_COUNT", 8));
286 size_t capture_max_elements = static_cast<size_t>(get_env_int("CACTUS_CAPTURE_MAX_ELEMENTS", 65536));
287
288 std::string env_profile = get_env_str("CACTUS_PROFILE_FILE");
289 if (env_profile.empty()) env_profile = get_env_str("CACTUS_PROFILE");
290
291 std::string target_profile = profile_file;
292 if (target_profile.empty() && !env_profile.empty()) {
293 target_profile = env_profile;
294 }
295
296 bool enable_profiling = !target_profile.empty();
297 bool to_stdout = (target_profile == "stdout" || target_profile == "-");
298
299 std::ofstream profile_out;
300 std::ostream* out = &std::cout;
301
302 if (enable_profiling && !to_stdout) {
303 profile_out.open(target_profile, std::ios::app);
304 if (profile_out.is_open()) {
305 out = &profile_out;
306 }
307 }
308

Callers 15

init_internalMethod · 0.45
prefillMethod · 0.45
decodeMethod · 0.45
get_embeddingsMethod · 0.45
get_token_embeddingsMethod · 0.45
cactus_graph_executeFunction · 0.45
diarizeMethod · 0.45
prefill_with_imagesMethod · 0.45
decode_with_imagesMethod · 0.45
forward_visionMethod · 0.45
get_image_embeddingMethod · 0.45

Calls 9

compute_node_optimizedFunction · 0.85
unpack_int4_as_int8x16x2Function · 0.85
get_op_nameFunction · 0.85
precision_to_stringFunction · 0.85
sizeMethod · 0.80
allocate_from_poolMethod · 0.80
get_dataMethod · 0.80
flushMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected