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

WIP: Custom operators #156

Closed
wants to merge 25 commits into from
Closed

WIP: Custom operators #156

wants to merge 25 commits into from

Conversation

decahedron1
Copy link
Member

Allows custom operator kernels to be written and used entirely in Rust. See here for an example of the API.

TODO

  • Documentation
  • Better example (can anyone help with this?)
  • Add GPU compute streams to kernel context
  • Implement GetKernelAttribute for all supported attribute types
  • Introduce a proc macro to make declaring operators less verbose, something like:
#[ort::operator("GroupNorm")]
fn group_norm(
    #[input]
    x: &Tensor<f32>,
    #[attribute(default = 1e-6)]
    epsilon: f32,
    #[output]
    y: &mut Tensor<f32>
) {
    ...
}

@decahedron1 decahedron1 added enhancement New feature or request needs testing relevant feature is implemented but needs further testing/debugging labels Feb 11, 2024
@decahedron1 decahedron1 self-assigned this Feb 11, 2024
@decahedron1 decahedron1 marked this pull request as draft February 11, 2024 07:12
@decahedron1 decahedron1 added the help wanted Extra attention is needed label Feb 11, 2024
Copy link

codecov bot commented Feb 11, 2024

Codecov Report

Attention: 182 lines in your changes are missing coverage. Please review.

Comparison is base (cc40e6b) 50.68% compared to head (27e8167) 44.48%.
Report is 7 commits behind head on main.

❗ Current head 27e8167 differs from pull request most recent head 6508f07. Consider uploading reports for the commit 6508f07 to get more accurate results

Files Patch % Lines
src/operator/bound.rs 0.00% 66 Missing ⚠️
src/value.rs 7.89% 35 Missing ⚠️
src/operator/io.rs 0.00% 28 Missing ⚠️
src/operator/mod.rs 0.00% 19 Missing ⚠️
src/operator/kernel.rs 0.00% 17 Missing ⚠️
src/error.rs 0.00% 8 Missing ⚠️
src/lib.rs 50.00% 5 Missing ⚠️
src/session/mod.rs 20.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #156      +/-   ##
==========================================
- Coverage   50.68%   44.48%   -6.21%     
==========================================
  Files          15       19       +4     
  Lines        1241     1423     +182     
==========================================
+ Hits          629      633       +4     
- Misses        612      790     +178     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

decahedron1 and others added 23 commits February 11, 2024 13:07
- Update existing documentation to be relevant to v2.0 changes
- Add missing documentation and doctests/examples
- Remove unused code
- Replace most pointer usage with `NonNull`
- Use slightly safer pointer `.cast()`s
- Disallow extracting string tensors with `extract_raw_tensor` (TODO: owned variant of this function)
- Add lifetime bound to `ModelMetadata` to fix a potential use-after-free
- Add per-run tag to `RunOptions`
- Replace `SessionInputKey` with `Cow<str>`
- Register execution providers inside `SessionBuilder::with_execution_providers`, not on commit
- Update existing documentation to be relevant to v2.0 changes
- Add missing documentation and doctests/examples
- Remove unused code
- Replace most pointer usage with `NonNull`
- Use slightly safer pointer `.cast()`s
- Disallow extracting string tensors with `extract_raw_tensor` (TODO: owned variant of this function)
- Add lifetime bound to `ModelMetadata` to fix a potential use-after-free
- Add per-run tag to `RunOptions`
- Replace `SessionInputKey` with `Cow<str>`
- Register execution providers inside `SessionBuilder::with_execution_providers`, not on commit
@decahedron1 decahedron1 deleted the custom-operators branch October 19, 2024 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed needs testing relevant feature is implemented but needs further testing/debugging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants