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 / concat.cpp

48 lines · 1647 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/frontend/exception.hpp>
7#include <openvino/op/concat.hpp>
8#include <openvino/op/convert.hpp>
9
10namespace ov {
11namespace frontend {
12namespace ggml {
13namespace op {
14
15OutputVector translate_concat(const NodeContext & context) {
16 num_inputs_check(context, 2, 2);
17
18 const int32_t * op_params = context.get_output_op_params();
19 FRONT_END_CHECK_IMPLEMENTED(op_params != nullptr, "CONCAT requires output op params");
20
21 const auto output_shape = context.get_output_shape();
22 FRONT_END_CHECK_IMPLEMENTED(output_shape.rank().is_static(), "CONCAT requires static output rank");
23
24 const auto rank = output_shape.rank().get_length();
25 const int32_t ggml_dim = op_params[0];
26 FRONT_END_CHECK_IMPLEMENTED(ggml_dim >= 0 && ggml_dim < rank, "CONCAT axis is out of range");
27
28 auto input_0 = process_view_input_new(context, 0);
29 auto input_1 = process_view_input_new(context, 1);
30 const auto output_type = context.get_output_type();
31
32 if (input_0.get_element_type() != output_type) {
33 input_0 = std::make_shared<ov::op::v0::Convert>(input_0, output_type);
34 }
35 if (input_1.get_element_type() != output_type) {
36 input_1 = std::make_shared<ov::op::v0::Convert>(input_1, output_type);
37 }
38
39 const auto axis = static_cast<int64_t>(rank - 1 - ggml_dim);
40 auto res = std::make_shared<ov::op::v0::Concat>(OutputVector{input_0, input_1}, axis);
41
42 return rename_outputs_with_suffix({res}, context.get_name());
43}
44
45} // namespace op
46} // namespace ggml
47} // namespace frontend
48} // namespace ov