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

[TensorRT EP] support user_compute_stream in python API #20168

Merged
merged 13 commits into from
Apr 16, 2024

Conversation

yf711
Copy link
Contributor

@yf711 yf711 commented Apr 1, 2024

Description

  • Implement user_compute_stream python api for TensorRT EP
    • Using this option will implicitly set has_user_compute_stream as true
  • Extend existing TRTEP unit test to verify user_compute_stream option
    • This has been verified in local pytorch env, with torch.cuda.Stream() passing into user_compute_stream:
...
# Before inference
if torch.cuda.is_available():
    s = torch.cuda.Stream()
    option = {"user_compute_stream": str(s.cuda_stream)}
    sess.set_providers(["TensorrtExecutionProvider"], [option])
    options = sess.get_provider_options()

    assert "TensorrtExecutionProvider" in options
    assert options["TensorrtExecutionProvider"].get("user_compute_stream", "") == str(s.cuda_stream)
    assert options["TensorrtExecutionProvider"].get("has_user_compute_stream", "") == "1"
...

Motivation and Context

Align with existing user_compute_stream python implementations for CUDA EP/ROCm EP

@yf711 yf711 changed the title [TensorRT EP] user_compute_stream [TensorRT EP] support user_compute_stream in python API Apr 11, 2024
@yf711 yf711 marked this pull request as ready for review April 11, 2024 19:55
@yf711 yf711 requested a review from jywu-msft April 12, 2024 16:52
@jywu-msft
Copy link
Member

merge latest main to get Big Models pipelines to pass.

@yf711 yf711 merged commit 54f91ea into main Apr 16, 2024
90 of 94 checks passed
@yf711 yf711 deleted the yifanl/trtep_user_compute_stream branch April 16, 2024 19:49
TedThemistokleous pushed a commit to TedThemistokleous/onnxruntime that referenced this pull request May 7, 2024
)

### Description
<!-- Describe your changes. -->

* Implement `user_compute_stream` python api for TensorRT EP
* Using this option will implicitly set `has_user_compute_stream` as
`true`
* Extend existing TRTEP unit test to verify `user_compute_stream` option
* This has been verified in local pytorch env, with
`torch.cuda.Stream()` passing into `user_compute_stream`:
```python
...
# Before inference
if torch.cuda.is_available():
    s = torch.cuda.Stream()
    option = {"user_compute_stream": str(s.cuda_stream)}
    sess.set_providers(["TensorrtExecutionProvider"], [option])
    options = sess.get_provider_options()

    assert "TensorrtExecutionProvider" in options
    assert options["TensorrtExecutionProvider"].get("user_compute_stream", "") == str(s.cuda_stream)
    assert options["TensorrtExecutionProvider"].get("has_user_compute_stream", "") == "1"
...
```
### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
Align with existing `user_compute_stream` python implementations for
[CUDA EP](https://github.com/microsoft/onnxruntime/pull/19229)/[ROCm
EP](microsoft#19619)
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.

2 participants