Skip to content

Commit af5d28e

Browse files
committed
fix(//tests): Add stride to complete tensors
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
1 parent 378690b commit af5d28e

File tree

6 files changed

+35
-32
lines changed

6 files changed

+35
-32
lines changed

Diff for: tests/core/converters/test_batch_norm.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
TEST(Converters, ATenBatchNormConvertsCorrectly) {
88
const auto graph = R"IR(
99
graph(%0 : Tensor,
10-
%1: Float(5),
11-
%2: Float(5),
12-
%3: Float(5),
13-
%4: Float(5)):
10+
%1: Float(5:1),
11+
%2: Float(5:1),
12+
%3: Float(5:1),
13+
%4: Float(5:1)):
1414
%5 : bool = prim::Constant[value=0]()
1515
%6 : float = prim::Constant[value=1.0000000000000001e-05]()
1616
%7 : float = prim::Constant[value=0.10000000000000001]()

Diff for: tests/core/converters/test_concat.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ TEST(Converters, ATenCatPureTensorConvertsCorrectly) {
3131
TEST(Converters, ATenCatDiffTensorConvertsCorrectly) {
3232
const auto graph = R"IR(
3333
graph(%0 : Tensor,
34-
%1 : Float(5)):
34+
%1 : Float(5:1)):
3535
%2 : Tensor[] = prim::ListConstruct(%0, %1)
3636
%3 : int = prim::Constant[value=0]()
3737
%4 : Tensor = aten::cat(%2, %3)

Diff for: tests/core/converters/test_conv_deconv.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ void conv_test_helper(std::string graph_ir) {
3939
TEST(Converters, ATenConvolutionConvertsCorrectly) {
4040
const auto graph = R"IR(
4141
graph(%0 : Tensor,
42-
%1 : Float(8, 3, 5, 5),
43-
%2 : Float(8)):
42+
%1 : Float(8:45, 3:15, 5:5, 5:1),
43+
%2 : Float(8:1)):
4444
%3 : int = prim::Constant[value=1]()
4545
%4 : int = prim::Constant[value=0]()
4646
%5 : int = prim::Constant[value=1]()
@@ -81,7 +81,7 @@ TEST(Converters, ATenConvolutionConvertsCorrectly) {
8181
TEST(Converters, ATenConvolutionNoBiasConvertsCorrectly) {
8282
const auto graph = R"IR(
8383
graph(%0 : Tensor,
84-
%1 : Float(4, 1, 3, 3)):
84+
%1 : Float(4:9, 1:9, 3:3, 3:1)):
8585
%2 : None = prim::Constant()
8686
%3 : int = prim::Constant[value=1]()
8787
%4 : int = prim::Constant[value=0]()
@@ -120,8 +120,8 @@ TEST(Converters, ATenConvolutionNoBiasConvertsCorrectly) {
120120
TEST(Converters, ATenConvolutionWithStrideConvertsCorrectly) {
121121
const auto graph = R"IR(
122122
graph(%0 : Tensor,
123-
%1 : Float(4, 3, 3, 3),
124-
%2 : Float(4)):
123+
%1 : Float(4:27, 3:9, 3:3, 3:1),
124+
%2 : Float(4:1)):
125125
%3 : int = prim::Constant[value=3]()
126126
%4 : int = prim::Constant[value=0]()
127127
%5 : int = prim::Constant[value=1]()
@@ -163,8 +163,8 @@ TEST(Converters, ATenConvolutionWithStrideConvertsCorrectly) {
163163
TEST(Converters, ATenConvolutionWithPaddingConvertsCorrectly) {
164164
const auto graph = R"IR(
165165
graph(%0 : Tensor,
166-
%1 : Float(4, 3, 4, 4),
167-
%2 : Float(4)):
166+
%1 : Float(4:48, 3:16, 4:4, 4:1),
167+
%2 : Float(4:1)):
168168
%3 : int = prim::Constant[value=1]()
169169
%4 : int = prim::Constant[value=2]()
170170
%5 : int = prim::Constant[value=1]()
@@ -206,8 +206,8 @@ TEST(Converters, ATenConvolutionWithPaddingConvertsCorrectly) {
206206
TEST(Converters, ATenConvTransposeConvertsCorrectly) {
207207
const auto graph = R"IR(
208208
graph(%0 : Tensor,
209-
%1 : Float(8, 3, 3, 3),
210-
%2 : Float(8)):
209+
%1 : Float(8:27, 3:9, 3:3, 3:1),
210+
%2 : Float(8:1)):
211211
%3 : int = prim::Constant[value=1]()
212212
%4 : int = prim::Constant[value=0]()
213213
%5 : int = prim::Constant[value=1]()
@@ -248,7 +248,7 @@ TEST(Converters, ATenConvTransposeConvertsCorrectly) {
248248
TEST(Converters, ATenConvTransposeNoBiasConvertsCorrectly) {
249249
const auto graph = R"IR(
250250
graph(%0 : Tensor,
251-
%1 : Float(4, 1, 3, 3)):
251+
%1 : Float(4:9, 1:9, 3:3, 3:1)):
252252
%2 : None = prim::Constant()
253253
%3 : int = prim::Constant[value=1]()
254254
%4 : int = prim::Constant[value=0]()
@@ -287,8 +287,8 @@ TEST(Converters, ATenConvTransposeNoBiasConvertsCorrectly) {
287287
TEST(Converters, ATenConvTransposeWithStrideConvertsCorrectly) {
288288
const auto graph = R"IR(
289289
graph(%0 : Tensor,
290-
%1 : Float(4, 3, 3, 3),
291-
%2 : Float(4)):
290+
%1 : Float(4:27, 3:9, 3:3, 3:1),
291+
%2 : Float(4:1)):
292292
%3 : int = prim::Constant[value=3]()
293293
%4 : int = prim::Constant[value=0]()
294294
%5 : int = prim::Constant[value=1]()
@@ -330,8 +330,8 @@ TEST(Converters, ATenConvTransposeWithStrideConvertsCorrectly) {
330330
TEST(Converters, ATenConvTransposeWithPaddingConvertsCorrectly) {
331331
const auto graph = R"IR(
332332
graph(%0 : Tensor,
333-
%1 : Float(4, 3, 4, 4),
334-
%2 : Float(4)):
333+
%1 : Float(4:48, 3:16, 4:4, 4:1),
334+
%2 : Float(4:1)):
335335
%3 : int = prim::Constant[value=1]()
336336
%4 : int = prim::Constant[value=2]()
337337
%5 : int = prim::Constant[value=1]()

Diff for: tests/core/converters/test_linear.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
TEST(Converters, ATenLinearNoBiasConvertsCorrectly) {
88
const auto graph = R"IR(
99
graph(%0 : Tensor,
10-
%1 : Float(3, 2)):
10+
%1 : Float(3:2, 2:1)):
1111
%2 : None = prim::Constant()
1212
%3 : Tensor = aten::linear(%0, %1, %2)
1313
return (%3))IR";
@@ -34,8 +34,8 @@ TEST(Converters, ATenLinearNoBiasConvertsCorrectly) {
3434
TEST(Converters, ATenLinearBiasConvertsCorrectly) {
3535
const auto graph = R"IR(
3636
graph(%0 : Tensor,
37-
%1 : Float(2, 3),
38-
%2 : Float(2)):
37+
%1 : Float(2:3, 3:1),
38+
%2 : Float(2:1)):
3939
%3 : Tensor = aten::linear(%0, %1, %2)
4040
return (%3))IR";
4141

Diff for: tests/core/converters/test_shuffle.cpp

+12-9
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,21 @@ TEST(Converters, ATenPermuteConvertsCorrectly) {
108108
return (%3))IR";
109109

110110
auto g = std::make_shared<torch::jit::Graph>();
111-
torch::jit::parseIR(graph, &*g);
111+
torch::jit::parseIR(graph, &*g);
112112

113-
auto in = at::randint(0, 5, {2, 3, 2, 3}, {at::kCUDA});
114-
auto params = trtorch::core::conversion::get_named_params(g->inputs(), {});
115-
auto jit_results = trtorch::tests::util::RunGraph(g, params, {in});
113+
auto in = at::randint(0, 5, {2, 3, 2, 3}, {at::kCUDA});
114+
auto params = trtorch::core::conversion::get_named_params(g->inputs(), {});
116115

117-
in = at::clone(in);
118-
params = trtorch::core::conversion::get_named_params(g->inputs(), {});
119-
auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in});
120-
auto trt = trt_results[0].reshape_as(jit_results[0]);
116+
std::cout << "Running JIT" << std::endl;
117+
auto jit_results = trtorch::tests::util::RunGraph(g, params, {in});
121118

122-
ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt, 2e-6));
119+
std::cout << "Running TRT" << std::endl;
120+
in = at::clone(in);
121+
params = trtorch::core::conversion::get_named_params(g->inputs(), {});
122+
auto trt_results = trtorch::tests::util::RunGraphEngine(g, params, {in});
123+
auto trt = trt_results[0].reshape_as(jit_results[0]);
124+
125+
ASSERT_TRUE(trtorch::tests::util::almostEqual(jit_results[0], trt, 2e-6));
123126
}
124127

125128
TEST(Converters, ATenPermute3DConvertsCorrectly) {

Diff for: tests/core/converters/test_stack.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ TEST(Converters, ATenStackPureTensorConvertsCorrectly) {
3131
TEST(Converters, ATenStackDiffTensorConvertsCorrectly) {
3232
const auto graph = R"IR(
3333
graph(%0 : Tensor,
34-
%1 : Float(4, 4, 4)):
34+
%1 : Float(4:16, 4:4, 4:1)):
3535
%2 : Tensor[] = prim::ListConstruct(%0, %1)
3636
%3 : int = prim::Constant[value=1]()
3737
%4 : Tensor = aten::stack(%2, %3)

0 commit comments

Comments
 (0)