-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.h
More file actions
24 lines (20 loc) · 816 Bytes
/
utils.h
File metadata and controls
24 lines (20 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef UTILS_H
#define UTILS_H
#include "dynamic_array.h"
#include "tensor.h"
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <stdbool.h>
void* safeMalloc(size_t size, char *msg);
void* safeCalloc(size_t nmemb, size_t size, char *msg);
void* safeRealloc(void *p, size_t size, char *msg);
void daIsNullCheck(DynamicArray *da);
bool daNeedsResize(size_t size, size_t capacity);
bool daIndexInBounds(size_t size, size_t idx);
size_t tensorComputeSize(size_t ndim, const size_t *shape);
void tensorComputeStrides(size_t ndim, const size_t *shape, size_t *strides);
void tensorIsNullCheck(Tensor *t);
void linearToIndices(size_t linear, const size_t *shape, const size_t *strides, size_t ndim, size_t *out);
size_t indicesToLinear(const size_t *indices, const size_t *strides, size_t ndim);
#endif