Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/ggml/blob/master/src/ggml-openvino/openvino/op/set.cpp # ggml [Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `ggml / src / ggml-openvino / openvino / op / set.cpp` 76 lines ยท 2847 bytes Raw Blame History 1 #include "../node_context.h" 2 #include "../op_table.h" 3 #include "../utils.h" 4 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 #include 14 #include 15 16 namespace ov { 17 namespace frontend { 18 namespace ggml { 19 namespace op { 20 21 // GGML SET writes src1 into a view of src0 and returns the updated tensor. 22 OutputVector translate_set(const NodeContext & context) { 23 num_inputs_check(context, 2, 2); 24 25 auto dst = process_view_input_new(context, 0); 26 auto src = process_view_input_new(context, 1); 27 28 src = std::make_shared(src, context.get_output_type()); 29 30 const auto dst_stride = context.get_input_stride(0); 31 FRONT_END_OP_CONVERSION_CHECK(dst_stride.size() >= 4, "SET requires 4D destination strides"); 32 33 const auto * op_params = reinterpret_cast(context.get_output_op_params()); 34 const size_t offset = static_cast(op_params[3]); 35 36 const size_t elem_size = dst_stride.back(); 37 FRONT_END_OP_CONVERSION_CHECK(elem_size != 0 && offset % elem_size == 0, 38 "SET offset must be aligned to destination element size"); 39 40 const int64_t offset_elems = static_cast(offset / elem_size); 41 42 auto dst_flat = std::make_shared( 43 dst, 44 ov::op::v0::Constant::create(ov::element::i64, {1}, {-1}), 45 false); 46 47 auto src_flat = std::make_shared( 48 src, 49 ov::op::v0::Constant::create(ov::element::i64, {1}, {-1}), 50 false); 51 52 auto src_shape = std::make_shared(src_flat, ov::element::i64); 53 auto src_len = std::make_shared( 54 src_shape, 55 ov::op::v0::Constant::create(ov::element::i64, {1}, {0}), 56 false); 57 58 auto start = ov::op::v0::Constant::create(ov::element::i64, {}, {offset_elems}); 59 auto stop = std::make_shared(start, src_len); 60 auto step = ov::op::v0::Constant::create(ov::element::i64, {}, {1}); 61 62 auto indices = std::make_shared(start, stop, step, ov::element::i64); 63 auto axis = ov::op::v0::Constant::create(ov::element::i64, {}, {0}); 64 65 auto updated_flat = std::make_shared(dst_flat, indices, src_flat, axis); 66 67 auto dst_shape = std::make_shared(dst, ov::element::i64); 68 auto res = std::make_shared(updated_flat, dst_shape, false); 69 70 return rename_outputs_with_suffix({res}, context.get_name()); 71 } 72 73 } // namespace op 74 } // namespace ggml 75 } // namespace frontend 76 } // namespace ov