@@ -550,7 +550,7 @@ def test_pooling(pooling, padds, backend):
550
550
# Verify correct parsing of layer
551
551
hls_pool = list (hls_model .get_layers ())[- 2 ]
552
552
if '2d' in pooling .__name__ :
553
- assert hls_pool .attributes ['name' ] == poolNode .name
553
+ assert hls_pool .attributes ['name' ] == "_" + poolNode .name . split ( "_" )[ - 1 ]
554
554
assert hls_pool .attributes ['class_name' ][- 2 ] == str (2 )
555
555
assert hls_pool .attributes ['stride_height' ] == class_object_pool .stride
556
556
assert hls_pool .attributes ['stride_width' ] == class_object_pool .stride
@@ -560,14 +560,14 @@ def test_pooling(pooling, padds, backend):
560
560
561
561
elif '1d' in pooling .__name__ :
562
562
if "Max" in pooling .__name__ :
563
- assert hls_pool .attributes ['name' ] == poolNode .name
563
+ assert hls_pool .attributes ['name' ] == "_" + poolNode .name . split ( "_" )[ - 1 ]
564
564
assert hls_pool .attributes ['class_name' ][- 2 ] == str (1 )
565
565
assert hls_pool .attributes ['pool_width' ] == class_object_pool .kernel_size
566
566
assert hls_pool .attributes ['stride_width' ] == class_object_pool .stride
567
567
assert hls_pool .attributes ['padding' ] == 'valid' if class_object_pool .padding == 0 else 'same'
568
568
569
569
else :
570
- assert hls_pool .attributes ['name' ] == poolNode .name
570
+ assert hls_pool .attributes ['name' ] == "_" + poolNode .name . split ( "_" )[ - 1 ]
571
571
assert hls_pool .attributes ['class_name' ][- 2 ] == str (1 )
572
572
assert hls_pool .attributes ['pool_width' ] == class_object_pool .kernel_size [0 ]
573
573
assert hls_pool .attributes ['stride_width' ] == class_object_pool .stride [0 ]
@@ -641,7 +641,7 @@ def test_squeeze(backend, io_type):
641
641
pytorch_prediction = model (torch .Tensor (X_input )).detach ().numpy ().flatten ()
642
642
643
643
config = config_from_pytorch_model (model )
644
- del config ['Model' ]['InputsChannelLast ' ] # We don't want anything touched for this test
644
+ del config ['Model' ]['ChannelsLastConversion ' ] # We don't want anything touched for this test
645
645
output_dir = str (test_root_path / f'hls4mlprj_pytorch_api_squeeze_{ backend } _{ io_type } ' )
646
646
647
647
hls_model = convert_from_pytorch_model (
@@ -719,7 +719,7 @@ def test_skipped_layers(backend, io_type):
719
719
input_shape = (3 , 8 )
720
720
batch_input_shape = (None ,) + input_shape
721
721
config = config_from_pytorch_model (
722
- model , default_precision = 'ap_fixed<32,16>' , inputs_channel_last = True , transpose_outputs = False
722
+ model , default_precision = 'ap_fixed<32,16>' , channels_last_conversion = "full" , transpose_outputs = False
723
723
)
724
724
output_dir = str (test_root_path / f'hls4mlprj_pytorch_api_skipped_{ backend } _{ io_type } ' )
725
725
hls_model = convert_from_pytorch_model (
@@ -734,10 +734,9 @@ def test_skipped_layers(backend, io_type):
734
734
hls_model .compile ()
735
735
736
736
input = torch .randn (10 , 3 , 8 )
737
- hls_input = np .ascontiguousarray (torch .permute (input , (0 , 2 , 1 )).detach ().numpy ()) # Transpose to channels_last
738
737
739
738
pytorch_prediction = model (input ).detach ().numpy ().flatten ()
740
- hls_prediction = hls_model .predict (hls_input ).flatten ()
739
+ hls_prediction = hls_model .predict (input . detach (). numpy () ).flatten ()
741
740
742
741
np .testing .assert_allclose (hls_prediction , pytorch_prediction , rtol = 0 , atol = 5e-2 )
743
742
@@ -785,8 +784,7 @@ def forward(self, x):
785
784
config = config_from_pytorch_model (
786
785
model ,
787
786
default_precision = 'ap_fixed<32,16>' ,
788
- inputs_channel_last = False , # Crucial for testing if the first Transpose was removed
789
- transpose_outputs = False ,
787
+ channels_last_conversion = "full" , # Crucial for testing if the first Transpose was removed
790
788
)
791
789
output_dir = str (test_root_path / f'hls4mlprj_pytorch_api_transpose_nop_{ tensor_rank } d_{ backend } _{ io_type } ' )
792
790
hls_model = convert_from_pytorch_model (
0 commit comments