Skip to content

Commit

Permalink
Add failure reasons to the asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
ekalda committed Feb 21, 2022
1 parent 3fb0edc commit ef1f9c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions python/tvm/relay/backend/contrib/ethosu/tir/passes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion tests/python/contrib/test_ethosu/test_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ef1f9c1

Please sign in to comment.