interplane.Get Omega
Read in your language

ggml

[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)

Brought by drakestapleton

branch master Branches Tags History

ggml / src / ggml-openvino / openvino / op / repeat.cpp

47 lines · 1612 bytes Raw Blame History
1#include "../node_context.h"
2#include "../op_table.h"
3#include "../utils.h"
4
5#include <memory>
6#include <openvino/op/broadcast.hpp>
7#include <openvino/op/constant.hpp>
8#include <openvino/op/divide.hpp>
9#include <openvino/op/shape_of.hpp>
10#include <openvino/op/tile.hpp>
11#include <vector>
12
13namespace ov {
14namespace frontend {
15namespace ggml {
16namespace op {
17
18// GGML_OP_REPEAT tiles src[0] to fill the destination shape. Every destination
19// dimension is an integer multiple of the corresponding source dimension.
20OutputVector translate_repeat(const NodeContext & context) {
21 num_inputs_check(context, 1, 2);
22
23 auto input = process_view_input_new(context, 0);
24
25 const auto input_shape = context.get_input_shape(0).to_shape();
26 const auto output_shape = context.get_output_shape().to_shape();
27
28 std::vector<int64_t> repeats(4, 1);
29 for (size_t axis = 0; axis < 4; ++axis) {
30 const int64_t input_dim = input_shape[axis];
31 const int64_t output_dim = output_shape[axis];
32
33 FRONT_END_OP_CONVERSION_CHECK(input_dim > 0 && output_dim > 0 && output_dim % input_dim == 0,
34 "REPEAT input shape ", input_shape, " cannot tile to match ", output_shape);
35
36 repeats[axis] = output_dim / input_dim;
37 }
38
39 auto repeats_node = ov::op::v0::Constant::create(ov::element::i64, {repeats.size()}, repeats);
40 ov::Output<ov::Node> res = std::make_shared<ov::op::v0::Tile>(input, repeats_node);
41 return rename_outputs_with_suffix({res}, context.get_name());
42}
43
44} // namespace op
45} // namespace ggml
46} // namespace frontend
47} // namespace ov