Skip to content

Commit aec0484

Browse files
authored
Merge branch 'main' into longsheng/add_onednn_graph
2 parents 08cf9cd + e0d4b65 commit aec0484

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,15 @@ add_subdirectory(include)
6161
add_subdirectory(lib)
6262
add_subdirectory(src)
6363

64-
add_library(graph_compiler SHARED ${GC_LIB_SOURCES})
65-
target_include_directories(graph_compiler PUBLIC ${GC_LIB_INCLUDES})
6664
set(GC_LIB_LINKED_LIBS
6765
MLIRLinalgx
6866
MLIRMicrokernel
6967
MLIROneDNNGraph
7068
)
69+
add_library(graph_compiler SHARED ${GC_LIB_SOURCES})
70+
target_include_directories(graph_compiler PUBLIC ${GC_LIB_INCLUDES})
71+
target_compile_options(graph_compiler PRIVATE -fvisibility=hidden)
72+
target_link_options(graph_compiler PRIVATE -Wl,--gc-sections)
7173
target_link_libraries(graph_compiler PRIVATE ${GC_LIB_LINKED_LIBS})
7274

7375
add_subdirectory(unittests)

src/dnnl/dnnl_graph_compiler.cpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
#include <new>
2323
#include <string_view>
2424

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+
2531
// dnnl_graph_compiler.h interface implementation.
2632
// TODO: Implement.
2733

@@ -43,7 +49,8 @@ struct dnnl_graph_compiler {
4349
compile(const std::string_view &graph_json) const;
4450
};
4551

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) {
4754
static const dnnl_graph_compiler_version ver = {
4855
.api_version = {DNNL_GC_API_V_MAJOR, DNNL_GC_API_V_MINOR,
4956
DNNL_GC_API_V_PATCH,
@@ -54,7 +61,7 @@ const dnnl_graph_compiler_version *dnnl_graph_compiler_get_version(void) {
5461
return &ver;
5562
}
5663

57-
dnnl_status_t
64+
GC_DLL_EXPORT dnnl_status_t
5865
dnnl_graph_compiler_create(const struct dnnl_graph_compiler_context *ctx,
5966
const struct dnnl_graph_compiler **gc) {
6067
try {
@@ -68,14 +75,14 @@ dnnl_graph_compiler_create(const struct dnnl_graph_compiler_context *ctx,
6875
}
6976
}
7077

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) {
7280
delete gc;
7381
}
7482

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) {
7986
try {
8087
auto ptr = gc->compile(std::string_view(graph_json));
8188
*exe = ptr.release();
@@ -88,17 +95,16 @@ dnnl_graph_compiler_compile(const dnnl_graph_compiler *gc,
8895
}
8996
}
9097

91-
void dnnl_graph_compiler_destroy_executable(
98+
GC_DLL_EXPORT void dnnl_graph_compiler_destroy_executable(
9299
const struct dnnl_graph_compiler *gc,
93100
const struct dnnl_graph_compiler_executable *exe) {
94101
delete exe;
95102
}
96103

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) {
102108
try {
103109
exe->execute(inputs, outputs);
104110
return dnnl_success;

0 commit comments

Comments
 (0)