22
22
#include < new>
23
23
#include < string_view>
24
24
25
+ #if defined _WIN32 || defined __CYGWIN__
26
+ #define GC_DLL_EXPORT __declspec (dllexport)
27
+ #else
28
+ #define GC_DLL_EXPORT __attribute__ ((visibility(" default" )))
29
+ #endif
30
+
25
31
// dnnl_graph_compiler.h interface implementation.
26
32
// TODO: Implement.
27
33
@@ -43,7 +49,8 @@ struct dnnl_graph_compiler {
43
49
compile (const std::string_view &graph_json) const ;
44
50
};
45
51
46
- const dnnl_graph_compiler_version *dnnl_graph_compiler_get_version (void ) {
52
+ GC_DLL_EXPORT const dnnl_graph_compiler_version *
53
+ dnnl_graph_compiler_get_version (void ) {
47
54
static const dnnl_graph_compiler_version ver = {
48
55
.api_version = {DNNL_GC_API_V_MAJOR, DNNL_GC_API_V_MINOR,
49
56
DNNL_GC_API_V_PATCH,
@@ -54,7 +61,7 @@ const dnnl_graph_compiler_version *dnnl_graph_compiler_get_version(void) {
54
61
return &ver;
55
62
}
56
63
57
- dnnl_status_t
64
+ GC_DLL_EXPORT dnnl_status_t
58
65
dnnl_graph_compiler_create (const struct dnnl_graph_compiler_context *ctx,
59
66
const struct dnnl_graph_compiler **gc) {
60
67
try {
@@ -68,14 +75,14 @@ dnnl_graph_compiler_create(const struct dnnl_graph_compiler_context *ctx,
68
75
}
69
76
}
70
77
71
- void dnnl_graph_compiler_destroy (const struct dnnl_graph_compiler *gc) {
78
+ GC_DLL_EXPORT void
79
+ dnnl_graph_compiler_destroy (const struct dnnl_graph_compiler *gc) {
72
80
delete gc;
73
81
}
74
82
75
- dnnl_status_t
76
- dnnl_graph_compiler_compile (const dnnl_graph_compiler *gc,
77
- const char *graph_json,
78
- const struct dnnl_graph_compiler_executable **exe) {
83
+ GC_DLL_EXPORT dnnl_status_t dnnl_graph_compiler_compile (
84
+ const dnnl_graph_compiler *gc, const char *graph_json,
85
+ const struct dnnl_graph_compiler_executable **exe) {
79
86
try {
80
87
auto ptr = gc->compile (std::string_view (graph_json));
81
88
*exe = ptr.release ();
@@ -88,17 +95,16 @@ dnnl_graph_compiler_compile(const dnnl_graph_compiler *gc,
88
95
}
89
96
}
90
97
91
- void dnnl_graph_compiler_destroy_executable (
98
+ GC_DLL_EXPORT void dnnl_graph_compiler_destroy_executable (
92
99
const struct dnnl_graph_compiler *gc,
93
100
const struct dnnl_graph_compiler_executable *exe) {
94
101
delete exe;
95
102
}
96
103
97
- dnnl_status_t
98
- dnnl_graph_compiler_execute (const struct dnnl_graph_compiler *gc,
99
- const struct dnnl_graph_compiler_executable *exe,
100
- dnnl_graph_compiler_tensor *inputs,
101
- dnnl_graph_compiler_tensor *outputs) {
104
+ GC_DLL_EXPORT dnnl_status_t dnnl_graph_compiler_execute (
105
+ const struct dnnl_graph_compiler *gc,
106
+ const struct dnnl_graph_compiler_executable *exe,
107
+ dnnl_graph_compiler_tensor *inputs, dnnl_graph_compiler_tensor *outputs) {
102
108
try {
103
109
exe->execute (inputs, outputs);
104
110
return dnnl_success;
0 commit comments