-
Notifications
You must be signed in to change notification settings - Fork 363
Add support for aten::squeeze, aten::unsqueeze #301
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
Conversation
Signed-off-by: inocsin <[email protected]>
f0a05d1
to
81e0cfa
Compare
unsqueeze ops Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code conforms to Python style guidelines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code conforms to Python style guidelines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
81e0cfa
to
9e0a1d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code conforms to Python style guidelines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code conforms to Python style guidelines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code conforms to Python style guidelines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code conforms to C++ style guidelines
Description
Adds
aten::squeeze
andaten::unsqueeze
to the compilerType of change
Please delete options that are not relevant and/or add your own.
Checklist: