From 84777c4a6b90be3bc116bc5a8dff86b1d19950af Mon Sep 17 00:00:00 2001 From: Elen Kalda Date: Wed, 16 Feb 2022 11:41:17 +0000 Subject: [PATCH] Add failure reasons to the asserts --- python/tvm/relay/backend/contrib/ethosu/tir/passes.py | 4 ++-- tests/python/contrib/test_ethosu/test_codegen.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/python/tvm/relay/backend/contrib/ethosu/tir/passes.py b/python/tvm/relay/backend/contrib/ethosu/tir/passes.py index a610eed5d61a8..a4a4ec648cb8e 100644 --- a/python/tvm/relay/backend/contrib/ethosu/tir/passes.py +++ b/python/tvm/relay/backend/contrib/ethosu/tir/passes.py @@ -343,7 +343,7 @@ def _new_buffer(old_buffer, new_value): def _encode_weights_or_bias(ptr1, ptr2, stmt, encode_func): """Encode the weights or align the bias either for one or two cores, depending on the variant.""" - assert ptr1 in pointer_to_buffer + assert ptr1 in pointer_to_buffer, "Weights or bias pointer is not associated with any buffer." buffer = pointer_to_buffer[ptr1] constant = buffer_to_const[buffer] @@ -363,7 +363,7 @@ def _encode_weights_or_bias(ptr1, ptr2, stmt, encode_func): new_const_length = len(new_const) # Encode half of the constant separately for the other core if it exists - assert ptr1.same_as(ptr2) + assert ptr1.same_as(ptr2), "The two weights or biases pointers don't match." const2_list = [split_const[i] for i in range(channels) if i % 2 == 1] const2_to_encode = np.concatenate(const2_list, axis=0) diff --git a/tests/python/contrib/test_ethosu/test_codegen.py b/tests/python/contrib/test_ethosu/test_codegen.py index 8c0ef02cdf064..be7080e464dbb 100644 --- a/tests/python/contrib/test_ethosu/test_codegen.py +++ b/tests/python/contrib/test_ethosu/test_codegen.py @@ -77,10 +77,11 @@ class Model(tf.Module): def tf_function(self, x): # Use tf.nn API to create the model tf_strides = [1, strides[0], strides[1], 1] + out_channels = 5 op = tf.nn.conv2d( x, filters=tf.constant( - np.random.uniform(size=[kernel_shape[0], kernel_shape[1], ifm_shape[3], 5]), + np.random.uniform(size=[kernel_shape[0], kernel_shape[1], ifm_shape[3], out_channels]), dtype=tf.float32, ), strides=tf_strides,