STYLE and minor REFACTOR
This commit is contained in:
parent
cdf5370cb5
commit
0d505b4e56
|
|
@ -1,4 +1,4 @@
|
||||||
#include "openvino/op/add.hpp"
|
#include <openvino/op/add.hpp>
|
||||||
|
|
||||||
#include "../node_context.hpp"
|
#include "../node_context.hpp"
|
||||||
#include "../utils.hpp"
|
#include "../utils.hpp"
|
||||||
|
|
@ -15,7 +15,7 @@ OutputVector translate_add(const NodeContext& context) {
|
||||||
auto rhs = context.get_input(1);
|
auto rhs = context.get_input(1);
|
||||||
auto add = std::make_shared<ov::op::v1::Add>(lhs, rhs);
|
auto add = std::make_shared<ov::op::v1::Add>(lhs, rhs);
|
||||||
return {add};
|
return {add};
|
||||||
};
|
}
|
||||||
|
|
||||||
} // namespace op
|
} // namespace op
|
||||||
} // namespace ggml
|
} // namespace ggml
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <openvino/op/reshape.hpp>
|
||||||
|
#include <openvino/op/slice.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../node_context.hpp"
|
#include "../node_context.hpp"
|
||||||
#include "../utils.hpp"
|
#include "../utils.hpp"
|
||||||
#include "openvino/op/reshape.hpp"
|
|
||||||
#include "openvino/op/slice.hpp"
|
|
||||||
|
|
||||||
namespace ov {
|
namespace ov {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
@ -48,7 +48,7 @@ OutputVector translate_cont(const NodeContext& context) {
|
||||||
|
|
||||||
return {slice};
|
return {slice};
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
} // namespace op
|
} // namespace op
|
||||||
} // namespace ggml
|
} // namespace ggml
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <openvino/core/node.hpp>
|
||||||
|
#include <openvino/core/node_output.hpp>
|
||||||
|
#include <openvino/op/add.hpp>
|
||||||
|
#include <openvino/op/constant.hpp>
|
||||||
|
#include <openvino/op/convert_like.hpp>
|
||||||
|
#include <openvino/op/range.hpp>
|
||||||
|
#include <openvino/op/reshape.hpp>
|
||||||
|
#include <openvino/op/scatter_nd_update.hpp>
|
||||||
|
#include <openvino/op/transpose.hpp>
|
||||||
|
#include <openvino/op/unsqueeze.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../node_context.hpp"
|
#include "../node_context.hpp"
|
||||||
#include "../utils.hpp"
|
#include "../utils.hpp"
|
||||||
#include "openvino/core/node.hpp"
|
|
||||||
#include "openvino/core/node_output.hpp"
|
|
||||||
#include "openvino/op/add.hpp"
|
|
||||||
#include "openvino/op/constant.hpp"
|
|
||||||
#include "openvino/op/convert_like.hpp"
|
|
||||||
#include "openvino/op/range.hpp"
|
|
||||||
#include "openvino/op/reshape.hpp"
|
|
||||||
#include "openvino/op/scatter_nd_update.hpp"
|
|
||||||
#include "openvino/op/transpose.hpp"
|
|
||||||
#include "openvino/op/unsqueeze.hpp"
|
|
||||||
|
|
||||||
namespace ov {
|
namespace ov {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
@ -98,7 +98,7 @@ OutputVector translate_cpy(const NodeContext& context) {
|
||||||
false);
|
false);
|
||||||
return {reshaped_res};
|
return {reshaped_res};
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
} // namespace op
|
} // namespace op
|
||||||
} // namespace ggml
|
} // namespace ggml
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
#include <cstdint>
|
#include <openvino/core/node.hpp>
|
||||||
|
#include <openvino/core/node_output.hpp>
|
||||||
|
#include <openvino/op/constant.hpp>
|
||||||
|
#include <openvino/op/convert.hpp>
|
||||||
|
#include <openvino/op/gather.hpp>
|
||||||
|
#include <openvino/op/reshape.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../node_context.hpp"
|
#include "../node_context.hpp"
|
||||||
#include "../utils.hpp"
|
#include "../utils.hpp"
|
||||||
#include "openvino/core/node.hpp"
|
|
||||||
#include "openvino/core/node_output.hpp"
|
|
||||||
#include "openvino/op/constant.hpp"
|
|
||||||
#include "openvino/op/convert.hpp"
|
|
||||||
#include "openvino/op/gather.hpp"
|
|
||||||
#include "openvino/op/reshape.hpp"
|
|
||||||
|
|
||||||
namespace ov {
|
namespace ov {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
@ -32,7 +31,7 @@ OutputVector translate_get_rows(const NodeContext& context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {res};
|
return {res};
|
||||||
};
|
}
|
||||||
|
|
||||||
} // namespace op
|
} // namespace op
|
||||||
} // namespace ggml
|
} // namespace ggml
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,7 @@
|
||||||
#include <cstdint>
|
#include <openvino/op/multiply.hpp>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "../node_context.hpp"
|
#include "../node_context.hpp"
|
||||||
#include "../utils.hpp"
|
#include "../utils.hpp"
|
||||||
#include "openvino/core/node.hpp"
|
|
||||||
#include "openvino/core/node_output.hpp"
|
|
||||||
#include "openvino/op/broadcast.hpp"
|
|
||||||
#include "openvino/op/constant.hpp"
|
|
||||||
#include "openvino/op/multiply.hpp"
|
|
||||||
#include "openvino/op/reshape.hpp"
|
|
||||||
|
|
||||||
namespace ov {
|
namespace ov {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
@ -20,7 +13,7 @@ OutputVector translate_mul(const NodeContext& context) {
|
||||||
|
|
||||||
auto res = std::make_shared<ov::op::v1::Multiply>(context.get_input(0), context.get_input(1));
|
auto res = std::make_shared<ov::op::v1::Multiply>(context.get_input(0), context.get_input(1));
|
||||||
return {res};
|
return {res};
|
||||||
};
|
}
|
||||||
|
|
||||||
} // namespace op
|
} // namespace op
|
||||||
} // namespace ggml
|
} // namespace ggml
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,23 @@
|
||||||
|
#include <openvino/op/constant.hpp>
|
||||||
|
#include <openvino/op/transpose.hpp>
|
||||||
|
|
||||||
#include "../node_context.hpp"
|
#include "../node_context.hpp"
|
||||||
#include "../utils.hpp"
|
#include "../utils.hpp"
|
||||||
#include "openvino/op/constant.hpp"
|
|
||||||
#include "openvino/op/transpose.hpp"
|
|
||||||
|
|
||||||
namespace ov {
|
namespace ov {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
namespace ggml {
|
namespace ggml {
|
||||||
namespace op {
|
namespace op {
|
||||||
|
|
||||||
OutputVector translate_permute(const NodeContext& context) {
|
OutputVector translate_permute(const NodeContext& context) {
|
||||||
num_inputs_check(context, 1, 1);
|
num_inputs_check(context, 1, 1);
|
||||||
|
|
||||||
// TODO: make this more general
|
auto perm = argsort_descend(context.get_output_stride(0));
|
||||||
auto res = std::make_shared<ov::op::v1::Transpose>(context.get_input(0),
|
auto res = std::make_shared<ov::op::v1::Transpose>(context.get_input(0),
|
||||||
ov::op::v0::Constant::create(ov::element::i64, {3}, {1, 0, 2}));
|
ov::op::v0::Constant::create(ov::element::i64, {3}, perm));
|
||||||
|
|
||||||
return {res};
|
return {res};
|
||||||
};
|
}
|
||||||
|
|
||||||
} // namespace op
|
} // namespace op
|
||||||
} // namespace ggml
|
} // namespace ggml
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
#include "openvino/op/reshape.hpp"
|
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <openvino/core/node.hpp>
|
||||||
|
#include <openvino/core/node_output.hpp>
|
||||||
|
#include <openvino/op/constant.hpp>
|
||||||
|
#include <openvino/op/reshape.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../node_context.hpp"
|
#include "../node_context.hpp"
|
||||||
#include "../utils.hpp"
|
#include "../utils.hpp"
|
||||||
#include "openvino/core/node.hpp"
|
|
||||||
#include "openvino/core/node_output.hpp"
|
|
||||||
#include "openvino/op/constant.hpp"
|
|
||||||
|
|
||||||
namespace ov {
|
namespace ov {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
@ -27,7 +26,7 @@ OutputVector translate_reshape(const NodeContext& context) {
|
||||||
std::vector<int64_t>{-1, (int64_t)output_shape[1], (int64_t)output_shape[2]});
|
std::vector<int64_t>{-1, (int64_t)output_shape[1], (int64_t)output_shape[2]});
|
||||||
Output<Node> res = std::make_shared<ov::op::v1::Reshape>(context.get_input(0), new_shape_node, false);
|
Output<Node> res = std::make_shared<ov::op::v1::Reshape>(context.get_input(0), new_shape_node, false);
|
||||||
return {res};
|
return {res};
|
||||||
};
|
}
|
||||||
|
|
||||||
} // namespace op
|
} // namespace op
|
||||||
} // namespace ggml
|
} // namespace ggml
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
|
#include <openvino/op/add.hpp>
|
||||||
|
#include <openvino/op/constant.hpp>
|
||||||
|
#include <openvino/op/divide.hpp>
|
||||||
|
#include <openvino/op/multiply.hpp>
|
||||||
|
#include <openvino/op/reduce_sum.hpp>
|
||||||
|
#include <openvino/op/sqrt.hpp>
|
||||||
|
|
||||||
#include "../node_context.hpp"
|
#include "../node_context.hpp"
|
||||||
#include "../utils.hpp"
|
#include "../utils.hpp"
|
||||||
#include "openvino/op/add.hpp"
|
|
||||||
#include "openvino/op/constant.hpp"
|
|
||||||
#include "openvino/op/divide.hpp"
|
|
||||||
#include "openvino/op/multiply.hpp"
|
|
||||||
#include "openvino/op/reduce_sum.hpp"
|
|
||||||
#include "openvino/op/sqrt.hpp"
|
|
||||||
|
|
||||||
namespace ov {
|
namespace ov {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
@ -39,7 +40,7 @@ OutputVector translate_rms_norm(const NodeContext& context) {
|
||||||
auto res = std::make_shared<ov::op::v1::Multiply>(input_node, scale);
|
auto res = std::make_shared<ov::op::v1::Multiply>(input_node, scale);
|
||||||
|
|
||||||
return {res};
|
return {res};
|
||||||
};
|
}
|
||||||
|
|
||||||
} // namespace op
|
} // namespace op
|
||||||
} // namespace ggml
|
} // namespace ggml
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,27 @@
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <openvino/core/node.hpp>
|
||||||
|
#include <openvino/core/node_output.hpp>
|
||||||
|
#include <openvino/op/add.hpp>
|
||||||
|
#include <openvino/op/broadcast.hpp>
|
||||||
|
#include <openvino/op/concat.hpp>
|
||||||
|
#include <openvino/op/constant.hpp>
|
||||||
|
#include <openvino/op/convert.hpp>
|
||||||
|
#include <openvino/op/cos.hpp>
|
||||||
|
#include <openvino/op/divide.hpp>
|
||||||
|
#include <openvino/op/multiply.hpp>
|
||||||
|
#include <openvino/op/reshape.hpp>
|
||||||
|
#include <openvino/op/shape_of.hpp>
|
||||||
|
#include <openvino/op/sin.hpp>
|
||||||
|
#include <openvino/op/slice.hpp>
|
||||||
|
#include <openvino/op/split.hpp>
|
||||||
|
#include <openvino/op/subtract.hpp>
|
||||||
|
#include <openvino/op/transpose.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../node_context.hpp"
|
#include "../node_context.hpp"
|
||||||
#include "../utils.hpp"
|
#include "../utils.hpp"
|
||||||
#include "openvino/core/node.hpp"
|
|
||||||
#include "openvino/core/node_output.hpp"
|
|
||||||
#include "openvino/op/add.hpp"
|
|
||||||
#include "openvino/op/broadcast.hpp"
|
|
||||||
#include "openvino/op/concat.hpp"
|
|
||||||
#include "openvino/op/constant.hpp"
|
|
||||||
#include "openvino/op/convert.hpp"
|
|
||||||
#include "openvino/op/cos.hpp"
|
|
||||||
#include "openvino/op/divide.hpp"
|
|
||||||
#include "openvino/op/multiply.hpp"
|
|
||||||
#include "openvino/op/reshape.hpp"
|
|
||||||
#include "openvino/op/shape_of.hpp"
|
|
||||||
#include "openvino/op/sin.hpp"
|
|
||||||
#include "openvino/op/slice.hpp"
|
|
||||||
#include "openvino/op/split.hpp"
|
|
||||||
#include "openvino/op/subtract.hpp"
|
|
||||||
#include "openvino/op/transpose.hpp"
|
|
||||||
|
|
||||||
#define GGML_ROPE_TYPE_NEOX 2
|
#define GGML_ROPE_TYPE_NEOX 2
|
||||||
|
|
||||||
|
|
@ -163,7 +163,7 @@ OutputVector translate_rope(const NodeContext& context) {
|
||||||
auto res_node = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{first_half_node, second_half_node}, 2);
|
auto res_node = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{first_half_node, second_half_node}, 2);
|
||||||
return {res_node};
|
return {res_node};
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
} // namespace op
|
} // namespace op
|
||||||
} // namespace ggml
|
} // namespace ggml
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,9 @@
|
||||||
#include <cstdint>
|
#include <openvino/op/constant.hpp>
|
||||||
|
#include <openvino/op/multiply.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../node_context.hpp"
|
#include "../node_context.hpp"
|
||||||
#include "../utils.hpp"
|
#include "../utils.hpp"
|
||||||
#include "openvino/core/node.hpp"
|
|
||||||
#include "openvino/core/node_output.hpp"
|
|
||||||
#include "openvino/op/constant.hpp"
|
|
||||||
#include "openvino/op/multiply.hpp"
|
|
||||||
|
|
||||||
namespace ov {
|
namespace ov {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
@ -23,7 +20,7 @@ OutputVector translate_scale(const NodeContext& context) {
|
||||||
auto res = std::make_shared<ov::op::v1::Multiply>(context.get_input(0), scale_node);
|
auto res = std::make_shared<ov::op::v1::Multiply>(context.get_input(0), scale_node);
|
||||||
|
|
||||||
return {res};
|
return {res};
|
||||||
};
|
}
|
||||||
|
|
||||||
} // namespace op
|
} // namespace op
|
||||||
} // namespace ggml
|
} // namespace ggml
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <openvino/core/node.hpp>
|
||||||
|
#include <openvino/core/node_output.hpp>
|
||||||
|
#include <openvino/op/add.hpp>
|
||||||
|
#include <openvino/op/concat.hpp>
|
||||||
|
#include <openvino/op/constant.hpp>
|
||||||
|
#include <openvino/op/convert.hpp>
|
||||||
|
#include <openvino/op/multiply.hpp>
|
||||||
|
#include <openvino/op/slice.hpp>
|
||||||
|
#include <openvino/op/softmax.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../node_context.hpp"
|
#include "../node_context.hpp"
|
||||||
#include "../utils.hpp"
|
#include "../utils.hpp"
|
||||||
#include "openvino/core/node.hpp"
|
|
||||||
#include "openvino/core/node_output.hpp"
|
|
||||||
#include "openvino/op/add.hpp"
|
|
||||||
#include "openvino/op/concat.hpp"
|
|
||||||
#include "openvino/op/constant.hpp"
|
|
||||||
#include "openvino/op/convert.hpp"
|
|
||||||
#include "openvino/op/multiply.hpp"
|
|
||||||
#include "openvino/op/slice.hpp"
|
|
||||||
#include "openvino/op/softmax.hpp"
|
|
||||||
|
|
||||||
namespace ov {
|
namespace ov {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include "openvino/op/transpose.hpp"
|
#include <openvino/op/transpose.hpp>
|
||||||
|
|
||||||
#include "../node_context.hpp"
|
#include "../node_context.hpp"
|
||||||
#include "../utils.hpp"
|
#include "../utils.hpp"
|
||||||
|
|
@ -15,7 +15,7 @@ OutputVector translate_transpose(const NodeContext& context) {
|
||||||
auto res = std::make_shared<ov::op::v1::Transpose>(context.get_input(0),
|
auto res = std::make_shared<ov::op::v1::Transpose>(context.get_input(0),
|
||||||
ov::op::v0::Constant::create(ov::element::i64, {3}, perm));
|
ov::op::v0::Constant::create(ov::element::i64, {3}, perm));
|
||||||
return {res};
|
return {res};
|
||||||
};
|
}
|
||||||
|
|
||||||
} // namespace op
|
} // namespace op
|
||||||
} // namespace ggml
|
} // namespace ggml
|
||||||
|
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "../node_context.hpp"
|
|
||||||
#include "../utils.hpp"
|
|
||||||
#include "openvino/core/node.hpp"
|
|
||||||
#include "openvino/core/node_output.hpp"
|
|
||||||
|
|
||||||
namespace ov {
|
|
||||||
namespace frontend {
|
|
||||||
namespace ggml {
|
|
||||||
namespace op {
|
|
||||||
|
|
||||||
OutputVector translate_unary(const NodeContext& context) {
|
|
||||||
num_inputs_check(context, 1, 1);
|
|
||||||
|
|
||||||
return {context.get_input(0)};
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace op
|
|
||||||
} // namespace ggml
|
|
||||||
} // namespace frontend
|
|
||||||
} // namespace ov
|
|
||||||
|
|
@ -1,12 +1,9 @@
|
||||||
#include <cstdint>
|
#include <openvino/core/node_output.hpp>
|
||||||
#include <vector>
|
#include <openvino/op/multiply.hpp>
|
||||||
|
#include <openvino/op/sigmoid.hpp>
|
||||||
|
|
||||||
#include "../node_context.hpp"
|
#include "../node_context.hpp"
|
||||||
#include "../utils.hpp"
|
#include "../utils.hpp"
|
||||||
#include "openvino/core/node.hpp"
|
|
||||||
#include "openvino/core/node_output.hpp"
|
|
||||||
#include "openvino/op/multiply.hpp"
|
|
||||||
#include "openvino/op/sigmoid.hpp"
|
|
||||||
|
|
||||||
namespace ov {
|
namespace ov {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
@ -21,7 +18,7 @@ OutputVector translate_unary_silu(const NodeContext& context) {
|
||||||
auto res = std::make_shared<ov::op::v1::Multiply>(input, sigmoid);
|
auto res = std::make_shared<ov::op::v1::Multiply>(input, sigmoid);
|
||||||
|
|
||||||
return {res};
|
return {res};
|
||||||
};
|
}
|
||||||
|
|
||||||
} // namespace op
|
} // namespace op
|
||||||
} // namespace ggml
|
} // namespace ggml
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,4 @@
|
||||||
#include <cstdint>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "../utils.hpp"
|
#include "../utils.hpp"
|
||||||
#include "openvino/core/node.hpp"
|
|
||||||
#include "openvino/core/node_output.hpp"
|
|
||||||
#include "openvino/op/constant.hpp"
|
|
||||||
#include "openvino/op/convert.hpp"
|
|
||||||
#include "openvino/op/reshape.hpp"
|
|
||||||
#include "openvino/op/strided_slice.hpp"
|
|
||||||
|
|
||||||
namespace ov {
|
namespace ov {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
@ -18,7 +9,7 @@ OutputVector translate_view(const NodeContext& context) {
|
||||||
num_inputs_check(context, 1, 1);
|
num_inputs_check(context, 1, 1);
|
||||||
|
|
||||||
return {context.get_input(0)};
|
return {context.get_input(0)};
|
||||||
};
|
}
|
||||||
|
|
||||||
} // namespace op
|
} // namespace op
|
||||||
} // namespace ggml
|
} // namespace ggml
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ GGML_OP_CONVERTER(translate_view);
|
||||||
|
|
||||||
} // namespace op
|
} // namespace op
|
||||||
|
|
||||||
const std::unordered_map<std::string, CreatorFunction> get_supported_ops() {
|
std::unordered_map<std::string, CreatorFunction> get_supported_ops() {
|
||||||
return {{"GGML_OP_ADD", op::translate_1to1_match_2_inputs<v1::Add>},
|
return {{"GGML_OP_ADD", op::translate_1to1_match_2_inputs<v1::Add>},
|
||||||
{"GGML_OP_ADD1", op::translate_1to1_match_2_inputs<v1::Add>},
|
{"GGML_OP_ADD1", op::translate_1to1_match_2_inputs<v1::Add>},
|
||||||
{"GGML_OP_CONT", op::translate_cont},
|
{"GGML_OP_CONT", op::translate_cont},
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ namespace ov {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
namespace ggml {
|
namespace ggml {
|
||||||
|
|
||||||
const std::unordered_map<std::string, CreatorFunction> get_supported_ops();
|
std::unordered_map<std::string, CreatorFunction> get_supported_ops();
|
||||||
|
|
||||||
} // namespace ggml
|
} // namespace ggml
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
#include "translate_session.hpp"
|
#include "translate_session.hpp"
|
||||||
|
|
||||||
#include <exception>
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include "input_model.hpp"
|
#include "input_model.hpp"
|
||||||
|
|
||||||
namespace ov {
|
namespace ov {
|
||||||
|
|
@ -22,39 +19,9 @@ std::shared_ptr<Model> TranslateSession::get_converted_model() {
|
||||||
return m_ov_model;
|
return m_ov_model;
|
||||||
}
|
}
|
||||||
m_ov_model = translate_graph(m_input_model);
|
m_ov_model = translate_graph(m_input_model);
|
||||||
// print_model_topology();
|
|
||||||
return m_ov_model;
|
return m_ov_model;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TranslateSession::print_model_topology() {
|
|
||||||
try {
|
|
||||||
std::ofstream outfile("model_topology.txt", std::ios::out | std::ios::app);
|
|
||||||
if (!outfile.is_open()) {
|
|
||||||
throw std::runtime_error("Failed to open file for writing model topology.");
|
|
||||||
}
|
|
||||||
|
|
||||||
outfile << "============ Model ============" << std::endl;
|
|
||||||
for (const auto& op : m_ov_model->get_ordered_ops()) {
|
|
||||||
outfile << "Operation: " << op->get_friendly_name() << std::endl;
|
|
||||||
outfile << " Inputs:" << std::endl;
|
|
||||||
for (const auto& input : op->inputs()) {
|
|
||||||
outfile << " " << input.get_node()->get_friendly_name() << " -> " << input.get_element_type() << " "
|
|
||||||
<< input.get_shape() << std::endl;
|
|
||||||
}
|
|
||||||
outfile << " Outputs:" << std::endl;
|
|
||||||
for (const auto& output : op->outputs()) {
|
|
||||||
outfile << " " << output.get_node()->get_friendly_name() << " -> " << output.get_element_type()
|
|
||||||
<< " " << output.get_shape() << std::endl;
|
|
||||||
}
|
|
||||||
outfile << std::endl;
|
|
||||||
}
|
|
||||||
outfile << "===============================" << std::endl;
|
|
||||||
outfile.close();
|
|
||||||
} catch (const std::exception& ex) {
|
|
||||||
std::cout << ex.what() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<Model> TranslateSession::translate_graph(const frontend::InputModel::Ptr& input_model) {
|
std::shared_ptr<Model> TranslateSession::translate_graph(const frontend::InputModel::Ptr& input_model) {
|
||||||
ov::ParameterVector params;
|
ov::ParameterVector params;
|
||||||
ov::ResultVector results;
|
ov::ResultVector results;
|
||||||
|
|
@ -86,16 +53,12 @@ std::shared_ptr<Model> TranslateSession::translate_graph(const frontend::InputMo
|
||||||
auto operation_type = node->get_op_type();
|
auto operation_type = node->get_op_type();
|
||||||
ov::OutputVector converted_outputs;
|
ov::OutputVector converted_outputs;
|
||||||
auto it = m_translator_map.find(operation_type);
|
auto it = m_translator_map.find(operation_type);
|
||||||
if (it != m_translator_map.end()) {
|
FRONT_END_OP_CONVERSION_CHECK(it != m_translator_map.end(),
|
||||||
try {
|
"Translation for operation type ",
|
||||||
NodeContext node_context(node, tensor_map, this);
|
operation_type,
|
||||||
converted_outputs = it->second(node_context);
|
" is not implemented.");
|
||||||
} catch (const std::exception& ex) {
|
NodeContext node_context(node, tensor_map, this);
|
||||||
std::cout << ex.what() << std::endl;
|
converted_outputs = it->second(node_context);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto& node_output_names = node->get_output_names();
|
const auto& node_output_names = node->get_output_names();
|
||||||
FRONT_END_OP_CONVERSION_CHECK(node_output_names.size() == converted_outputs.size(),
|
FRONT_END_OP_CONVERSION_CHECK(node_output_names.size() == converted_outputs.size(),
|
||||||
|
|
@ -122,7 +85,7 @@ std::shared_ptr<Model> TranslateSession::translate_graph(const frontend::InputMo
|
||||||
"Output name not found in tensor map: ",
|
"Output name not found in tensor map: ",
|
||||||
name);
|
name);
|
||||||
auto result = std::make_shared<v0::Result>(tensor_map->at(name));
|
auto result = std::make_shared<v0::Result>(tensor_map->at(name));
|
||||||
// result->set_friendly_name(it);
|
result->set_friendly_name(name);
|
||||||
results.push_back(result);
|
results.push_back(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,10 +69,13 @@ enum ggml_status openvino_frontend_compute(ggml_backend_t backend, struct ggml_c
|
||||||
|
|
||||||
std::shared_ptr<ov::Model> model;
|
std::shared_ptr<ov::Model> model;
|
||||||
ov::CompiledModel compiled_model;
|
ov::CompiledModel compiled_model;
|
||||||
|
int64_t decoder_end_time;
|
||||||
int64_t conversion_end_time;
|
int64_t conversion_end_time;
|
||||||
int64_t compile_end_time;
|
int64_t compile_end_time;
|
||||||
|
|
||||||
auto ggml_decoder = get_ggml_decoder(cgraph);
|
auto ggml_decoder = get_ggml_decoder(cgraph);
|
||||||
|
decoder_end_time = ggml_time_us();
|
||||||
|
|
||||||
auto it = compiled_cache.find(cgraph);
|
auto it = compiled_cache.find(cgraph);
|
||||||
if (it != compiled_cache.end()) {
|
if (it != compiled_cache.end()) {
|
||||||
model = it->second.first;
|
model = it->second.first;
|
||||||
|
|
@ -147,7 +150,8 @@ enum ggml_status openvino_frontend_compute(ggml_backend_t backend, struct ggml_c
|
||||||
|
|
||||||
if (getenv("GGML_OPENVINO_PROFILING")) {
|
if (getenv("GGML_OPENVINO_PROFILING")) {
|
||||||
GGML_LOG_INFO("GGML OpenVINO Backend: \n");
|
GGML_LOG_INFO("GGML OpenVINO Backend: \n");
|
||||||
GGML_LOG_INFO(" - Graph conversion Time: %ld ms \n", (conversion_end_time - start_time) / 1000);
|
GGML_LOG_INFO(" - Graph decoder Time: %ld ms \n", (decoder_end_time - start_time) / 1000);
|
||||||
|
GGML_LOG_INFO(" - Graph conversion Time: %ld ms \n", (conversion_end_time - decoder_end_time) / 1000);
|
||||||
GGML_LOG_INFO(" - Graph compile Time: %ld ms \n", (compile_end_time - conversion_end_time) / 1000);
|
GGML_LOG_INFO(" - Graph compile Time: %ld ms \n", (compile_end_time - conversion_end_time) / 1000);
|
||||||
GGML_LOG_INFO(" - Graph Input Time: %ld ms \n", (input_end_time - compile_end_time) / 1000);
|
GGML_LOG_INFO(" - Graph Input Time: %ld ms \n", (input_end_time - compile_end_time) / 1000);
|
||||||
GGML_LOG_INFO(" - Graph Inference Time: %ld ms \n", (infer_end_time - input_end_time) / 1000);
|
GGML_LOG_INFO(" - Graph Inference Time: %ld ms \n", (infer_end_time - input_end_time) / 1000);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue