@@ -2075,7 +2075,7 @@ static void ggml_backend_cann_synchronize(ggml_backend_t backend) {
20752075 ACL_CHECK (aclrtSynchronizeStream (cann_ctx->stream ()));
20762076}
20772077
2078- #ifdef USE_CANN_GRAPH
2078+ #ifdef CANN_GRAPH
20792079/* *
20802080 * @brief Populate the internal CANN graph node properties from the ggml computation graph.
20812081 *
@@ -2171,7 +2171,7 @@ static bool is_cann_graph_update_required(ggml_backend_cann_context * cann_ctx,
21712171 }
21722172 return false ;
21732173}
2174- #endif // USE_CANN_GRAPH
2174+ #endif // CANN_GRAPH
21752175
21762176/* *
21772177 * @brief Evaluate the computation graph and optionally capture or execute it using CANN graph API.
@@ -2188,15 +2188,15 @@ static bool is_cann_graph_update_required(ggml_backend_cann_context * cann_ctx,
21882188 */
21892189static void evaluate_and_capture_cann_graph (ggml_backend_cann_context * cann_ctx, ggml_cgraph * cgraph,
21902190 bool & use_cann_graph, bool & cann_graph_update_required) {
2191- #ifdef USE_CANN_GRAPH
2191+ #ifdef CANN_GRAPH
21922192 if (use_cann_graph && cann_graph_update_required) {
21932193 if (cann_ctx->cann_graph ->graph != nullptr ) {
21942194 ACL_CHECK (aclmdlRIDestroy (cann_ctx->cann_graph ->graph ));
21952195 cann_ctx->cann_graph ->graph = nullptr ;
21962196 }
21972197 ACL_CHECK (aclmdlRICaptureBegin (cann_ctx->stream (), ACL_MODEL_RI_CAPTURE_MODE_GLOBAL));
21982198 }
2199- #endif // USE_CANN_GRAPH
2199+ #endif // CANN_GRAPH
22002200
22012201 // Only perform the graph execution if CANN graphs are not enabled, or we are capturing the graph.
22022202 // With the use of CANN graphs, the execution will be performed by the graph launch.
@@ -2216,7 +2216,7 @@ static void evaluate_and_capture_cann_graph(ggml_backend_cann_context * cann_ctx
22162216 }
22172217 }
22182218
2219- #ifdef USE_CANN_GRAPH
2219+ #ifdef CANN_GRAPH
22202220 if (use_cann_graph && cann_graph_update_required) { // End CANN graph capture
22212221 ACL_CHECK (aclmdlRICaptureEnd (cann_ctx->stream (), &cann_ctx->cann_graph ->graph ));
22222222 }
@@ -2243,45 +2243,32 @@ static void evaluate_and_capture_cann_graph(ggml_backend_cann_context * cann_ctx
22432243 */
22442244static enum ggml_status ggml_backend_cann_graph_compute (
22452245 ggml_backend_t backend, ggml_cgraph* cgraph) {
2246-
22472246 ggml_backend_cann_context* cann_ctx =
22482247 (ggml_backend_cann_context*)backend->context ;
22492248 ggml_cann_set_device (cann_ctx->device );
22502249 release_nz_workspace ();
2251- #ifdef USE_CANN_GRAPH
2250+ #ifdef CANN_GRAPH
22522251 bool use_cann_graph = true ;
22532252 bool cann_graph_update_required = false ;
22542253
22552254 // check environment LLAMA_SET_ROWS
2256- const char * LLAMA_SET_ROWS_ENV = std::getenv (" LLAMA_SET_ROWS" );
2257- bool supports_set_rows = LLAMA_SET_ROWS_ENV ? (std::atoi (LLAMA_SET_ROWS_ENV) != 0 ) : false ;
2258-
2259- if (!supports_set_rows) {
2260- if (cann_ctx->set_row_log ) {
2261- GGML_LOG_ERROR (
2262- " %s: CANN Graph disabled — environment variable LLAMA_SET_ROWS not set or invalid. "
2263- " To enable CANN ACL Graph execution, export LLAMA_SET_ROWS=1. "
2264- " Falling back to non-graph mode on device %d.\n " ,
2265- __func__, cann_ctx->device
2266- );
2267- cann_ctx->set_row_log = false ;
2268- }
2255+ if (!cann_ctx->support_set_rows ) {
22692256 use_cann_graph = false ;
22702257 }
22712258
22722259 if (use_cann_graph) {
22732260 if (cann_ctx->cann_graph == nullptr ) {
22742261 cann_ctx->cann_graph .reset (new ggml_cann_graph ());
22752262 cann_graph_update_required = true ;
2276- }
2263+ }
22772264
22782265 cann_graph_update_required = is_cann_graph_update_required (cann_ctx, cgraph);
22792266 set_ggml_graph_node_properties (cann_ctx, cgraph);
22802267 }
22812268#else
22822269 bool use_cann_graph = false ;
22832270 bool cann_graph_update_required = false ;
2284- #endif // USE_CANN_GRAPH
2271+ #endif // CANN_GRAPH
22852272
22862273 evaluate_and_capture_cann_graph (
22872274 cann_ctx,
0 commit comments