Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/ggml/blob/master/src/ggml-openvino/openvino/op/argsort.cpp # ggml [Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `ggml / src / ggml-openvino / openvino / op / argsort.cpp` 51 lines ยท 1731 bytes Raw Blame History 1 #include "../node_context.h" 2 #include "../op_table.h" 3 #include "../utils.h" 4 #include "ggml.h" 5 6 #include 7 #include 8 #include 9 #include 10 11 namespace ov { 12 namespace frontend { 13 namespace ggml { 14 namespace op { 15 16 OutputVector translate_argsort(const NodeContext & context) { 17 num_inputs_check(context, 1, 1); 18 19 auto input = process_view_input_new(context, 0); 20 21 const int32_t order = context.get_output_op_params()[0]; 22 23 ov::op::v11::TopK::Mode mode; 24 switch (order) { 25 case GGML_SORT_ORDER_ASC: 26 mode = ov::op::v11::TopK::Mode::MIN; 27 break; 28 case GGML_SORT_ORDER_DESC: 29 mode = ov::op::v11::TopK::Mode::MAX; 30 break; 31 default: 32 FRONT_END_OP_CONVERSION_CHECK(false, "Unsupported GGML_OP_ARGSORT order: ", order); 33 } 34 35 // Stateful models drop the leading size-1 batch dim, so the expert axis is 2 there 36 // instead of 3 (same rank-3-vs-rank-4 split as get_rows.cpp / process_view_input). 37 const int axis = (context.is_stateful() && input.get_partial_shape().rank() == 3) ? 2 : 3; 38 39 auto k = std::make_shared(get_dimensions(input.get_node_shared_ptr(), {axis}), 40 ov::op::v0::Constant::create(ov::element::i64, {1}, {0})); 41 42 auto topk = std::make_shared(input, k, axis, mode, ov::op::v11::TopK::SortType::SORT_VALUES, 43 context.get_output_type(), false); 44 45 return rename_outputs_with_suffix({topk->output(1)}, context.get_name()); 46 } 47 48 } // namespace op 49 } // namespace ggml 50 } // namespace frontend 51 } // namespace ov