Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions tests/converter_tests/test_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ def test_batch_norm_nd(nd, with_conv):
inputs = [torch.randn(*input_size).cuda()]
cross_validate(module, inputs, fp16_mode=False, tol=1e-1)

if nd == 1:
input_size = [2, 3]
inputs = [torch.randn(*input_size).cuda()]
cross_validate(module, inputs, fp16_mode=False, tol=1e-1)


@pytest.mark.parametrize("dim", [1, -1])
def test_cat(dim):
Expand Down
4 changes: 2 additions & 2 deletions torch2trt/converters/native_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def convert_batch_norm(ctx):
bias = bias.detach().cpu().numpy() - running_mean.detach().cpu().numpy() * scale
power = np.ones_like(scale)

if ndim == 1:
if ndim == 1 or ndim == 0:
# reshape to 2D
layer = ctx.network.add_shuffle(input_trt)

Expand All @@ -171,7 +171,7 @@ def convert_batch_norm(ctx):

layer = ctx.network.add_scale_nd(scale_input, trt.ScaleMode.CHANNEL, bias, scale, power, 1)

if ndim == 1:
if ndim == 1 or ndim == 0:
# reshape back to 1D
layer = ctx.network.add_shuffle(layer.get_output(0))
if len(input.shape) == 2:
Expand Down