ggml
[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)
Brought by drakestapleton
ggml / src / ggml-openvino / openvino / op / fill.cpp
| 1 | #include "../node_context.h" |
| 2 | #include "../op_table.h" |
| 3 | #include "../utils.h" |
| 4 | |
| 5 | #include <openvino/op/broadcast.hpp> |
| 6 | #include <openvino/op/constant.hpp> |
| 7 | |
| 8 | namespace ov { |
| 9 | namespace frontend { |
| 10 | namespace ggml { |
| 11 | namespace op { |
| 12 | |
| 13 | // GGML FILL sets all elements of a tensor to a constant value. |
| 14 | // The constant is stored as a float in op_params[0]. |
| 15 | OutputVector translate_fill(const NodeContext & context) { |
| 16 | num_inputs_check(context, 1, 1); |
| 17 | |
| 18 | float c; |
| 19 | memcpy(&c, context.get_output_op_params(), sizeof(float)); |
| 20 | |
| 21 | auto shape = context.get_input_shape(0).to_shape(); |
| 22 | |
| 23 | auto val = ov::op::v0::Constant::create(context.get_output_type(), {}, {c}); |
| 24 | auto target_shape = ov::op::v0::Constant::create(ov::element::i64, {shape.size()}, |
| 25 | std::vector<int64_t>(shape.begin(), shape.end())); |
| 26 | auto res = std::make_shared<ov::op::v3::Broadcast>(val, target_shape); |
| 27 | |
| 28 | return rename_outputs_with_suffix({res}, context.get_name()); |
| 29 | } |
| 30 | |
| 31 | } // namespace op |
| 32 | } // namespace ggml |
| 33 | } // namespace frontend |
| 34 | } // namespace ov |