diff --git a/src/tensor.cpp b/src/tensor.cpp deleted file mode 100644 index bcdbcb9..0000000 --- a/src/tensor.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include -#include -#include "tensor.h" - -extern "C" { - - Tensor *create_tensor(float *data, int *shape, int ndim) { - Tensor *tensor = (Tensor *)malloc(sizeof(Tensor)); - if (tensor == NULL) { - fprintf(stderr, "Memory allocation failed\n"); - exit(1); - } - tensor->data = data; - tensor->shape = shape; - tensor->ndim = ndim; - - tensor->strides = (int *)malloc(ndim * sizeof(int)); - if (tensor->strides == NULL) { - fprintf(stderr, "Memory allocation failed\n"); - exit(1); - } - int stride = 1; - for (int i = ndim - 1; i >= 0; i--) { - tensor->strides[i] = stride; - stride *= shape[i]; - } - - printf("Tensor created successfully\n"); - printf("Tensor information:\n"); - printf("Number of dimensions: %d\n", tensor->ndim); - printf("Shape: ["); - for (int i = 0; i < ndim; i++) { - printf("%d", tensor->shape[i]); - if (i < ndim - 1) { - printf(", "); - } - } - printf("]\n"); - - printf("Data:\n["); - for (int i = 0; i < stride; i++) { - printf("%.2f", tensor->data[i]); - if (i < stride - 1) { - printf(", "); - } - } - printf("]\n"); - - - return tensor; - } - - float get_item(Tensor *tensor, int *indices) { - int index = 0; - for (int i = 0; i < tensor->ndim; i++) { - index += indices[i] * tensor->strides[i]; - } - return tensor->data[index]; - } - - void free_tensor(Tensor *tensor) { - free(tensor->data); - free(tensor->shape); - free(tensor->strides); - free(tensor); - } -} diff --git a/src/tensor.h b/src/tensor.h deleted file mode 100644 index f93b22a..0000000 --- a/src/tensor.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef TENSOR_H -#define TENSOR_H - -typedef struct { - float *data; - int *strides; - int *shape; - int ndim; -} Tensor; - -extern "C" { - Tensor *create_tensor(float *data, int *shape, int ndim); - float get_item(Tensor *tensor, int *indices); - void delete_tensor(Tensor* tensor); -} - -#endif /* TENSOR_H */ diff --git a/src/tensor.o b/src/tensor.o deleted file mode 100644 index 237b41a..0000000 Binary files a/src/tensor.o and /dev/null differ