Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions core/conversion/var/Var.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,16 @@ nvinfer1::ITensor* Var::ITensorOrFreeze(ConversionCtx* ctx) {
"Requested either IValue containing a Tensor, or ITensor, however Var type is " << type_name());

nvinfer1::ITensor* out;

auto weights = converters::Weights();
if (isIValue()) {
auto weights = converters::Weights(ctx, ptr_.ivalue->toTensor());
auto tensor = ptr_.ivalue->toTensor();
if (tensor.scalar_type() == at::kLong) {
weights = converters::Weights(ctx, tensor.toType(at::kInt));
} else if (tensor.scalar_type() == at::kDouble) {
weights = converters::Weights(ctx, tensor.toType(at::kFloat));
} else {
weights = converters::Weights(ctx, tensor);
}

auto const_layer = ctx->net->addConstant(weights.shape, weights.data);
TRTORCH_CHECK(const_layer, "Unable to freeze tensor into constant layer");
Expand Down