Skip to content

Commit

Permalink
reduce firmware size
Browse files Browse the repository at this point in the history
  • Loading branch information
v923z committed Jul 23, 2024
1 parent 18ee573 commit 0f6be0c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions code/ndarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0f6be0c

Please sign in to comment.