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

Handle compiler warnings for TRT EP #9956

Merged
merged 16 commits into from
Dec 9, 2021
Merged

Conversation

chilo-ms
Copy link
Contributor

@chilo-ms chilo-ms commented Dec 8, 2021

Modify code for removing compiler warning of C4244, C4267 and C4996 of TRT EP in order to comply with Service 360 security rules.

Here is the issue from BinSkim: https://msdata.visualstudio.com/DefaultCollection/Vienna/_workitems/edit/1523090/

@@ -1104,7 +1105,7 @@ TensorrtExecutionProvider::GetCapability(const GraphViewer& graph,

// Remove subgraphs if its size is less than the predefined minimal size
for (auto it = supported_nodes_vector.begin(); it != supported_nodes_vector.end(); ++it) {
const int subgraph_size = it->first.size();
const int subgraph_size = static_cast<int>(it->first.size());
Copy link
Contributor Author

@chilo-ms chilo-ms Dec 8, 2021

Choose a reason for hiding this comment

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

Thought about changing from "const int subgraph_size" to "const size_t subgraph_size". Which means the type of min_subgraph_size_ should be changed to size_t as well. However, min_subgraph_size_ is one of C APIs, it's better not to modify it.

@@ -1432,8 +1433,8 @@ common::Status TensorrtExecutionProvider::Compile(const std::vector<Node*>& fuse
auto trt_context = trt_state->context->get();
auto trt_profile = &(trt_state->trt_profile);
auto alloc = trt_state->scratch_allocator;
int num_inputs = input_indexes.size();
int num_outputs = output_indexes.size();
int num_inputs = static_cast<int>(input_indexes.size());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we change to "size_t num_inputs", we will need to add "static_cast<int32_t>(i)" to "auto input = trt_state->network->get()->getInput(i);" at line 1510.
So don't change this part and also it's not highly possible number of inputs is large enough to overflow 'int' type.

@chilo-ms chilo-ms merged commit 4669048 into master Dec 9, 2021
@chilo-ms chilo-ms deleted the chi/remove_disabled_warning branch December 9, 2021 23:33
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