@@ -346,9 +346,9 @@ def convert_precision_string(cls, precision):
346
346
347
347
@classmethod
348
348
def _convert_ap_type (cls , precision ):
349
- '''
349
+ """
350
350
Convert a precision string (e.g. "ap_fixed<16,6>" to the internal FixedPrecisionTypes etc)
351
- '''
351
+ """
352
352
bits = re .search ('.+<(.+?)>' , precision ).group (1 ).split (',' )
353
353
sat_mode = None
354
354
round_mode = None
@@ -357,12 +357,12 @@ def _convert_ap_type(cls, precision):
357
357
width = int (bits [0 ])
358
358
integer = int (bits [1 ])
359
359
fields = 2
360
- signed = not ( 'u' in precision )
360
+ signed = 'u' not in precision
361
361
elif 'int' in precision :
362
362
width = int (bits [0 ])
363
363
integer = width
364
364
fields = 1
365
- signed = not ( 'u' in precision )
365
+ signed = 'u' not in precision
366
366
if len (bits ) > fields :
367
367
round_mode = bits [fields ]
368
368
if len (bits ) > fields + 1 :
@@ -376,9 +376,9 @@ def _convert_ap_type(cls, precision):
376
376
377
377
@classmethod
378
378
def _convert_ac_type (cls , precision ):
379
- '''
379
+ """
380
380
Convert a precision string (e.g. "ac_fixed<16,6>" to the internal FixedPrecisionTypes etc)
381
- '''
381
+ """
382
382
bits = re .search ('.+<(.+?)>' , precision ).group (1 ).split (',' )
383
383
signed = True # default is signed
384
384
sat_mode = None
@@ -414,18 +414,18 @@ def _convert_ac_type(cls, precision):
414
414
415
415
@classmethod
416
416
def _convert_auto_type (cls , precision ):
417
- '''
417
+ """
418
418
Convert a "auto" precision string into the UnspecifiedPrecisionType
419
- '''
419
+ """
420
420
return UnspecifiedPrecisionType ()
421
421
422
422
def product_type (self , data_T , weight_T ):
423
- '''
423
+ """
424
424
Helper function to determine which product implementation to use during inference
425
- '''
426
- assert not isinstance (
427
- data_T , ExponentPrecisionType
428
- ), "Only ExponentPrecisionType (aka 'power of 2') weights are currently supported, not data."
425
+ """
426
+ assert not isinstance (data_T , ExponentPrecisionType ), (
427
+ "Only ExponentPrecisionType (aka 'power of 2') weights are currently supported, not data."
428
+ )
429
429
product = 'mult'
430
430
if isinstance (weight_T , ExponentPrecisionType ):
431
431
product = 'weight_exponential'
@@ -754,14 +754,14 @@ def generate_conv1d_line_buffer_fn(self, layer_idx, n_partitions, in_W, in_C, ke
754
754
im2col_matrix = self ._compute_conv1d_im2col ((in_W , in_C ), kernel , stride , (pad_left , pad_right ), dilation )
755
755
756
756
generated_code = (
757
- " template<class data_T, typename CONFIG_T>\n "
758
- " class fill_buffer_{index} : public nnet::FillConv1DBuffer<data_T, CONFIG_T> {{\n "
759
- " public:\n "
760
- " static void fill_buffer(\n "
761
- " data_T data[CONFIG_T::in_width * CONFIG_T::n_chan],\n "
762
- " data_T buffer[CONFIG_T::n_pixels][CONFIG_T::filt_width * CONFIG_T::n_chan],\n "
763
- " const unsigned partition\n "
764
- " ) {{\n "
757
+ ' template<class data_T, typename CONFIG_T>\n '
758
+ ' class fill_buffer_{index} : public nnet::FillConv1DBuffer<data_T, CONFIG_T> {{\n '
759
+ ' public:\n '
760
+ ' static void fill_buffer(\n '
761
+ ' data_T data[CONFIG_T::in_width * CONFIG_T::n_chan],\n '
762
+ ' data_T buffer[CONFIG_T::n_pixels][CONFIG_T::filt_width * CONFIG_T::n_chan],\n '
763
+ ' const unsigned partition\n '
764
+ ' ) {{\n '
765
765
).format (index = layer_idx )
766
766
indent = ' '
767
767
@@ -884,14 +884,14 @@ def generate_conv2d_line_buffer_fn(
884
884
)
885
885
886
886
generated_code = (
887
- " template<class data_T, typename CONFIG_T>\n "
888
- " class fill_buffer_{index} : public nnet::FillConv2DBuffer<data_T, CONFIG_T> {{\n "
889
- " public:\n "
890
- " static void fill_buffer(\n "
891
- " data_T data[CONFIG_T::in_height * CONFIG_T::in_width * CONFIG_T::n_chan],\n "
892
- " data_T buffer[CONFIG_T::n_pixels][CONFIG_T::filt_height * CONFIG_T::filt_width * CONFIG_T::n_chan],\n "
893
- " const unsigned partition\n "
894
- " ) {{\n "
887
+ ' template<class data_T, typename CONFIG_T>\n '
888
+ ' class fill_buffer_{index} : public nnet::FillConv2DBuffer<data_T, CONFIG_T> {{\n '
889
+ ' public:\n '
890
+ ' static void fill_buffer(\n '
891
+ ' data_T data[CONFIG_T::in_height * CONFIG_T::in_width * CONFIG_T::n_chan],\n '
892
+ ' data_T buffer[CONFIG_T::n_pixels][CONFIG_T::filt_height * CONFIG_T::filt_width * CONFIG_T::n_chan],\n '
893
+ ' const unsigned partition\n '
894
+ ' ) {{\n '
895
895
).format (index = layer_idx )
896
896
indent = ' '
897
897
0 commit comments