Added stdbool.h

This commit is contained in:
2023-05-08 17:06:49 +02:00
parent 53710f8b31
commit 7d96a0f7f1
2 changed files with 9 additions and 9 deletions

View File

@@ -15,25 +15,25 @@ void tensor_destroy(tensor t)
free(t);
}
uint8_t tensor_is_empty(const tensor t)
bool tensor_is_empty(const tensor t)
{
return t->elements == NULL || t->size == NULL;
}
uint8_t tensor_is_equal(const tensor t1, const tensor t2)
bool tensor_is_equal(const tensor t1, const tensor t2)
{
assert(!tensor_is_empty(t1));
assert(!tensor_is_empty(t2));
uint32_t i;
if (t1->rank != t2->rank) return 0;
if (t1->rank != t2->rank) return false;
for (i = 0; i < t1->rank; i++) {
if (t1->size[i] != t2->size[i]) return 0;
if (t1->size[i] != t2->size[i]) return false;
}
for (i = 0; i < t1->num_elem; i++) {
if (DTYPE_NE(t1->elements[i], t2->elements[i])) return 0;
if (DTYPE_NE(t1->elements[i], t2->elements[i])) return false;
}
return 1;
return true;
}
uint8_t _tensor_check_size(const uint32_t *size, uint8_t rank)

View File

@@ -6,8 +6,8 @@
#include <string.h>
#include <time.h>
#include <assert.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdbool.h>
/* Defining the datatype of the tensor */
typedef float dtype;
@@ -39,8 +39,8 @@ typedef struct _tensor {
tensor tensor_new(void);
void tensor_destroy(tensor t);
uint8_t tensor_is_empty(const tensor t);
uint8_t tensor_is_equal(const tensor t1, const tensor t2);
bool tensor_is_empty(const tensor t);
bool tensor_is_equal(const tensor t1, const tensor t2);
uint8_t _tensor_check_size(const uint32_t *size, uint8_t rank);
uint8_t _tensor_set_size(tensor t, const uint32_t *size, uint8_t rank);