Skip to content

Commit 0ccee81

Browse files
committed
fix: update slice, correct typo
Signed-off-by: inocsin <[email protected]>
1 parent de42bf0 commit 0ccee81

File tree

3 files changed

+9
-22
lines changed

3 files changed

+9
-22
lines changed

core/conversion/converters/converter_util.cpp

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ nvinfer1::ITensor* clamp_to_input_dim(ConversionCtx* ctx, nvinfer1::ITensor* x,
243243
}
244244

245245
// return indices < 0 ? inputDims + indices : indices
246-
nvinfer1::ITensor* bump_if_negtive(ConversionCtx* ctx, nvinfer1::ITensor* input_dim, nvinfer1::ITensor* indices, int nbdims) {
246+
nvinfer1::ITensor* bump_if_negative(ConversionCtx* ctx, nvinfer1::ITensor* input_dim, nvinfer1::ITensor* indices, int nbdims) {
247247
auto zero = torch::zeros({nbdims}).to(torch::kI32);
248248
auto neg = -torch::ones({nbdims}).to(torch::kI32);
249249
auto zero_itensor = tensor_to_const(ctx, zero);
@@ -253,14 +253,14 @@ nvinfer1::ITensor* bump_if_negtive(ConversionCtx* ctx, nvinfer1::ITensor* input_
253253

254254
// get the inputDim value where indices == -1, else 0
255255
auto mul = ctx->net->addElementWise(*signs, *input_dim, nvinfer1::ElementWiseOperation::kPROD);
256-
TORCHTRT_CHECK(mul, "Unable to create mul layer in bump_if_negtive");
257-
LOG_DEBUG(ctx->logger, "Create " << mul->getName() << " for bump_if_negtive");
256+
TORCHTRT_CHECK(mul, "Unable to create mul layer in bump_if_negative");
257+
LOG_DEBUG(ctx->logger, "Create " << mul->getName() << " for bump_if_negative");
258258
auto mul_itensor = mul->getOutput(0);
259259

260260
// add the inputDim value to indices where indices == -1
261261
auto sub = ctx->net->addElementWise(*indices, *mul_itensor, nvinfer1::ElementWiseOperation::kSUB);
262-
TORCHTRT_CHECK(sub, "Unable to create sub layer in bump_if_negtive");
263-
LOG_DEBUG(ctx->logger, "Create " << sub->getName() << " for bump_if_negtive");
262+
TORCHTRT_CHECK(sub, "Unable to create sub layer in bump_if_negative");
263+
LOG_DEBUG(ctx->logger, "Create " << sub->getName() << " for bump_if_negative");
264264
auto sub_itensor = sub->getOutput(0);
265265
return sub_itensor;
266266
}
@@ -271,9 +271,9 @@ std::vector<nvinfer1::ITensor*> update_start_and_end(
271271
nvinfer1::ITensor* in_start,
272272
nvinfer1::ITensor* in_end,
273273
int nbdims) {
274-
auto start = bump_if_negtive(ctx, in_shape, in_start, nbdims);
274+
auto start = bump_if_negative(ctx, in_shape, in_start, nbdims);
275275
auto out_start = clamp_to_input_dim(ctx, start, in_shape, nbdims);
276-
auto end = bump_if_negtive(ctx, in_shape, in_end, nbdims);
276+
auto end = bump_if_negative(ctx, in_shape, in_end, nbdims);
277277
auto out_end = clamp_to_input_dim(ctx, end, in_shape, nbdims);
278278
std::vector<nvinfer1::ITensor*> outputs;
279279
outputs.push_back(out_start);
@@ -309,17 +309,6 @@ nvinfer1::ITensor* calculate_output_size(
309309
return size_itensor;
310310
}
311311

312-
bool is_dynamic_shape(nvinfer1::ITensor* tensor) {
313-
auto dim = tensor->getDimensions();
314-
auto ndims = dim.nbDims;
315-
for (int i = 0; i < ndims; i++) {
316-
if (dim.d[i] == -1) {
317-
return true;
318-
}
319-
}
320-
return false;
321-
}
322-
323312
} // namespace converters
324313
} // namespace conversion
325314
} // namespace core

core/conversion/converters/converter_util.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ nvinfer1::ITensor* clamp(
5757
nvinfer1::ITensor* lower_bound,
5858
nvinfer1::ITensor* upper_bound);
5959

60-
nvinfer1::ITensor* bump_if_negtive(ConversionCtx* ctx, nvinfer1::ITensor* input_dim, nvinfer1::ITensor* indices);
60+
nvinfer1::ITensor* bump_if_negative(ConversionCtx* ctx, nvinfer1::ITensor* input_dim, nvinfer1::ITensor* indices);
6161

6262
std::vector<nvinfer1::ITensor*> update_start_and_end(
6363
ConversionCtx* ctx,
@@ -73,8 +73,6 @@ nvinfer1::ITensor* calculate_output_size(
7373
nvinfer1::ITensor* stride,
7474
int nbdims);
7575

76-
bool is_dynamic_shape(nvinfer1::ITensor* tensor);
77-
7876
} // namespace converters
7977
} // namespace conversion
8078
} // namespace core

core/conversion/converters/impl/select.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ auto select_registrations TORCHTRT_UNUSED =
309309
auto in = args[0].ITensorOrFreeze(ctx);
310310
int axis = args[1].unwrapToInt();
311311
int maxDim = static_cast<int32_t>(in->getDimensions().d[axis]);
312-
bool dynamic_shape = is_dynamic_shape(in);
312+
bool dynamic_shape = ctx->input_is_dynamic;
313313
auto input_dim = in->getDimensions();
314314
// add Shape Tensor
315315
auto ishape_layer = ctx->net->addShape(*in);

0 commit comments

Comments
 (0)