File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -453,11 +453,12 @@ namespace sd::ggml_graph_cut {
453453 if (tensor == nullptr || tensor->name [0 ] == ' \0 ' ) {
454454 return false ;
455455 }
456- return std::strncmp (tensor->name , GGML_RUNNER_CUT_PREFIX , std::strlen (GGML_RUNNER_CUT_PREFIX )) == 0 ;
456+ return starts_with (tensor->name , GGML_RUNNER_CUT_PREFIX ) &&
457+ ends_with (tensor->name , GGML_RUNNER_CUT_SUFFIX );
457458 }
458459
459460 std::string make_graph_cut_name (const std::string& group, const std::string& output) {
460- return std::string (GGML_RUNNER_CUT_PREFIX ) + group + " |" + output;
461+ return std::string (GGML_RUNNER_CUT_PREFIX ) + group + " |" + output + GGML_RUNNER_CUT_SUFFIX ;
461462 }
462463
463464 void mark_graph_cut (ggml_tensor* tensor, const std::string& group, const std::string& output) {
@@ -783,7 +784,9 @@ namespace sd::ggml_graph_cut {
783784
784785 plan.has_cuts = true ;
785786 std::string full_name (node->name );
786- std::string payload = full_name.substr (std::strlen (GGML_RUNNER_CUT_PREFIX ));
787+ size_t prefix_len = std::strlen (GGML_RUNNER_CUT_PREFIX );
788+ size_t suffix_len = std::strlen (GGML_RUNNER_CUT_SUFFIX );
789+ std::string payload = full_name.substr (prefix_len, full_name.size () - prefix_len - suffix_len);
787790 size_t sep = payload.find (' |' );
788791 std::string group = sep == std::string::npos ? payload : payload.substr (0 , sep);
789792
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ namespace sd::ggml_graph_cut {
6868 };
6969
7070 static constexpr const char * GGML_RUNNER_CUT_PREFIX = " ggml_runner_cut:" ;
71+ static constexpr const char * GGML_RUNNER_CUT_SUFFIX = " |" ;
7172
7273 struct MaxVramAssignment {
7374 float default_gib = 0 .f;
You can’t perform that action at this time.
0 commit comments