Skip to content

Commit d1c579e

Browse files
authored
Fixing ort test issues (#12)
* Uncommenting ort test * One more attempt at linking * Testing with static libraru * Removing linux custom linkopts * Fixed ort issues by using prebuilt version of onnx runtime library
1 parent cf03fae commit d1c579e

33 files changed

+14169
-1271
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
third_party/onnxruntime/lib/** filter=lfs diff=lfs merge=lfs -text

MODULE.bazel

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,3 @@ http_archive(
7777
strip_prefix = "OpenCL-Headers-2023.04.17",
7878
url = "https://github.com/KhronosGroup/OpenCL-Headers/archive/refs/tags/v2023.04.17.tar.gz",
7979
)
80-
81-
new_git_repository(
82-
name = "onnx_runtime",
83-
build_file = "//third_party:onnxruntime.BUILD",
84-
# branch= "rel-1.20.1",
85-
commit = "5c1b7ccbff7e5141c1da7a9d963d660e5741c319",
86-
patches = ["//third_party/patch:onnx.patch"],
87-
recursive_init_submodules = True,
88-
remote = "https://github.com/microsoft/onnxruntime",
89-
)
90-
91-
new_git_repository(
92-
name = "onnx_runtime_extensions",
93-
build_file = "//third_party:onnxruntime_extensions.BUILD",
94-
commit = "81e7799c69044c745239202085eb0a98f102937b",
95-
patches = ["//third_party/patch:onnx_ext.patch"],
96-
remote = "https://github.com/microsoft/onnxruntime-extensions",
97-
)

kernels/onnxRT/BUILD

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ cc_library(
1414
],
1515
deps = [
1616
"//:corevx",
17-
"@onnx_runtime//:onnxruntime_lib",
17+
"//third_party:onnxruntime",
1818
],
19+
linkstatic = True,
20+
alwayslink = True,
1921
visibility = ["//visibility:public"]
2022
)

kernels/onnxRT/ort_runner.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#include <string>
1414
#include <vector>
1515

16-
#include <core/session/onnxruntime_cxx_api.h>
1716
#include <VX/vx.h>
17+
#include <onnxruntime_cxx_api.h>
1818

1919
/**
2020
* @brief Onnx Runtime Model Runner Object

targets/onnxRT/BUILD

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
cc_library(
32
name = "onnxRT",
43
srcs = glob([
@@ -15,19 +14,21 @@ cc_library(
1514
"//:corevx",
1615
"//kernels/onnxRT:ort_kernels",
1716
],
17+
linkstatic = True,
18+
alwayslink = True,
1819
visibility = ["//visibility:public"]
1920
)
2021

2122
cc_shared_library(
22-
name = "openvx-onnxRT",
23-
deps = [
23+
name="openvx-onnxRT",
24+
deps=[
2425
":onnxRT",
2526
],
26-
visibility = ["//visibility:public"]
27+
visibility=["//visibility:public"]
2728
)
2829

2930
cc_import(
30-
name = "imported_openvx_onnxRT",
31-
shared_library = ":openvx-onnxRT",
32-
visibility = ["//visibility:public"]
31+
name="imported_openvx_onnxRT",
32+
shared_library=":openvx-onnxRT",
33+
visibility=["//visibility:public"]
3334
)

tests/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ cc_binary(
1010
],
1111
deps = [
1212
"//:corevx",
13+
"//targets/ai_server:imported_openvx_ai_server",
1314
"//targets/c_model:imported_openvx_c_model",
1415
"//targets/debug:imported_openvx_debug",
1516
"//targets/extras:imported_openvx_extras",
17+
"//targets/liteRT:imported_openvx_liteRT",
1618
"//targets/opencl:imported_openvx_opencl",
19+
"//targets/onnxRT:imported_openvx_onnxRT",
20+
"//targets/executorch:imported_openvx_torch",
1721
"//tests/xyz:imported_xyz",
1822
],
1923
linkopts = select({

tests/integration_test/BUILD

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,30 @@ cc_test(
2020
size = "small"
2121
)
2222

23-
# cc_test(
24-
# name = "test_ort",
25-
# srcs = [
26-
# "test_ort.cpp"
27-
# ],
28-
# deps = [
29-
# "//:corevx",
30-
# "@googletest//:gtest_main",
31-
# "//targets/c_model:imported_openvx_c_model",
32-
# "//targets/debug:imported_openvx_debug",
33-
# "//targets/extras:imported_openvx_extras",
34-
# "//targets/opencl:imported_openvx_opencl",
35-
# "//targets/onnxRT:imported_openvx_onnxRT",
36-
# ],
37-
# linkopts = select({
38-
# "@platforms//os:linux": ["-Wl,-rpath,$ORIGIN"],
39-
# "@platforms//os:macos": ["-Wl,-rpath,@executable_path"],
40-
# "//conditions:default": [],
41-
# }),
42-
# data = [
43-
# "//tests/raw:models",
44-
# ],
45-
# size = "small"
46-
# )
23+
cc_test(
24+
name="test_ort",
25+
srcs=[
26+
"test_ort.cpp"
27+
],
28+
deps=[
29+
"//:corevx",
30+
"@googletest//:gtest_main",
31+
"//targets/c_model:imported_openvx_c_model",
32+
"//targets/debug:imported_openvx_debug",
33+
"//targets/extras:imported_openvx_extras",
34+
"//targets/opencl:imported_openvx_opencl",
35+
"//targets/onnxRT:imported_openvx_onnxRT",
36+
],
37+
linkopts=select({
38+
"@platforms//os:linux": ["-Wl,-rpath,$ORIGIN"],
39+
"@platforms//os:macos": ["-Wl,-rpath,@executable_path"],
40+
"//conditions:default": [],
41+
}),
42+
data=[
43+
"//tests/raw:models",
44+
],
45+
size="small"
46+
)
4747

4848
cc_test(
4949
name = "test_tflite",

third_party/BUILD

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,35 @@
22
BUILD file for build defs for third party deps
33
"""
44

5+
# ONNX Runtime
6+
cc_import(
7+
name="onnxruntime-providers",
8+
shared_library=select({
9+
"@platforms//os:linux": "onnxruntime/lib/libonnxruntime_providers_shared.so",
10+
"//conditions:default": None,
11+
}),
12+
visibility=["//visibility:public"],
13+
)
14+
15+
cc_import(
16+
name="onnxruntime-prebuilt",
17+
shared_library=select({
18+
"@platforms//os:macos": "onnxruntime/lib/libonnxruntime.1.22.0.dylib",
19+
"@platforms//os:linux": "onnxruntime/lib/libonnxruntime.so.1",
20+
"//conditions:default": None,
21+
}),
22+
deps=[":onnxruntime-providers"],
23+
visibility=["//visibility:public"],
24+
)
25+
26+
cc_library(
27+
name="onnxruntime",
28+
hdrs=glob(["onnxruntime/include/**/*.h"]),
29+
includes=["onnxruntime/include"],
30+
deps=[":onnxruntime-prebuilt"],
31+
visibility=["//visibility:public"],
32+
)
33+
534
# TensorFlow Lite
635
cc_import(
736
name = "tflite",

0 commit comments

Comments
 (0)