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/transpose.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 / transpose.cpp` 52 lines ยท 1723 bytes Raw Blame History 1 #include "../node_context.h" 2 #include "../op_table.h" 3 #include "../utils.h" 4 5 #include 6 7 namespace ov { 8 namespace frontend { 9 namespace ggml { 10 namespace op { 11 12 OutputVector translate_transpose(const NodeContext & context) { 13 num_inputs_check(context, 1, 1); 14 15 // Compute permute order from input/output shape and stride information 16 // so it adapts to different input and output layouts. 17 auto input_stride = context.get_input_stride(0); 18 auto output_stride = context.get_output_stride(); 19 20 // Compute permute order by matching output and input stride rankings. 21 // Build pairs. 22 std::vector> output_stride_dims; 23 std::vector> input_stride_dims; 24 25 for (int i = 0; i < 4; ++i) { 26 output_stride_dims.push_back({output_stride[i], i}); 27 input_stride_dims.push_back({input_stride[i], i}); 28 } 29 30 // Sort by stride in descending order. 31 std::sort(output_stride_dims.rbegin(), output_stride_dims.rend()); 32 std::sort(input_stride_dims.rbegin(), input_stride_dims.rend()); 33 34 // Build permute order. 35 std::vector permute_order(4); 36 for (int i = 0; i < 4; ++i) { 37 int output_dim = output_stride_dims[i].second; 38 int input_dim = input_stride_dims[i].second; 39 permute_order[output_dim] = input_dim; 40 } 41 42 auto input = process_view_input_new(context, 0); 43 44 auto res = std::make_shared( 45 input, ov::op::v0::Constant::create(ov::element::i64, {4}, permute_order)); 46 return rename_outputs_with_suffix({res}, context.get_name()); 47 } 48 49 } // namespace op 50 } // namespace ggml 51 } // namespace frontend 52 } // namespace ov