chundoong-lab-ta/APWS23/project/uNet.h

84 lines
3.2 KiB
C

#pragma once
#include "tensor.h"
// Model parameters
#define PARAMETER_FILE_SIZE 45663232
#define NUM_IMAGES 256
#define OFFSET0 0
#define OFFSET1 (OFFSET0 + 64*3*3*3)
#define OFFSET2 (OFFSET1 + 64)
#define OFFSET3 (OFFSET2 + 64)
#define OFFSET4 (OFFSET3 + 64*64*3*3)
#define OFFSET5 (OFFSET4 + 64)
#define OFFSET6 (OFFSET5 + 64)
#define OFFSET7 (OFFSET6 + 128*64*3*3)
#define OFFSET8 (OFFSET7 + 128)
#define OFFSET9 (OFFSET8 + 128)
#define OFFSET10 (OFFSET9 + 128*128*3*3)
#define OFFSET11 (OFFSET10 + 128)
#define OFFSET12 (OFFSET11 + 128)
#define OFFSET13 (OFFSET12 + 256*128*3*3)
#define OFFSET14 (OFFSET13 + 256)
#define OFFSET15 (OFFSET14 + 256)
#define OFFSET16 (OFFSET15 + 256*256*3*3)
#define OFFSET17 (OFFSET16 + 256)
#define OFFSET18 (OFFSET17 + 256)
#define OFFSET19 (OFFSET18 + 512*256*3*3)
#define OFFSET20 (OFFSET19 + 512)
#define OFFSET21 (OFFSET20 + 512)
#define OFFSET22 (OFFSET21 + 512*512*3*3)
#define OFFSET23 (OFFSET22 + 512)
#define OFFSET24 (OFFSET23 + 512)
#define OFFSET25 (OFFSET24 + 1024*512*3*3)
#define OFFSET26 (OFFSET25 + 1024)
#define OFFSET27 (OFFSET26 + 1024)
#define OFFSET28 (OFFSET27 + 1024*1024*3*3)
#define OFFSET29 (OFFSET28 + 1024)
#define OFFSET30 (OFFSET29 + 1024)
#define OFFSET31 (OFFSET30 + 1024*512*2*2)
#define OFFSET32 (OFFSET31 + 512)
#define OFFSET33 (OFFSET32 + 512*1024*3*3)
#define OFFSET34 (OFFSET33 + 512)
#define OFFSET35 (OFFSET34 + 512)
#define OFFSET36 (OFFSET35 + 512*512*3*3)
#define OFFSET37 (OFFSET36 + 512)
#define OFFSET38 (OFFSET37 + 512)
#define OFFSET39 (OFFSET38 + 512*256*2*2)
#define OFFSET40 (OFFSET39 + 256)
#define OFFSET41 (OFFSET40 + 256*512*3*3)
#define OFFSET42 (OFFSET41 + 256)
#define OFFSET43 (OFFSET42 + 256)
#define OFFSET44 (OFFSET43 + 256*256*3*3)
#define OFFSET45 (OFFSET44 + 256)
#define OFFSET46 (OFFSET45 + 256)
#define OFFSET47 (OFFSET46 + 256*128*2*2)
#define OFFSET48 (OFFSET47 + 128)
#define OFFSET49 (OFFSET48 + 128*256*3*3)
#define OFFSET50 (OFFSET49 + 128)
#define OFFSET51 (OFFSET50 + 128)
#define OFFSET52 (OFFSET51 + 128*128*3*3)
#define OFFSET53 (OFFSET52 + 128)
#define OFFSET54 (OFFSET53 + 128)
#define OFFSET55 (OFFSET54 + 128*64*2*2)
#define OFFSET56 (OFFSET55 + 64)
#define OFFSET57 (OFFSET56 + 64*128*3*3)
#define OFFSET58 (OFFSET57 + 64)
#define OFFSET59 (OFFSET58 + 64)
#define OFFSET60 (OFFSET59 + 64*64*3*3)
#define OFFSET61 (OFFSET60 + 64)
#define OFFSET62 (OFFSET61 + 64)
#define OFFSET63 (OFFSET62 + 2*64*1*1)
void Conv2d(Tensor *input, Tensor *weight, Tensor *bias, Tensor *output, int stride, int pad, int dilation, bool has_bias);
void ReLU(Tensor *inout);
void BatchNorm2d(Tensor *input, Tensor *weight, Tensor *bias, Tensor *running_mean, Tensor *running_var, Tensor *output, const float eps);
void ConvTranspose2d(Tensor *input, Tensor *weight, Tensor *bias, Tensor *output, int stride, int pad);
void Softmax(Tensor *input, Tensor *output);
void MaxPool2d(Tensor *input, Tensor *output);
void Concat(Tensor *input1, Tensor *input2, Tensor *output);
void uNet_initialize(int, int, char*);
void uNet(Tensor*, Tensor*);
void uNet_finalize();