Skip to content

Commit 38fe056

Browse files
authored
wasi-nn: reduce code duplication a bit (#4433)
1 parent 430cc5e commit 38fe056

File tree

5 files changed

+21
-55
lines changed

5 files changed

+21
-55
lines changed

core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.h renamed to core/iwasm/libraries/wasi-nn/src/wasi_nn_backend.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,26 @@
33
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44
*/
55

6-
#ifndef WASI_NN_OPENVINO_HPP
7-
#define WASI_NN_OPENVINO_HPP
6+
#ifndef WASI_NN_BACKEND_H
7+
#define WASI_NN_BACKEND_H
88

99
#include "wasi_nn_types.h"
1010

11+
#ifdef __cplusplus
12+
extern "C" {
13+
#endif
14+
1115
__attribute__((visibility("default"))) wasi_nn_error
1216
load(void *ctx, graph_builder_array *builder, graph_encoding encoding,
1317
execution_target target, graph *g);
1418

19+
__attribute__((visibility("default"))) wasi_nn_error
20+
load_by_name(void *tflite_ctx, const char *name, uint32_t namelen, graph *g);
21+
22+
__attribute__((visibility("default"))) wasi_nn_error
23+
load_by_name_with_config(void *ctx, const char *name, uint32_t namelen,
24+
const char *config, uint32_t config_len, graph *g);
25+
1526
__attribute__((visibility("default"))) wasi_nn_error
1627
init_execution_context(void *ctx, graph g, graph_execution_context *exec_ctx);
1728

@@ -32,4 +43,8 @@ init_backend(void **ctx);
3243
__attribute__((visibility("default"))) wasi_nn_error
3344
deinit_backend(void *ctx);
3445

35-
#endif /* WASI_NN_OPENVINO_HPP */
46+
#ifdef __cplusplus
47+
}
48+
#endif
49+
50+
#endif /* WASI_NN_BACKEND_H */

core/iwasm/libraries/wasi-nn/src/wasi_nn_llamacpp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include <stdlib.h>
77

8-
#include "wasi_nn_types.h"
8+
#include "wasi_nn_backend.h"
99
#include "utils/logger.h"
1010
#include "llama.h"
1111
#include "ggml.h"

core/iwasm/libraries/wasi-nn/src/wasi_nn_openvino.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44
*/
55

6-
#include "wasi_nn_types.h"
7-
#include "wasi_nn_openvino.h"
6+
#include "wasi_nn_backend.h"
87
#include "utils/logger.h"
98
#include "bh_platform.h"
109

core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44
*/
55

6-
#include "wasi_nn_tensorflowlite.hpp"
76
#include "utils/logger.h"
87

98
#include "bh_platform.h"
10-
#include "wasi_nn_types.h"
9+
#include "wasi_nn_backend.h"
1110
#include "wasm_export.h"
1211

1312
#include <tensorflow/lite/interpreter.h>

core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.hpp

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)