chundoong-lab-ta/APWS23/project/main.cpp

51 lines
980 B
C++
Raw Normal View History

2023-02-01 22:30:00 +09:00
#include <cstdio>
#include <cstdlib>
#include <unistd.h>
2023-02-02 19:02:36 +09:00
#include "uNet.h"
2023-02-01 22:30:00 +09:00
#include "util.h"
// Global variables
int N = 1;
int random_seed = 1;
int print_max = 8;
int MAX_LEN = 10;
char *parameter_fname;
char *output_fname;
char *input_fname;
2023-02-01 22:30:00 +09:00
int main(int argc, char **argv) {
check_and_parse_args(argc, argv);
// Initialize model
2023-02-02 23:37:40 +09:00
uNet_initialize(N, random_seed, parameter_fname);
2023-02-01 22:30:00 +09:00
Tensor *input = new Tensor({1, 3, 640, 959});
Tensor *output = new Tensor({1, 2, 640, 959});
size_t input_size = 0; // byte
input->buf = (float*)read_binary(input_fname, &input_size);
2023-02-03 01:25:19 +09:00
printf("running %d images...", N);
2023-02-01 22:30:00 +09:00
fflush(stdout);
2023-02-03 01:25:19 +09:00
// run uNet and measure time
2023-02-02 23:37:40 +09:00
double uNet_st = get_time();
2023-02-01 22:30:00 +09:00
2023-02-03 01:25:19 +09:00
uNet(input, output);
2023-02-01 22:30:00 +09:00
2023-02-02 23:37:40 +09:00
double uNet_en = get_time();
2023-02-01 22:30:00 +09:00
2023-02-02 23:37:40 +09:00
double elapsed_time = uNet_en - uNet_st;
2023-02-05 18:26:22 +09:00
printf("Done! %lf s\n", elapsed_time);
2023-02-01 22:30:00 +09:00
// Print first few result
// print_first_few_result(output, print_max, elapsed_time);
2023-02-01 22:30:00 +09:00
// Finalize program
2023-02-02 23:37:40 +09:00
uNet_finalize();
2023-02-01 22:30:00 +09:00
}