Skip to content

Commit

Permalink
Merge pull request #1110 from Xilinx/feature/per_tensor_rtl_thresh
Browse files Browse the repository at this point in the history
Optimizing resources for per tensor quantization
  • Loading branch information
auphelia authored Jun 24, 2024
2 parents 25c1c99 + bc8dc04 commit 9cd8bab
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/finn/custom_op/fpgadataflow/rtl/thresholding_rtl.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ def prepare_codegen_rtl_values(self, model):
num_channels = self.get_nodeattr("NumChannels") # number of channels

# If a single threshold value is found, broadcast the value
expected_shape = (num_channels, expected_thresholds)
if t_packed.shape != expected_shape:
t_packed = np.broadcast_to(t_packed, expected_shape)
if t_packed.shape[0] == 1:
t_packed = np.broadcast_to(t_packed, (pe, expected_thresholds))
num_channels = pe

channel_fold = int(num_channels / pe)

Expand Down Expand Up @@ -531,11 +531,11 @@ def make_weight_file(self, weights, weight_file_mode, weight_file_name):
min_val = wdt.min()
thresholds = np.insert(thresholds, 0, min_val, axis=1)
n_thres_steps += 1
expected_shape = (ch, expected_thresholds)

# If a single threshold value is found, broadcast the value
if thresholds.shape != expected_shape:
thresholds = np.broadcast_to(thresholds, expected_shape)
if thresholds.shape[0] == 1:
thresholds = np.broadcast_to(thresholds, (pe, expected_thresholds))
ch = pe

width_padded = roundup_to_integer_multiple(thresholds.shape[1], 2**o_bitwidth)
thresh_padded = np.zeros((thresholds.shape[0], width_padded))
Expand Down

0 comments on commit 9cd8bab

Please sign in to comment.