fix: 修复动态维度内存分配错误
- 处理 TensorRT 引擎的负维度 (-1) - 将动态 Batch 维度替换为最小值 1
This commit is contained in:
@@ -148,11 +148,13 @@ class TensorRTEngine:
|
||||
|
||||
if self._input_binding:
|
||||
shape = self._input_binding["shape"]
|
||||
shape = tuple(max(1, s) if s < 0 else s for s in shape)
|
||||
dtype = self._get_numpy_dtype(self._input_binding["dtype"])
|
||||
self._memory_pool["input"] = np.zeros(shape, dtype=dtype)
|
||||
|
||||
for output in self._output_bindings:
|
||||
shape = output["shape"]
|
||||
shape = tuple(max(1, s) if s < 0 else s for s in shape)
|
||||
dtype = self._get_numpy_dtype(output["dtype"])
|
||||
self._memory_pool[output["name"]] = np.zeros(shape, dtype=dtype)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user