-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for registring custom op libraries #68
Draft
marshallpierce
wants to merge
6
commits into
nbigaouette:master
Choose a base branch
from
marshallpierce:mp/custom-op
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0d34d23
Introduce a new trait to represent types that can be used as output f…
marshallpierce 555bec7
Use `DynOrtTensor` for model output tensors
marshallpierce d2f1ebe
Support the onnx string type in output tensors
marshallpierce 495ecb4
Support the onnx string type in output tensors
marshallpierce 6cf6d0e
Add support for registring custom op libraries
marshallpierce 457012b
Remove stray
marshallpierce File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
* | ||
!/Cargo.* | ||
!/onnxruntime/Cargo.toml | ||
!/onnxruntime/src | ||
!/onnxruntime/tests | ||
!/onnxruntime-sys/Cargo.toml | ||
!/onnxruntime-sys/build.rs | ||
!/onnxruntime-sys/src | ||
!/test-models/tensorflow/*.onnx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# onnxruntime requires execinfo.h to build, which only works on glibc-based systems, so alpine is out... | ||
FROM debian:bullseye-slim as base | ||
|
||
RUN apt-get update && apt-get -y dist-upgrade | ||
|
||
FROM base AS onnxruntime | ||
|
||
RUN apt-get install -y \ | ||
git \ | ||
bash \ | ||
python3 \ | ||
cmake \ | ||
git \ | ||
build-essential \ | ||
llvm \ | ||
locales | ||
|
||
# onnxruntime built in tests need en_US.UTF-8 available | ||
# Uncomment en_US.UTF-8, then generate | ||
RUN sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen && locale-gen | ||
|
||
# build onnxruntime | ||
RUN mkdir -p /opt/onnxruntime/tmp | ||
# onnxruntime build relies on being in a git repo, so can't just get a tarball | ||
# it's a big repo, so fetch shallowly | ||
RUN cd /opt/onnxruntime/tmp && \ | ||
git clone --recursive --depth 1 --shallow-submodules https://github.com/Microsoft/onnxruntime | ||
|
||
# use version that onnxruntime-sys expects | ||
RUN cd /opt/onnxruntime/tmp/onnxruntime && \ | ||
git fetch --depth 1 origin tag v1.6.0 && \ | ||
git checkout v1.6.0 | ||
|
||
RUN /opt/onnxruntime/tmp/onnxruntime/build.sh --config RelWithDebInfo --build_shared_lib --parallel | ||
|
||
# Build ort-customops, linked against the onnxruntime built above. | ||
# No tags / releases yet - that commit is from 2021-02-16 | ||
RUN mkdir -p /opt/ort-customops/tmp && \ | ||
cd /opt/ort-customops/tmp && \ | ||
git clone --recursive https://github.com/microsoft/ort-customops.git && \ | ||
cd ort-customops && \ | ||
git checkout 92f6b51106c9e9143c452e537cb5e41d2dcaa266 | ||
|
||
RUN cd /opt/ort-customops/tmp/ort-customops && \ | ||
./build.sh -D ONNXRUNTIME_LIB_DIR=/opt/onnxruntime/tmp/onnxruntime/build/Linux/RelWithDebInfo | ||
|
||
|
||
# install rust toolchain | ||
FROM base AS rust-toolchain | ||
|
||
ARG RUST_VERSION=1.50.0 | ||
|
||
RUN apt-get install -y \ | ||
curl | ||
|
||
# install rust toolchain | ||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUST_VERSION | ||
|
||
ENV PATH $PATH:/root/.cargo/bin | ||
|
||
|
||
# build onnxruntime-rs | ||
FROM rust-toolchain as onnxruntime-rs | ||
# clang & llvm needed by onnxruntime-sys | ||
RUN apt-get install -y \ | ||
build-essential \ | ||
llvm-dev \ | ||
libclang-dev \ | ||
clang | ||
|
||
RUN mkdir -p \ | ||
/onnxruntime-rs/build/onnxruntime-sys/src/ \ | ||
/onnxruntime-rs/build/onnxruntime/src/ \ | ||
/onnxruntime-rs/build/onnxruntime/tests/ \ | ||
/opt/onnxruntime/lib \ | ||
/opt/ort-customops/lib | ||
|
||
COPY --from=onnxruntime /opt/onnxruntime/tmp/onnxruntime/build/Linux/RelWithDebInfo/libonnxruntime.so /opt/onnxruntime/lib/ | ||
COPY --from=onnxruntime /opt/ort-customops/tmp/ort-customops/out/Linux/libortcustomops.so /opt/ort-customops/lib/ | ||
|
||
WORKDIR /onnxruntime-rs/build | ||
|
||
ENV ORT_STRATEGY=system | ||
# this has /lib/ appended to it and is used as a lib search path in onnxruntime-sys's build.rs | ||
ENV ORT_LIB_LOCATION=/opt/onnxruntime/ | ||
|
||
ENV ONNXRUNTIME_RS_TEST_ORT_CUSTOMOPS_LIB=/opt/ort-customops/lib/libortcustomops.so | ||
|
||
# create enough of an empty project that dependencies can build | ||
COPY /Cargo.lock /Cargo.toml /onnxruntime-rs/build/ | ||
COPY /onnxruntime/Cargo.toml /onnxruntime-rs/build/onnxruntime/ | ||
COPY /onnxruntime-sys/Cargo.toml /onnxruntime-sys/build.rs /onnxruntime-rs/build/onnxruntime-sys/ | ||
|
||
CMD cargo test | ||
|
||
# build dependencies and clean the bogus contents of our two packages | ||
RUN touch \ | ||
onnxruntime/src/lib.rs \ | ||
onnxruntime/tests/integration_tests.rs \ | ||
onnxruntime-sys/src/lib.rs \ | ||
&& cargo build --tests \ | ||
&& cargo clean --package onnxruntime-sys \ | ||
&& cargo clean --package onnxruntime \ | ||
&& rm -rf \ | ||
onnxruntime/src/ \ | ||
onnxruntime/tests/ \ | ||
onnxruntime-sys/src/ | ||
|
||
# now build the actual source | ||
COPY /test-models test-models | ||
COPY /onnxruntime-sys/src onnxruntime-sys/src | ||
COPY /onnxruntime/src onnxruntime/src | ||
COPY /onnxruntime/tests onnxruntime/tests | ||
|
||
RUN ln -s /opt/onnxruntime/lib/libonnxruntime.so /opt/onnxruntime/lib/libonnxruntime.so.1.6.0 | ||
ENV LD_LIBRARY_PATH=/opt/onnxruntime/lib | ||
|
||
RUN cargo build --tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dockerfile sets up onnxruntime and ort-customops so that the "regex" model can run. Not sure how best to integrate this into CI.