File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
core/conversion/converters/impl Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -80,11 +80,20 @@ auto reduce_registrations TRTORCH_UNUSED =
80
80
[](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
81
81
auto in_tensor = args[0 ].ITensorOrFreeze (ctx);
82
82
auto dims = args[1 ].unwrapToIntList ();
83
- LOG_DEBUG (" Dim to reduce:" << util::toDims (dims)); // Some abuse of toDim but just for debug info
83
+ c10::List<int64_t > dims_copy;
84
+ auto in_dims = util::toVec (in_tensor->getDimensions ());
85
+ LOG_DEBUG (" InDims " << in_dims); // Some abuse of toDim but just for debug info
86
+ LOG_DEBUG (" Dim to reduce(original):" << util::toDims (dims)); // Some abuse of toDim but just for debug info
87
+ for (int i = 0 ; i < dims.size (); i++) {
88
+ auto dim_val = dims[i] == -1 ? (in_dims.size () - 1 ) : dims[i];
89
+ dims_copy.push_back (dim_val);
90
+ }
91
+
92
+ LOG_DEBUG (" Dim to reduce(converted):" << util::toDims (dims_copy)); // Some abuse of toDim but just for debug info
84
93
85
94
uint32_t axis_mask = 0 ;
86
- for (size_t d = 0 ; d < dims .size (); d++) {
87
- axis_mask |= 1 << dims [d];
95
+ for (size_t d = 0 ; d < dims_copy .size (); d++) {
96
+ axis_mask |= 1 << dims_copy [d];
88
97
}
89
98
LOG_DEBUG (" Axis Mask" << std::bitset<32 >(axis_mask));
90
99
Original file line number Diff line number Diff line change @@ -26,6 +26,9 @@ static auto softmax_registrations TRTORCH_UNUSED = RegisterNodeConversionPattern
26
26
}
27
27
28
28
int64_t dim = args[1 ].IValue ()->toInt ();
29
+ if (dim == -1 ) {
30
+ dim = shape.size () - 1 ;
31
+ }
29
32
auto softmax = ctx->net ->addSoftMax (*in);
30
33
31
34
TRTORCH_CHECK (softmax, " Unable to create softmax layer from node: " << *n);
You can’t perform that action at this time.
0 commit comments