#include "../node_context.h" #include "../op_table.h" #include "../utils.h" #include #include #include #include #include #include #include #include #include #include namespace ov { namespace frontend { namespace ggml { namespace op { // GGML SET writes src1 into a view of src0 and returns the updated tensor. OutputVector translate_set(const NodeContext & context) { num_inputs_check(context, 2, 2); auto dst = process_view_input_new(context, 0); auto src = process_view_input_new(context, 1); src = std::make_shared(src, context.get_output_type()); const auto dst_stride = context.get_input_stride(0); FRONT_END_OP_CONVERSION_CHECK(dst_stride.size() >= 4, "SET requires 4D destination strides"); const auto * op_params = reinterpret_cast(context.get_output_op_params()); const size_t offset = static_cast(op_params[3]); const size_t elem_size = dst_stride.back(); FRONT_END_OP_CONVERSION_CHECK(elem_size != 0 && offset % elem_size == 0, "SET offset must be aligned to destination element size"); const int64_t offset_elems = static_cast(offset / elem_size); auto dst_flat = std::make_shared( dst, ov::op::v0::Constant::create(ov::element::i64, {1}, {-1}), false); auto src_flat = std::make_shared( src, ov::op::v0::Constant::create(ov::element::i64, {1}, {-1}), false); auto src_shape = std::make_shared(src_flat, ov::element::i64); auto src_len = std::make_shared( src_shape, ov::op::v0::Constant::create(ov::element::i64, {1}, {0}), false); auto start = ov::op::v0::Constant::create(ov::element::i64, {}, {offset_elems}); auto stop = std::make_shared(start, src_len); auto step = ov::op::v0::Constant::create(ov::element::i64, {}, {1}); auto indices = std::make_shared(start, stop, step, ov::element::i64); auto axis = ov::op::v0::Constant::create(ov::element::i64, {}, {0}); auto updated_flat = std::make_shared(dst_flat, indices, src_flat, axis); auto dst_shape = std::make_shared(dst, ov::element::i64); auto res = std::make_shared(updated_flat, dst_shape, false); return rename_outputs_with_suffix({res}, context.get_name()); } } // namespace op } // namespace ggml } // namespace frontend } // namespace ov