char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Zijun Yuopenvino: OV 2026.2, context-shift, Q5_1 support, gemma4 dense/embedding, and -fa off (#24503)890f1a27e

char/aliceai-t5-moe
1.8 KiB54 linesraw
1#include "../node_context.h"
2#include "../op_table.h"
3#include "../utils.h"
4
5#include <openvino/op/transpose.hpp>
6
7namespace ov {
8namespace frontend {
9namespace ggml {
10namespace op {
11
12OutputVector 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_shape = context.get_input_shape(0).to_shape();
18    auto input_stride = context.get_input_stride(0);
19    auto output_shape = context.get_output_shape().to_shape();
20    auto output_stride = context.get_output_stride();
21
22    // Compute permute order by matching output and input stride rankings.
23    // Build <stride, dim_index> pairs.
24    std::vector<std::pair<size_t, int>> output_stride_dims;
25    std::vector<std::pair<size_t, int>> input_stride_dims;
26
27    for (int i = 0; i < 4; ++i) {
28        output_stride_dims.push_back({output_stride[i], i});
29        input_stride_dims.push_back({input_stride[i], i});
30    }
31
32    // Sort by stride in descending order.
33    std::sort(output_stride_dims.rbegin(), output_stride_dims.rend());
34    std::sort(input_stride_dims.rbegin(), input_stride_dims.rend());
35
36    // Build permute order.
37    std::vector<int64_t> permute_order(4);
38    for (int i = 0; i < 4; ++i) {
39        int output_dim = output_stride_dims[i].second;
40        int input_dim = input_stride_dims[i].second;
41        permute_order[output_dim] = input_dim;
42    }
43
44    auto input = process_view_input_new(context, 0);
45
46    auto res = std::make_shared<ov::op::v1::Transpose>(
47        input, ov::op::v0::Constant::create(ov::element::i64, {4}, permute_order));
48    return rename_outputs_with_suffix({res}, context.get_name());
49}
50
51}  // namespace op
52}  // namespace ggml
53}  // namespace frontend
54}  // namespace ov