2828#include "src/xnnpack/common.h"
2929#include "src/xnnpack/internal.h"
3030#include "src/xnnpack/log.h"
31+ #include "src/xnnpack/math.h"
3132#include "src/xnnpack/memory-planner.h"
3233#include "src/xnnpack/memory.h"
3334#include "src/xnnpack/microkernel-type.h"
@@ -651,9 +652,9 @@ static enum xnn_status create_runtime_impl(
651652 }
652653
653654 runtime -> threadpool = threadpool ;
654- #ifdef XNN_SLINKY_AVAILABLE
655+ #ifdef XNN_SLINKY_ENABLED
655656 runtime -> xnn_threadpool = xnn_threadpool ;
656- #endif // XNN_SLINKY_AVAILABLE
657+ #endif // XNN_SLINKY_ENABLED
657658
658659 for (uint32_t i = 0 ; i < runtime -> num_values ; i ++ ) {
659660 struct xnn_runtime_value * value = & runtime -> values [i ];
@@ -704,7 +705,19 @@ enum xnn_status xnn_create_runtime_v4(
704705 return create_runtime_impl (subgraph , weights_cache , workspace , threadpool , /*xnn_threadpool=*/ NULL , flags , runtime_out );
705706}
706707
707- #ifndef XNN_SLINKY_AVAILABLE
708+ #ifdef XNN_SLINKY_ENABLED
709+ static bool use_slinky (uint32_t flags ) {
710+ #ifdef XNN_USE_SLINKY
711+ // If compiling with XNN_USE_SLINKY defined, assume we always
712+ // want Slinky enabled, regardless of the runtime flag
713+ return true;
714+ #else
715+ return (flags & XNN_FLAG_SLINKY_ENABLED ) != 0 ;
716+ #endif // XNN_USE_SLINKY
717+ }
718+ #endif // XNN_SLINKY_ENABLED
719+
720+ #ifndef XNN_SLINKY_ENABLED
708721enum xnn_status xnn_create_threadpool_v2 (
709722 struct xnn_scheduler_v2 scheduler ,
710723 void * scheduler_context ,
@@ -720,7 +733,7 @@ enum xnn_status xnn_delete_threadpool(xnn_threadpool_t threadpool)
720733{
721734 return xnn_status_success ;
722735}
723- #endif
736+ #endif // XNN_SLINKY_ENABLED
724737
725738enum xnn_status xnn_create_runtime_with_threadpool (
726739 xnn_subgraph_t subgraph ,
@@ -731,14 +744,14 @@ enum xnn_status xnn_create_runtime_with_threadpool(
731744 return create_runtime_impl (subgraph , weights_cache , /*workspace=*/ NULL , /*threadpool*/ NULL , threadpool , flags , runtime_out );
732745}
733746
734- #ifndef XNN_SLINKY_AVAILABLE
747+ #ifndef XNN_SLINKY_ENABLED
735748enum xnn_status xnn_update_runtime_with_threadpool (
736749 xnn_runtime_t runtime ,
737750 xnn_threadpool_t threadpool ) {
738751 // This operation is not supported.
739752 return xnn_status_deprecated ;
740753}
741- #endif
754+ #endif // XNN_SLINKY_ENABLED
742755
743756enum xnn_status xnn_plan_memory (
744757 xnn_runtime_t runtime ) {
@@ -787,18 +800,9 @@ enum xnn_status xnn_plan_memory(
787800 return status ;
788801}
789802
790- enum xnn_status xnn_reshape_runtime (
791- xnn_runtime_t runtime )
792- {
803+ enum xnn_status xnn_reshape_runtime (xnn_runtime_t runtime ) {
793804#ifdef XNN_SLINKY_ENABLED
794- // If compiling with XNN_SLINKY_ENABLED defined, assume we always
795- // want Slinky enabled, regardless of the runtime flag
796- const bool use_slinky = true;
797- #else
798- const bool use_slinky = (runtime -> flags & XNN_FLAG_SLINKY_ENABLED ) != 0 ;
799- #endif
800- if (use_slinky ) {
801- #ifdef XNN_SLINKY_AVAILABLE
805+ if (use_slinky (runtime -> flags )) {
802806 if (!runtime -> slinky_pipeline || (runtime -> flags & XNN_FLAG_SLINKY_STATIC_BOUNDS ) != 0 ) {
803807 enum xnn_status status = slinky_init_pipeline (runtime );
804808 if (status != xnn_status_success ) {
@@ -807,8 +811,8 @@ enum xnn_status xnn_reshape_runtime(
807811 }
808812 slinky_setup_pipeline (runtime );
809813 return slinky_reshape_pipeline (runtime );
810- #endif
811814 }
815+ #endif // XNN_SLINKY_ENABLED
812816
813817 bool reallocation_required = false;
814818
@@ -910,12 +914,12 @@ enum xnn_status xnn_setup_runtime(
910914 return status ;
911915 }
912916
913- #ifdef XNN_SLINKY_AVAILABLE
917+ #ifdef XNN_SLINKY_ENABLED
914918 if (runtime -> slinky_pipeline ) {
915919 // Slinky reshape also performs setup.
916920 return xnn_status_success ;
917921 }
918- #endif
922+ #endif // XNN_SLINKY_ENABLED
919923
920924 return setup_runtime (runtime );
921925}
@@ -930,12 +934,12 @@ enum xnn_status xnn_setup_runtime_v2(
930934 return status ;
931935 }
932936
933- #ifdef XNN_SLINKY_AVAILABLE
937+ #ifdef XNN_SLINKY_ENABLED
934938 if (runtime -> slinky_pipeline ) {
935939 slinky_setup_pipeline (runtime );
936940 return xnn_status_success ;
937941 }
938- #endif
942+ #endif // XNN_SLINKY_ENABLED
939943
940944 return setup_runtime (runtime );
941945}
@@ -1091,11 +1095,11 @@ enum xnn_status xnn_get_runtime_profiling_info(xnn_runtime_t runtime,
10911095enum xnn_status xnn_invoke_runtime (
10921096 xnn_runtime_t runtime )
10931097{
1094- #ifdef XNN_SLINKY_AVAILABLE
1098+ #ifdef XNN_SLINKY_ENABLED
10951099 if (runtime -> slinky_pipeline ) {
10961100 return slinky_invoke_pipeline (runtime );
10971101 }
1098- #endif
1102+ #endif // XNN_SLINKY_ENABLED
10991103
11001104 if (runtime -> profiling ) {
11011105 runtime -> start_ts = xnn_read_timer ();
@@ -1123,9 +1127,9 @@ enum xnn_status xnn_delete_runtime(
11231127 xnn_runtime_t runtime )
11241128{
11251129 if (runtime != NULL ) {
1126- #ifdef XNN_SLINKY_AVAILABLE
1130+ #ifdef XNN_SLINKY_ENABLED
11271131 slinky_destroy_pipeline (runtime );
1128- #endif
1132+ #endif // XNN_SLINKY_ENABLED
11291133
11301134 if (runtime -> opdata != NULL ) {
11311135 for (size_t i = 0 ; i < runtime -> num_ops ; i ++ ) {
@@ -1167,11 +1171,11 @@ enum xnn_status xnn_delete_runtime(
11671171 }
11681172 }
11691173
1170- #ifdef XNN_SLINKY_AVAILABLE
1174+ #ifdef XNN_SLINKY_ENABLED
11711175 if (runtime -> owned_xnn_threadpool != NULL ) {
11721176 xnn_delete_threadpool (runtime -> owned_xnn_threadpool );
11731177 }
1174- #endif // XNN_SLINKY_AVAILABLE
1178+ #endif // XNN_SLINKY_ENABLED
11751179
11761180 xnn_release_memory (runtime );
11771181 }
0 commit comments