Skip to content

Commit a9a918d

Browse files
committed
Add API version getter to the graph compiler
Signed-off-by: Dmitry Chigarev <[email protected]>
1 parent 5f03042 commit a9a918d

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/dnnl/dnnl_graph_compiler.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
#include "dnnl_graph_compiler.hpp"
2+
#include "dnnl_graph_compiler_version.h"
23
#include <new>
34

45
// dnnl_graph_compiler.h interface implementation.
56
// TODO: Implement
67

8+
dnnl_status_t
9+
dnnl_graph_compiler_get_api_version(dnnl_graph_compiler_api_version *v) {
10+
if (!v)
11+
return dnnl_invalid_arguments;
12+
v->major = GC_API_VERSION_MAJOR;
13+
v->minor = GC_API_VERSION_MINOR;
14+
v->patch = GC_API_VERSION_PATCH;
15+
v->hash = GC_API_VERSION_HASH;
16+
return dnnl_success;
17+
}
18+
719
dnnl_status_t
820
dnnl_graph_compiler_create(const struct dnnl_graph_compiler_context *ctx,
921
const struct dnnl_graph_compiler **gc) {

test/dnnl/test_dnnl_c_interface.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "dnnl_graph_compiler.h"
2+
#include "dnnl_graph_compiler_version.h"
23
#include "dnnl_test_utils.hpp"
34
#include <gtest/gtest.h>
45

@@ -17,7 +18,7 @@ TEST(dnnl_graph_compiler, c_interface) {
1718
dnnl_graph_compiler_tensor inputs[2];
1819
dnnl_graph_compiler_tensor outputs[1];
1920
uint8_t data_buf[160];
20-
size_t dims[1] = {10};
21+
int64_t dims[1] = {10};
2122
inputs[0] = {.id = 0, .ndims = 1, .dims = dims, .data = data_buf};
2223
inputs[1] = {.id = 1, .ndims = 1, .dims = dims, .data = &data_buf[40]};
2324
outputs[0] = {.id = 2, .ndims = 1, .dims = dims, .data = &data_buf[80]};
@@ -29,6 +30,17 @@ TEST(dnnl_graph_compiler, c_interface) {
2930
dnnl_graph_compiler_destroy(gc);
3031
}
3132

33+
TEST(dnnl_graph_compiler, get_api_version) {
34+
ASSERT_EQ(dnnl_graph_compiler_get_api_version(NULL), dnnl_invalid_arguments);
35+
36+
dnnl_graph_compiler_api_version v;
37+
ASSERT_EQ(dnnl_graph_compiler_get_api_version(&v), dnnl_success);
38+
ASSERT_EQ(v.major, GC_API_VERSION_MAJOR);
39+
ASSERT_EQ(v.minor, GC_API_VERSION_MINOR);
40+
ASSERT_EQ(v.patch, GC_API_VERSION_PATCH);
41+
ASSERT_STREQ(v.hash, GC_API_VERSION_HASH);
42+
}
43+
3244
int main(int argc, char **argv) {
3345
::testing::InitGoogleTest(&argc, argv);
3446
return RUN_ALL_TESTS();

0 commit comments

Comments
 (0)