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

feat!: Masking FX path for SBSA build [Do Not Merge yet] #1244

Closed
wants to merge 1 commit into from

Conversation

andi4191
Copy link
Contributor

@andi4191 andi4191 commented Aug 9, 2022

Signed-off-by: Anurag Dixit a.dixit91@gmail.com

Description

Currently, the code base for torch.fx.passes.pass_manager does not work with Jetson AGX platform. Hence, causing failure to import torch_tensorrt on Jetson AGX with Build artifact for Jetson AGX.

Masking the FX path to workaround this issue.

Fixes # (issue)

Type of change

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

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

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

@andi4191 andi4191 added the WIP Work is in progress, pull request should not be merged yet label Aug 9, 2022
@andi4191 andi4191 self-assigned this Aug 9, 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.

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

diff --git a/workspace/py/torch_tensorrt/csrc/register_tensorrt_classes.cpp b/tmp/changes.txt
index 9db567c..ba07250 100644
--- a/workspace/py/torch_tensorrt/csrc/register_tensorrt_classes.cpp
+++ b/tmp/changes.txt
@@ -26,11 +26,11 @@ void RegisterTRTCompileSpec() {
  static auto TORCHTRT_UNUSED TRTInputSignatureTSRegistration =
      torch::class_<torch_tensorrt::pyapi::InputSignature>("tensorrt", "_InputSignature")
          .def(torch::init<>())
-          .def("_set_signature_ivalue_torchbind",
-                [](const c10::intrusive_ptr<torch_tensorrt::pyapi::InputSignature>& self,
-                  torch::jit::IValue ival) {
-                    self->signature_ivalue = ival;
-                })
+          .def(
+              "_set_signature_ivalue_torchbind",
+              [](const c10::intrusive_ptr<torch_tensorrt::pyapi::InputSignature>& self, torch::jit::IValue ival) {
+                self->signature_ivalue = ival;
+              })
          .def("__str__", &torch_tensorrt::pyapi::InputSignature::to_str);

  ADD_FIELD_GET_SET_REGISTRATION(
diff --git a/workspace/core/conversion/evaluators/aten.cpp b/tmp/changes.txt
index ca9ff4d..aa58dc7 100644
--- a/workspace/core/conversion/evaluators/aten.cpp
+++ b/tmp/changes.txt
@@ -176,7 +176,7 @@ auto aten_registrations TORCHTRT_UNUSED =

                      int64_t start = 0;
                      auto startIVal = args.at(n->input(1)).IValue();
-                      if(!startIVal->isNone()){
+                      if (!startIVal->isNone()) {
                        start = args.at(n->input(1)).unwrapToInt();
                      }
                      int64_t end = args.at(n->input(2)).unwrapToInt();
diff --git a/workspace/core/conversion/evaluators/eval_util.cpp b/tmp/changes.txt
index 742a4f4..c14f9a6 100644
--- a/workspace/core/conversion/evaluators/eval_util.cpp
+++ b/tmp/changes.txt
@@ -20,7 +20,6 @@ int64_t normalizeIndex(int64_t idx, int64_t list_size) {
  return idx;
}

-
// TODO: Switch back to PyTorch canonical implimentation
c10::optional<torch::jit::IValue> toIValue(const torch::jit::Value* v) {
  if (v->node()->kind() != torch::jit::prim::Constant || v->type()->cast<c10::FunctionType>()) {
diff --git a/workspace/core/conversion/evaluators/prim.cpp b/tmp/changes.txt
index 338c427..244c3e8 100644
--- a/workspace/core/conversion/evaluators/prim.cpp
+++ b/tmp/changes.txt
@@ -260,40 +260,39 @@ auto prim_registrations =
                    },
                    EvalOptions().validSchemas({"prim::shape(Tensor a) -> (int[])"})})
        .evaluator({torch::jit::prim::TupleConstruct,
-                  [](const torch::jit::Node* n, kwargs& args) -> c10::optional<torch::jit::IValue> {
-                    auto num_inputs = n->inputs().size();
-                    c10::IValue tuple = c10::ivalue::Tuple::create();
-                    switch (num_inputs) {
-                      case 0:
-                        tuple = c10::ivalue::Tuple::create();
-                        break;
-                      case 1:
-                        tuple = c10::ivalue::Tuple::create(std::move((*args.at(n->input(0)).IValue())));
-                        break;
-                      case 2: {
-                        tuple = c10::ivalue::Tuple::create(
-                            std::move(*(args.at(n->input(0)).IValue())),
-                            std::move(*(args.at(n->input(1)).IValue())));
-                        break;
-                      }
-                      case 3: {
-                        tuple = c10::ivalue::Tuple::create(
-                            std::move(*(args.at(n->input(0)).IValue())),
-                            std::move(*(args.at(n->input(1)).IValue())),
-                            std::move(*(args.at(n->input(2)).IValue())));
-                        break;
-                      }
-                      default: {
-                        std::vector<c10::IValue> elems;
-                        for (size_t i = 0; i < num_inputs; i++) {
-                          elems.push_back(*(args.at(n->input(i)).IValue()));
+                    [](const torch::jit::Node* n, kwargs& args) -> c10::optional<torch::jit::IValue> {
+                      auto num_inputs = n->inputs().size();
+                      c10::IValue tuple = c10::ivalue::Tuple::create();
+                      switch (num_inputs) {
+                        case 0:
+                          tuple = c10::ivalue::Tuple::create();
+                          break;
+                        case 1:
+                          tuple = c10::ivalue::Tuple::create(std::move((*args.at(n->input(0)).IValue())));
+                          break;
+                        case 2: {
+                          tuple = c10::ivalue::Tuple::create(
+                              std::move(*(args.at(n->input(0)).IValue())), std::move(*(args.at(n->input(1)).IValue())));
+                          break;
+                        }
+                        case 3: {
+                          tuple = c10::ivalue::Tuple::create(
+                              std::move(*(args.at(n->input(0)).IValue())),
+                              std::move(*(args.at(n->input(1)).IValue())),
+                              std::move(*(args.at(n->input(2)).IValue())));
+                          break;
+                        }
+                        default: {
+                          std::vector<c10::IValue> elems;
+                          for (size_t i = 0; i < num_inputs; i++) {
+                            elems.push_back(*(args.at(n->input(i)).IValue()));
+                          }
+                          tuple = c10::ivalue::Tuple::create(std::move(elems));
+                          break;
                        }
-                        tuple = c10::ivalue::Tuple::create(std::move(elems));
-                        break;
                      }
-                    }
-                    return c10::optional<torch::jit::IValue>(std::move(tuple));
-                  }})
+                      return c10::optional<torch::jit::IValue>(std::move(tuple));
+                    }})
        .evaluator({torch::jit::prim::TupleIndex,
                    [](const torch::jit::Node* n, kwargs& args) -> c10::optional<torch::jit::IValue> {
                      // Outputs is an IValue which has list of tensors which can be found in ctx->evaluated_value_map
diff --git a/workspace/core/conversion/converters/impl/unary.cpp b/tmp/changes.txt
index a1d03a3..6b0ee2b 100644
--- a/workspace/core/conversion/converters/impl/unary.cpp
+++ b/tmp/changes.txt
@@ -10,45 +10,41 @@ namespace converters {
namespace impl {
namespace {

-
auto abs_registration TORCHTRT_UNUSED = RegisterNodeConversionPatterns().pattern(
-  {"aten::abs (Tensor self) -> Tensor",
-  [](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
-    auto in = args[0].ITensor();
-    bool unary_supported_input = in->getType() == nvinfer1::DataType::kFLOAT
-     || in->getType() == nvinfer1::DataType::kHALF
-     || in->getType() == nvinfer1::DataType::kINT8;
-    if(unary_supported_input){
-      auto unary_layer = ctx->net->addUnary(*in, nvinfer1::UnaryOperation::kABS);
-      TORCHTRT_CHECK(unary_layer, "Unable to create abs layer from node: " << *n);
-      unary_layer->setName(util::node_info(n).c_str());
-      auto out_tensor = ctx->AssociateValueAndTensor(n->outputs()[0], unary_layer->getOutput(0));
-      LOG_DEBUG("Output tensor shape: " << out_tensor->getDimensions());
-      return true;
-    }
-    else{
-      //For types not supported by kABS, use an elementwise implementation abs(x) = max(x, -1 * x)
-      at::Tensor neg_one = torch::full({1}, -1).to(util::TRTDataTypeToScalarType(in->getType()));
-      auto neg_one_const = tensor_to_const(ctx, neg_one);
-      auto neg_layer = add_elementwise(
+    {"aten::abs (Tensor self) -> Tensor", [](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
+       auto in = args[0].ITensor();
+       bool unary_supported_input = in->getType() == nvinfer1::DataType::kFLOAT ||
+           in->getType() == nvinfer1::DataType::kHALF || in->getType() == nvinfer1::DataType::kINT8;
+       if (unary_supported_input) {
+         auto unary_layer = ctx->net->addUnary(*in, nvinfer1::UnaryOperation::kABS);
+         TORCHTRT_CHECK(unary_layer, "Unable to create abs layer from node: " << *n);
+         unary_layer->setName(util::node_info(n).c_str());
+         auto out_tensor = ctx->AssociateValueAndTensor(n->outputs()[0], unary_layer->getOutput(0));
+         LOG_DEBUG("Output tensor shape: " << out_tensor->getDimensions());
+         return true;
+       } else {
+         // For types not supported by kABS, use an elementwise implementation abs(x) = max(x, -1 * x)
+         at::Tensor neg_one = torch::full({1}, -1).to(util::TRTDataTypeToScalarType(in->getType()));
+         auto neg_one_const = tensor_to_const(ctx, neg_one);
+         auto neg_layer = add_elementwise(
             ctx,
             nvinfer1::ElementWiseOperation::kPROD,
             in,
             neg_one_const,
             util::node_info(n) + std::string("_Negation"));
-      TORCHTRT_CHECK(neg_layer, "Unable to create prod layer from node: " << *n);
-      auto max_layer = add_elementwise(
+         TORCHTRT_CHECK(neg_layer, "Unable to create prod layer from node: " << *n);
+         auto max_layer = add_elementwise(
             ctx,
             nvinfer1::ElementWiseOperation::kMAX,
             in,
             neg_layer->getOutput(0),
             util::node_info(n) + std::string("_Max"));
-      TORCHTRT_CHECK(max_layer, "Unable to create max layer from node: " << *n);
-      auto out_tensor = ctx->AssociateValueAndTensor(n->outputs()[0], max_layer->getOutput(0));
-      LOG_DEBUG("Output tensor shape: " << out_tensor->getDimensions());
-      return true;
-    }
-  }});
+         TORCHTRT_CHECK(max_layer, "Unable to create max layer from node: " << *n);
+         auto out_tensor = ctx->AssociateValueAndTensor(n->outputs()[0], max_layer->getOutput(0));
+         LOG_DEBUG("Output tensor shape: " << out_tensor->getDimensions());
+         return true;
+       }
+     }});

#define convert(unary, trt_type)                                                               \
  auto unary##_registrations TORCHTRT_UNUSED = RegisterNodeConversionPatterns().pattern(       \
diff --git a/workspace/tests/core/conversion/converters/test_element_wise.cpp b/tmp/changes.txt
index 939c9b7..db60896 100644
--- a/workspace/tests/core/conversion/converters/test_element_wise.cpp
+++ b/tmp/changes.txt
@@ -30,14 +30,15 @@ void pointwise_test_helper(
    torch_inputs.push_back(at::randint(1, 5, shape2, {at::kCUDA}));
  }

-  TORCHTRT_CHECK(!((int_tensors && (float_int_tensors || int_float_tensors)) || (float_int_tensors && int_float_tensors)),
-    "Invalid test configuration, only one of int_tensors, float_int_tensors, int_float_tensors can be true");
+  TORCHTRT_CHECK(
+      !((int_tensors && (float_int_tensors || int_float_tensors)) || (float_int_tensors && int_float_tensors)),
+      "Invalid test configuration, only one of int_tensors, float_int_tensors, int_float_tensors can be true");

-  if(int_tensors){
-    for(size_t i = 0UL; i < torch_inputs.size(); ++i){
+  if (int_tensors) {
+    for (size_t i = 0UL; i < torch_inputs.size(); ++i) {
      torch_inputs[i] = torch_inputs[i].to(at::kInt);
    }
-  } else if(float_int_tensors) {
+  } else if (float_int_tensors) {
    TORCHTRT_CHECK(!singleInput, "float_int_tensors tests require two inputs");
    torch_inputs[0] = torch_inputs[0].to(at::kFloat);
    torch_inputs[1] = torch_inputs[1].to(at::kInt);
diff --git a/workspace/tests/core/conversion/converters/test_unary.cpp b/tmp/changes.txt
index a7ab3bb..1d40c3c 100644
--- a/workspace/tests/core/conversion/converters/test_unary.cpp
+++ b/tmp/changes.txt
@@ -1,9 +1,9 @@
#include <string>
-#include "torch/torch.h"
#include "core/compiler.h"
#include "gtest/gtest.h"
#include "tests/util/util.h"
#include "torch/csrc/jit/ir/irparser.h"
+#include "torch/torch.h"

namespace {
std::string gen_test_graph(const std::string& unary) {
@@ -22,7 +22,7 @@ TEST(Converters, ATenAbsIntConvertsCorrectly) {

  auto in = at::tensor({-1, 1, -2, 2, -3, 3}, {at::kCUDA}).to(torch::kInt32);
  auto params = torch_tensorrt::core::ir::get_static_params(g->inputs(), {});
-  auto jit_results = torch_tensorrt::tests::util::RunGraph(g, params, {in});  
+  auto jit_results = torch_tensorrt::tests::util::RunGraph(g, params, {in});

  in = at::clone(in);
  params = torch_tensorrt::core::ir::get_static_params(g->inputs(), {});
diff --git a/workspace/tests/core/conversion/converters/test_select.cpp b/tmp/changes.txt
index 03b6bda..67b760a 100644
--- a/workspace/tests/core/conversion/converters/test_select.cpp
+++ b/tmp/changes.txt
@@ -376,7 +376,7 @@ TEST(Converters, ATenSliceListConvertsCorrectly) {
          %slice : Tensor[] = aten::slice(%list, %1, %2, %3)
          %out.1 : Tensor, %out.2 : Tensor = prim::ListUnpack(%slice)
          return (%out.1, %out.2))IR";
-  
+
  auto g = std::make_shared<torch::jit::Graph>();

  torch::jit::parseIR(graph, g.get());
diff --git a/workspace/tests/cpp/test_collections.cpp b/tmp/changes.txt
index 31495a4..d01665a 100644
--- a/workspace/tests/cpp/test_collections.cpp
+++ b/tmp/changes.txt
@@ -135,7 +135,7 @@ TEST(CppAPITests, TestCollectionListInput) {

  auto compile_settings = torch_tensorrt::ts::CompileSpec(complex_input_shape2);
  compile_settings.min_block_size = 1;
-  //compile_settings.torch_executed_ops.push_back("aten::__getitem__");
+  // compile_settings.torch_executed_ops.push_back("aten::__getitem__");

  // // FP16 execution
  compile_settings.enabled_precisions = {torch::kHalf};
diff --git a/workspace/cpp/src/compile_spec.cpp b/tmp/changes.txt
index 8c7bb8b..cfbc228 100644
--- a/workspace/cpp/src/compile_spec.cpp
+++ b/tmp/changes.txt
@@ -69,22 +69,24 @@ torchtrt::core::CompileSpec init_compile_spec(CompileSpec& external) {
    return internal;
  } else {
    torch::jit::IValue converted_input_signature;
-    LOG_WARNING( "Input signature parsing is an experimental feature, behavior and APIs may change");
+    LOG_WARNING("Input signature parsing is an experimental feature, behavior and APIs may change");
    to_internal_input_signature(external.graph_inputs.input_signature, converted_input_signature);
    torchtrt::core::CompileSpec internal(converted_input_signature);

-    TORCHTRT_CHECK(!external.require_full_compilation, \
-      "Grouped inputs currently requires partial compilation to be enabled, \
+    TORCHTRT_CHECK(
+        !external.require_full_compilation,
+        "Grouped inputs currently requires partial compilation to be enabled, \
      this restriction will be relaxed in a future release");

    LOG_DEBUG("Grouped inputs currently requires additional settings to enable the feature");
-    LOG_DEBUG("Adding the following ops to torch_executed_ops:" \
-       << std::endl << "  - aten::__getitem__" \
-       << std::endl << "  - prim::ListConstruct" \
-       << std::endl << "  - prim::ListUnpack" \
-       << std::endl << "  - prim::TupleIndex" \
-       << std::endl << "  - prim::TupleConstruct" \
-       << std::endl << "  - prim::TupleUnpack");
+    LOG_DEBUG(
+        "Adding the following ops to torch_executed_ops:" << std::endl
+                                                          << "  - aten::__getitem__" << std::endl
+                                                          << "  - prim::ListConstruct" << std::endl
+                                                          << "  - prim::ListUnpack" << std::endl
+                                                          << "  - prim::TupleIndex" << std::endl
+                                                          << "  - prim::TupleConstruct" << std::endl
+                                                          << "  - prim::TupleUnpack");
    external.torch_executed_ops.push_back("aten::__getitem__");
    external.torch_executed_ops.push_back("prim::ListConstruct");
    external.torch_executed_ops.push_back("prim::ListUnpack");
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.

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

diff --git a/workspace/py/torch_tensorrt/csrc/register_tensorrt_classes.cpp b/tmp/changes.txt
index 9db567c..ba07250 100644
--- a/workspace/py/torch_tensorrt/csrc/register_tensorrt_classes.cpp
+++ b/tmp/changes.txt
@@ -26,11 +26,11 @@ void RegisterTRTCompileSpec() {
  static auto TORCHTRT_UNUSED TRTInputSignatureTSRegistration =
      torch::class_<torch_tensorrt::pyapi::InputSignature>("tensorrt", "_InputSignature")
          .def(torch::init<>())
-          .def("_set_signature_ivalue_torchbind",
-                [](const c10::intrusive_ptr<torch_tensorrt::pyapi::InputSignature>& self,
-                  torch::jit::IValue ival) {
-                    self->signature_ivalue = ival;
-                })
+          .def(
+              "_set_signature_ivalue_torchbind",
+              [](const c10::intrusive_ptr<torch_tensorrt::pyapi::InputSignature>& self, torch::jit::IValue ival) {
+                self->signature_ivalue = ival;
+              })
          .def("__str__", &torch_tensorrt::pyapi::InputSignature::to_str);

  ADD_FIELD_GET_SET_REGISTRATION(
diff --git a/workspace/core/conversion/evaluators/aten.cpp b/tmp/changes.txt
index ca9ff4d..aa58dc7 100644
--- a/workspace/core/conversion/evaluators/aten.cpp
+++ b/tmp/changes.txt
@@ -176,7 +176,7 @@ auto aten_registrations TORCHTRT_UNUSED =

                      int64_t start = 0;
                      auto startIVal = args.at(n->input(1)).IValue();
-                      if(!startIVal->isNone()){
+                      if (!startIVal->isNone()) {
                        start = args.at(n->input(1)).unwrapToInt();
                      }
                      int64_t end = args.at(n->input(2)).unwrapToInt();
diff --git a/workspace/core/conversion/evaluators/eval_util.cpp b/tmp/changes.txt
index 742a4f4..c14f9a6 100644
--- a/workspace/core/conversion/evaluators/eval_util.cpp
+++ b/tmp/changes.txt
@@ -20,7 +20,6 @@ int64_t normalizeIndex(int64_t idx, int64_t list_size) {
  return idx;
}

-
// TODO: Switch back to PyTorch canonical implimentation
c10::optional<torch::jit::IValue> toIValue(const torch::jit::Value* v) {
  if (v->node()->kind() != torch::jit::prim::Constant || v->type()->cast<c10::FunctionType>()) {
diff --git a/workspace/core/conversion/evaluators/prim.cpp b/tmp/changes.txt
index 338c427..244c3e8 100644
--- a/workspace/core/conversion/evaluators/prim.cpp
+++ b/tmp/changes.txt
@@ -260,40 +260,39 @@ auto prim_registrations =
                    },
                    EvalOptions().validSchemas({"prim::shape(Tensor a) -> (int[])"})})
        .evaluator({torch::jit::prim::TupleConstruct,
-                  [](const torch::jit::Node* n, kwargs& args) -> c10::optional<torch::jit::IValue> {
-                    auto num_inputs = n->inputs().size();
-                    c10::IValue tuple = c10::ivalue::Tuple::create();
-                    switch (num_inputs) {
-                      case 0:
-                        tuple = c10::ivalue::Tuple::create();
-                        break;
-                      case 1:
-                        tuple = c10::ivalue::Tuple::create(std::move((*args.at(n->input(0)).IValue())));
-                        break;
-                      case 2: {
-                        tuple = c10::ivalue::Tuple::create(
-                            std::move(*(args.at(n->input(0)).IValue())),
-                            std::move(*(args.at(n->input(1)).IValue())));
-                        break;
-                      }
-                      case 3: {
-                        tuple = c10::ivalue::Tuple::create(
-                            std::move(*(args.at(n->input(0)).IValue())),
-                            std::move(*(args.at(n->input(1)).IValue())),
-                            std::move(*(args.at(n->input(2)).IValue())));
-                        break;
-                      }
-                      default: {
-                        std::vector<c10::IValue> elems;
-                        for (size_t i = 0; i < num_inputs; i++) {
-                          elems.push_back(*(args.at(n->input(i)).IValue()));
+                    [](const torch::jit::Node* n, kwargs& args) -> c10::optional<torch::jit::IValue> {
+                      auto num_inputs = n->inputs().size();
+                      c10::IValue tuple = c10::ivalue::Tuple::create();
+                      switch (num_inputs) {
+                        case 0:
+                          tuple = c10::ivalue::Tuple::create();
+                          break;
+                        case 1:
+                          tuple = c10::ivalue::Tuple::create(std::move((*args.at(n->input(0)).IValue())));
+                          break;
+                        case 2: {
+                          tuple = c10::ivalue::Tuple::create(
+                              std::move(*(args.at(n->input(0)).IValue())), std::move(*(args.at(n->input(1)).IValue())));
+                          break;
+                        }
+                        case 3: {
+                          tuple = c10::ivalue::Tuple::create(
+                              std::move(*(args.at(n->input(0)).IValue())),
+                              std::move(*(args.at(n->input(1)).IValue())),
+                              std::move(*(args.at(n->input(2)).IValue())));
+                          break;
+                        }
+                        default: {
+                          std::vector<c10::IValue> elems;
+                          for (size_t i = 0; i < num_inputs; i++) {
+                            elems.push_back(*(args.at(n->input(i)).IValue()));
+                          }
+                          tuple = c10::ivalue::Tuple::create(std::move(elems));
+                          break;
                        }
-                        tuple = c10::ivalue::Tuple::create(std::move(elems));
-                        break;
                      }
-                    }
-                    return c10::optional<torch::jit::IValue>(std::move(tuple));
-                  }})
+                      return c10::optional<torch::jit::IValue>(std::move(tuple));
+                    }})
        .evaluator({torch::jit::prim::TupleIndex,
                    [](const torch::jit::Node* n, kwargs& args) -> c10::optional<torch::jit::IValue> {
                      // Outputs is an IValue which has list of tensors which can be found in ctx->evaluated_value_map
diff --git a/workspace/core/conversion/converters/impl/unary.cpp b/tmp/changes.txt
index a1d03a3..6b0ee2b 100644
--- a/workspace/core/conversion/converters/impl/unary.cpp
+++ b/tmp/changes.txt
@@ -10,45 +10,41 @@ namespace converters {
namespace impl {
namespace {

-
auto abs_registration TORCHTRT_UNUSED = RegisterNodeConversionPatterns().pattern(
-  {"aten::abs (Tensor self) -> Tensor",
-  [](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
-    auto in = args[0].ITensor();
-    bool unary_supported_input = in->getType() == nvinfer1::DataType::kFLOAT
-     || in->getType() == nvinfer1::DataType::kHALF
-     || in->getType() == nvinfer1::DataType::kINT8;
-    if(unary_supported_input){
-      auto unary_layer = ctx->net->addUnary(*in, nvinfer1::UnaryOperation::kABS);
-      TORCHTRT_CHECK(unary_layer, "Unable to create abs layer from node: " << *n);
-      unary_layer->setName(util::node_info(n).c_str());
-      auto out_tensor = ctx->AssociateValueAndTensor(n->outputs()[0], unary_layer->getOutput(0));
-      LOG_DEBUG("Output tensor shape: " << out_tensor->getDimensions());
-      return true;
-    }
-    else{
-      //For types not supported by kABS, use an elementwise implementation abs(x) = max(x, -1 * x)
-      at::Tensor neg_one = torch::full({1}, -1).to(util::TRTDataTypeToScalarType(in->getType()));
-      auto neg_one_const = tensor_to_const(ctx, neg_one);
-      auto neg_layer = add_elementwise(
+    {"aten::abs (Tensor self) -> Tensor", [](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
+       auto in = args[0].ITensor();
+       bool unary_supported_input = in->getType() == nvinfer1::DataType::kFLOAT ||
+           in->getType() == nvinfer1::DataType::kHALF || in->getType() == nvinfer1::DataType::kINT8;
+       if (unary_supported_input) {
+         auto unary_layer = ctx->net->addUnary(*in, nvinfer1::UnaryOperation::kABS);
+         TORCHTRT_CHECK(unary_layer, "Unable to create abs layer from node: " << *n);
+         unary_layer->setName(util::node_info(n).c_str());
+         auto out_tensor = ctx->AssociateValueAndTensor(n->outputs()[0], unary_layer->getOutput(0));
+         LOG_DEBUG("Output tensor shape: " << out_tensor->getDimensions());
+         return true;
+       } else {
+         // For types not supported by kABS, use an elementwise implementation abs(x) = max(x, -1 * x)
+         at::Tensor neg_one = torch::full({1}, -1).to(util::TRTDataTypeToScalarType(in->getType()));
+         auto neg_one_const = tensor_to_const(ctx, neg_one);
+         auto neg_layer = add_elementwise(
             ctx,
             nvinfer1::ElementWiseOperation::kPROD,
             in,
             neg_one_const,
             util::node_info(n) + std::string("_Negation"));
-      TORCHTRT_CHECK(neg_layer, "Unable to create prod layer from node: " << *n);
-      auto max_layer = add_elementwise(
+         TORCHTRT_CHECK(neg_layer, "Unable to create prod layer from node: " << *n);
+         auto max_layer = add_elementwise(
             ctx,
             nvinfer1::ElementWiseOperation::kMAX,
             in,
             neg_layer->getOutput(0),
             util::node_info(n) + std::string("_Max"));
-      TORCHTRT_CHECK(max_layer, "Unable to create max layer from node: " << *n);
-      auto out_tensor = ctx->AssociateValueAndTensor(n->outputs()[0], max_layer->getOutput(0));
-      LOG_DEBUG("Output tensor shape: " << out_tensor->getDimensions());
-      return true;
-    }
-  }});
+         TORCHTRT_CHECK(max_layer, "Unable to create max layer from node: " << *n);
+         auto out_tensor = ctx->AssociateValueAndTensor(n->outputs()[0], max_layer->getOutput(0));
+         LOG_DEBUG("Output tensor shape: " << out_tensor->getDimensions());
+         return true;
+       }
+     }});

#define convert(unary, trt_type)                                                               \
  auto unary##_registrations TORCHTRT_UNUSED = RegisterNodeConversionPatterns().pattern(       \
diff --git a/workspace/tests/core/conversion/converters/test_element_wise.cpp b/tmp/changes.txt
index 939c9b7..db60896 100644
--- a/workspace/tests/core/conversion/converters/test_element_wise.cpp
+++ b/tmp/changes.txt
@@ -30,14 +30,15 @@ void pointwise_test_helper(
    torch_inputs.push_back(at::randint(1, 5, shape2, {at::kCUDA}));
  }

-  TORCHTRT_CHECK(!((int_tensors && (float_int_tensors || int_float_tensors)) || (float_int_tensors && int_float_tensors)),
-    "Invalid test configuration, only one of int_tensors, float_int_tensors, int_float_tensors can be true");
+  TORCHTRT_CHECK(
+      !((int_tensors && (float_int_tensors || int_float_tensors)) || (float_int_tensors && int_float_tensors)),
+      "Invalid test configuration, only one of int_tensors, float_int_tensors, int_float_tensors can be true");

-  if(int_tensors){
-    for(size_t i = 0UL; i < torch_inputs.size(); ++i){
+  if (int_tensors) {
+    for (size_t i = 0UL; i < torch_inputs.size(); ++i) {
      torch_inputs[i] = torch_inputs[i].to(at::kInt);
    }
-  } else if(float_int_tensors) {
+  } else if (float_int_tensors) {
    TORCHTRT_CHECK(!singleInput, "float_int_tensors tests require two inputs");
    torch_inputs[0] = torch_inputs[0].to(at::kFloat);
    torch_inputs[1] = torch_inputs[1].to(at::kInt);
diff --git a/workspace/tests/core/conversion/converters/test_unary.cpp b/tmp/changes.txt
index a7ab3bb..1d40c3c 100644
--- a/workspace/tests/core/conversion/converters/test_unary.cpp
+++ b/tmp/changes.txt
@@ -1,9 +1,9 @@
#include <string>
-#include "torch/torch.h"
#include "core/compiler.h"
#include "gtest/gtest.h"
#include "tests/util/util.h"
#include "torch/csrc/jit/ir/irparser.h"
+#include "torch/torch.h"

namespace {
std::string gen_test_graph(const std::string& unary) {
@@ -22,7 +22,7 @@ TEST(Converters, ATenAbsIntConvertsCorrectly) {

  auto in = at::tensor({-1, 1, -2, 2, -3, 3}, {at::kCUDA}).to(torch::kInt32);
  auto params = torch_tensorrt::core::ir::get_static_params(g->inputs(), {});
-  auto jit_results = torch_tensorrt::tests::util::RunGraph(g, params, {in});  
+  auto jit_results = torch_tensorrt::tests::util::RunGraph(g, params, {in});

  in = at::clone(in);
  params = torch_tensorrt::core::ir::get_static_params(g->inputs(), {});
diff --git a/workspace/tests/core/conversion/converters/test_select.cpp b/tmp/changes.txt
index 03b6bda..67b760a 100644
--- a/workspace/tests/core/conversion/converters/test_select.cpp
+++ b/tmp/changes.txt
@@ -376,7 +376,7 @@ TEST(Converters, ATenSliceListConvertsCorrectly) {
          %slice : Tensor[] = aten::slice(%list, %1, %2, %3)
          %out.1 : Tensor, %out.2 : Tensor = prim::ListUnpack(%slice)
          return (%out.1, %out.2))IR";
-  
+
  auto g = std::make_shared<torch::jit::Graph>();

  torch::jit::parseIR(graph, g.get());
diff --git a/workspace/tests/cpp/test_collections.cpp b/tmp/changes.txt
index 31495a4..d01665a 100644
--- a/workspace/tests/cpp/test_collections.cpp
+++ b/tmp/changes.txt
@@ -135,7 +135,7 @@ TEST(CppAPITests, TestCollectionListInput) {

  auto compile_settings = torch_tensorrt::ts::CompileSpec(complex_input_shape2);
  compile_settings.min_block_size = 1;
-  //compile_settings.torch_executed_ops.push_back("aten::__getitem__");
+  // compile_settings.torch_executed_ops.push_back("aten::__getitem__");

  // // FP16 execution
  compile_settings.enabled_precisions = {torch::kHalf};
diff --git a/workspace/cpp/src/compile_spec.cpp b/tmp/changes.txt
index 8c7bb8b..cfbc228 100644
--- a/workspace/cpp/src/compile_spec.cpp
+++ b/tmp/changes.txt
@@ -69,22 +69,24 @@ torchtrt::core::CompileSpec init_compile_spec(CompileSpec& external) {
    return internal;
  } else {
    torch::jit::IValue converted_input_signature;
-    LOG_WARNING( "Input signature parsing is an experimental feature, behavior and APIs may change");
+    LOG_WARNING("Input signature parsing is an experimental feature, behavior and APIs may change");
    to_internal_input_signature(external.graph_inputs.input_signature, converted_input_signature);
    torchtrt::core::CompileSpec internal(converted_input_signature);

-    TORCHTRT_CHECK(!external.require_full_compilation, \
-      "Grouped inputs currently requires partial compilation to be enabled, \
+    TORCHTRT_CHECK(
+        !external.require_full_compilation,
+        "Grouped inputs currently requires partial compilation to be enabled, \
      this restriction will be relaxed in a future release");

    LOG_DEBUG("Grouped inputs currently requires additional settings to enable the feature");
-    LOG_DEBUG("Adding the following ops to torch_executed_ops:" \
-       << std::endl << "  - aten::__getitem__" \
-       << std::endl << "  - prim::ListConstruct" \
-       << std::endl << "  - prim::ListUnpack" \
-       << std::endl << "  - prim::TupleIndex" \
-       << std::endl << "  - prim::TupleConstruct" \
-       << std::endl << "  - prim::TupleUnpack");
+    LOG_DEBUG(
+        "Adding the following ops to torch_executed_ops:" << std::endl
+                                                          << "  - aten::__getitem__" << std::endl
+                                                          << "  - prim::ListConstruct" << std::endl
+                                                          << "  - prim::ListUnpack" << std::endl
+                                                          << "  - prim::TupleIndex" << std::endl
+                                                          << "  - prim::TupleConstruct" << std::endl
+                                                          << "  - prim::TupleUnpack");
    external.torch_executed_ops.push_back("aten::__getitem__");
    external.torch_executed_ops.push_back("prim::ListConstruct");
    external.torch_executed_ops.push_back("prim::ListUnpack");
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.

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

diff --git a/workspace/py/torch_tensorrt/csrc/register_tensorrt_classes.cpp b/tmp/changes.txt
index 9db567c..ba07250 100644
--- a/workspace/py/torch_tensorrt/csrc/register_tensorrt_classes.cpp
+++ b/tmp/changes.txt
@@ -26,11 +26,11 @@ void RegisterTRTCompileSpec() {
  static auto TORCHTRT_UNUSED TRTInputSignatureTSRegistration =
      torch::class_<torch_tensorrt::pyapi::InputSignature>("tensorrt", "_InputSignature")
          .def(torch::init<>())
-          .def("_set_signature_ivalue_torchbind",
-                [](const c10::intrusive_ptr<torch_tensorrt::pyapi::InputSignature>& self,
-                  torch::jit::IValue ival) {
-                    self->signature_ivalue = ival;
-                })
+          .def(
+              "_set_signature_ivalue_torchbind",
+              [](const c10::intrusive_ptr<torch_tensorrt::pyapi::InputSignature>& self, torch::jit::IValue ival) {
+                self->signature_ivalue = ival;
+              })
          .def("__str__", &torch_tensorrt::pyapi::InputSignature::to_str);

  ADD_FIELD_GET_SET_REGISTRATION(
diff --git a/workspace/core/conversion/evaluators/aten.cpp b/tmp/changes.txt
index ca9ff4d..aa58dc7 100644
--- a/workspace/core/conversion/evaluators/aten.cpp
+++ b/tmp/changes.txt
@@ -176,7 +176,7 @@ auto aten_registrations TORCHTRT_UNUSED =

                      int64_t start = 0;
                      auto startIVal = args.at(n->input(1)).IValue();
-                      if(!startIVal->isNone()){
+                      if (!startIVal->isNone()) {
                        start = args.at(n->input(1)).unwrapToInt();
                      }
                      int64_t end = args.at(n->input(2)).unwrapToInt();
diff --git a/workspace/core/conversion/evaluators/eval_util.cpp b/tmp/changes.txt
index 742a4f4..c14f9a6 100644
--- a/workspace/core/conversion/evaluators/eval_util.cpp
+++ b/tmp/changes.txt
@@ -20,7 +20,6 @@ int64_t normalizeIndex(int64_t idx, int64_t list_size) {
  return idx;
}

-
// TODO: Switch back to PyTorch canonical implimentation
c10::optional<torch::jit::IValue> toIValue(const torch::jit::Value* v) {
  if (v->node()->kind() != torch::jit::prim::Constant || v->type()->cast<c10::FunctionType>()) {
diff --git a/workspace/core/conversion/evaluators/prim.cpp b/tmp/changes.txt
index 338c427..244c3e8 100644
--- a/workspace/core/conversion/evaluators/prim.cpp
+++ b/tmp/changes.txt
@@ -260,40 +260,39 @@ auto prim_registrations =
                    },
                    EvalOptions().validSchemas({"prim::shape(Tensor a) -> (int[])"})})
        .evaluator({torch::jit::prim::TupleConstruct,
-                  [](const torch::jit::Node* n, kwargs& args) -> c10::optional<torch::jit::IValue> {
-                    auto num_inputs = n->inputs().size();
-                    c10::IValue tuple = c10::ivalue::Tuple::create();
-                    switch (num_inputs) {
-                      case 0:
-                        tuple = c10::ivalue::Tuple::create();
-                        break;
-                      case 1:
-                        tuple = c10::ivalue::Tuple::create(std::move((*args.at(n->input(0)).IValue())));
-                        break;
-                      case 2: {
-                        tuple = c10::ivalue::Tuple::create(
-                            std::move(*(args.at(n->input(0)).IValue())),
-                            std::move(*(args.at(n->input(1)).IValue())));
-                        break;
-                      }
-                      case 3: {
-                        tuple = c10::ivalue::Tuple::create(
-                            std::move(*(args.at(n->input(0)).IValue())),
-                            std::move(*(args.at(n->input(1)).IValue())),
-                            std::move(*(args.at(n->input(2)).IValue())));
-                        break;
-                      }
-                      default: {
-                        std::vector<c10::IValue> elems;
-                        for (size_t i = 0; i < num_inputs; i++) {
-                          elems.push_back(*(args.at(n->input(i)).IValue()));
+                    [](const torch::jit::Node* n, kwargs& args) -> c10::optional<torch::jit::IValue> {
+                      auto num_inputs = n->inputs().size();
+                      c10::IValue tuple = c10::ivalue::Tuple::create();
+                      switch (num_inputs) {
+                        case 0:
+                          tuple = c10::ivalue::Tuple::create();
+                          break;
+                        case 1:
+                          tuple = c10::ivalue::Tuple::create(std::move((*args.at(n->input(0)).IValue())));
+                          break;
+                        case 2: {
+                          tuple = c10::ivalue::Tuple::create(
+                              std::move(*(args.at(n->input(0)).IValue())), std::move(*(args.at(n->input(1)).IValue())));
+                          break;
+                        }
+                        case 3: {
+                          tuple = c10::ivalue::Tuple::create(
+                              std::move(*(args.at(n->input(0)).IValue())),
+                              std::move(*(args.at(n->input(1)).IValue())),
+                              std::move(*(args.at(n->input(2)).IValue())));
+                          break;
+                        }
+                        default: {
+                          std::vector<c10::IValue> elems;
+                          for (size_t i = 0; i < num_inputs; i++) {
+                            elems.push_back(*(args.at(n->input(i)).IValue()));
+                          }
+                          tuple = c10::ivalue::Tuple::create(std::move(elems));
+                          break;
                        }
-                        tuple = c10::ivalue::Tuple::create(std::move(elems));
-                        break;
                      }
-                    }
-                    return c10::optional<torch::jit::IValue>(std::move(tuple));
-                  }})
+                      return c10::optional<torch::jit::IValue>(std::move(tuple));
+                    }})
        .evaluator({torch::jit::prim::TupleIndex,
                    [](const torch::jit::Node* n, kwargs& args) -> c10::optional<torch::jit::IValue> {
                      // Outputs is an IValue which has list of tensors which can be found in ctx->evaluated_value_map
diff --git a/workspace/core/conversion/converters/impl/unary.cpp b/tmp/changes.txt
index a1d03a3..6b0ee2b 100644
--- a/workspace/core/conversion/converters/impl/unary.cpp
+++ b/tmp/changes.txt
@@ -10,45 +10,41 @@ namespace converters {
namespace impl {
namespace {

-
auto abs_registration TORCHTRT_UNUSED = RegisterNodeConversionPatterns().pattern(
-  {"aten::abs (Tensor self) -> Tensor",
-  [](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
-    auto in = args[0].ITensor();
-    bool unary_supported_input = in->getType() == nvinfer1::DataType::kFLOAT
-     || in->getType() == nvinfer1::DataType::kHALF
-     || in->getType() == nvinfer1::DataType::kINT8;
-    if(unary_supported_input){
-      auto unary_layer = ctx->net->addUnary(*in, nvinfer1::UnaryOperation::kABS);
-      TORCHTRT_CHECK(unary_layer, "Unable to create abs layer from node: " << *n);
-      unary_layer->setName(util::node_info(n).c_str());
-      auto out_tensor = ctx->AssociateValueAndTensor(n->outputs()[0], unary_layer->getOutput(0));
-      LOG_DEBUG("Output tensor shape: " << out_tensor->getDimensions());
-      return true;
-    }
-    else{
-      //For types not supported by kABS, use an elementwise implementation abs(x) = max(x, -1 * x)
-      at::Tensor neg_one = torch::full({1}, -1).to(util::TRTDataTypeToScalarType(in->getType()));
-      auto neg_one_const = tensor_to_const(ctx, neg_one);
-      auto neg_layer = add_elementwise(
+    {"aten::abs (Tensor self) -> Tensor", [](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
+       auto in = args[0].ITensor();
+       bool unary_supported_input = in->getType() == nvinfer1::DataType::kFLOAT ||
+           in->getType() == nvinfer1::DataType::kHALF || in->getType() == nvinfer1::DataType::kINT8;
+       if (unary_supported_input) {
+         auto unary_layer = ctx->net->addUnary(*in, nvinfer1::UnaryOperation::kABS);
+         TORCHTRT_CHECK(unary_layer, "Unable to create abs layer from node: " << *n);
+         unary_layer->setName(util::node_info(n).c_str());
+         auto out_tensor = ctx->AssociateValueAndTensor(n->outputs()[0], unary_layer->getOutput(0));
+         LOG_DEBUG("Output tensor shape: " << out_tensor->getDimensions());
+         return true;
+       } else {
+         // For types not supported by kABS, use an elementwise implementation abs(x) = max(x, -1 * x)
+         at::Tensor neg_one = torch::full({1}, -1).to(util::TRTDataTypeToScalarType(in->getType()));
+         auto neg_one_const = tensor_to_const(ctx, neg_one);
+         auto neg_layer = add_elementwise(
             ctx,
             nvinfer1::ElementWiseOperation::kPROD,
             in,
             neg_one_const,
             util::node_info(n) + std::string("_Negation"));
-      TORCHTRT_CHECK(neg_layer, "Unable to create prod layer from node: " << *n);
-      auto max_layer = add_elementwise(
+         TORCHTRT_CHECK(neg_layer, "Unable to create prod layer from node: " << *n);
+         auto max_layer = add_elementwise(
             ctx,
             nvinfer1::ElementWiseOperation::kMAX,
             in,
             neg_layer->getOutput(0),
             util::node_info(n) + std::string("_Max"));
-      TORCHTRT_CHECK(max_layer, "Unable to create max layer from node: " << *n);
-      auto out_tensor = ctx->AssociateValueAndTensor(n->outputs()[0], max_layer->getOutput(0));
-      LOG_DEBUG("Output tensor shape: " << out_tensor->getDimensions());
-      return true;
-    }
-  }});
+         TORCHTRT_CHECK(max_layer, "Unable to create max layer from node: " << *n);
+         auto out_tensor = ctx->AssociateValueAndTensor(n->outputs()[0], max_layer->getOutput(0));
+         LOG_DEBUG("Output tensor shape: " << out_tensor->getDimensions());
+         return true;
+       }
+     }});

#define convert(unary, trt_type)                                                               \
  auto unary##_registrations TORCHTRT_UNUSED = RegisterNodeConversionPatterns().pattern(       \
diff --git a/workspace/tests/core/conversion/converters/test_element_wise.cpp b/tmp/changes.txt
index 939c9b7..db60896 100644
--- a/workspace/tests/core/conversion/converters/test_element_wise.cpp
+++ b/tmp/changes.txt
@@ -30,14 +30,15 @@ void pointwise_test_helper(
    torch_inputs.push_back(at::randint(1, 5, shape2, {at::kCUDA}));
  }

-  TORCHTRT_CHECK(!((int_tensors && (float_int_tensors || int_float_tensors)) || (float_int_tensors && int_float_tensors)),
-    "Invalid test configuration, only one of int_tensors, float_int_tensors, int_float_tensors can be true");
+  TORCHTRT_CHECK(
+      !((int_tensors && (float_int_tensors || int_float_tensors)) || (float_int_tensors && int_float_tensors)),
+      "Invalid test configuration, only one of int_tensors, float_int_tensors, int_float_tensors can be true");

-  if(int_tensors){
-    for(size_t i = 0UL; i < torch_inputs.size(); ++i){
+  if (int_tensors) {
+    for (size_t i = 0UL; i < torch_inputs.size(); ++i) {
      torch_inputs[i] = torch_inputs[i].to(at::kInt);
    }
-  } else if(float_int_tensors) {
+  } else if (float_int_tensors) {
    TORCHTRT_CHECK(!singleInput, "float_int_tensors tests require two inputs");
    torch_inputs[0] = torch_inputs[0].to(at::kFloat);
    torch_inputs[1] = torch_inputs[1].to(at::kInt);
diff --git a/workspace/tests/core/conversion/converters/test_unary.cpp b/tmp/changes.txt
index a7ab3bb..1d40c3c 100644
--- a/workspace/tests/core/conversion/converters/test_unary.cpp
+++ b/tmp/changes.txt
@@ -1,9 +1,9 @@
#include <string>
-#include "torch/torch.h"
#include "core/compiler.h"
#include "gtest/gtest.h"
#include "tests/util/util.h"
#include "torch/csrc/jit/ir/irparser.h"
+#include "torch/torch.h"

namespace {
std::string gen_test_graph(const std::string& unary) {
@@ -22,7 +22,7 @@ TEST(Converters, ATenAbsIntConvertsCorrectly) {

  auto in = at::tensor({-1, 1, -2, 2, -3, 3}, {at::kCUDA}).to(torch::kInt32);
  auto params = torch_tensorrt::core::ir::get_static_params(g->inputs(), {});
-  auto jit_results = torch_tensorrt::tests::util::RunGraph(g, params, {in});  
+  auto jit_results = torch_tensorrt::tests::util::RunGraph(g, params, {in});

  in = at::clone(in);
  params = torch_tensorrt::core::ir::get_static_params(g->inputs(), {});
diff --git a/workspace/tests/core/conversion/converters/test_select.cpp b/tmp/changes.txt
index 03b6bda..67b760a 100644
--- a/workspace/tests/core/conversion/converters/test_select.cpp
+++ b/tmp/changes.txt
@@ -376,7 +376,7 @@ TEST(Converters, ATenSliceListConvertsCorrectly) {
          %slice : Tensor[] = aten::slice(%list, %1, %2, %3)
          %out.1 : Tensor, %out.2 : Tensor = prim::ListUnpack(%slice)
          return (%out.1, %out.2))IR";
-  
+
  auto g = std::make_shared<torch::jit::Graph>();

  torch::jit::parseIR(graph, g.get());
diff --git a/workspace/tests/cpp/test_collections.cpp b/tmp/changes.txt
index 31495a4..d01665a 100644
--- a/workspace/tests/cpp/test_collections.cpp
+++ b/tmp/changes.txt
@@ -135,7 +135,7 @@ TEST(CppAPITests, TestCollectionListInput) {

  auto compile_settings = torch_tensorrt::ts::CompileSpec(complex_input_shape2);
  compile_settings.min_block_size = 1;
-  //compile_settings.torch_executed_ops.push_back("aten::__getitem__");
+  // compile_settings.torch_executed_ops.push_back("aten::__getitem__");

  // // FP16 execution
  compile_settings.enabled_precisions = {torch::kHalf};
diff --git a/workspace/cpp/src/compile_spec.cpp b/tmp/changes.txt
index 8c7bb8b..cfbc228 100644
--- a/workspace/cpp/src/compile_spec.cpp
+++ b/tmp/changes.txt
@@ -69,22 +69,24 @@ torchtrt::core::CompileSpec init_compile_spec(CompileSpec& external) {
    return internal;
  } else {
    torch::jit::IValue converted_input_signature;
-    LOG_WARNING( "Input signature parsing is an experimental feature, behavior and APIs may change");
+    LOG_WARNING("Input signature parsing is an experimental feature, behavior and APIs may change");
    to_internal_input_signature(external.graph_inputs.input_signature, converted_input_signature);
    torchtrt::core::CompileSpec internal(converted_input_signature);

-    TORCHTRT_CHECK(!external.require_full_compilation, \
-      "Grouped inputs currently requires partial compilation to be enabled, \
+    TORCHTRT_CHECK(
+        !external.require_full_compilation,
+        "Grouped inputs currently requires partial compilation to be enabled, \
      this restriction will be relaxed in a future release");

    LOG_DEBUG("Grouped inputs currently requires additional settings to enable the feature");
-    LOG_DEBUG("Adding the following ops to torch_executed_ops:" \
-       << std::endl << "  - aten::__getitem__" \
-       << std::endl << "  - prim::ListConstruct" \
-       << std::endl << "  - prim::ListUnpack" \
-       << std::endl << "  - prim::TupleIndex" \
-       << std::endl << "  - prim::TupleConstruct" \
-       << std::endl << "  - prim::TupleUnpack");
+    LOG_DEBUG(
+        "Adding the following ops to torch_executed_ops:" << std::endl
+                                                          << "  - aten::__getitem__" << std::endl
+                                                          << "  - prim::ListConstruct" << std::endl
+                                                          << "  - prim::ListUnpack" << std::endl
+                                                          << "  - prim::TupleIndex" << std::endl
+                                                          << "  - prim::TupleConstruct" << std::endl
+                                                          << "  - prim::TupleUnpack");
    external.torch_executed_ops.push_back("aten::__getitem__");
    external.torch_executed_ops.push_back("prim::ListConstruct");
    external.torch_executed_ops.push_back("prim::ListUnpack");
ERROR: Some files do not conform to style guidelines

@andi4191 andi4191 force-pushed the anuragd/tweak_circleci_for_jetpack branch from 3502546 to 7fd15f8 Compare August 9, 2022 18:27
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/workspace/py/torch_tensorrt/csrc/register_tensorrt_classes.cpp b/tmp/changes.txt
index 9db567c..ba07250 100644
--- a/workspace/py/torch_tensorrt/csrc/register_tensorrt_classes.cpp
+++ b/tmp/changes.txt
@@ -26,11 +26,11 @@ void RegisterTRTCompileSpec() {
  static auto TORCHTRT_UNUSED TRTInputSignatureTSRegistration =
      torch::class_<torch_tensorrt::pyapi::InputSignature>("tensorrt", "_InputSignature")
          .def(torch::init<>())
-          .def("_set_signature_ivalue_torchbind",
-                [](const c10::intrusive_ptr<torch_tensorrt::pyapi::InputSignature>& self,
-                  torch::jit::IValue ival) {
-                    self->signature_ivalue = ival;
-                })
+          .def(
+              "_set_signature_ivalue_torchbind",
+              [](const c10::intrusive_ptr<torch_tensorrt::pyapi::InputSignature>& self, torch::jit::IValue ival) {
+                self->signature_ivalue = ival;
+              })
          .def("__str__", &torch_tensorrt::pyapi::InputSignature::to_str);

  ADD_FIELD_GET_SET_REGISTRATION(
diff --git a/workspace/core/conversion/evaluators/aten.cpp b/tmp/changes.txt
index ca9ff4d..aa58dc7 100644
--- a/workspace/core/conversion/evaluators/aten.cpp
+++ b/tmp/changes.txt
@@ -176,7 +176,7 @@ auto aten_registrations TORCHTRT_UNUSED =

                      int64_t start = 0;
                      auto startIVal = args.at(n->input(1)).IValue();
-                      if(!startIVal->isNone()){
+                      if (!startIVal->isNone()) {
                        start = args.at(n->input(1)).unwrapToInt();
                      }
                      int64_t end = args.at(n->input(2)).unwrapToInt();
diff --git a/workspace/core/conversion/evaluators/eval_util.cpp b/tmp/changes.txt
index 742a4f4..c14f9a6 100644
--- a/workspace/core/conversion/evaluators/eval_util.cpp
+++ b/tmp/changes.txt
@@ -20,7 +20,6 @@ int64_t normalizeIndex(int64_t idx, int64_t list_size) {
  return idx;
}

-
// TODO: Switch back to PyTorch canonical implimentation
c10::optional<torch::jit::IValue> toIValue(const torch::jit::Value* v) {
  if (v->node()->kind() != torch::jit::prim::Constant || v->type()->cast<c10::FunctionType>()) {
diff --git a/workspace/core/conversion/evaluators/prim.cpp b/tmp/changes.txt
index 338c427..244c3e8 100644
--- a/workspace/core/conversion/evaluators/prim.cpp
+++ b/tmp/changes.txt
@@ -260,40 +260,39 @@ auto prim_registrations =
                    },
                    EvalOptions().validSchemas({"prim::shape(Tensor a) -> (int[])"})})
        .evaluator({torch::jit::prim::TupleConstruct,
-                  [](const torch::jit::Node* n, kwargs& args) -> c10::optional<torch::jit::IValue> {
-                    auto num_inputs = n->inputs().size();
-                    c10::IValue tuple = c10::ivalue::Tuple::create();
-                    switch (num_inputs) {
-                      case 0:
-                        tuple = c10::ivalue::Tuple::create();
-                        break;
-                      case 1:
-                        tuple = c10::ivalue::Tuple::create(std::move((*args.at(n->input(0)).IValue())));
-                        break;
-                      case 2: {
-                        tuple = c10::ivalue::Tuple::create(
-                            std::move(*(args.at(n->input(0)).IValue())),
-                            std::move(*(args.at(n->input(1)).IValue())));
-                        break;
-                      }
-                      case 3: {
-                        tuple = c10::ivalue::Tuple::create(
-                            std::move(*(args.at(n->input(0)).IValue())),
-                            std::move(*(args.at(n->input(1)).IValue())),
-                            std::move(*(args.at(n->input(2)).IValue())));
-                        break;
-                      }
-                      default: {
-                        std::vector<c10::IValue> elems;
-                        for (size_t i = 0; i < num_inputs; i++) {
-                          elems.push_back(*(args.at(n->input(i)).IValue()));
+                    [](const torch::jit::Node* n, kwargs& args) -> c10::optional<torch::jit::IValue> {
+                      auto num_inputs = n->inputs().size();
+                      c10::IValue tuple = c10::ivalue::Tuple::create();
+                      switch (num_inputs) {
+                        case 0:
+                          tuple = c10::ivalue::Tuple::create();
+                          break;
+                        case 1:
+                          tuple = c10::ivalue::Tuple::create(std::move((*args.at(n->input(0)).IValue())));
+                          break;
+                        case 2: {
+                          tuple = c10::ivalue::Tuple::create(
+                              std::move(*(args.at(n->input(0)).IValue())), std::move(*(args.at(n->input(1)).IValue())));
+                          break;
+                        }
+                        case 3: {
+                          tuple = c10::ivalue::Tuple::create(
+                              std::move(*(args.at(n->input(0)).IValue())),
+                              std::move(*(args.at(n->input(1)).IValue())),
+                              std::move(*(args.at(n->input(2)).IValue())));
+                          break;
+                        }
+                        default: {
+                          std::vector<c10::IValue> elems;
+                          for (size_t i = 0; i < num_inputs; i++) {
+                            elems.push_back(*(args.at(n->input(i)).IValue()));
+                          }
+                          tuple = c10::ivalue::Tuple::create(std::move(elems));
+                          break;
                        }
-                        tuple = c10::ivalue::Tuple::create(std::move(elems));
-                        break;
                      }
-                    }
-                    return c10::optional<torch::jit::IValue>(std::move(tuple));
-                  }})
+                      return c10::optional<torch::jit::IValue>(std::move(tuple));
+                    }})
        .evaluator({torch::jit::prim::TupleIndex,
                    [](const torch::jit::Node* n, kwargs& args) -> c10::optional<torch::jit::IValue> {
                      // Outputs is an IValue which has list of tensors which can be found in ctx->evaluated_value_map
diff --git a/workspace/core/conversion/converters/impl/unary.cpp b/tmp/changes.txt
index a1d03a3..6b0ee2b 100644
--- a/workspace/core/conversion/converters/impl/unary.cpp
+++ b/tmp/changes.txt
@@ -10,45 +10,41 @@ namespace converters {
namespace impl {
namespace {

-
auto abs_registration TORCHTRT_UNUSED = RegisterNodeConversionPatterns().pattern(
-  {"aten::abs (Tensor self) -> Tensor",
-  [](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
-    auto in = args[0].ITensor();
-    bool unary_supported_input = in->getType() == nvinfer1::DataType::kFLOAT
-     || in->getType() == nvinfer1::DataType::kHALF
-     || in->getType() == nvinfer1::DataType::kINT8;
-    if(unary_supported_input){
-      auto unary_layer = ctx->net->addUnary(*in, nvinfer1::UnaryOperation::kABS);
-      TORCHTRT_CHECK(unary_layer, "Unable to create abs layer from node: " << *n);
-      unary_layer->setName(util::node_info(n).c_str());
-      auto out_tensor = ctx->AssociateValueAndTensor(n->outputs()[0], unary_layer->getOutput(0));
-      LOG_DEBUG("Output tensor shape: " << out_tensor->getDimensions());
-      return true;
-    }
-    else{
-      //For types not supported by kABS, use an elementwise implementation abs(x) = max(x, -1 * x)
-      at::Tensor neg_one = torch::full({1}, -1).to(util::TRTDataTypeToScalarType(in->getType()));
-      auto neg_one_const = tensor_to_const(ctx, neg_one);
-      auto neg_layer = add_elementwise(
+    {"aten::abs (Tensor self) -> Tensor", [](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
+       auto in = args[0].ITensor();
+       bool unary_supported_input = in->getType() == nvinfer1::DataType::kFLOAT ||
+           in->getType() == nvinfer1::DataType::kHALF || in->getType() == nvinfer1::DataType::kINT8;
+       if (unary_supported_input) {
+         auto unary_layer = ctx->net->addUnary(*in, nvinfer1::UnaryOperation::kABS);
+         TORCHTRT_CHECK(unary_layer, "Unable to create abs layer from node: " << *n);
+         unary_layer->setName(util::node_info(n).c_str());
+         auto out_tensor = ctx->AssociateValueAndTensor(n->outputs()[0], unary_layer->getOutput(0));
+         LOG_DEBUG("Output tensor shape: " << out_tensor->getDimensions());
+         return true;
+       } else {
+         // For types not supported by kABS, use an elementwise implementation abs(x) = max(x, -1 * x)
+         at::Tensor neg_one = torch::full({1}, -1).to(util::TRTDataTypeToScalarType(in->getType()));
+         auto neg_one_const = tensor_to_const(ctx, neg_one);
+         auto neg_layer = add_elementwise(
             ctx,
             nvinfer1::ElementWiseOperation::kPROD,
             in,
             neg_one_const,
             util::node_info(n) + std::string("_Negation"));
-      TORCHTRT_CHECK(neg_layer, "Unable to create prod layer from node: " << *n);
-      auto max_layer = add_elementwise(
+         TORCHTRT_CHECK(neg_layer, "Unable to create prod layer from node: " << *n);
+         auto max_layer = add_elementwise(
             ctx,
             nvinfer1::ElementWiseOperation::kMAX,
             in,
             neg_layer->getOutput(0),
             util::node_info(n) + std::string("_Max"));
-      TORCHTRT_CHECK(max_layer, "Unable to create max layer from node: " << *n);
-      auto out_tensor = ctx->AssociateValueAndTensor(n->outputs()[0], max_layer->getOutput(0));
-      LOG_DEBUG("Output tensor shape: " << out_tensor->getDimensions());
-      return true;
-    }
-  }});
+         TORCHTRT_CHECK(max_layer, "Unable to create max layer from node: " << *n);
+         auto out_tensor = ctx->AssociateValueAndTensor(n->outputs()[0], max_layer->getOutput(0));
+         LOG_DEBUG("Output tensor shape: " << out_tensor->getDimensions());
+         return true;
+       }
+     }});

#define convert(unary, trt_type)                                                               \
  auto unary##_registrations TORCHTRT_UNUSED = RegisterNodeConversionPatterns().pattern(       \
diff --git a/workspace/tests/core/conversion/converters/test_element_wise.cpp b/tmp/changes.txt
index 939c9b7..db60896 100644
--- a/workspace/tests/core/conversion/converters/test_element_wise.cpp
+++ b/tmp/changes.txt
@@ -30,14 +30,15 @@ void pointwise_test_helper(
    torch_inputs.push_back(at::randint(1, 5, shape2, {at::kCUDA}));
  }

-  TORCHTRT_CHECK(!((int_tensors && (float_int_tensors || int_float_tensors)) || (float_int_tensors && int_float_tensors)),
-    "Invalid test configuration, only one of int_tensors, float_int_tensors, int_float_tensors can be true");
+  TORCHTRT_CHECK(
+      !((int_tensors && (float_int_tensors || int_float_tensors)) || (float_int_tensors && int_float_tensors)),
+      "Invalid test configuration, only one of int_tensors, float_int_tensors, int_float_tensors can be true");

-  if(int_tensors){
-    for(size_t i = 0UL; i < torch_inputs.size(); ++i){
+  if (int_tensors) {
+    for (size_t i = 0UL; i < torch_inputs.size(); ++i) {
      torch_inputs[i] = torch_inputs[i].to(at::kInt);
    }
-  } else if(float_int_tensors) {
+  } else if (float_int_tensors) {
    TORCHTRT_CHECK(!singleInput, "float_int_tensors tests require two inputs");
    torch_inputs[0] = torch_inputs[0].to(at::kFloat);
    torch_inputs[1] = torch_inputs[1].to(at::kInt);
diff --git a/workspace/tests/core/conversion/converters/test_unary.cpp b/tmp/changes.txt
index a7ab3bb..1d40c3c 100644
--- a/workspace/tests/core/conversion/converters/test_unary.cpp
+++ b/tmp/changes.txt
@@ -1,9 +1,9 @@
#include <string>
-#include "torch/torch.h"
#include "core/compiler.h"
#include "gtest/gtest.h"
#include "tests/util/util.h"
#include "torch/csrc/jit/ir/irparser.h"
+#include "torch/torch.h"

namespace {
std::string gen_test_graph(const std::string& unary) {
@@ -22,7 +22,7 @@ TEST(Converters, ATenAbsIntConvertsCorrectly) {

  auto in = at::tensor({-1, 1, -2, 2, -3, 3}, {at::kCUDA}).to(torch::kInt32);
  auto params = torch_tensorrt::core::ir::get_static_params(g->inputs(), {});
-  auto jit_results = torch_tensorrt::tests::util::RunGraph(g, params, {in});  
+  auto jit_results = torch_tensorrt::tests::util::RunGraph(g, params, {in});

  in = at::clone(in);
  params = torch_tensorrt::core::ir::get_static_params(g->inputs(), {});
diff --git a/workspace/tests/core/conversion/converters/test_select.cpp b/tmp/changes.txt
index 03b6bda..67b760a 100644
--- a/workspace/tests/core/conversion/converters/test_select.cpp
+++ b/tmp/changes.txt
@@ -376,7 +376,7 @@ TEST(Converters, ATenSliceListConvertsCorrectly) {
          %slice : Tensor[] = aten::slice(%list, %1, %2, %3)
          %out.1 : Tensor, %out.2 : Tensor = prim::ListUnpack(%slice)
          return (%out.1, %out.2))IR";
-  
+
  auto g = std::make_shared<torch::jit::Graph>();

  torch::jit::parseIR(graph, g.get());
diff --git a/workspace/tests/cpp/test_collections.cpp b/tmp/changes.txt
index 31495a4..d01665a 100644
--- a/workspace/tests/cpp/test_collections.cpp
+++ b/tmp/changes.txt
@@ -135,7 +135,7 @@ TEST(CppAPITests, TestCollectionListInput) {

  auto compile_settings = torch_tensorrt::ts::CompileSpec(complex_input_shape2);
  compile_settings.min_block_size = 1;
-  //compile_settings.torch_executed_ops.push_back("aten::__getitem__");
+  // compile_settings.torch_executed_ops.push_back("aten::__getitem__");

  // // FP16 execution
  compile_settings.enabled_precisions = {torch::kHalf};
diff --git a/workspace/cpp/src/compile_spec.cpp b/tmp/changes.txt
index 8c7bb8b..cfbc228 100644
--- a/workspace/cpp/src/compile_spec.cpp
+++ b/tmp/changes.txt
@@ -69,22 +69,24 @@ torchtrt::core::CompileSpec init_compile_spec(CompileSpec& external) {
    return internal;
  } else {
    torch::jit::IValue converted_input_signature;
-    LOG_WARNING( "Input signature parsing is an experimental feature, behavior and APIs may change");
+    LOG_WARNING("Input signature parsing is an experimental feature, behavior and APIs may change");
    to_internal_input_signature(external.graph_inputs.input_signature, converted_input_signature);
    torchtrt::core::CompileSpec internal(converted_input_signature);

-    TORCHTRT_CHECK(!external.require_full_compilation, \
-      "Grouped inputs currently requires partial compilation to be enabled, \
+    TORCHTRT_CHECK(
+        !external.require_full_compilation,
+        "Grouped inputs currently requires partial compilation to be enabled, \
      this restriction will be relaxed in a future release");

    LOG_DEBUG("Grouped inputs currently requires additional settings to enable the feature");
-    LOG_DEBUG("Adding the following ops to torch_executed_ops:" \
-       << std::endl << "  - aten::__getitem__" \
-       << std::endl << "  - prim::ListConstruct" \
-       << std::endl << "  - prim::ListUnpack" \
-       << std::endl << "  - prim::TupleIndex" \
-       << std::endl << "  - prim::TupleConstruct" \
-       << std::endl << "  - prim::TupleUnpack");
+    LOG_DEBUG(
+        "Adding the following ops to torch_executed_ops:" << std::endl
+                                                          << "  - aten::__getitem__" << std::endl
+                                                          << "  - prim::ListConstruct" << std::endl
+                                                          << "  - prim::ListUnpack" << std::endl
+                                                          << "  - prim::TupleIndex" << std::endl
+                                                          << "  - prim::TupleConstruct" << std::endl
+                                                          << "  - prim::TupleUnpack");
    external.torch_executed_ops.push_back("aten::__getitem__");
    external.torch_executed_ops.push_back("prim::ListConstruct");
    external.torch_executed_ops.push_back("prim::ListUnpack");
ERROR: Some files do not conform to style guidelines

Signed-off-by: Anurag Dixit <a.dixit91@gmail.com>
@andi4191 andi4191 force-pushed the anuragd/tweak_circleci_for_jetpack branch from 7fd15f8 to cba613a Compare August 9, 2022 21:27
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

@github-actions
Copy link

github-actions bot commented Nov 9, 2022

This PR has not seen activity for 90 days, Remove stale label or comment or this will be closed in 10 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
channel: linux-sbsa cla signed No Activity WIP Work is in progress, pull request should not be merged yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants