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