-
Notifications
You must be signed in to change notification settings - Fork 133
fix: Create and refactor to use safe GetElementCount and GetByteSize APIs #475
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
Merged
yinggeh
merged 18 commits into
main
from
yinggeh/tri-737-psirt-triton-inference-servercore-integer-overflow
Mar 12, 2026
Merged
Changes from 12 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
fe9055d
Check overflow
yinggeh 78be987
Address copilot comments
yinggeh 82d93f1
Change error message
yinggeh 300957a
Address review comments
yinggeh c0b41ce
Address comments
yinggeh d43597a
Address comments
yinggeh eb9d8ca
Address comment
yinggeh 2344268
Refactor to use safe function calls
yinggeh aab8e04
Copyrights
yinggeh ccb127c
Merge branch 'main' of https://github.com/triton-inference-server/cor…
yinggeh a63e576
Refactor GetByteSize
yinggeh 0e20a05
fIx
yinggeh 197e7ea
xx
yinggeh 807dde8
Address comments
yinggeh a6d6963
Fix
yinggeh 92beeb8
Fix bug
yinggeh 4a79a2f
Merge branch 'main' into yinggeh/tri-737-psirt-triton-inference-serve…
yinggeh 87cf549
Merge branch 'main' into yinggeh/tri-737-psirt-triton-inference-serve…
yinggeh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| // Copyright 2018-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // Copyright 2018-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // | ||
| // Redistribution and use in source and binary forms, with or without | ||
| // modification, are permitted provided that the following conditions | ||
|
|
@@ -384,13 +384,14 @@ SequenceBatchScheduler::GenerateInitialStateData( | |
| auto state_dim = state.dims().begin(); | ||
| for (; initial_state_dim != initial_state.dims().end(); | ||
| initial_state_dim++, state_dim++) { | ||
| if (*initial_state_dim == -1) { | ||
| if (*initial_state_dim == triton::common::WILDCARD_DIM) { | ||
| return Status( | ||
| Status::Code::INVALID_ARG, | ||
| std::string("'initial_state' field for state input name '") + | ||
| state.input_name() + "' contains variable dimensions."); | ||
| } else { | ||
| if (*state_dim != -1 && *initial_state_dim != *state_dim) { | ||
| if (*state_dim != triton::common::WILDCARD_DIM && | ||
| *initial_state_dim != *state_dim) { | ||
| return Status( | ||
| Status::Code::INVALID_ARG, | ||
| std::string("'initial_state' dim for input name '") + | ||
|
|
@@ -404,15 +405,10 @@ SequenceBatchScheduler::GenerateInitialStateData( | |
| } | ||
|
|
||
| // Calculate total memory byte size | ||
| auto element_count = triton::common::GetElementCount(initial_state.dims()); | ||
| size_t dtype_byte_size = | ||
| triton::common::GetDataTypeByteSize(initial_state.data_type()); | ||
| size_t total_byte_size = element_count * dtype_byte_size; | ||
|
|
||
| // Custom handling for TYPE_BYTES | ||
| if (dtype_byte_size == 0) { | ||
| total_byte_size = sizeof(int32_t) * element_count; | ||
| } | ||
| size_t total_byte_size = 0; | ||
| RETURN_IF_ERROR(GetByteSize( | ||
| initial_state.data_type(), initial_state.dims(), state.input_name(), | ||
| reinterpret_cast<int64_t*>(&total_byte_size))); | ||
|
||
|
|
||
| switch (initial_state.state_data_case()) { | ||
| case inference::ModelSequenceBatching_InitialState::StateDataCase:: | ||
|
|
@@ -1757,8 +1753,13 @@ DirectSequenceBatch::BatcherThread(const int nice) | |
| // Use null-request if necessary otherwise use the next | ||
| // request in the queue... | ||
| if (use_null_request) { | ||
| std::unique_ptr<InferenceRequest> ni( | ||
| InferenceRequest::CopyAsNull(*null_irequest)); | ||
| std::unique_ptr<InferenceRequest> ni = nullptr; | ||
| Status status = InferenceRequest::CopyAsNull(*null_irequest, &ni); | ||
| if (!status.IsOk()) { | ||
| LOG_ERROR | ||
| << "internal: unexpecting failure copying null request: " | ||
yinggeh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| << status.Message(); | ||
| } | ||
| // Note that when the not-ready control input of the | ||
| // request is "true" the model can't assume that any | ||
| // other inputs are meaningful, including CORRID. So we | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.