From 0f6be0cc019c7389ef9a2786273476e38a001301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20V=C3=B6r=C3=B6s?= Date: Tue, 23 Jul 2024 18:57:20 +0200 Subject: [PATCH] reduce firmware size --- code/ndarray.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/code/ndarray.c b/code/ndarray.c index a50d9f83..26ced6fc 100644 --- a/code/ndarray.c +++ b/code/ndarray.c @@ -567,7 +567,7 @@ ndarray_obj_t *ndarray_new_ndarray_from_tuple(mp_obj_tuple_t *_shape, uint8_t dt for(size_t i = 0; i < _shape->len; i++) { shape[ULAB_MAX_DIMS - 1 - i] = mp_obj_get_int(_shape->items[_shape->len - 1 - i]); } - return ndarray_new_ndarray(_shape->len, shape, NULL, dtype, NULL); + return ndarray_new_dense_ndarray(_shape->len, shape, dtype); } void ndarray_copy_array(ndarray_obj_t *source, ndarray_obj_t *target, uint8_t shift) { @@ -665,7 +665,7 @@ ndarray_obj_t *ndarray_copy_view_convert_type(ndarray_obj_t *source, uint8_t dty if(dtype == source->dtype) { return ndarray_copy_view(source); } - ndarray_obj_t *ndarray = ndarray_new_ndarray(source->ndim, source->shape, NULL, dtype, NULL); + ndarray_obj_t *ndarray = ndarray_new_dense_ndarray(source->ndim, source->shape, dtype); uint8_t *sarray = (uint8_t *)source->array; uint8_t *array = (uint8_t *)ndarray->array; @@ -829,10 +829,10 @@ MP_DEFINE_CONST_FUN_OBJ_1(ndarray_copy_obj, ndarray_copy); ndarray_obj_t *ndarray_new_linear_array(size_t len, uint8_t dtype) { size_t *shape = m_new(size_t, ULAB_MAX_DIMS); if(len == 0) { - return ndarray_new_ndarray(0, shape, NULL, dtype, NULL); + return ndarray_new_dense_ndarray(0, shape, dtype); } shape[ULAB_MAX_DIMS-1] = len; - return ndarray_new_ndarray(1, shape, NULL, dtype, NULL); + return ndarray_new_dense_ndarray(1, shape, dtype); } ndarray_obj_t *ndarray_from_iterable(mp_obj_t obj, uint8_t dtype) { @@ -873,7 +873,7 @@ ndarray_obj_t *ndarray_from_iterable(mp_obj_t obj, uint8_t dtype) { shape[ULAB_MAX_DIMS - i - 1] = shape[ndim - 1 - i]; } - ndarray_obj_t *ndarray = ndarray_new_ndarray(ndim, shape, NULL, dtype, NULL); + ndarray_obj_t *ndarray = ndarray_new_dense_ndarray(ndim, shape, dtype); item = obj; for(uint8_t i = 0; i < ndim - 1; i++) { // if ndim > 1, descend into the hierarchy @@ -2073,7 +2073,7 @@ mp_obj_t ndarray_reshape_core(mp_obj_t oin, mp_obj_t _shape, bool inplace) { if(inplace) { mp_raise_ValueError(MP_ERROR_TEXT("cannot assign new shape")); } - ndarray = ndarray_new_ndarray(shape->len, new_shape, NULL, source->dtype, NULL); + ndarray = ndarray_new_dense_ndarray(shape->len, new_shape, source->dtype); ndarray_copy_array(source, ndarray, 0); } return MP_OBJ_FROM_PTR(ndarray);