Skip to content

Conversation

narendasan
Copy link
Collaborator

Description

Adds aten::squeeze and aten::unsqueeze to the compiler

Type of change

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

  • New feature (non-breaking change which adds functionality)

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

Signed-off-by: inocsin <vcheungyi@163.com>
@github-actions github-actions bot added component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: core Issues re: The core compiler component: tests Issues re: Tests labels Jan 29, 2021
unsqueeze ops

Signed-off-by: Naren Dasan <naren@narendasan.com>
Signed-off-by: Naren Dasan <narens@nvidia.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/workspace/core/util/trt_util.cpp b/tmp/changes.txt
index 6a510e7..de34c9a 100644
--- a/workspace/core/util/trt_util.cpp
+++ b/tmp/changes.txt
@@ -204,11 +204,9 @@ nvinfer1::Dims squeezeDims(const nvinfer1::Dims& d, int pos) {
      if (i <= d.nbDims) {
        dims.d[j] = d.d[i];
      }
-      
    }
    i++;
    j++;
-    
  }

  dims.nbDims = d.nbDims - 1;
diff --git a/workspace/core/conversion/converters/impl/squeeze.cpp b/tmp/changes.txt
index 2471cb8..f91e471 100644
--- a/workspace/core/conversion/converters/impl/squeeze.cpp
+++ b/tmp/changes.txt
@@ -22,7 +22,7 @@ auto squeeze_registrations TRTORCH_UNUSED = RegisterNodeConversionPatterns().pat

       auto selfDim = util::toVec(self->getDimensions());
       if (dim < 0) {
-           dim = selfDim.size() + dim;
+         dim = selfDim.size() + dim;
       }

       auto shuffle_layer = ctx->net->addShuffle(*self);
diff --git a/workspace/core/conversion/converters/impl/unsqueeze.cpp b/tmp/changes.txt
index 1c2e6cf..d5239db 100644
--- a/workspace/core/conversion/converters/impl/unsqueeze.cpp
+++ b/tmp/changes.txt
@@ -22,7 +22,7 @@ auto unsqueeze_registrations TRTORCH_UNUSED = RegisterNodeConversionPatterns().p

       auto selfDim = util::toVec(self->getDimensions());
       if (dim < 0) {
-           dim = selfDim.size() + dim;
+         dim = selfDim.size() + dim;
       }

       auto shuffle_layer = ctx->net->addShuffle(*self);
diff --git a/workspace/tests/core/conversion/converters/test_squeeze.cpp b/tmp/changes.txt
index 6441e47..b271672 100644
--- a/workspace/tests/core/conversion/converters/test_squeeze.cpp
+++ b/tmp/changes.txt
@@ -4,8 +4,6 @@
#include "tests/util/util.h"
#include "torch/csrc/jit/ir/irparser.h"

