diff options
Diffstat (limited to 'ethosu/vela/supported_operators.py')
-rw-r--r-- | ethosu/vela/supported_operators.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/ethosu/vela/supported_operators.py b/ethosu/vela/supported_operators.py index f57cbee2..8ec77207 100644 --- a/ethosu/vela/supported_operators.py +++ b/ethosu/vela/supported_operators.py @@ -201,10 +201,13 @@ class SupportedOperators: return False # check data type - ifm_tensor, _, weight_tensor, _ = op.get_ifm_ifm2_weights_ofm() + ifm_tensor, _, weight_tensor, bias_tensor, _ = op.get_ifm_ifm2_weights_biases_ofm() if weight_tensor.element_size() > 1: return False + if not self.check_bias_restrictions(bias_tensor): + return False + # check kernel size [HWIO] dilated_weight_w = weight_tensor.shape[1] + (weight_tensor.shape[1] - 1) * (dilation_w_factor - 1) dilated_weight_h = weight_tensor.shape[0] + (weight_tensor.shape[0] - 1) * (dilation_h_factor - 1) @@ -307,10 +310,13 @@ class SupportedOperators: def check_vector_product_restrictions(self, op): # check data type - ifm_tensor, _, weight_tensor, _ = op.get_ifm_ifm2_weights_ofm() + _, _, weight_tensor, bias_tensor, _ = op.get_ifm_ifm2_weights_biases_ofm() if weight_tensor.element_size() > 1: return False + if not self.check_bias_restrictions(bias_tensor): + return False + return True def check_element_wise_restrictions(self, op): @@ -407,3 +413,16 @@ class SupportedOperators: return False return True + + def check_bias_restrictions(self, bias_tensor): + # check data type + if bias_tensor.dtype not in (DataType.int32, DataType.int64): + return False + + # check if values fits in 40-bit + if bias_tensor.dtype == DataType.int64: + for value in bias_tensor.values: + if not (-(1 << 39) <= value < (1 << 39)): + return False + + return True |