oop_and_ml/easynn_test.cpp

47 lines
1.1 KiB
C++
Executable file

/**
* A simple test program helps you to debug your easynn implementation.
*/
#include <stdio.h>
#include "src/libeasynn.h"
int main()
{
program *prog = create_program();
int inputs0[] = {};
append_expression(prog, 0, "a", "Input", inputs0, 0);
//int inputs1[] = {0, 0};
//append_expression(prog, 1, "", "Add", inputs1, 2);
//int inputs2[] = {2, 2};
//append_expression(prog, 2, "", "Mul", inputs2, 2);
//int inputs3[] = {10, 5};
//append_expression(prog, 3, "", "Sub", inputs3, 2);
evaluation *eval = build(prog);
add_kwargs_double(eval, "a", 5);
// tensor tests
// it is easier for me
// to just compile the library and run the python grading tests than to use this program
int dim = 0;
size_t *shape = nullptr;
double *data = nullptr;
if (execute(eval, &dim, &shape, &data) != 0)
{
printf("evaluation fails\n");
return -1;
}
if (dim == 0)
printf("res = %f\n", data[0]);
else
printf("result as tensor is not supported yet\n");
return 0;
}