Put dtype definition in separate file.
This commit is contained in:
23
dtype.h
Normal file
23
dtype.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _DTYPE_H_INCLUDED_
|
||||
#define _DTYPE_H_INCLUDED_
|
||||
|
||||
|
||||
/* Defining the datatype of the tensor */
|
||||
typedef float dtype;
|
||||
/* dtype needs to implement add, sub, mul and div, */
|
||||
#define DTYPE_ADD(a, b) ((a) + (b))
|
||||
#define DTYPE_SUB(a, b) ((a) - (b))
|
||||
#define DTYPE_MUL(a, b) ((a) * (b))
|
||||
#define DTYPE_DIV(a, b) ((a) / (b))
|
||||
/* equal and not equal,*/
|
||||
#define DTYPE_EQ(a, b) ((a) == (b))
|
||||
#define DTYPE_NE(a, b) ((a) != (b))
|
||||
/* one and zero, */
|
||||
#define DTYPE_ONE 1.0
|
||||
#define DTYPE_ZERO 0.0
|
||||
/* and a random and pruint8_t function */
|
||||
#define DTYPE_RAND(max) ((float) rand() / RAND_MAX * (max))
|
||||
#define DTYPE_PRINT(a) (printf(" %4.1f ", (a)))
|
||||
|
||||
|
||||
#endif // _DTYPE_H_INCLUDED_
|
||||
25
tensor.h
25
tensor.h
@@ -1,31 +1,16 @@
|
||||
#ifndef TENSOR_H_INCLUDED
|
||||
#define TENSOR_H_INCLUDED
|
||||
#ifndef _TENSOR_H_INCLUDED_
|
||||
#define _TENSOR_H_INCLUDED_
|
||||
|
||||
#include "dtype.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Defining the datatype of the tensor */
|
||||
typedef float dtype;
|
||||
/* dtype needs to implement add, sub, mul and div, */
|
||||
#define DTYPE_ADD(a, b) ((a) + (b))
|
||||
#define DTYPE_SUB(a, b) ((a) - (b))
|
||||
#define DTYPE_MUL(a, b) ((a) * (b))
|
||||
#define DTYPE_DIV(a, b) ((a) / (b))
|
||||
/* equal and not equal,*/
|
||||
#define DTYPE_EQ(a, b) ((a) == (b))
|
||||
#define DTYPE_NE(a, b) ((a) != (b))
|
||||
/* one and zero, */
|
||||
#define DTYPE_ONE 1.0
|
||||
#define DTYPE_ZERO 0.0
|
||||
/* and a random and pruint8_t function */
|
||||
#define DTYPE_RAND(max) ((float) rand() / RAND_MAX * (max))
|
||||
#define DTYPE_PRINT(a) (printf(" %4.1f ", (a)))
|
||||
|
||||
|
||||
typedef struct _tensor {
|
||||
dtype *elements;
|
||||
|
||||
Reference in New Issue
Block a user