#pragma once #include "node_context.h" #include #include #include #include #include namespace ov { namespace frontend { namespace ggml { std::string getCurrentTime(); void dump_ov_model(std::shared_ptr model); void num_inputs_check(const NodeContext & context, size_t min_inputs, size_t max_inputs); int non_cont_dim(std::vector ne, std::vector nb); template std::vector argsort_descend(const std::vector & v) { std::vector idx(v.size()); std::iota(idx.begin(), idx.end(), 0); std::sort(idx.begin(), idx.end(), [&v](int i1, int i2) { return v[i1] > v[i2]; }); return idx; } template std::vector sorted_descend(std::vector v) { std::sort(v.begin(), v.end(), [](T a, T b) { return a > b; }); return v; } template bool is_permuted(const std::vector & strides) { for (size_t i = 0; i < strides.size() - 1; ++i) { if (strides[i] < strides[i + 1]) { return true; } } return false; } template std::vector permute(const std::vector & x, const std::vector & perm) { std::vector result; result.reserve(perm.size()); for (int i : perm) { result.push_back(x[i]); } return result; } std::shared_ptr get_dimensions(const std::shared_ptr & shape, const std::vector & dims); std::shared_ptr get_dimensions(const std::shared_ptr & node, const std::vector & dims); OutputVector rename_outputs_with_suffix(const OutputVector & outputs, const std::string & suffix); std::pair, ov::Output> make_sin_cos(int32_t * rope_params, std::shared_ptr inp_pos, std::shared_ptr rope_freqs_weight = nullptr, bool imrope = false, bool stateful = false); ov::Output process_view_input(const NodeContext & context, int input_index, int slice_len = 0, int axis = -1); ov::Output process_view_input_new(const NodeContext & context, int input_index); namespace op { template OutputVector translate_1to1_match_2_inputs(const NodeContext & context) { num_inputs_check(context, 2, 2); auto input_0 = process_view_input_new(context, 0); auto input_1 = process_view_input_new(context, 1); auto res = std::make_shared(input_0, input_1); return rename_outputs_with_suffix({res}, context.get_name()); } template OutputVector translate_1to1_match_1_input(const NodeContext & context) { num_inputs_check(context, 1, 1); auto input = process_view_input_new(context, 0); auto res = std::make_shared(input); return rename_outputs_with_suffix({res}, context.get_name()); } } // namespace op } // namespace ggml } // namespace frontend } // namespace ov