Skip to content

Commit f70bed6

Browse files
committed
refactor: Apply linting
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
1 parent c9aa99a commit f70bed6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

core/conversion/var/Var.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ nvinfer1::ITensor* Var::ITensorOrFreeze(ConversionCtx* ctx) {
8989
if (isIValue()) {
9090
LOG_DEBUG(ctx->logger, "Found IValue containing object of type " << *(ptr_.ivalue->type()));
9191
}
92-
92+
9393
TRTORCH_CHECK(
9494
isITensor() || (isIValue() && (ptr_.ivalue->isTensor() || ptr_.ivalue->isCustomClass())),
9595
"Requested either IValue containing a Tensor, or ITensor, however Var type is " << type_name());
@@ -100,8 +100,10 @@ nvinfer1::ITensor* Var::ITensorOrFreeze(ConversionCtx* ctx) {
100100
if (ptr_.ivalue->isTensor()) {
101101
auto weights = converters::Weights();
102102
auto tensor = ptr_.ivalue->toTensor();
103-
if ((tensor.scalar_type() == at::kLong || tensor.scalar_type() == at::kDouble) && !ctx->settings.truncate_long_and_double) {
104-
TRTORCH_THROW_ERROR("Unable to freeze tensor of type Int64/Float64 into constant layer, try to compile model with truncate_long_and_double enabled");
103+
if ((tensor.scalar_type() == at::kLong || tensor.scalar_type() == at::kDouble) &&
104+
!ctx->settings.truncate_long_and_double) {
105+
TRTORCH_THROW_ERROR(
106+
"Unable to freeze tensor of type Int64/Float64 into constant layer, try to compile model with truncate_long_and_double enabled");
105107
} else if (tensor.scalar_type() == at::kLong && ctx->settings.truncate_long_and_double) {
106108
weights = converters::Weights(ctx, tensor.toType(at::kInt));
107109
LOG_WARNING("Truncating weight (constant in the graph) from Int64 to Int32");
@@ -111,7 +113,7 @@ nvinfer1::ITensor* Var::ITensorOrFreeze(ConversionCtx* ctx) {
111113
} else {
112114
weights = converters::Weights(ctx, tensor);
113115
}
114-
116+
115117
auto const_layer = ctx->net->addConstant(weights.shape, weights.data);
116118
TRTORCH_CHECK(const_layer, "Unable to freeze tensor into constant layer");
117119
out = const_layer->getOutput(0);

0 commit comments

Comments
 (0)