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

chore: minor fixes #1397

Merged
merged 3 commits into from
Oct 11, 2022
Merged

chore: minor fixes #1397

merged 3 commits into from
Oct 11, 2022

Conversation

peri044
Copy link
Collaborator

@peri044 peri044 commented Oct 10, 2022

Signed-off-by: Dheeraj Peri peri.dheeraj@gmail.com

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of change

Please delete options that are not relevant and/or add your own.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes
  • I have added the relevant labels to my PR in so that relevant reviewers are notified

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>
@peri044 peri044 requested a review from narendasan October 10, 2022 20:32
@github-actions github-actions bot added the component: tests Issues re: Tests label Oct 10, 2022
@github-actions github-actions bot requested a review from andi4191 October 10, 2022 20:32
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

There are some changes that do not conform to C++ style guidelines:

diff --git a/home/runner/work/TensorRT/TensorRT/tests/util/util.cpp b/tmp/changes.txt
index c51ed5b..39d1eb1 100644
--- a/home/runner/work/TensorRT/TensorRT/tests/util/util.cpp
+++ b/tmp/changes.txt
@@ -32,7 +32,7 @@ bool cosineSimEqual(const at::Tensor& computed_tensor, const at::Tensor& gt_tens
  std::ostringstream ss;
  ss << computed_tensor << std::endl << gt_tensor << std::endl;
  LOG_DEBUG(ss.str());
-  if (computed_tensor.sum().item<float>() == 0.f || gt_tensor.sum().item<float>() == 0.f){
+  if (computed_tensor.sum().item<float>() == 0.f || gt_tensor.sum().item<float>() == 0.f) {
    return almostEqual(computed_tensor, gt_tensor);
  } else {
    LOG_DEBUG(std::string("Cosine Similarity score: ") + std::to_string(cosine_sim.item<float>()));
diff --git a/home/runner/work/TensorRT/TensorRT/tests/cpp/test_compiled_modules.cpp b/tmp/changes.txt
index 5d8eace..d982c8e 100644
--- a/home/runner/work/TensorRT/TensorRT/tests/cpp/test_compiled_modules.cpp
+++ b/tmp/changes.txt
@@ -41,8 +41,7 @@ TEST_P(CppAPITests, CompiledModuleIsClose) {
  }

  for (size_t i = 0; i < trt_results.size(); i++) {
-    ASSERT_TRUE(
-        torch_tensorrt::tests::util::cosineSimEqual(jit_results[i], trt_results[i].reshape_as(jit_results[i])));
+    ASSERT_TRUE(torch_tensorrt::tests::util::cosineSimEqual(jit_results[i], trt_results[i].reshape_as(jit_results[i])));
  }
}

diff --git a/home/runner/work/TensorRT/TensorRT/tests/cpp/test_default_input_types.cpp b/tmp/changes.txt
index 46908b8..dd32001 100644
--- a/home/runner/work/TensorRT/TensorRT/tests/cpp/test_default_input_types.cpp
+++ b/tmp/changes.txt
@@ -116,5 +116,4 @@ TEST_P(CppAPITests, InputsRespectUserSettingFP32WeightsFP16In) {
INSTANTIATE_TEST_SUITE_P(
    CompiledModuleForwardIsCloseSuite,
    CppAPITests,
-    testing::Values(
-        PathAndInput({"tests/modules/resnet18_traced.jit.pt", {{1, 3, 224, 224}}, {at::kFloat}})));
+    testing::Values(PathAndInput({"tests/modules/resnet18_traced.jit.pt", {{1, 3, 224, 224}}, {at::kFloat}})));
diff --git a/home/runner/work/TensorRT/TensorRT/tests/cpp/test_multiple_registered_engines.cpp b/tmp/changes.txt
index ae986b6..23029bb 100644
--- a/home/runner/work/TensorRT/TensorRT/tests/cpp/test_multiple_registered_engines.cpp
+++ b/tmp/changes.txt
@@ -56,13 +56,13 @@ TEST(CppAPITest, CanRunMultipleEngines) {
  trt2_results.push_back(trt2_results_ivalues.toTensor());

  for (size_t i = 0; i < trt1_results.size(); i++) {
-    ASSERT_TRUE(torch_tensorrt::tests::util::cosineSimEqual(
-        jit1_results[i], trt1_results[i].reshape_as(jit1_results[i])));
+    ASSERT_TRUE(
+        torch_tensorrt::tests::util::cosineSimEqual(jit1_results[i], trt1_results[i].reshape_as(jit1_results[i])));
  }

  for (size_t i = 0; i < trt2_results.size(); i++) {
-    ASSERT_TRUE(torch_tensorrt::tests::util::cosineSimEqual(
-        jit2_results[i], trt2_results[i].reshape_as(jit2_results[i])));
+    ASSERT_TRUE(
+        torch_tensorrt::tests::util::cosineSimEqual(jit2_results[i], trt2_results[i].reshape_as(jit2_results[i])));
  }
}
#endif
diff --git a/home/runner/work/TensorRT/TensorRT/tests/cpp/test_modules_as_engines.cpp b/tmp/changes.txt
index f68bac9..b76bae7 100644
--- a/home/runner/work/TensorRT/TensorRT/tests/cpp/test_modules_as_engines.cpp
+++ b/tmp/changes.txt
@@ -14,8 +14,7 @@ TEST_P(CppAPITests, ModuleAsEngineIsClose) {
  jit_results.push_back(jit_results_ivalues.toTensor());
  auto trt_results = torch_tensorrt::tests::util::RunModuleForwardAsEngine(mod, inputs);

-  ASSERT_TRUE(torch_tensorrt::tests::util::cosineSimEqual(
-      jit_results[0], trt_results[0].reshape_as(jit_results[0])));
+  ASSERT_TRUE(torch_tensorrt::tests::util::cosineSimEqual(jit_results[0], trt_results[0].reshape_as(jit_results[0])));
}

#ifndef DISABLE_TEST_IN_CI
diff --git a/home/runner/work/TensorRT/TensorRT/tests/cpp/test_collections.cpp b/tmp/changes.txt
index 248d4da..7fcc006 100644
--- a/home/runner/work/TensorRT/TensorRT/tests/cpp/test_collections.cpp
+++ b/tmp/changes.txt
@@ -188,8 +188,10 @@ TEST(CppAPITests, TestCollectionTupleInputOutput) {
  auto trt_mod = torch_tensorrt::torchscript::compile(mod, compile_settings);
  auto trt_out = trt_mod.forward(complex_inputs);

-  ASSERT_TRUE(torch_tensorrt::tests::util::cosineSimEqual(out.toTuple()->elements()[0].toTensor(), trt_out.toTuple()->elements()[0].toTensor()));
-  ASSERT_TRUE(torch_tensorrt::tests::util::cosineSimEqual(out.toTuple()->elements()[1].toTensor(), trt_out.toTuple()->elements()[1].toTensor()));
+  ASSERT_TRUE(torch_tensorrt::tests::util::cosineSimEqual(
+      out.toTuple()->elements()[0].toTensor(), trt_out.toTuple()->elements()[0].toTensor()));
+  ASSERT_TRUE(torch_tensorrt::tests::util::cosineSimEqual(
+      out.toTuple()->elements()[1].toTensor(), trt_out.toTuple()->elements()[1].toTensor()));
}

TEST(CppAPITests, TestCollectionListInputOutput) {
@@ -247,8 +249,10 @@ TEST(CppAPITests, TestCollectionListInputOutput) {
  auto trt_mod = torch_tensorrt::torchscript::compile(mod, compile_settings);
  auto trt_out = trt_mod.forward(complex_inputs);

-  ASSERT_TRUE(torch_tensorrt::tests::util::cosineSimEqual(out.toList().vec()[0].toTensor(), trt_out.toList().vec()[0].toTensor()));
-  ASSERT_TRUE(torch_tensorrt::tests::util::cosineSimEqual(out.toList().vec()[1].toTensor(), trt_out.toList().vec()[1].toTensor()));
+  ASSERT_TRUE(torch_tensorrt::tests::util::cosineSimEqual(
+      out.toList().vec()[0].toTensor(), trt_out.toList().vec()[0].toTensor()));
+  ASSERT_TRUE(torch_tensorrt::tests::util::cosineSimEqual(
+      out.toList().vec()[1].toTensor(), trt_out.toList().vec()[1].toTensor()));
}

TEST(CppAPITests, TestCollectionComplexModel) {
@@ -306,6 +310,8 @@ TEST(CppAPITests, TestCollectionComplexModel) {
  auto trt_mod = torch_tensorrt::torchscript::compile(mod, compile_settings);
  auto trt_out = trt_mod.forward(complex_inputs);

-  ASSERT_TRUE(torch_tensorrt::tests::util::cosineSimEqual(out.toTuple()->elements()[0].toTensor(), trt_out.toTuple()->elements()[0].toTensor()));
-  ASSERT_TRUE(torch_tensorrt::tests::util::cosineSimEqual(out.toTuple()->elements()[1].toTensor(), trt_out.toTuple()->elements()[1].toTensor()));
+  ASSERT_TRUE(torch_tensorrt::tests::util::cosineSimEqual(
+      out.toTuple()->elements()[0].toTensor(), trt_out.toTuple()->elements()[0].toTensor()));
+  ASSERT_TRUE(torch_tensorrt::tests::util::cosineSimEqual(
+      out.toTuple()->elements()[1].toTensor(), trt_out.toTuple()->elements()[1].toTensor()));
}
ERROR: Some files do not conform to style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

@peri044
Copy link
Collaborator Author

peri044 commented Oct 11, 2022

@narendasan
Changes in a gist :

  • Moved all (except converters/evaluators) to cosimeSim based testing.
  • Defined threshold constants in tests/utils. Any custom threshold required for a model can be defined here as well instead of changing it at the test level.
  • SSD isn't being used so I removed it in hub.py

Signed-off-by: Dheeraj Peri <peri.dheeraj@gmail.com>
@github-actions github-actions bot added the component: build system Issues re: Build system label Oct 11, 2022
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link
Collaborator

@narendasan narendasan left a comment

Choose a reason for hiding this comment

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

LGTM

@peri044 peri044 merged commit a558e2a into master Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: build system Issues re: Build system component: tests Issues re: Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants