Skip to content

Commit 7b6733b

Browse files
committed
fix bug stack when dim -1
Signed-off-by: hongwei03 <[email protected]>
1 parent 11bcb98 commit 7b6733b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

core/conversion/converters/impl/stack.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,16 @@ auto stack_registrations TORCHTRT_UNUSED = RegisterNodeConversionPatterns().patt
1919
[](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
2020
auto in = args[0].IValue()->toListRef();
2121
auto dim = args[1].unwrapToInt();
22+
if (-1 == dim) {
23+
auto first_in = in[0];
24+
if (first_in.isTensor()) {
25+
dim = first_in.toTensor().ndimension();
26+
} else {
27+
dim = first_in.toCustomClass<TensorContainer>()->tensor()->getDimensions().nbDims;
28+
}
29+
}
2230

2331
std::vector<nvinfer1::ITensor*> tensors;
24-
2532
for (auto t : in) {
2633
nvinfer1::ITensor* itensor;
2734

0 commit comments

Comments
 (0)