Skip to content

Commit c82c359

Browse files
committed
pre-commit fix
1 parent cc85809 commit c82c359

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

hls4ml/converters/pytorch/reshape.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def handle_upsample(operation, layer_name, input_names, input_shapes, node, clas
162162

163163
return layer, output_shape
164164

165+
165166
@pytorch_handler('ConstantPad2d')
166167
def parse_constantpad2d_layer(operation, layer_name, input_names, input_shapes, node, class_object, data_reader, config):
167168
assert operation == 'ConstantPad2d'

test/pytest/test_pytorch_constpadmapping.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from pathlib import Path
2-
import torch
31
import torch.nn as nn
2+
43
from hls4ml.converters import convert_from_pytorch_model
54
from hls4ml.utils.config import config_from_pytorch_model
65

6+
77
def test_pytorch_constantpad_1d_2d():
88
class Pad1DModel(nn.Module):
99
def __init__(self):
@@ -22,8 +22,6 @@ def forward(self, x):
2222
return self.pad(x)
2323

2424
# 1D test: batch=1, channels=2, width=4, values 1,2,3,4
25-
x1d = torch.tensor([[[1., 2., 3., 4.],
26-
[4., 3., 2., 1.]]]) # shape (1, 2, 4)
2725
model_1d = Pad1DModel()
2826
model_1d.eval()
2927
config_1d = config_from_pytorch_model(model_1d, (2, 4))
@@ -33,8 +31,6 @@ def forward(self, x):
3331
print(f"{layer.name}: {layer.class_name}")
3432

3533
# 2D test: batch=1, channels=1, height=2, width=4, values 1,2,3,4,5,6,7,8
36-
x2d = torch.tensor([[[[1., 2., 3., 4.],
37-
[5., 6., 7., 8.]]]]) # shape (1, 1, 2, 4)
3834
model_2d = Pad2DModel()
3935
model_2d.eval()
4036
config_2d = config_from_pytorch_model(model_2d, (1, 2, 4))
@@ -45,4 +41,4 @@ def forward(self, x):
4541

4642
# Write the HLS projects, cannot compile on Windows
4743
hls_model_1d.write()
48-
hls_model_2d.write()
44+
hls_model_2d.write()

0 commit comments

Comments
 (0)