op/diag.cpp

whisper.cpp · ggml/src/ggml-openvino/openvino/op/diag.cpp · cpp · MIT
ai, tag:knn-classified

Implements the GGML diag operation in OpenVINO, converting a vector into a diagonal matrix.

// Source: https://github.com/ggml-org/whisper.cpp | License: MIT | Copyright 2023-2026 The ggml authors
// Provided via justclaw.it.com; keep this notice with the code.
#include "../node_context.h"
#include "../op_table.h"
#include "../utils.h"

#include <openvino/op/constant.hpp>
#include <openvino/op/eye.hpp>
#include <openvino/op/multiply.hpp>

namespace ov {
namespace frontend {
namespace ggml {
namespace op {

// GGML DIAG takes a 1D vector (ne0, 1, ne2, ne3) and produces a diagonal matrix
// of shape (ne0, ne0, ne2, ne3).
// In OV layout (ggml [ne0, ne1, ne2, ne3] → OV [ne3, ne2, ne1, ne0]):
//   input:  [ne3, ne2, 1, ne0]
//   output: [ne3, ne2, ne0, ne0]
// The diagonal: output[..., i, j] = input[..., 0, j] if i == j, else 0.
OutputVector translate_diag(const NodeContext & context

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key