-
Notifications
You must be signed in to change notification settings - Fork 696
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
feat(tensorrt_common): add gtest #5174
Closed
cyn-liu
wants to merge
4
commits into
autowarefoundation:main
from
cyn-liu:add-gtest-to-tensorrt-common
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
880519c
feat(tensorrt_common): add gtest
cyn-liu 8ade1a8
style(pre-commit): autofix
pre-commit-ci[bot] fe616bd
Merge branch 'autowarefoundation:main' into add-gtest-to-tensorrt-common
cyn-liu 64a9b04
Merge branch 'main' into add-gtest-to-tensorrt-common
mitsudome-r 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 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 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 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2023 TIER IV, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "tensorrt_common/tensorrt_common.hpp" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
// test get_input_dims function | ||
TEST(TrtCommonTest, TestGetInputDims) | ||
{ | ||
std::string onnx_file_path = | ||
"src/universe/autoware.universe/common/tensorrt_common/data/yolov5s.onnx"; | ||
nvinfer1::Dims input_dims = tensorrt_common::get_input_dims(onnx_file_path); | ||
ASSERT_GT(input_dims.nbDims, 0); | ||
} | ||
|
||
// test is_valid_precision_string function | ||
TEST(TrtCommonTest, TestIsValidPrecisionString) | ||
{ | ||
std::string valid_precision = "fp16"; | ||
std::string invalid_precision = "invalid_precision"; | ||
ASSERT_TRUE(tensorrt_common::is_valid_precision_string(valid_precision)); | ||
ASSERT_FALSE(tensorrt_common::is_valid_precision_string(invalid_precision)); | ||
} | ||
|
||
// In the future, more test cases will be written to test the functionality of TrtCommon class | ||
|
||
int main(int argc, char * argv[]) | ||
{ | ||
testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided not to include download scripts in CMake.
Maybe we could skip TestGetInputDims for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without downloading the model this package will not be able to be tested.
so do I go ahead and write test case for this package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, this package is not really used in autoware.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure about that? The header files seems to be included by the other packages. (example)
I will discuss this in the next Software WG if we could consider adding sample models in the repository or not for tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mitsudome-r
sorry, I didn't make it clear, there are 3 packages in the perception folder related to tensorrt:
tensorrt_classifier
,tensorrt_yolo
,tensorrt_yolox
, where bothtensorrt_classifier
andtensorrt_yolox
contain thetensorrt_common
, buttensorrt_yolo
does not contain it. for our real car tests we only used thetensorrt_yolo
.