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/glu_geglu_quick.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 / glu_geglu_quick.cpp` 62 lines ยท 2349 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_glu_geglu_quick(const NodeContext & context) { 18 num_inputs_check(context, 1, 2); 19 20 ov::Output src0; 21 ov::Output src1; 22 if (context.get_input_size() == 2) { 23 src0 = process_view_input_new(context, 0); 24 src1 = process_view_input_new(context, 1); 25 } else { 26 // split along last axis, nc = ne[0] / 2 27 auto combined = process_view_input_new(context, 0); 28 auto combined_shape = combined.get_partial_shape(); 29 int64_t last_dim_val = combined_shape[combined_shape.rank().get_length() - 1].get_length(); 30 int64_t nc = last_dim_val / 2; 31 32 auto axis = ov::op::v0::Constant::create(ov::element::i64, {1}, {-1}); 33 auto step = ov::op::v0::Constant::create(ov::element::i64, {1}, {1}); 34 auto start0 = ov::op::v0::Constant::create(ov::element::i64, {1}, {0}); 35 auto stop0 = ov::op::v0::Constant::create(ov::element::i64, {1}, {nc}); 36 auto start1 = ov::op::v0::Constant::create(ov::element::i64, {1}, {nc}); 37 auto stop1 = ov::op::v0::Constant::create(ov::element::i64, {1}, {2 * nc}); 38 39 src0 = std::make_shared(combined, start0, stop0, step, axis); 40 src1 = std::make_shared(combined, start1, stop1, step, axis); 41 } 42 43 int32_t * params = context.get_output_op_params(); 44 const int32_t swapped = params[1]; 45 if (swapped) { 46 std::swap(src0, src1); 47 } 48 49 // GELU_QUICK(x) = x * sigmoid(1.702 * x) 50 // Create the constant in the same type as src0 to avoid f16/f32 mismatch. 51 auto input_type = src0.get_element_type(); 52 auto coef = ov::op::v0::Constant::create(input_type, ov::Shape{}, {1.702f}); 53 auto gated = std::make_shared(src0, coef); 54 auto res = std::make_shared(gated, src1); 55 56 return rename_outputs_with_suffix({res}, context.get_name()); 57 } 58 59 } // namespace op 60 } // namespace ggml 61 } // namespace frontend 62 } // namespace ov