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/l2_norm.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 / l2_norm.cpp` 61 lines ยท 2350 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 15 namespace ov { 16 namespace frontend { 17 namespace ggml { 18 namespace op { 19 20 OutputVector translate_l2_norm(const NodeContext & context) { 21 num_inputs_check(context, 1, 1); 22 23 auto input_node = process_view_input_new(context, 0); 24 25 if (context.get_op_case() == 1) { 26 // 92: [ 128, 16, 1, 2] VIEW q_conv-1 27 // [ 6144, 1, 2, 1] 0: UNARY conv_output_silu-1 28 // 93: [ 128, 16, 1, 2] L2_NORM q_conv_predelta-1 29 // [ 128, 16, 1, 2] 0: VIEW q_conv-1 30 auto output_shape = context.get_output_shape().to_shape(); 31 input_node = process_view_input(context, 0, output_shape[2] * output_shape[3], 3); 32 input_node = 33 std::make_shared(input_node, ov::op::v0::Constant::create(ov::element::i64, {1}, {0})); 34 35 std::vector reshape_pattern = {0, 0, (int64_t) output_shape[2], (int64_t) output_shape[3]}; 36 input_node = std::make_shared( 37 input_node, ov::op::v0::Constant::create(ov::element::i64, {4}, reshape_pattern), true); 38 } 39 40 auto squared = std::make_shared(input_node, input_node); 41 42 auto sum_squared = std::make_shared( 43 squared, ov::op::v0::Constant::create(ov::element::i64, ov::Shape{1}, {-1}), true); 44 45 auto l2_norm = std::make_shared(sum_squared); 46 47 float eps; 48 memcpy(&eps, context.get_output_op_params(), sizeof(float)); 49 50 auto eps_const = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{1}, {eps}); 51 auto clamped_norm = std::make_shared(l2_norm, eps_const); 52 53 auto res = std::make_shared(input_node, clamped_norm); 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