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

492 lines
22 KiB
Plaintext

#include "uNet.h"
#include "util.h"
#include "tensor.h"
#include <stdlib.h>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cmath>
// Parameters
Tensor *inc_double_conv_0_weight;
Tensor *inc_double_conv_1_weight;
Tensor *inc_double_conv_1_bias;
Tensor *inc_double_conv_3_weight;
Tensor *inc_double_conv_4_weight;
Tensor *inc_double_conv_4_bias;
Tensor *down1_maxpool_conv_1_double_conv_0_weight;
Tensor *down1_maxpool_conv_1_double_conv_1_weight;
Tensor *down1_maxpool_conv_1_double_conv_1_bias;
Tensor *down1_maxpool_conv_1_double_conv_3_weight;
Tensor *down1_maxpool_conv_1_double_conv_4_weight;
Tensor *down1_maxpool_conv_1_double_conv_4_bias;
Tensor *down2_maxpool_conv_1_double_conv_0_weight;
Tensor *down2_maxpool_conv_1_double_conv_1_weight;
Tensor *down2_maxpool_conv_1_double_conv_1_bias;
Tensor *down2_maxpool_conv_1_double_conv_3_weight;
Tensor *down2_maxpool_conv_1_double_conv_4_weight;
Tensor *down2_maxpool_conv_1_double_conv_4_bias;
Tensor *down3_maxpool_conv_1_double_conv_0_weight;
Tensor *down3_maxpool_conv_1_double_conv_1_weight;
Tensor *down3_maxpool_conv_1_double_conv_1_bias;
Tensor *down3_maxpool_conv_1_double_conv_3_weight;
Tensor *down3_maxpool_conv_1_double_conv_4_weight;
Tensor *down3_maxpool_conv_1_double_conv_4_bias;
Tensor *down4_maxpool_conv_1_double_conv_0_weight;
Tensor *down4_maxpool_conv_1_double_conv_1_weight;
Tensor *down4_maxpool_conv_1_double_conv_1_bias;
Tensor *down4_maxpool_conv_1_double_conv_3_weight;
Tensor *down4_maxpool_conv_1_double_conv_4_weight;
Tensor *down4_maxpool_conv_1_double_conv_4_bias;
Tensor *up1_up_weight;
Tensor *up1_up_bias;
Tensor *up1_conv_double_conv_0_weight;
Tensor *up1_conv_double_conv_1_weight;
Tensor *up1_conv_double_conv_1_bias ;
Tensor *up1_conv_double_conv_3_weight;
Tensor *up1_conv_double_conv_4_weight;
Tensor *up1_conv_double_conv_4_bias ;
Tensor *up2_up_weight;
Tensor *up2_up_bias;
Tensor *up2_conv_double_conv_0_weight;
Tensor *up2_conv_double_conv_1_weight;
Tensor *up2_conv_double_conv_1_bias;
Tensor *up2_conv_double_conv_3_weight;
Tensor *up2_conv_double_conv_4_weight;
Tensor *up2_conv_double_conv_4_bias;
Tensor *up3_up_weight;
Tensor *up3_up_bias;
Tensor *up3_conv_double_conv_0_weight;
Tensor *up3_conv_double_conv_1_weight;
Tensor *up3_conv_double_conv_1_bias;
Tensor *up3_conv_double_conv_3_weight;
Tensor *up3_conv_double_conv_4_weight;
Tensor *up3_conv_double_conv_4_bias;
Tensor *up4_up_weight;
Tensor *up4_up_bias;
Tensor *up4_conv_double_conv_0_weight;
Tensor *up4_conv_double_conv_1_weight;
Tensor *up4_conv_double_conv_1_bias;
Tensor *up4_conv_double_conv_3_weight;
Tensor *up4_conv_double_conv_4_weight;
Tensor *up4_conv_double_conv_4_bias;
Tensor *outc_conv_weight;
Tensor *outc_conv_bias;
// Activations
Tensor *inc_conv_0_output;
Tensor *inc_batchnorm_0_output;
Tensor *inc_conv_1_output;
Tensor *inc_batchnorm_1_output;
Tensor *down1_maxpool2d_0_output;
Tensor *down1_conv_0_output;
Tensor *down1_batchnorm_0_output;
Tensor *down1_conv_1_output;
Tensor *down1_batchnorm_1_output;
Tensor *down2_maxpool2d_0_output;
Tensor *down2_conv_0_output;
Tensor *down2_batchnorm_0_output;
Tensor *down2_conv_1_output;
Tensor *down2_batchnorm_1_output;
Tensor *down3_maxpool2d_0_output;
Tensor *down3_conv_0_output;
Tensor *down3_batchnorm_0_output;
Tensor *down3_conv_1_output;
Tensor *down3_batchnorm_1_output;
Tensor *down4_maxpool2d_0_output;
Tensor *down4_conv_0_output;
Tensor *down4_batchnorm_0_output;
Tensor *down4_conv_1_output;
Tensor *down4_batchnorm_1_output;
Tensor *up1_convt_0_output;
Tensor *up1_concat_0_output;
Tensor *up2_convt_0_output;
Tensor *up2_concat_0_output;
Tensor *up3_convt_0_output;
Tensor *up3_concat_0_output;
Tensor *up4_convt_0_output;
Tensor *up4_concat_0_output;
Tensor *outc_conv_0_output;
// forward declaration, prototype
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(int, float*, char*);
void uNet_finalize();
/*
* uNet
*/
void uNet(float *input, float *output) {
Tensor *input_tensor = new Tensor({1,2,3,4}, input); // TODO
Tensor *output_tensor = new Tensor({1,2,3,4}); // TODO
// inc(n_channels, 64)
Conv2d(input_tensor, inc_double_conv_0_weight, NULL, inc_conv_0_output, 1, 1, 0, false);
BatchNorm2d(inc_conv_0_output, inc_double_conv_1_weight, inc_double_conv_1_bias, NULL, NULL, inc_batchnorm_0_output, 1e-5);
ReLU(inc_batchnorm_0_output);
Conv2d(inc_batchnorm_0_output, inc_double_conv_3_weight, NULL, inc_conv_1_output, 1, 1, 0, false);
BatchNorm2d(inc_conv_1_output, inc_double_conv_4_weight, inc_double_conv_4_bias, NULL, NULL, inc_batchnorm_1_output, 1e-5);
ReLU(inc_batchnorm_1_output);
// down1(64, 128)
MaxPool2d(inc_batchnorm_1_output, down1_maxpool2d_0_output);
Conv2d(down1_maxpool2d_0_output, down1_maxpool_conv_1_double_conv_0_weight, NULL, down1_conv_0_output, 1, 1, 0, false);
BatchNorm2d(down1_conv_0_output, down1_maxpool_conv_1_double_conv_1_weight, down1_maxpool_conv_1_double_conv_1_bias, NULL, NULL, down1_batchnorm_0_output, 1e-5);
ReLU(down1_batchnorm_0_output);
Conv2d(down1_batchnorm_0_output, down1_maxpool_conv_1_double_conv_3_weight, NULL, down1_conv_1_output, 1, 1, 0, false);
BatchNorm2d(down1_conv_1_output, down1_maxpool_conv_1_double_conv_4_weight, down1_maxpool_conv_1_double_conv_4_bias, NULL, NULL, down1_batchnorm_1_output, 1e-5);
ReLU(down1_batchnorm_1_output);
// down2(128, 256)
MaxPool2d(down1_batchnorm_1_output, down2_maxpool2d_0_output);
Conv2d(down2_maxpool2d_0_output, down2_maxpool_conv_1_double_conv_0_weight, NULL, down2_conv_0_output, 1, 1, 0, false);
BatchNorm2d(down2_conv_0_output, down2_maxpool_conv_1_double_conv_1_weight, down2_maxpool_conv_1_double_conv_1_bias, NULL, NULL, down2_batchnorm_0_output, 1e-5);
ReLU(down2_batchnorm_0_output);
Conv2d(down2_batchnorm_0_output, down2_maxpool_conv_1_double_conv_3_weight, NULL, down2_conv_1_output, 1, 1, 0, false);
BatchNorm2d(down2_conv_1_output, down2_maxpool_conv_1_double_conv_4_weight, down2_maxpool_conv_1_double_conv_4_bias, NULL, NULL, down2_batchnorm_1_output, 1e-5);
ReLU(down2_batchnorm_1_output);
// down3(256, 512)
MaxPool2d(down2_batchnorm_1_output, down3_maxpool2d_0_output);
Conv2d(down3_maxpool2d_0_output, down3_maxpool_conv_1_double_conv_0_weight, NULL, down3_conv_0_output, 1, 1, 0, false);
BatchNorm2d(down3_conv_0_output, down3_maxpool_conv_1_double_conv_1_weight, down3_maxpool_conv_1_double_conv_1_bias, NULL, NULL, down3_batchnorm_0_output, 1e-5);
ReLU(down3_batchnorm_0_output);
Conv2d(down3_batchnorm_0_output, down3_maxpool_conv_1_double_conv_3_weight, NULL, down3_conv_1_output, 1, 1, 0, false);
BatchNorm2d(down3_conv_1_output, down3_maxpool_conv_1_double_conv_4_weight, down3_maxpool_conv_1_double_conv_4_bias, NULL, NULL, down3_batchnorm_1_output, 1e-5);
ReLU(down3_batchnorm_1_output);
// down4(512, 1024)
MaxPool2d(down3_batchnorm_1_output, down4_maxpool2d_0_output);
Conv2d(down4_maxpool2d_0_output, down4_maxpool_conv_1_double_conv_0_weight, NULL, down4_conv_0_output, 1, 1, 0, false);
BatchNorm2d(down4_conv_0_output, down4_maxpool_conv_1_double_conv_1_weight, down4_maxpool_conv_1_double_conv_1_bias, NULL, NULL, down4_batchnorm_0_output, 1e-5);
ReLU(down4_batchnorm_0_output);
Conv2d(down4_batchnorm_0_output, down4_maxpool_conv_1_double_conv_3_weight, NULL, down4_conv_1_output, 1, 1, 0, false);
BatchNorm2d(down4_conv_1_output, down4_maxpool_conv_1_double_conv_4_weight, down4_maxpool_conv_1_double_conv_4_bias, NULL, NULL, down4_batchnorm_1_output, 1e-5);
ReLU(down4_batchnorm_1_output);
// up1(1024, 512), (down4_batchnorm_1_output, down3_batchnorm_1_output)
ConvTranspose2d(down4_batchnorm_1_output, up1_up_weight, up1_up_bias, up1_convt_0_output, 2, 0);
Concat(up1_convt_0_output, down3_batchnorm_1_output, up1_concat_0_output);
// up2(512, 256), (up1_concat_0_output, down2_batchnorm_1_output)
ConvTranspose2d(up1_concat_0_output, up2_up_weight, up2_up_bias, up2_convt_0_output, 2, 0);
Concat(up2_convt_0_output, down2_batchnorm_1_output, up2_concat_0_output);
// up3(256, 128), (up2_concat_0_output, down1_batchnorm_1_output)
ConvTranspose2d(up2_concat_0_output, up3_up_weight, up3_up_bias, up3_convt_0_output, 2, 0);
Concat(up3_convt_0_output, down2_batchnorm_1_output, up3_concat_0_output);
// up4(128, 64), (up3_concat_0_output, inc_batchnorm_1_output)
ConvTranspose2d(up3_concat_0_output, up4_up_weight, up4_up_bias, up4_convt_0_output, 2, 0);
Concat(up4_convt_0_output, down2_batchnorm_1_output, up4_concat_0_output);
// outc(64, n_classes)
Conv2d(up4_concat_0_output, outc_conv_weight, outc_conv_bias, output_tensor, 1, 0, 0, true);
output = output_tensor->buf;
}
/*
* Convolution
* input shape = (C, H, W)
* weight shape = (K, C, R, S)
* bias shape = (K)
* output shape = (K, OH, OW)
* where OH = (H + 2 * pad - dilation * (R - 1) - 1) / stride + 1,
* OW = (W + 2 * pad - dilation * (S - 1) - 1) / stride + 1
*/
void Conv2d(Tensor *input, Tensor *weight, Tensor *bias, Tensor *output, int stride, int pad, int dilation, bool has_bias) {
int C = input->shape[0], H = input->shape[1], W = input->shape[2];
int K = weight->shape[0], R = weight->shape[2], S = weight->shape[3];
int OH = output->shape[1], OW = output->shape[2];
CHECK_ERROR(OH == (H + 2 * pad - dilation * (R - 1) - 1) / stride + 1, "Output height mismatch");
CHECK_ERROR(OW == (W + 2 * pad - dilation * (S - 1) - 1) / stride + 1, "Output width mismatch");
CHECK_ERROR(weight->shape[1] == C && (!has_bias || bias->shape[0] == K) && output->shape[0] == K, "Channel size mismatch");
for (int k = 0; k < K; ++k) {
for (int oh = 0; oh < OH; ++oh) {
for (int ow = 0; ow < OW; ++ow) {
float o = has_bias ? bias->buf[k] : 0;
for (int c = 0; c < C; ++c) {
for (int r = 0; r < R; ++r) {
for (int s = 0; s < S; ++s) {
int h = oh * stride - pad + r * dilation;
int w = ow * stride - pad + s * dilation;
if (h < 0 || h >= H || w < 0 || w >= W) continue;
float i = input->buf[c * H * W + h * W + w];
float f = weight->buf[k * C * R * S + c * R * S + r * S + s];
o += i * f;
}
}
}
output->buf[k * OH * OW + oh * OW + ow] = o;
}
}
}
}
/*
* ReLU
* Formula: y = max(x, 0)
*/
void ReLU(Tensor *inout) {
int C = inout->shape[0], H = inout->shape[1], W = inout->shape[2];
for (int c = 0; c < C; ++c) {
for (int h = 0; h < H; ++h) {
for (int w = 0; w < W; ++w) {
int idx = c * H * W + h * W + w;
inout->buf[idx] = inout->buf[idx] > 0 ? inout->buf[idx] : 0;
}
}
}
}
/*
* Batch Normaliztion
* input shape = (C, H, W)
* weight shape = (C)
* bias shape = (C)
* running_mean shape = (C)
* running_var shape = (C)
* output shape = (C, H, W)
*/
void BatchNorm2d(Tensor *input, Tensor *weight, Tensor *bias, Tensor *running_mean, Tensor *running_var, Tensor *output, const float eps) {
int C = input->shape[0], H = input->shape[1], W = input->shape[2];
CHECK_ERROR(weight->shape[0] == C && bias->shape[0] == C && running_mean->shape[0] == C && running_var->shape[0] == C, "Shape mismatch");
CHECK_ERROR(output->shape[0] == C && output->shape[1] == H && output->shape[2] == W, "Shape mismatch");
for (int c = 0; c < C; ++c) {
for (int h = 0; h < H; ++h) {
for (int w = 0; w < W; ++w) {
int idx = c * H * W + h * W + w;
output->buf[idx] = (input->buf[idx] - running_mean->buf[c]) / sqrtf(running_var->buf[c] + eps) * weight->buf[c] + bias->buf[c];
}
}
}
}
/*
* Transposed convolution
* input shape = (C, H, W)
* weight shape = (C, K, R, S)
* bias shape = (K)
* output shape = (K, OH, OW)
* where OH = (H - 1) * stride - 2 * pad + R
* OW = (W - 1) * stride - 2 * pad + S
*/
void ConvTranspose2d(Tensor *input, Tensor *weight, Tensor *bias, Tensor *output, int stride, int pad) {
int C = input->shape[0], H = input->shape[1], W = input->shape[2];
int K = weight->shape[1], R = weight->shape[2], S = weight->shape[3];
int OH = output->shape[1], OW = output->shape[2];
CHECK_ERROR(OH == (H - 1) * stride - 2 * pad + R, "Output height mismatch");
CHECK_ERROR(OW == (W - 1) * stride - 2 * pad + S, "Output width mismatch");
CHECK_ERROR(weight->shape[0] == C && bias->shape[0] == K && output->shape[0] == K, "Channel size mismatch");
for (int k = 0; k < K; ++k) {
for (int oh = 0; oh < OH; ++oh) {
for (int ow = 0; ow < OW; ++ow) {
float o = bias->buf[k];
for (int c = 0; c < C; ++c) {
for (int r = 0; r < R; ++r) {
for (int s = 0; s < S; ++s) {
if ((oh + pad - r) % stride != 0) continue;
if ((ow + pad - s) % stride != 0) continue;
int h = (oh + pad - r) / stride;
int w = (ow + pad - s) / stride;
if (h < 0 || h >= H || w < 0 || w >= W) continue;
float i = input->buf[c * H * W + h * W + w];
float f = weight->buf[c * K * R * S + k * R * S + r * S + s];
o += i * f;
}
}
}
output->buf[k * OH * OW + oh * OW + ow] = o;
}
}
}
}
/*
* Softmax
* Formula: y = e^x / sum(e^x)
*/
void Softmax(Tensor *input, Tensor *output) {
int C = input->shape[0], H = input->shape[1], W = input->shape[2];
CHECK_ERROR(output->shape[0] == C && output->shape[1] == H && output->shape[2] == W, "shape mismatch");
for (int h = 0; h < H; ++h) {
for (int w = 0; w < W; ++w) {
float sum = 0;
for (int c = 0; c < C; ++c) {
sum += expf(input->buf[c * H * W + h * W + w]);
}
for (int c = 0; c < C; ++c) {
output->buf[c * H * W + h * W + w] = expf(input->buf[c * H * W + h * W + w]) / sum;
}
}
}
}
void MaxPool2d(Tensor *input, Tensor *output){}
void Concat(Tensor *input1, Tensor *input2, Tensor *output){}
/*
* uNet_initialize
* Initialize the model. Do input-independent job here.
*/
void uNet_initialize(int N, int random_seed, char *parameter_fname) {
size_t parameter_binary_size = 0;
float *parameter = (float *)read_binary(parameter_fname, &parameter_binary_size);
inc_double_conv_0_weight = new Tensor({64,3,3,3}, parameter + OFFSET0);
inc_double_conv_1_weight = new Tensor({64}, parameter + OFFSET1);
inc_double_conv_1_bias = new Tensor({64}, parameter + OFFSET2);
inc_double_conv_3_weight = new Tensor({64,64,3,3}, parameter + OFFSET3);
inc_double_conv_4_weight = new Tensor({64}, parameter + OFFSET4);
inc_double_conv_4_bias = new Tensor({64}, parameter + OFFSET5);
down1_maxpool_conv_1_double_conv_0_weight = new Tensor({128,64,3,3}, parameter + OFFSET6);
down1_maxpool_conv_1_double_conv_1_weight = new Tensor({128}, parameter + OFFSET7);
down1_maxpool_conv_1_double_conv_1_bias = new Tensor({128}, parameter + OFFSET8);
down1_maxpool_conv_1_double_conv_3_weight = new Tensor({128,3,3}, parameter + OFFSET9);
down1_maxpool_conv_1_double_conv_4_weight = new Tensor({128}, parameter + OFFSET10);
down1_maxpool_conv_1_double_conv_4_bias = new Tensor({128}, parameter + OFFSET11);
down2_maxpool_conv_1_double_conv_0_weight = new Tensor({256,128,3,3}, parameter + OFFSET12);
down2_maxpool_conv_1_double_conv_1_weight = new Tensor({256}, parameter + OFFSET13);
down2_maxpool_conv_1_double_conv_1_bias = new Tensor({256}, parameter + OFFSET14);
down2_maxpool_conv_1_double_conv_3_weight = new Tensor({256,256,3,3}, parameter + OFFSET15);
down2_maxpool_conv_1_double_conv_4_weight = new Tensor({256}, parameter + OFFSET16);
down2_maxpool_conv_1_double_conv_4_bias = new Tensor({256}, parameter + OFFSET17);
down3_maxpool_conv_1_double_conv_0_weight = new Tensor({512,256,3,3}, parameter + OFFSET18);
down3_maxpool_conv_1_double_conv_1_weight = new Tensor({512}, parameter + OFFSET19);
down3_maxpool_conv_1_double_conv_1_bias = new Tensor({512}, parameter + OFFSET20);
down3_maxpool_conv_1_double_conv_3_weight = new Tensor({512,512,3,3}, parameter + OFFSET21);
down3_maxpool_conv_1_double_conv_4_weight = new Tensor({512}, parameter + OFFSET22);
down3_maxpool_conv_1_double_conv_4_bias = new Tensor({512}, parameter + OFFSET23);
down4_maxpool_conv_1_double_conv_0_weight = new Tensor({1024,512,3,3}, parameter + OFFSET24);
down4_maxpool_conv_1_double_conv_1_weight = new Tensor({1024}, parameter + OFFSET25);
down4_maxpool_conv_1_double_conv_1_bias = new Tensor({1024}, parameter + OFFSET26);
down4_maxpool_conv_1_double_conv_3_weight = new Tensor({1024,1024,3,3}, parameter + OFFSET27);
down4_maxpool_conv_1_double_conv_4_weight = new Tensor({1024}, parameter + OFFSET28);
down4_maxpool_conv_1_double_conv_4_bias = new Tensor({1024}, parameter + OFFSET29);
up1_up_weight = new Tensor({1024,512,2,2}, parameter + OFFSET30);
up1_up_bias = new Tensor({512}, parameter + OFFSET31);
up1_conv_double_conv_0_weight = new Tensor({512,1024,3,3}, parameter + OFFSET32);
up1_conv_double_conv_1_weight = new Tensor({512}, parameter + OFFSET33);
up1_conv_double_conv_1_bias = new Tensor({512}, parameter + OFFSET34);
up1_conv_double_conv_3_weight = new Tensor({512,512,3,3}, parameter + OFFSET35);
up1_conv_double_conv_4_weight = new Tensor({512}, parameter + OFFSET36);
up1_conv_double_conv_4_bias = new Tensor({512}, parameter + OFFSET37);
up2_up_weight = new Tensor({512,256,2,2}, parameter + OFFSET38);
up2_up_bias = new Tensor({256}, parameter + OFFSET39);
up2_conv_double_conv_0_weight = new Tensor({256,512,3,3}, parameter + OFFSET40);
up2_conv_double_conv_1_weight = new Tensor({256}, parameter + OFFSET41);
up2_conv_double_conv_1_bias = new Tensor({256}, parameter + OFFSET42);
up2_conv_double_conv_3_weight = new Tensor({256,256,3,3}, parameter + OFFSET43);
up2_conv_double_conv_4_weight = new Tensor({256}, parameter + OFFSET44);
up2_conv_double_conv_4_bias = new Tensor({256}, parameter + OFFSET45);
up3_up_weight = new Tensor({256,128,2,2}, parameter + OFFSET46);
up3_up_bias = new Tensor({128}, parameter + OFFSET47);
up3_conv_double_conv_0_weight = new Tensor({128,256,3,3}, parameter + OFFSET48);
up3_conv_double_conv_1_weight = new Tensor({128}, parameter + OFFSET49);
up3_conv_double_conv_1_bias = new Tensor({128}, parameter + OFFSET50);
up3_conv_double_conv_3_weight = new Tensor({128,128,3,3}, parameter + OFFSET51);
up3_conv_double_conv_4_weight = new Tensor({128}, parameter + OFFSET52);
up3_conv_double_conv_4_bias = new Tensor({128}, parameter + OFFSET53);
up4_up_weight = new Tensor({128,64,2,2}, parameter + OFFSET54);
up4_up_bias = new Tensor({64}, parameter + OFFSET55);
up4_conv_double_conv_0_weight = new Tensor({64,128,3,3}, parameter + OFFSET56);
up4_conv_double_conv_1_weight = new Tensor({64}, parameter + OFFSET57);
up4_conv_double_conv_1_bias = new Tensor({64}, parameter + OFFSET58);
up4_conv_double_conv_3_weight = new Tensor({64,64,3,3}, parameter + OFFSET59);
up4_conv_double_conv_4_weight = new Tensor({64}, parameter + OFFSET60);
up4_conv_double_conv_4_bias = new Tensor({}, parameter + OFFSET61);
outc_conv_weight = new Tensor({2,64,1,1}, parameter + OFFSET62);
outc_conv_bias = new Tensor({2}, parameter + OFFSET63);
}
/*
* uNet_finalize
* Finalize the model.
*/
void uNet_finalize() {
delete inc_double_conv_0_weight;
delete inc_double_conv_1_weight;
delete inc_double_conv_1_bias;
delete inc_double_conv_3_weight;
delete inc_double_conv_4_weight;
delete inc_double_conv_4_bias;
delete down1_maxpool_conv_1_double_conv_0_weight;
delete down1_maxpool_conv_1_double_conv_1_weight;
delete down1_maxpool_conv_1_double_conv_1_bias;
delete down1_maxpool_conv_1_double_conv_3_weight;
delete down1_maxpool_conv_1_double_conv_4_weight;
delete down1_maxpool_conv_1_double_conv_4_bias;
delete down2_maxpool_conv_1_double_conv_0_weight;
delete down2_maxpool_conv_1_double_conv_1_weight;
delete down2_maxpool_conv_1_double_conv_1_bias;
delete down2_maxpool_conv_1_double_conv_3_weight;
delete down2_maxpool_conv_1_double_conv_4_weight;
delete down2_maxpool_conv_1_double_conv_4_bias;
delete down3_maxpool_conv_1_double_conv_0_weight;
delete down3_maxpool_conv_1_double_conv_1_weight;
delete down3_maxpool_conv_1_double_conv_1_bias;
delete down3_maxpool_conv_1_double_conv_3_weight;
delete down3_maxpool_conv_1_double_conv_4_weight;
delete down3_maxpool_conv_1_double_conv_4_bias;
delete down4_maxpool_conv_1_double_conv_0_weight;
delete down4_maxpool_conv_1_double_conv_1_weight;
delete down4_maxpool_conv_1_double_conv_1_bias;
delete down4_maxpool_conv_1_double_conv_3_weight;
delete down4_maxpool_conv_1_double_conv_4_weight;
delete down4_maxpool_conv_1_double_conv_4_bias;
delete up1_up_weight;
delete up1_up_bias;
delete up1_conv_double_conv_0_weight;
delete up1_conv_double_conv_1_weight;
delete up1_conv_double_conv_1_bias ;
delete up1_conv_double_conv_3_weight;
delete up1_conv_double_conv_4_weight;
delete up1_conv_double_conv_4_bias ;
delete up2_up_weight;
delete up2_up_bias;
delete up2_conv_double_conv_0_weight;
delete up2_conv_double_conv_1_weight;
delete up2_conv_double_conv_1_bias;
delete up2_conv_double_conv_3_weight;
delete up2_conv_double_conv_4_weight;
delete up2_conv_double_conv_4_bias;
delete up3_up_weight;
delete up3_up_bias;
delete up3_conv_double_conv_0_weight;
delete up3_conv_double_conv_1_weight;
delete up3_conv_double_conv_1_bias;
delete up3_conv_double_conv_3_weight;
delete up3_conv_double_conv_4_weight;
delete up3_conv_double_conv_4_bias;
delete up4_up_weight;
delete up4_up_bias;
delete up4_conv_double_conv_0_weight;
delete up4_conv_double_conv_1_weight;
delete up4_conv_double_conv_1_bias;
delete up4_conv_double_conv_3_weight;
delete up4_conv_double_conv_4_weight;
delete up4_conv_double_conv_4_bias;
delete outc_conv_weight;
delete outc_conv_bias;
}