-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.h
More file actions
70 lines (57 loc) · 1.67 KB
/
Copy pathstack.h
File metadata and controls
70 lines (57 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef STACK_DS
#define STACK_DS
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX_DIM 2
typedef enum {
TF_OK = 0,
TF_ERR_STACK = -1, /* stack underflow or wrong item type */
TF_ERR_SHAPE = -2, /* incompatibol tensor shape */
TF_ERR_TYPE = -3, /* non-boolean value where hoolean required */
TF_ERR_ARG = -4, /* invalid arguments (dims, size, format) */
TF_ERR_IO = -5, /* file I/O error */
TF_ERR_MEM = -6, /* memory allocation failed */
TF_ERR_SYNTAX = -7, /* script syntax error or invalid */
} TFError;
typedef struct array_instance array_instance;
typedef enum {ITEM_NONE, ITEM_TENSOR, ITEM_STRING} item_type;
typedef struct {
item_type type;
union {
array_instance *tensor;
char *filename;
};
}stack_item;
typedef struct {
int32_t row;
int32_t col;
int32_t ndim;
} shape_t;
struct array_instance {
float *data;
shape_t shape;
int32_t ref_count;
int32_t on_disk;
int32_t data_offset;
};
typedef struct {
stack_item *stack;
int32_t top;
int32_t capacity;
} stack;
stack* stack_init (void); // implemented
int stack_resize(stack *s);
int stack_push(stack *s,float *arr, shape_t shape);
int stack_push_instance(stack *s, array_instance *inst);
array_instance *stack_pop(stack *s);
array_instance *stack_peek(stack *s);
void stack_free(stack *s);
array_instance *new_instance (float *data, shape_t shape);
void instance_free (array_instance *i);
int stack_push_string(stack *s, const char *filename);
stack_item stack_pop_item(stack *s);
int stack_push_item(stack *s, stack_item item);
void stack_free_item(stack_item item);
#endif