Skip to content

Add TensorRT basic unit tests#12

Merged
chilo-ms merged 13 commits into
mainfrom
chi/add_unit_tests
Jun 16, 2026
Merged

Add TensorRT basic unit tests#12
chilo-ms merged 13 commits into
mainfrom
chi/add_unit_tests

Conversation

@chilo-ms

@chilo-ms chilo-ms commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add unit tests adapted from onnxruntime/test/providers/tensorrt/tensorrt_basic_test.cc to the plugin EP repo, using the C++ gtest infrastructure. Also includes a bug fix for DDS (data-dependent shape) output support.

Tests Added (11 tests, all passing)

Test What it covers
FunctionTest Basic Add+Add model inference (M = (X+Y)+Z)
TestSessionOutputs_MultipleOutputs Model with 4 outputs (TopK-based)
TestSessionOutputs_UnusedNodeOutput Model with unused node output
DDSOutputTest Data-dependent shape output
MultiThreadInference 5-thread concurrent inference
MnistModelTest Real MNIST model load and inference
EngineCacheTest Engine cache file creation
EPContextNode_ForeignSourceSkipped Foreign EP source attribution
EPContextNode_NoSourceAttribute_BackwardCompat Legacy backward compat
SequentialRuns Repeated inference stability
DynamicInputShapes Varying input dimensions with explicit profile shapes

Bug Fix: DDS Output Allocator

When the TRT execution context is recreated (due to engine rebuild from shape changes), the \dds_output_allocator_map\ retained entries from the old context. On subsequent runs, the code saw \known_DDS=true\ and skipped calling \setOutputAllocator()\ on the new context, causing \�nqueueV3\ to fail with "Neither address or allocator is set for output tensor".

Fix: Clear \dds_output_allocator_map\ when \context_update\ recreates the execution context, so allocators are re-registered on the new context.

Other Changes

  • Testdata: Added mnist.onnx, topk_and_multiple_graph_outputs.onnx, node_output_not_used.onnx, ort_github_issue_26272_dds.onnx from onnxruntime repo
  • CMakeLists.txt: Added testdata copy post-build rule and TESTDATA_DIR env for test discovery
  • CI pipelines: Updated Linux and Windows workflows to copy testdata into artifacts and set TESTDATA_DIR when running unit tests

Notes

  • Custom op tests excluded (will be added in a separate branch)

chilo-ms and others added 12 commits June 15, 2026 14:17
Port tests from onnxruntime/test/providers/tensorrt/tensorrt_basic_test.cc
to work with the plugin EP library registration approach. Tests include:

- FunctionTest: basic Add+Add model inference
- RemoveCycleTest: boolean logic ops graph partitioning
- TestSessionOutputs: model output count verification
- DDSOutputTest: data-dependent shape output
- MnistModelTest: real model load and inference
- EngineCacheTest: engine caching verification
- MultiThreadInference: concurrent inference stability
- SequentialRuns: repeated inference stability
- DynamicInputShapes: varying input dimensions
- EPContext source attribution tests (foreign/no source)

Also adds testdata models from onnxruntime repo and CMake
post-build copy rule to make testdata available to tests.

Custom op tests excluded (will be in separate branch).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Use unique dim_param names per dynamic dimension to avoid TRT
  constraint conflicts when dims share the same symbolic name.
- Add explicit profile shapes (min/max/opt) for dynamic shape test.
- Disable DDSOutputTest: TRT EP doesn't support output allocator
  for data-dependent shape outputs yet.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Enable ORTTensorRTEp_BUILD_TESTS=ON in build-trtep job
- Copy trt_ep_tests binary to artifact upload directory
- Add 'Run CUDA graph tests' step in run-tests job
- Copy onnxruntime runtime library for test execution
- Include CUDA graph test XML results in artifact upload
- Apply changes to both Windows and Linux workflows

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts:
#	CMakeLists.txt
- Rename 'Run CUDA graph tests' step to 'Run unit tests' since the
  binary now includes both CUDA graph and TensorRT basic tests.
- Copy testdata directory alongside test binary in build artifacts.
- Set TESTDATA_DIR env var so tests can find model files.
- Update artifact upload to use new XML result filename.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@chilo-ms chilo-ms changed the base branch from chi/add_missing_features to main June 16, 2026 20:05
@chilo-ms chilo-ms closed this Jun 16, 2026
@chilo-ms chilo-ms reopened this Jun 16, 2026
When the TRT execution context is recreated (due to engine rebuild from
shape changes), the DDS output allocator map retained entries from the
old context. On subsequent runs, the code saw known_DDS=true and skipped
calling setOutputAllocator on the new context, causing enqueueV3 to fail
with 'Neither address or allocator is set for output tensor'.

Fix: clear dds_output_allocator_map when context_update recreates the
execution context, so allocators are re-registered on the new context.

Also re-enables DDSOutputTest which now passes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@chilo-ms chilo-ms merged commit 40223a6 into main Jun 16, 2026
3 of 12 checks passed
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