aboutsummaryrefslogtreecommitdiff
path: root/ethosu/mlw_codec/mlw_codecmodule.c
diff options
context:
space:
mode:
authorMauricio Briceno <mauricio.briceno@arm.com>2021-06-09 09:49:05 +0200
committerMauricio Briceno <mauricio.briceno@arm.com>2021-06-09 15:07:24 +0200
commit3e4168d741c167d2d52b1a3fc9a800c101bba09b (patch)
tree20a6f72b345d50e34b995effc72474d0df202f9c /ethosu/mlw_codec/mlw_codecmodule.c
parentd784af7e8995a10fb403157af48371699c35bbfe (diff)
downloadethos-u-vela-3e4168d741c167d2d52b1a3fc9a800c101bba09b.tar.gz
mlw_codec: Fixed alignment warning
- Restructured pointer API to prevent alignment warnings - Changed weight tensor data type to np.int16 Change-Id: I310c1ca733bf98724c84e8b2194becb4be3e7eea
Diffstat (limited to 'ethosu/mlw_codec/mlw_codecmodule.c')
-rw-r--r--ethosu/mlw_codec/mlw_codecmodule.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/ethosu/mlw_codec/mlw_codecmodule.c b/ethosu/mlw_codec/mlw_codecmodule.c
index b752a4e2..ddc8e7e1 100644
--- a/ethosu/mlw_codec/mlw_codecmodule.c
+++ b/ethosu/mlw_codec/mlw_codecmodule.c
@@ -81,7 +81,7 @@ method_reorder_encode (PyObject *self, PyObject *args)
PyArrayObject* input_ndarray_object = (PyArrayObject*)PyArray_FROM_OTF(
input_object,
- NPY_INT64,
+ NPY_INT16,
NPY_ARRAY_ALIGNED);
if (input_ndarray_object == NULL)
{
@@ -99,13 +99,19 @@ method_reorder_encode (PyObject *self, PyObject *args)
int kernel_width = (int)PyArray_DIM(input_ndarray_object, 2);
int ifm_depth = (int)PyArray_DIM(input_ndarray_object, 3);
- int64_t* brick_weights = (int64_t*)PyArray_DATA(input_ndarray_object);
+ int16_t* brick_weights = (int16_t*)PyArray_DATA(input_ndarray_object);
int brick_strides[4];
for (int i = 0; i < 4; i++)
{
- brick_strides[i] = (int)PyArray_STRIDE(input_ndarray_object, i);
+ int stride = (int)PyArray_STRIDE(input_ndarray_object, i);
+ if (stride % sizeof(int16_t))
+ {
+ PyErr_SetString(PyExc_ValueError, "Invalid stride");
+ return NULL;
+ }
+ brick_strides[i] = stride / sizeof(int16_t);
}
- if ((unsigned)PyArray_ITEMSIZE(input_ndarray_object) != sizeof(int64_t))
+ if ((unsigned)PyArray_ITEMSIZE(input_ndarray_object) != sizeof(int16_t))
{
PyErr_SetString(PyExc_ValueError, "Invalid input type");
return NULL;