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

Attempt at progressively feeding the Session to bypass type checking in #69

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Narsil
Copy link

@Narsil Narsil commented Mar 10, 2021

@marshallpierce I would love some feedback about this approach for differently typed tensors for inputs.

Just as a reminder,the inputs of the graph I have contain differently shaped and differently typed arrays

(input_ids, i64, [x, y]) , (past_key_values, f32, (x, y, z, m))

The session starts keeping the pointers, which means I have to leak the pointer from the feed function, and drop them after running the session.

The good thing with this approach is that run can keep backward compatibility and still enable more advanced usages (and no super complex types and extractions.

marshallpierce and others added 4 commits February 24, 2021 10:00
…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.
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 #69 (f11527a) into master (1948683) will increase coverage by 30.08%.
The diff coverage is 80.93%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #69       +/-   ##
===========================================
+ Coverage   14.58%   44.66%   +30.08%     
===========================================
  Files          18       19        +1     
  Lines         960     1097      +137     
===========================================
+ Hits          140      490      +350     
+ Misses        820      607      -213     
Impacted Files Coverage Δ
onnxruntime/src/tensor/ort_tensor.rs 79.16% <75.47%> (-3.19%) ⬇️
onnxruntime/src/session.rs 69.28% <77.55%> (+69.28%) ⬆️
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...f11527a. Read the comment docs.

@marshallpierce
Copy link
Contributor

marshallpierce commented Apr 5, 2021

Sorry for the delay; I've been busy with other projects but I'll be able to take a look soon (famous last words...).

@Narsil Narsil mentioned this pull request Aug 29, 2022
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

3 participants