Skip to content

Commit 8929d3f

Browse files
authored
[TOPI] Add shape validation to prevent negative dimensions in conv operations (#17942)
* add negative output dim checking for conv2d.py * Update conv2d.py
1 parent 92ea12d commit 8929d3f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

python/tvm/topi/nn/conv2d.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,11 @@ def conv(
743743
dimensions, kernel_dimensions, dilations, pad_begin, pad_end, strides
744744
)
745745
]
746+
for out_dim in out_dimensions:
747+
if isinstance(out_dim, int) and out_dim <= 0:
748+
raise ValueError(
749+
f"Invalid conv parameters: lead to negative output shape {out_dimensions}. "
750+
)
746751
# compute graph
747752
pad_before = list(np.array([0, 0] + pad_begin)[data_permutation_from])
748753
pad_after = list(np.array([0, 0] + pad_end)[data_permutation_from])

0 commit comments

Comments
 (0)