// File: /workspace/github_c_makefile_star2_O0/xtanitfy[P]Murphy/examples/mnist/mnist_train.c
// Function: MnistBuildTrainNet
int MnistBuildTrainNet(int batchSize,int h,int w)
{

#if 0
	DATA_LAYER_PARA_s inputPara;
	inputPara.hSize = h;
	inputPara.wSize = w;
	inputPara.channelSize = 1;
	strcpy(inputPara.typeName,"data");
	strcpy(inputPara.name,"data");
	int ret = DataLayer_register(pNetTrain,&inputPara);
	CHECK_EXPR_RET(ret != 0,ret);
#else
	LAYER_PARA_s para;
	para.select.dataLayer.hSize = h;
	para.select.dataLayer.wSize = w;
	para.select.dataLayer.channelSize = w;
	strcpy(para.typeName,"data");
	strcpy(para.name,"data");
	int ret = NET_addLayer(pNetTrain,&para);
	CHECK_EXPR_RET(ret != 0,ret);
#endif

#if 0
	CONV_LAYER_PARA_s convPara;
	memset(&convPara,0,sizeof(convPara));
	convPara.function = sigmoidExt;
	convPara.weightInit = weightInit;
	convPara.biasInit = biasInit;
	convPara.num = 6;
	convPara.kernelX = 5;
	convPara.kernelY = 5;
	convPara.strideX = 1;
	convPara.strideY = 1;
	strcpy(convPara.typeName,"conv");
	strcpy(convPara.name,"conv0");
	strcpy(convPara.namePrev[convPara.nNamePrev++],"data");
	ret = ConvLayer_register(pNetTrain,&convPara);
	CHECK_EXPR_RET(ret != 0,ret);
#else
	memset(&para,0,sizeof(para));
	para.select.convLayer.function = sigmoidExt;
	para.select.convLayer.weightInit = weightInit;
	para.select.convLayer.biasInit = biasInit;
	para.select.convLayer.num = 6;
	para.select.convLayer.kernelX = 5;
	para.select.convLayer.kernelY = 5;
	para.select.convLayer.strideX = 1;
	para.select.convLayer.strideY = 1;
	strcpy(para.typeName,"conv");
	strcpy(para.name,"conv0");
	strcpy(para.namePrev[para.nNamePrev++],"data");
	ret = NET_addLayer(pNetTrain,&para);
	CHECK_EXPR_RET(ret != 0,-1);
#endif

#if 0
	SAMP_LAYER_PARA_s sampPara;
	memset(&sampPara,0,sizeof(sampPara));
	sampPara.type = SAMP_TYPE_AVERAGE;
	sampPara.stride = 2;
	strcpy(sampPara.typeName,"samp");
	strcpy(sampPara.name,"samp0");
	strcpy(sampPara.namePrev[sampPara.nNamePrev++],"conv0");
	ret = SampLayer_register(pNetTrain,&sampPara);
	CHECK_EXPR_RET(ret != 0,ret);
#else
	memset(&para,0,sizeof(para));
	para.select.sampLayer.type = SAMP_TYPE_AVERAGE;
	para.select.sampLayer.stride = 2;
	strcpy(para.typeName,"samp");
	strcpy(para.name,"samp0");
	strcpy(para.namePrev[para.nNamePrev++],"conv0");
	ret = NET_addLayer(pNetTrain,&para);
	CHECK_EXPR_RET(ret != 0,ret);
#endif


#if 0
	CONV_LAYER_PARA_s convPara1;
	memset(&convPara1,0,sizeof(convPara1));
	convPara1.function = sigmoidExt;
	convPara1.weightInit = weightInit;
	convPara1.biasInit = biasInit;
	convPara1.num = 12;
	convPara1.kernelX = 5;
	convPara1.kernelY = 5;
	convPara1.strideX = 1;
	convPara1.strideY = 1;
	strcpy(convPara1.typeName,"conv");
	strcpy(convPara1.name,"conv1");
	strcpy(convPara1.namePrev[convPara1.nNamePrev++],"samp0");
	ret = ConvLayer_register(pNetTrain,&convPara1);
	CHECK_EXPR_RET(ret != 0,ret);
#else
	memset(&para,0,sizeof(para));
	para.select.convLayer.function = sigmoidExt;
	para.select.convLayer.weightInit = weightInit;
	para.select.convLayer.biasInit = biasInit;
	para.select.convLayer.num = 12;
	para.select.convLayer.kernelX = 5;
	para.select.convLayer.kernelY = 5;
	para.select.convLayer.strideX = 1;
	para.select.convLayer.strideY = 1;
	strcpy(para.typeName,"conv");
	strcpy(para.name,"conv1");
	strcpy(para.namePrev[para.nNamePrev++],"samp0");
	ret = NET_addLayer(pNetTrain,&para);
	CHECK_EXPR_RET(ret != 0,ret);
#endif

#if 0
	SAMP_LAYER_PARA_s sampPara1;
	memset(&sampPara1,0,sizeof(sampPara1));
	sampPara1.type = SAMP_TYPE_AVERAGE;
	sampPara1.stride = 2;
	strcpy(sampPara1.typeName,"samp");
	strcpy(sampPara1.name,"samp1");
	strcpy(sampPara1.namePrev[sampPara1.nNamePrev++],"conv1");
	ret = SampLayer_register(pNetTrain,&sampPara1);
	CHECK_EXPR_RET(ret != 0,ret);
#else
	memset(&para,0,sizeof(para));
	para.select.sampLayer.type = SAMP_TYPE_AVERAGE;
	para.select.sampLayer.stride = 2;
	strcpy(para.typeName,"samp");
	strcpy(para.name,"samp1");
	strcpy(para.namePrev[para.nNamePrev++],"conv1");
	ret = NET_addLayer(pNetTrain,&para);
	CHECK_EXPR_RET(ret != 0,ret);
#endif

#if 0
	LINEAR_LAYER_PARA_s linearPara;
	memset(&linearPara,0,sizeof(linearPara));
	strcpy(linearPara.typeName,"linear");
	strcpy(linearPara.name,"linear0");
	strcpy(linearPara.namePrev[linearPara.nNamePrev++],"samp1");
	LinearLayer_register(pNetTrain,&linearPara);
#else
	memset(&para,0,sizeof(para));
	strcpy(para.typeName,"linear");
	strcpy(para.name,"linear0");
	strcpy(para.namePrev[para.nNamePrev++],"samp1");
	ret = NET_addLayer(pNetTrain,&para);
	CHECK_EXPR_RET(ret != 0,ret);
#endif


#if 0	
	OUTPUT_LAYER_PARA_s outputPara;
	memset(&outputPara,0,sizeof(outputPara));
	strcpy(outputPara.typeName,"output");
	strcpy(outputPara.name,"output");
	strcpy(outputPara.namePrev[outputPara.nNamePrev++],"linear0");
	outputPara.num = 10;
	outputPara.function = sigmoidExt;
	outputPara.weightInit = Mnist_GetInitFw;
	outputPara.biasInit = biasInit;
	OutputLayer_register(pNetTrain,&outputPara);
#else
	memset(&para,0,sizeof(para));
	strcpy(para.typeName,"output");
	strcpy(para.name,"output");
	strcpy(para.namePrev[para.nNamePrev++],"linear0");
	para.select.outputLayer.num = 10;
	para.select.outputLayer.function = sigmoidExt;
	para.select.outputLayer.weightInit = Mnist_GetInitFw;
	para.select.outputLayer.biasInit = biasInit;
	ret = NET_addLayer(pNetTrain,&para);
	CHECK_EXPR_RET(ret != 0,ret);
#endif

	NET_printForward(pNetTrain);
	NET_printBackward(pNetTrain);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x34(%rbp)
leaq -0x2c8(%rbp), %rdi
addq $0x4, %rdi
leaq 0x9d68(%rip), %rsi      # 0xb010
callq 0x10a0
leaq -0x2c8(%rbp), %rdi
addq $0x44, %rdi
leaq 0x9d51(%rip), %rsi      # 0xb010
callq 0x10a0
movq 0xcff5(%rip), %rdi      # 0xe2c0
leaq -0x2c8(%rbp), %rsi
callq 0x3540
movl %eax, -0x2cc(%rbp)
cmpl $0x0, -0x2cc(%rbp)
je 0x1315
leaq 0x9d28(%rip), %rdi      # 0xb015
leaq 0x9d37(%rip), %rsi      # 0xb02b
leaq 0x9d3e(%rip), %rdx      # 0xb039
movl $0x3f, %ecx
movb $0x0, %al
callq 0x1030
movl -0x2cc(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x187b
leaq -0x2c8(%rbp), %rdi
xorl %esi, %esi
movl $0x2b8, %edx            # imm = 0x2B8
callq 0x1070
leaq 0x1cf1(%rip), %rax      # 0x3020
movq %rax, -0x28(%rbp)
leaq 0x1d66(%rip), %rax      # 0x30a0
movq %rax, -0x20(%rbp)
leaq 0x1fcb(%rip), %rax      # 0x3310
movq %rax, -0x18(%rbp)
movl $0x6, -0x40(%rbp)
movl $0x5, -0x3c(%rbp)
movl $0x5, -0x38(%rbp)
movl $0x1, -0x34(%rbp)
movl $0x1, -0x30(%rbp)
leaq -0x2c8(%rbp), %rdi
addq $0x4, %rdi
leaq 0x9cce(%rip), %rsi      # 0xb04c
callq 0x10a0
leaq -0x2c8(%rbp), %rdi
addq $0x44, %rdi
leaq 0x9cbc(%rip), %rsi      # 0xb051
callq 0x10a0
leaq -0x2c8(%rbp), %rdi
addq $0x84, %rdi
movl -0x44(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
cltq
shlq $0x6, %rax
addq %rax, %rdi
leaq 0x9c4d(%rip), %rsi      # 0xb010
callq 0x10a0
movq 0xcef1(%rip), %rdi      # 0xe2c0
leaq -0x2c8(%rbp), %rsi
callq 0x3540
movl %eax, -0x2cc(%rbp)
cmpl $0x0, -0x2cc(%rbp)
je 0x1417
leaq 0x9c24(%rip), %rdi      # 0xb015
leaq 0x9c33(%rip), %rsi      # 0xb02b
leaq 0x9c3a(%rip), %rdx      # 0xb039
movl $0x60, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x187b
leaq -0x2c8(%rbp), %rdi
xorl %esi, %esi
movl $0x2b8, %edx            # imm = 0x2B8
callq 0x1070
movl $0x0, -0x40(%rbp)
movl $0x2, -0x3c(%rbp)
leaq -0x2c8(%rbp), %rdi
addq $0x4, %rdi
leaq 0x9c0d(%rip), %rsi      # 0xb057
callq 0x10a0
leaq -0x2c8(%rbp), %rdi
addq $0x44, %rdi
leaq 0x9bfb(%rip), %rsi      # 0xb05c
callq 0x10a0
leaq -0x2c8(%rbp), %rdi
addq $0x84, %rdi
movl -0x44(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
cltq
shlq $0x6, %rax
addq %rax, %rdi
leaq 0x9bc2(%rip), %rsi      # 0xb051
callq 0x10a0
movq 0xce25(%rip), %rdi      # 0xe2c0
leaq -0x2c8(%rbp), %rsi
callq 0x3540
movl %eax, -0x2cc(%rbp)
cmpl $0x0, -0x2cc(%rbp)
je 0x14e5
leaq 0x9b58(%rip), %rdi      # 0xb015
leaq 0x9b67(%rip), %rsi      # 0xb02b
leaq 0x9b6e(%rip), %rdx      # 0xb039
movl $0x75, %ecx
movb $0x0, %al
callq 0x1030
movl -0x2cc(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x187b
leaq -0x2c8(%rbp), %rdi
xorl %esi, %esi
movl $0x2b8, %edx            # imm = 0x2B8
callq 0x1070
leaq 0x1b21(%rip), %rax      # 0x3020
movq %rax, -0x28(%rbp)
leaq 0x1b96(%rip), %rax      # 0x30a0
movq %rax, -0x20(%rbp)
leaq 0x1dfb(%rip), %rax      # 0x3310
movq %rax, -0x18(%rbp)
movl $0xc, -0x40(%rbp)
movl $0x5, -0x3c(%rbp)
movl $0x5, -0x38(%rbp)
movl $0x1, -0x34(%rbp)
movl $0x1, -0x30(%rbp)
leaq -0x2c8(%rbp), %rdi
addq $0x4, %rdi
leaq 0x9afe(%rip), %rsi      # 0xb04c
callq 0x10a0
leaq -0x2c8(%rbp), %rdi
addq $0x44, %rdi
leaq 0x9afd(%rip), %rsi      # 0xb062
callq 0x10a0
leaq -0x2c8(%rbp), %rdi
addq $0x84, %rdi
movl -0x44(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
cltq
shlq $0x6, %rax
addq %rax, %rdi
leaq 0x9ac9(%rip), %rsi      # 0xb05c
callq 0x10a0
movq 0xcd21(%rip), %rdi      # 0xe2c0
leaq -0x2c8(%rbp), %rsi
callq 0x3540
movl %eax, -0x2cc(%rbp)
cmpl $0x0, -0x2cc(%rbp)
je 0x15e9
leaq 0x9a54(%rip), %rdi      # 0xb015
leaq 0x9a63(%rip), %rsi      # 0xb02b
leaq 0x9a6a(%rip), %rdx      # 0xb039
movl $0x97, %ecx
movb $0x0, %al
callq 0x1030
movl -0x2cc(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x187b
leaq -0x2c8(%rbp), %rdi
xorl %esi, %esi
movl $0x2b8, %edx            # imm = 0x2B8
callq 0x1070
movl $0x0, -0x40(%rbp)
movl $0x2, -0x3c(%rbp)
leaq -0x2c8(%rbp), %rdi
addq $0x4, %rdi
leaq 0x9a3b(%rip), %rsi      # 0xb057
callq 0x10a0
leaq -0x2c8(%rbp), %rdi
addq $0x44, %rdi
leaq 0x9a35(%rip), %rsi      # 0xb068
callq 0x10a0
leaq -0x2c8(%rbp), %rdi
addq $0x84, %rdi
movl -0x44(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
cltq
shlq $0x6, %rax
addq %rax, %rdi
leaq 0x9a01(%rip), %rsi      # 0xb062
callq 0x10a0
movq 0xcc53(%rip), %rdi      # 0xe2c0
leaq -0x2c8(%rbp), %rsi
callq 0x3540
movl %eax, -0x2cc(%rbp)
cmpl $0x0, -0x2cc(%rbp)
je 0x16b7
leaq 0x9986(%rip), %rdi      # 0xb015
leaq 0x9995(%rip), %rsi      # 0xb02b
leaq 0x999c(%rip), %rdx      # 0xb039
movl $0xac, %ecx
movb $0x0, %al
callq 0x1030
movl -0x2cc(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x187b
leaq -0x2c8(%rbp), %rdi
xorl %esi, %esi
movl $0x2b8, %edx            # imm = 0x2B8
callq 0x1070
leaq -0x2c8(%rbp), %rdi
addq $0x4, %rdi
leaq 0x9992(%rip), %rsi      # 0xb06e
callq 0x10a0
leaq -0x2c8(%rbp), %rdi
addq $0x44, %rdi
leaq 0x9982(%rip), %rsi      # 0xb075
callq 0x10a0
leaq -0x2c8(%rbp), %rdi
addq $0x84, %rdi
movl -0x44(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
cltq
shlq $0x6, %rax
addq %rax, %rdi
leaq 0x9947(%rip), %rsi      # 0xb068
callq 0x10a0
movq 0xcb93(%rip), %rdi      # 0xe2c0
leaq -0x2c8(%rbp), %rsi
callq 0x3540
movl %eax, -0x2cc(%rbp)
cmpl $0x0, -0x2cc(%rbp)
je 0x1777
leaq 0x98c6(%rip), %rdi      # 0xb015
leaq 0x98d5(%rip), %rsi      # 0xb02b
leaq 0x98dc(%rip), %rdx      # 0xb039
movl $0xbc, %ecx
movb $0x0, %al
callq 0x1030
movl -0x2cc(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x187b
leaq -0x2c8(%rbp), %rdi
xorl %esi, %esi
movl $0x2b8, %edx            # imm = 0x2B8
callq 0x1070
leaq -0x2c8(%rbp), %rdi
addq $0x4, %rdi
leaq 0x98e1(%rip), %rsi      # 0xb07d
callq 0x10a0
leaq -0x2c8(%rbp), %rdi
addq $0x44, %rdi
leaq 0x98ca(%rip), %rsi      # 0xb07d
callq 0x10a0
leaq -0x2c8(%rbp), %rdi
addq $0x84, %rdi
movl -0x44(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
cltq
shlq $0x6, %rax
addq %rax, %rdi
leaq 0x9894(%rip), %rsi      # 0xb075
callq 0x10a0
movl $0xa, -0x40(%rbp)
leaq 0x182c(%rip), %rax      # 0x3020
movq %rax, -0x38(%rbp)
leaq 0x731(%rip), %rax       # 0x1f30
movq %rax, -0x30(%rbp)
leaq 0x1b06(%rip), %rax      # 0x3310
movq %rax, -0x28(%rbp)
movq 0xcaab(%rip), %rdi      # 0xe2c0
leaq -0x2c8(%rbp), %rsi
callq 0x3540
movl %eax, -0x2cc(%rbp)
cmpl $0x0, -0x2cc(%rbp)
je 0x185c
leaq 0x97de(%rip), %rdi      # 0xb015
leaq 0x97ed(%rip), %rsi      # 0xb02b
leaq 0x97f4(%rip), %rdx      # 0xb039
movl $0xd5, %ecx
movb $0x0, %al
callq 0x1030
movl -0x2cc(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x187b
movq 0xca5d(%rip), %rdi      # 0xe2c0
callq 0x4410
movq 0xca51(%rip), %rdi      # 0xe2c0
callq 0x45c0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbp
retq
nopw (%rax,%rax)