Skip to content
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
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

marshallpierce
Copy link
Contributor

Based on #67.

…rom a tensor

This is some prep work for string output types and tensor types that vary across the model outputs. For now, the supported types are just the basic numeric types.

Since strings have to be copied out of a tensor, it only makes sense to have `String` be an output type, not `str`, hence the new type so that we can have more input types supported than output types.
Outputs aren't all the same type for a single model, so this allows extracting different types per tensor.
@@ -0,0 +1,118 @@
# onnxruntime requires execinfo.h to build, which only works on glibc-based systems, so alpine is out...
Copy link
Contributor Author

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.

#[cfg(windows)]
fn close_lib_handle(handle: *mut ::std::os::raw::c_void) {
unsafe {
winapi::um::libloaderapi::FreeLibrary(handle as winapi::shared::minwindef::HINSTANCE)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this works but it does at least compile on windows.

This approach allocates owned Strings for each element, which works, but stresses the allocator, and incurs unnecessary copying.

Part of the complication stems from the limitation that in Rust, a field can't be a reference to another field in the same struct. This means that having a Vec<u8> of copied data, referred to by a Vec<&str>, which is then referred to by an ArrayView, requires a sequence of 3 structs to express. Building a Vec<String> gets rid of the references, but also loses the efficiency of 1 allocation with strs pointing into it.
This approach allocates owned Strings for each element, which works, but stresses the allocator, and incurs unnecessary copying.

Part of the complication stems from the limitation that in Rust, a field can't be a reference to another field in the same struct. This means that having a Vec<u8> of copied data, referred to by a Vec<&str>, which is then referred to by an ArrayView, requires a sequence of 3 structs to express. Building a Vec<String> gets rid of the references, but also loses the efficiency of 1 allocation with strs pointing into it.
@codecov-io
Copy link

Codecov Report

Merging #68 (457012b) into master (1948683) will increase coverage by 28.71%.
The diff coverage is 78.54%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #68       +/-   ##
===========================================
+ Coverage   14.58%   43.29%   +28.71%     
===========================================
  Files          18       19        +1     
  Lines         960     1111      +151     
===========================================
+ Hits          140      481      +341     
+ Misses        820      630      -190     
Impacted Files Coverage Δ
onnxruntime/src/session.rs 63.43% <68.91%> (+63.43%) ⬆️
onnxruntime/src/tensor/ort_tensor.rs 79.16% <75.47%> (-3.19%) ⬇️
onnxruntime/src/tensor.rs 85.50% <85.50%> (ø)
onnxruntime/src/tensor/ort_owned_tensor.rs 87.09% <85.71%> (+87.09%) ⬆️
onnxruntime/src/error.rs 62.50% <100.00%> (+5.35%) ⬆️
onnxruntime/src/lib.rs 72.46% <100.00%> (+35.11%) ⬆️
onnxruntime/src/environment.rs 93.22% <0.00%> (+3.38%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3b5fcd3...457012b. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants