Skip to content

Commit d36494a

Browse files
committed
fixed a bug due to shape_change
1 parent d6ed44e commit d36494a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

core/runtime/execute_engine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void setup_input_tensors(
141141
at::Tensor contig_input = inputs[i].view(shape).contiguous();
142142
formatted_inputs.emplace_back(std::move(contig_input));
143143

144-
if (need_cudagraphs_record) {
144+
if (need_cudagraphs_record or compiled_engine->allocated_outputs.size() == 0) {
145145
// Create a new persistent input buffer
146146
compiled_engine->input_buffers[i] = std::move(formatted_inputs.back().clone());
147147
}

py/torch_tensorrt/dynamo/runtime/_PythonTorchTensorRTModule.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,9 @@ def setup_input_tensors(
417417
inputs_cpu = contiguous_inputs[i].cpu().to(torch.int64).numpy().copy()
418418
self.context.set_tensor_address(input_name, inputs_cpu.ctypes.data)
419419
else:
420-
if need_cudagraphs_record:
420+
if (
421+
need_cudagraphs_record or self.output_tensors is None
422+
): # First time execution:
421423
self.context.set_input_shape(
422424
input_name, tuple(contiguous_inputs[i].shape)
423425
)

0 commit comments

Comments
 (0)