-
-
TEST(Converters, ATenSqueezeConvertsCorrectly) {
  const auto graph = R"IR(
      graph(%0 : Tensor):
diff --git a/workspace/tests/core/conversion/converters/test_unsqueeze.cpp b/tmp/changes.txt
index 2027000..f92eb4f 100644
--- a/workspace/tests/core/conversion/converters/test_unsqueeze.cpp
+++ b/tmp/changes.txt
@@ -4,8 +4,6 @@
#include "tests/util/util.h"
#include "torch/csrc/jit/ir/irparser.h"

-
-
TEST(Converters, ATenUnsqueezeConvertsCorrectly) {
  const auto graph = R"IR(
      graph(%0 : Tensor):
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

@narendasan narendasan requested a review from peri044 January 29, 2021 03:11
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.

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

diff --git a/workspace/core/util/trt_util.cpp b/tmp/changes.txt
index 6a510e7..de34c9a 100644
--- a/workspace/core/util/trt_util.cpp
+++ b/tmp/changes.txt
@@ -204,11 +204,9 @@ nvinfer1::Dims squeezeDims(const nvinfer1::Dims& d, int pos) {
      if (i <= d.nbDims) {
        dims.d[j] = d.d[i];
      }
-      
    }
    i++;
    j++;
-    
  }

  dims.nbDims = d.nbDims - 1;
diff --git a/workspace/core/conversion/converters/impl/squeeze.cpp b/tmp/changes.txt
index 2471cb8..f91e471 100644
--- a/workspace/core/conversion/converters/impl/squeeze.cpp
+++ b/tmp/changes.txt
@@ -22,7 +22,7 @@ auto squeeze_registrations TRTORCH_UNUSED = RegisterNodeConversionPatterns().pat

       auto selfDim = util::toVec(self->getDimensions());
       if (dim < 0) {
-           dim = selfDim.size() + dim;
+         dim = selfDim.size() + dim;
       }

       auto shuffle_layer = ctx->net->addShuffle(*self);
diff --git a/workspace/core/conversion/converters/impl/unsqueeze.cpp b/tmp/changes.txt
index 1c2e6cf..d5239db 100644
--- a/workspace/core/conversion/converters/impl/unsqueeze.cpp
+++ b/tmp/changes.txt
@@ -22,7 +22,7 @@ auto unsqueeze_registrations TRTORCH_UNUSED = RegisterNodeConversionPatterns().p

       auto selfDim = util::toVec(self->getDimensions());
       if (dim < 0) {
-           dim = selfDim.size() + dim;
+         dim = selfDim.size() + dim;
       }

       auto shuffle_layer = ctx->net->addShuffle(*self);
diff --git a/workspace/tests/core/conversion/converters/test_squeeze.cpp b/tmp/changes.txt
index 6441e47..b271672 100644
--- a/workspace/tests/core/conversion/converters/test_squeeze.cpp
+++ b/tmp/changes.txt
@@ -4,8 +4,6 @@
#include "tests/util/util.h"
#include "torch/csrc/jit/ir/irparser.h"

-
-
TEST(Converters, ATenSqueezeConvertsCorrectly) {
  const auto graph = R"IR(
      graph(%0 : Tensor):
diff --git a/workspace/tests/core/conversion/converters/test_unsqueeze.cpp b/tmp/changes.txt
index 2027000..f92eb4f 100644
--- a/workspace/tests/core/conversion/converters/test_unsqueeze.cpp
+++ b/tmp/changes.txt
@@ -4,8 +4,6 @@
#include "tests/util/util.h"
#include "torch/csrc/jit/ir/irparser.h"

-
-
TEST(Converters, ATenUnsqueezeConvertsCorrectly) {
  const auto graph = R"IR(
      graph(%0 : Tensor):
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/core/util/trt_util.cpp b/tmp/changes.txt
index 6a510e7..de34c9a 100644
--- a/workspace/core/util/trt_util.cpp
+++ b/tmp/changes.txt
@@ -204,11 +204,9 @@ nvinfer1::Dims squeezeDims(const nvinfer1::Dims& d, int pos) {
      if (i <= d.nbDims) {
        dims.d[j] = d.d[i];
      }
-      
    }
    i++;
    j++;
-    
  }

  dims.nbDims = d.nbDims - 1;
diff --git a/workspace/core/conversion/converters/impl/squeeze.cpp b/tmp/changes.txt
index 2471cb8..f91e471 100644
--- a/workspace/core/conversion/converters/impl/squeeze.cpp
+++ b/tmp/changes.txt
@@ -22,7 +22,7 @@ auto squeeze_registrations TRTORCH_UNUSED = RegisterNodeConversionPatterns().pat

       auto selfDim = util::toVec(self->getDimensions());
       if (dim < 0) {
-           dim = selfDim.size() + dim;
+         dim = selfDim.size() + dim;
       }

       auto shuffle_layer = ctx->net->addShuffle(*self);
diff --git a/workspace/core/conversion/converters/impl/unsqueeze.cpp b/tmp/changes.txt
index 1c2e6cf..d5239db 100644
--- a/workspace/core/conversion/converters/impl/unsqueeze.cpp
+++ b/tmp/changes.txt
@@ -22,7 +22,7 @@ auto unsqueeze_registrations TRTORCH_UNUSED = RegisterNodeConversionPatterns().p

       auto selfDim = util::toVec(self->getDimensions());
       if (dim < 0) {
-           dim = selfDim.size() + dim;
+         dim = selfDim.size() + dim;
       }

       auto shuffle_layer = ctx->net->addShuffle(*self);
diff --git a/workspace/tests/core/conversion/converters/test_squeeze.cpp b/tmp/changes.txt
index 6441e47..b271672 100644
--- a/workspace/tests/core/conversion/converters/test_squeeze.cpp
+++ b/tmp/changes.txt
@@ -4,8 +4,6 @@
#include "tests/util/util.h"
#include "torch/csrc/jit/ir/irparser.h"

-
-
TEST(Converters, ATenSqueezeConvertsCorrectly) {
  const auto graph = R"IR(
      graph(%0 : Tensor):
diff --git a/workspace/tests/core/conversion/converters/test_unsqueeze.cpp b/tmp/changes.txt
index 2027000..f92eb4f 100644
--- a/workspace/tests/core/conversion/converters/test_unsqueeze.cpp
+++ b/tmp/changes.txt
@@ -4,8 +4,6 @@
#include "tests/util/util.h"
#include "torch/csrc/jit/ir/irparser.h"

-
-
TEST(Converters, ATenUnsqueezeConvertsCorrectly) {
  const auto graph = R"IR(
      graph(%0 : Tensor):
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

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.

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

diff --git a/workspace/core/util/trt_util.cpp b/tmp/changes.txt
index 6a510e7..de34c9a 100644
--- a/workspace/core/util/trt_util.cpp
+++ b/tmp/changes.txt
@@ -204,11 +204,9 @@ nvinfer1::Dims squeezeDims(const nvinfer1::Dims& d, int pos) {
      if (i <= d.nbDims) {
        dims.d[j] = d.d[i];
      }
-      
    }
    i++;
    j++;
-    
  }

  dims.nbDims = d.nbDims - 1;
diff --git a/workspace/core/conversion/converters/impl/squeeze.cpp b/tmp/changes.txt
index 2471cb8..f91e471 100644
--- a/workspace/core/conversion/converters/impl/squeeze.cpp
+++ b/tmp/changes.txt
@@ -22,7 +22,7 @@ auto squeeze_registrations TRTORCH_UNUSED = RegisterNodeConversionPatterns().pat

       auto selfDim = util::toVec(self->getDimensions());
       if (dim < 0) {
-           dim = selfDim.size() + dim;
+         dim = selfDim.size() + dim;
       }

       auto shuffle_layer = ctx->net->addShuffle(*self);
diff --git a/workspace/core/conversion/converters/impl/unsqueeze.cpp b/tmp/changes.txt
index 1c2e6cf..d5239db 100644
--- a/workspace/core/conversion/converters/impl/unsqueeze.cpp
+++ b/tmp/changes.txt
@@ -22,7 +22,7 @@ auto unsqueeze_registrations TRTORCH_UNUSED = RegisterNodeConversionPatterns().p

       auto selfDim = util::toVec(self->getDimensions());
       if (dim < 0) {
-           dim = selfDim.size() + dim;
+         dim = selfDim.size() + dim;
       }

       auto shuffle_layer = ctx->net->addShuffle(*self);
diff --git a/workspace/tests/core/conversion/converters/test_squeeze.cpp b/tmp/changes.txt
index 6441e47..b271672 100644
--- a/workspace/tests/core/conversion/converters/test_squeeze.cpp
+++ b/tmp/changes.txt
@@ -4,8 +4,6 @@
#include "tests/util/util.h"
#include "torch/csrc/jit/ir/irparser.h"

-
-
TEST(Converters, ATenSqueezeConvertsCorrectly) {
  const auto graph = R"IR(
      graph(%0 : Tensor):
diff --git a/workspace/tests/core/conversion/converters/test_unsqueeze.cpp b/tmp/changes.txt
index 2027000..f92eb4f 100644
--- a/workspace/tests/core/conversion/converters/test_unsqueeze.cpp
+++ b/tmp/changes.txt
@@ -4,8 +4,6 @@
#include "tests/util/util.h"
#include "torch/csrc/jit/ir/irparser.h"

-
-
TEST(Converters, ATenUnsqueezeConvertsCorrectly) {
  const auto graph = R"IR(
      graph(%0 : Tensor):
ERROR: Some files do not conform to style guidelines

Signed-off-by: Naren Dasan <naren@narendasan.com>
Signed-off-by: Naren Dasan <narens@nvidia.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.

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

@narendasan narendasan merged commit 05652b8 into master Feb 1, 2021
@narendasan narendasan deleted the squeeze_unsqueeze branch February 1, 2021 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: core Issues re: The core compiler component: tests Issues re: Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants