// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2b8, %rsp            # imm = 0x2B8
movq %rsp, %rax
movl %esi, 0x28c(%rax)
movl %edx, 0x290(%rax)
movl %edx, 0x294(%rax)
movl $0x61746164, %ecx       # imm = 0x61746164
movl %ecx, 0x4(%rax)
xorl %edx, %edx
movb %dl, 0x8(%rax)
movl %ecx, 0x44(%rax)
movb %dl, 0x48(%rax)
movq 0x9004(%rip), %rdi      # 0xa2d0
movq %rax, %rsi
callq 0x2874
testl %eax, %eax
je 0x1300
movl %eax, %ebx
leaq 0x5d64(%rip), %rdi      # 0x7045
leaq 0x5d73(%rip), %rsi      # 0x705b
leaq 0x5d7a(%rip), %rdx      # 0x7069
movl $0x3f, %ecx
xorl %eax, %eax
callq 0x1030
jmp 0x13c4
leaq 0x4(%rsp), %r15
movq %rsp, %rbx
xorl %r14d, %r14d
movl $0x2a0, %edx            # imm = 0x2A0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1070
leaq 0x12a7(%rip), %rax      # 0x25c8
movq %rax, 0x2a0(%rbx)
leaq 0x12dd(%rip), %rbp      # 0x260c
movq %rbp, 0x2a8(%rbx)
leaq 0x13c2(%rip), %r13      # 0x26ff
movq %r13, 0x2b0(%rbx)
movabsq $0x100000001, %r12      # imm = 0x100000001
movq %r12, 0x294(%rbx)
movl $0x766e6f63, %eax       # imm = 0x766E6F63
movl %eax, (%r15)
movb %r14b, 0x4(%r15)
movl %eax, 0x40(%r15)
movw $0x30, 0x44(%r15)
movaps 0x5c9d(%rip), %xmm0     # 0x7010
movups %xmm0, 0x284(%rbx)
movb %r14b, 0x88(%rbx)
movl $0x61746164, 0x84(%rbx) # imm = 0x61746164
movq 0x8f3e(%rip), %rdi      # 0xa2d0
movq %rbx, %rsi
callq 0x2874
testl %eax, %eax
je 0x13d8
leaq 0x5ca0(%rip), %rdi      # 0x7045
leaq 0x5caf(%rip), %rsi      # 0x705b
leaq 0x5cb6(%rip), %rdx      # 0x7069
movl $0x60, %ecx
xorl %eax, %eax
callq 0x1030
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x84(%rsp), %r14
movq %rsp, %rbx
movl $0x2b8, %edx            # imm = 0x2B8
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1070
movl $0x2, 0x28c(%rbx)
movl $0x706d6173, %eax       # imm = 0x706D6173
movl %eax, (%r15)
movb $0x0, 0x4(%r15)
movw $0x30, %cx
movw %cx, 0x44(%r15)
movl %eax, 0x40(%r15)
movl $0x1, 0x284(%rbx)
movw %cx, 0x4(%r14)
movl $0x766e6f63, (%r14)     # imm = 0x766E6F63
movq 0x8e9d(%rip), %rdi      # 0xa2d0
movq %rbx, %rsi
callq 0x2874
testl %eax, %eax
je 0x1460
movl %eax, %ebx
leaq 0x5bfd(%rip), %rdi      # 0x7045
leaq 0x5c0c(%rip), %rsi      # 0x705b
leaq 0x5c13(%rip), %rdx      # 0x7069
movl $0x75, %ecx
jmp 0x12f4
movq %rsp, %rbx
movl $0x2a0, %edx            # imm = 0x2A0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1070
leaq 0x114f(%rip), %rax      # 0x25c8
movq %rax, 0x2a0(%rbx)
movq %rbp, 0x2a8(%rbx)
movq %r13, 0x2b0(%rbx)
movq %r12, 0x294(%rbx)
movl $0x766e6f63, %eax       # imm = 0x766E6F63
movl %eax, (%r15)
movb $0x0, 0x4(%r15)
movl %eax, 0x40(%r15)
movw $0x31, 0x44(%r15)
movaps 0x5b6c(%rip), %xmm0     # 0x7020
movups %xmm0, 0x284(%rbx)
movw $0x30, 0x4(%r14)
movl $0x706d6173, (%r14)     # imm = 0x706D6173
movq 0x8e00(%rip), %rdi      # 0xa2d0
movq %rbx, %rsi
callq 0x2874
testl %eax, %eax
je 0x14fd
movl %eax, %ebx
leaq 0x5b60(%rip), %rdi      # 0x7045
leaq 0x5b6f(%rip), %rsi      # 0x705b
leaq 0x5b76(%rip), %rdx      # 0x7069
movl $0x97, %ecx
jmp 0x12f4
movq %rsp, %rbx
movl $0x2b8, %edx            # imm = 0x2B8
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1070
movl $0x2, 0x28c(%rbx)
movl $0x706d6173, %eax       # imm = 0x706D6173
movl %eax, (%r15)
movb $0x0, 0x4(%r15)
movw $0x31, %cx
movw %cx, 0x44(%r15)
movl %eax, 0x40(%r15)
movl $0x1, 0x284(%rbx)
movw %cx, 0x4(%r14)
movl $0x766e6f63, (%r14)     # imm = 0x766E6F63
movq 0x8d80(%rip), %rdi      # 0xa2d0
movq %rbx, %rsi
callq 0x2874
testl %eax, %eax
je 0x157d
movl %eax, %ebx
leaq 0x5ae0(%rip), %rdi      # 0x7045
leaq 0x5aef(%rip), %rsi      # 0x705b
leaq 0x5af6(%rip), %rdx      # 0x7069
movl $0xac, %ecx
jmp 0x12f4
movabsq $0x307261656e696c, %r12 # imm = 0x307261656E696C
movq %rsp, %rbx
movl $0x2b8, %edx            # imm = 0x2B8
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1070
movl $0x656e696c, (%r15)     # imm = 0x656E696C
movl $0x726165, 0x3(%r15)    # imm = 0x726165
movq %r12, 0x44(%rbx)
movl $0x1, 0x284(%rbx)
movl $0x706d6173, (%r14)     # imm = 0x706D6173
movw $0x31, 0x4(%r14)
movq 0x8d05(%rip), %rdi      # 0xa2d0
movq %rbx, %rsi
callq 0x2874
testl %eax, %eax
je 0x15f8
movl %eax, %ebx
leaq 0x5a65(%rip), %rdi      # 0x7045
leaq 0x5a74(%rip), %rsi      # 0x705b
leaq 0x5a7b(%rip), %rdx      # 0x7069
movl $0xbc, %ecx
jmp 0x12f4
movq %rsp, %r14
xorl %ebx, %ebx
movl $0x2b8, %edx            # imm = 0x2B8
movq %r14, %rdi
xorl %esi, %esi
callq 0x1070
movl $0x7074756f, %eax       # imm = 0x7074756F
movl %eax, (%r15)
movl $0x747570, %ecx         # imm = 0x747570
movl %ecx, 0x3(%r15)
movl %ecx, 0x43(%r15)
movl %eax, 0x40(%r15)
movabsq $0xa00000001, %rax      # imm = 0xA00000001
movq %rax, 0x284(%r14)
movq %r12, 0x84(%r14)
leaq 0xf84(%rip), %rax       # 0x25c8
movq %rax, 0x290(%r14)
leaq 0x4ed(%rip), %rax       # 0x1b3f
movq %rax, 0x298(%r14)
movq %r13, 0x2a0(%r14)
movq 0x8c69(%rip), %rdi      # 0xa2d0
movq %r14, %rsi
callq 0x2874
testl %eax, %eax
je 0x169d
movl %eax, %ebp
leaq 0x59c9(%rip), %rdi      # 0x7045
leaq 0x59d8(%rip), %rsi      # 0x705b
leaq 0x59df(%rip), %rdx      # 0x7069
movl $0xd5, %ecx
xorl %eax, %eax
callq 0x1030
movl %ebp, %ebx
jmp 0x13c4
movq 0x8c2c(%rip), %rdi      # 0xa2d0
callq 0x31e0
movq 0x8c20(%rip), %rdi      # 0xa2d0
callq 0x3312
jmp 0x13c4