Skip to content

Update CUDA custom op unit tests to account for recent ORT change - #6971

Merged
hariharans29 merged 22 commits into
masterfrom
hari/cudaCustomOpEnhancement
Mar 12, 2021
Merged

Update CUDA custom op unit tests to account for recent ORT change#6971
hariharans29 merged 22 commits into
masterfrom
hari/cudaCustomOpEnhancement

Conversation

@hariharans29

@hariharans29 hariharans29 commented Mar 10, 2021

Copy link
Copy Markdown
Member

Description: #3723 made a change to move the hand-crafted ORT CUDA kernels from the per-thread default stream to a compute stream that ORT created by default or a user provided compute stream. This change will require exposing an interface in custom ops to obtain ORT's compute stream or at the very least update the CUDA custom op unit tests so as to show that a user needs to use the same compute stream for both the ORT kernels (passed in via session options) and their custom kernels for synchronization. This change updates the unit tests.

Motivation and Context
The unit tests will work as is as they are just single node toy models but if users were to adapt existing custom op implementations for their models that will require interleaving with ORT's existing CUDA kernels, they will lack synchronization and result in garbage output. Hence, this change for illustrative purposes.

(Takeaway from #6952)

@hariharans29
hariharans29 requested a review from a team as a code owner March 10, 2021 13:35
Comment thread onnxruntime/test/shared_lib/utils.h Outdated
Comment thread onnxruntime/test/shared_lib/utils.cc
Comment thread onnxruntime/test/shared_lib/test_inference.cc
@skottmckay

Copy link
Copy Markdown
Contributor

Assuming doco on https://www.onnxruntime.ai/docs/how-to/add-custom-op.html will be updated separately to describe what's necessary to create a working CUDA based custom op and why.

skottmckay
skottmckay previously approved these changes Mar 11, 2021

@skottmckay skottmckay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:shipit:

@hariharans29

Copy link
Copy Markdown
Member Author

Assuming doco on https://www.onnxruntime.ai/docs/how-to/add-custom-op.html will be updated separately to describe what's necessary to create a working CUDA based custom op and why.

Yes, will come in a separate change

${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/utils.h
${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/utils.cc)
${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/utils.cc
${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/custom_op_utils.h

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: 2 tabs

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will combine with another PR

@skottmckay skottmckay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:shipit:

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