Changed the iterator to iterate over the same size tensors in the same order independent of memory layout.

This commit is contained in:
2023-09-13 14:12:02 +02:00
parent fd8a3d53e1
commit 15078171df
3 changed files with 40 additions and 24 deletions

View File

@@ -4,16 +4,16 @@
#include "tensor.h"
typedef struct _tensor_scalar_iterator {
dtype *current;
uint32_t length;
tensor t;
uint32_t *index;
} * tensoriter_scalar;
tensoriter_scalar tensoriter_scalar_create(tensor t);
void tensoriter_scalar_destroy(tensoriter_scalar it);
bool tensoriter_scalar_next(tensoriter_scalar it);
dtype tensoriter_scalar_get(tensoriter_scalar it);
void tensoriter_scalar_set(tensoriter_scalar it, dtype value);
dtype tensoriter_scalar_get(tensoriter_scalar it, bool *success);
bool tensoriter_scalar_set(tensoriter_scalar it, dtype value);
void tensoriter_scalar_map(tensoriter_scalar it, dtype (*func)(dtype));
void tensoriter_scalar_map_add(tensoriter_scalar it, dtype scalar);