Skip to content

Commit 9e5f8bd

Browse files
committed
Fix test-backend-ops
1 parent e6201f3 commit 9e5f8bd

File tree

6 files changed

+27
-6
lines changed

6 files changed

+27
-6
lines changed

ggml/src/ggml-openvino/ggml-decoder.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ GgmlOvDecoder::GgmlOvDecoder(struct ggml_cgraph* cgraph) {
7676
m_cgraph = cgraph;
7777
for (int node_n = 0; node_n < cgraph->n_nodes; node_n++) {
7878
auto* cur_node = cgraph->nodes[node_n];
79+
if (cur_node->op == GGML_OP_NONE) {
80+
continue;
81+
}
7982
m_nodes.push_back(cur_node);
8083
set_input_output(cur_node, true);
8184
}

ggml/src/ggml-openvino/ggml-openvino.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,25 @@ static bool is_op_unsupported_case(const ggml_tensor* op) {
258258
}
259259
}
260260

261+
if (op->op == GGML_OP_PERMUTE) {
262+
if (op->type == GGML_TYPE_BF16) {
263+
// err msg: [GPU] Could not find a suitable kernel for transpose
264+
GGML_LOG_WARN("OpenVINO backend does not support PERMUTE with BF16 type\n");
265+
return true;
266+
}
267+
}
268+
261269
if (op->op == GGML_OP_MUL_MAT) {
262270
if ((op->src[0]->view_src && op->src[0]->op != GGML_OP_PERMUTE) ||
263271
(op->src[1]->view_src && op->src[1]->op != GGML_OP_PERMUTE)) {
264272
GGML_LOG_WARN("OpenVINO backend does not support MUL_MAT with view_src tensors that are not PERMUTE\n");
265273
return true;
266274
}
275+
if (op->src[0]->type == GGML_TYPE_F16 && op->src[1]->type == GGML_TYPE_F16) {
276+
// Has accuracy issue, try enabling this and see `test-backend-ops -o "MUL_MAT"`
277+
GGML_LOG_WARN("OpenVINO backend does not support MUL_MAT with two F16 tensors\n");
278+
return true;
279+
}
267280
}
268281

269282
if (op->op == GGML_OP_ROPE) {

ggml/src/ggml-openvino/openvino/op/soft_max.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ OutputVector translate_soft_max(const NodeContext& context) {
5353

5454
auto mask_node = context.get_input(1);
5555

56-
auto token_len = context.get_input("token_len");
56+
auto token_len = context.has_input("token_len") ? context.get_input("token_len") : get_dimensions(input_node, {1});
5757
auto zero = ov::op::v0::Constant::create(ov::element::i64, {1}, {0});
5858
auto one = ov::op::v0::Constant::create(ov::element::i64, {1}, {1});
5959
std::shared_ptr<ov::Node> mask_node_sliced =

ggml/src/ggml-openvino/openvino/pass/mark_decompression_convert_constant_folding.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ class TRANSFORMATIONS_API MarkCompressedFloatConstants;
2424

2525
class ov::pass::MarkCompressedFloatConstants : public MatcherPass {
2626
public:
27-
OPENVINO_MATCHER_PASS_RTTI("MarkCompressedFloatConstants");
27+
OPENVINO_MATCHER_PASS_RTTI("MarkCompressedFloatConstants")
2828
MarkCompressedFloatConstants();
2929
};

ggml/src/ggml-openvino/utils.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ enum ggml_status openvino_frontend_compute(ggml_backend_t backend, struct ggml_c
8181
config = get_npu_config();
8282
}
8383

84-
if (cgraph->n_nodes == 1) {
84+
if (is_naive(cgraph)) {
8585
return naive_compute(cgraph, core, device, config);
8686
}
8787

@@ -250,11 +250,16 @@ ov::AnyMap get_npu_config() {
250250
return config;
251251
}
252252

253+
bool is_naive(struct ggml_cgraph* cgraph) {
254+
constexpr int naive_graph_size_threshold = 20;
255+
return cgraph->n_nodes < naive_graph_size_threshold;
256+
}
257+
253258
enum ggml_status naive_compute(struct ggml_cgraph* cgraph,
254259
ov::Core& core,
255260
const std::string& device,
256261
const ov::AnyMap& config) {
257-
if (cgraph->nodes[0]->op == GGML_OP_NONE) {
262+
if (cgraph->n_nodes == 1 && cgraph->nodes[0]->op == GGML_OP_NONE) {
258263
return GGML_STATUS_SUCCESS;
259264
}
260265

@@ -264,8 +269,6 @@ enum ggml_status naive_compute(struct ggml_cgraph* cgraph,
264269
auto model = ov::frontend::ggml::FrontEnd::convert(input_model, naive);
265270
auto infer_request = core.compile_model(model, device, config).create_infer_request();
266271

267-
ov::serialize(model, "IR.xml");
268-
269272
auto ov_params = model->get_parameters();
270273
for (size_t i = 0; i < ov_params.size(); i++) {
271274
auto param_name = ov_params[i]->get_friendly_name();

ggml/src/ggml-openvino/utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,7 @@ ov::AnyMap get_npu_config();
4444

4545
ov::Tensor get_ov_input_tensor(std::shared_ptr<GgmlOvDecoder> ggml_decoder, const std::string& param_name);
4646

47+
bool is_naive(struct ggml_cgraph* cgraph);
48+
4749
enum ggml_status naive_compute(struct ggml_cgraph* cgraph, ov::Core& core, const std::string& device,
4850
const ov::AnyMap& config);

0 commit comments

Comments
 (0)