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/ssm_conv.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 / ssm_conv.cpp` 61 lines ยท 2618 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 12 namespace ov { 13 namespace frontend { 14 namespace ggml { 15 namespace op { 16 17 OutputVector translate_ssm_conv(const NodeContext & context) { 18 num_inputs_check(context, 2, 2); 19 20 auto sx = context.get_input(0); // conv state + input: OV shape [1, n_s, d_inner, ncs] 21 auto c = context.get_input(1); // conv1d weight: OV shape [1, 1, d_inner, d_conv] 22 23 auto sx_shape = context.get_input_shape(0).to_shape(); // [1, n_s, d_inner, ncs] 24 auto c_shape = context.get_input_shape(1).to_shape(); // [1, 1, d_inner, d_conv] 25 26 // int64_t n_s = sx_shape[1]; 27 int64_t d_inner = sx_shape[2]; 28 // int64_t ncs = sx_shape[3]; // d_conv - 1 + n_t 29 int64_t d_conv = c_shape[3]; 30 // int64_t n_t = ncs - d_conv + 1; 31 32 // Reshape sx from [1, n_s, d_inner, ncs] to [n_s, d_inner, ncs] for 1D GroupConvolution 33 auto sx_reshaped = 34 std::make_shared(sx, ov::op::v0::Constant::create(ov::element::i64, {1}, {0})); 35 36 // Reshape c from [1, 1, d_inner, d_conv] to [d_inner, 1, 1, d_conv] 37 // GroupConvolution filter: [groups, out_channels/groups, in_channels/groups, kernel_size] 38 auto c_new_shape = ov::op::v0::Constant::create(ov::element::i64, {4}, std::vector{d_inner, 1, 1, d_conv}); 39 auto c_reshaped = std::make_shared(c, c_new_shape, false); 40 41 // Depthwise 1D convolution: groups=d_inner, stride=1, no padding, no dilation 42 // Input: [n_s, d_inner, ncs], Filter: [d_inner, 1, 1, d_conv] 43 // Output: [n_s, d_inner, n_t] 44 auto conv = std::make_shared( 45 sx_reshaped, c_reshaped, ov::Strides{1}, ov::CoordinateDiff{0}, ov::CoordinateDiff{0}, ov::Strides{1}); 46 47 // Transpose from [n_s, d_inner, n_t] to [n_s, n_t, d_inner] 48 auto perm = ov::op::v0::Constant::create(ov::element::i64, {3}, std::vector{0, 2, 1}); 49 auto transposed = std::make_shared(conv, perm); 50 51 // Reshape to output shape [1, n_s, n_t, d_inner] 52 auto res = 53 std::make_shared(transposed, ov::op::v0::Constant::create(ov::element::i64, {1}, {0})); 54 55 return rename_outputs_with_suffix({res}, context.get_name()); 56 } 57 58 } // namespace op 59 } // namespace ggml 60 } // namespace frontend 61 } // namespace ov