@@ -5038,28 +5038,6 @@ struct ggml_tensor * ggml_roll(
50385038 return result ;
50395039}
50405040
5041- // ggml_arange
5042-
5043- struct ggml_tensor * ggml_arange (
5044- struct ggml_context * ctx ,
5045- float start ,
5046- float stop ,
5047- float step ) {
5048- GGML_ASSERT (stop > start );
5049-
5050- const int64_t steps = (int64_t ) ceilf ((stop - start ) / step );
5051-
5052- struct ggml_tensor * result = ggml_new_tensor_1d (ctx , GGML_TYPE_F32 , steps );
5053-
5054- ggml_set_op_params_f32 (result , 0 , start );
5055- ggml_set_op_params_f32 (result , 1 , stop );
5056- ggml_set_op_params_f32 (result , 2 , step );
5057-
5058- result -> op = GGML_OP_ARANGE ;
5059-
5060- return result ;
5061- }
5062-
50635041// ggml_timestep_embedding
50645042
50655043struct ggml_tensor * ggml_timestep_embedding (
@@ -5152,6 +5130,24 @@ struct ggml_tensor * ggml_argsort(
51525130 return result ;
51535131}
51545132
5133+ // ggml_argsort_top_k
5134+
5135+ struct ggml_tensor * ggml_argsort_top_k (
5136+ struct ggml_context * ctx ,
5137+ struct ggml_tensor * a ,
5138+ int k ) {
5139+ GGML_ASSERT (a -> ne [0 ] >= k );
5140+
5141+ struct ggml_tensor * result = ggml_argsort (ctx , a , GGML_SORT_ORDER_DESC );
5142+
5143+ result = ggml_view_4d (ctx , result ,
5144+ k , result -> ne [1 ], result -> ne [2 ], result -> ne [3 ],
5145+ result -> nb [1 ], result -> nb [2 ], result -> nb [3 ],
5146+ 0 );
5147+
5148+ return result ;
5149+ }
5150+
51555151// ggml_top_k
51565152
51575153struct ggml_tensor * ggml_top_k (
@@ -5170,6 +5166,28 @@ struct ggml_tensor * ggml_top_k(
51705166 return result ;
51715167}
51725168
5169+ // ggml_arange
5170+
5171+ struct ggml_tensor * ggml_arange (
5172+ struct ggml_context * ctx ,
5173+ float start ,
5174+ float stop ,
5175+ float step ) {
5176+ GGML_ASSERT (stop > start );
5177+
5178+ const int64_t steps = (int64_t ) ceilf ((stop - start ) / step );
5179+
5180+ struct ggml_tensor * result = ggml_new_tensor_1d (ctx , GGML_TYPE_F32 , steps );
5181+
5182+ ggml_set_op_params_f32 (result , 0 , start );
5183+ ggml_set_op_params_f32 (result , 1 , stop );
5184+ ggml_set_op_params_f32 (result , 2 , step );
5185+
5186+ result -> op = GGML_OP_ARANGE ;
5187+
5188+ return result ;
5189+ }
5190+
51735191// ggml_flash_attn_ext
51745192
51755193struct ggml_tensor * ggml_flash_attn_ext (
0 commit comments