// File: /workspace/github_c_makefile_star2_O2/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 0xa004(%rip), %rdi      # 0xb2d0
movq %rax, %rsi
callq 0x26f8
testl %eax, %eax
je 0x12fe
movl %eax, %ebx
leaq 0x5d64(%rip), %rdi      # 0x7045
leaq 0x5d73(%rip), %rsi      # 0x705b
leaq 0x5d7a(%rip), %rdx      # 0x7069
pushq $0x3f
popq %rcx
xorl %eax, %eax
callq 0x1030
jmp 0x13be
leaq 0x4(%rsp), %r15
movq %rsp, %rbx
xorl %r14d, %r14d
movl $0x2a0, %edx            # imm = 0x2A0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1070
leaq 0x118d(%rip), %rax      # 0x24ac
movq %rax, 0x2a0(%rbx)
leaq 0x11c3(%rip), %rbp      # 0x24f0
movq %rbp, 0x2a8(%rbx)
leaq 0x12a3(%rip), %r13      # 0x25de
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 0x5c9f(%rip), %xmm0     # 0x7010
movups %xmm0, 0x284(%rbx)
movb %r14b, 0x88(%rbx)
movl $0x61746164, 0x84(%rbx) # imm = 0x61746164
movq 0x9f40(%rip), %rdi      # 0xb2d0
movq %rbx, %rsi
callq 0x26f8
testl %eax, %eax
je 0x13d2
leaq 0x5ca2(%rip), %rdi      # 0x7045
leaq 0x5cb1(%rip), %rsi      # 0x705b
leaq 0x5cb8(%rip), %rdx      # 0x7069
pushq $0x60
popq %rcx
xorl %eax, %eax
callq 0x1030
pushq $-0x1
popq %rbx
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 0x9ea3(%rip), %rdi      # 0xb2d0
movq %rbx, %rsi
callq 0x26f8
testl %eax, %eax
je 0x1457
movl %eax, %ebx
leaq 0x5c03(%rip), %rdi      # 0x7045
leaq 0x5c12(%rip), %rsi      # 0x705b
leaq 0x5c19(%rip), %rdx      # 0x7069
pushq $0x75
jmp 0x12f1
movq %rsp, %rbx
movl $0x2a0, %edx            # imm = 0x2A0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1070
leaq 0x103c(%rip), %rax      # 0x24ac
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 0x5b75(%rip), %xmm0     # 0x7020
movups %xmm0, 0x284(%rbx)
movw $0x30, 0x4(%r14)
movl $0x706d6173, (%r14)     # imm = 0x706D6173
movq 0x9e09(%rip), %rdi      # 0xb2d0
movq %rbx, %rsi
callq 0x26f8
testl %eax, %eax
je 0x14f4
movl %eax, %ebx
leaq 0x5b69(%rip), %rdi      # 0x7045
leaq 0x5b78(%rip), %rsi      # 0x705b
leaq 0x5b7f(%rip), %rdx      # 0x7069
movl $0x97, %ecx
jmp 0x12f2
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 0x9d89(%rip), %rdi      # 0xb2d0
movq %rbx, %rsi
callq 0x26f8
testl %eax, %eax
je 0x1574
movl %eax, %ebx
leaq 0x5ae9(%rip), %rdi      # 0x7045
leaq 0x5af8(%rip), %rsi      # 0x705b
leaq 0x5aff(%rip), %rdx      # 0x7069
movl $0xac, %ecx
jmp 0x12f2
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 0x9d0e(%rip), %rdi      # 0xb2d0
movq %rbx, %rsi
callq 0x26f8
testl %eax, %eax
je 0x15ef
movl %eax, %ebx
leaq 0x5a6e(%rip), %rdi      # 0x7045
leaq 0x5a7d(%rip), %rsi      # 0x705b
leaq 0x5a84(%rip), %rdx      # 0x7069
movl $0xbc, %ecx
jmp 0x12f2
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 0xe71(%rip), %rax       # 0x24ac
movq %rax, 0x290(%r14)
leaq 0x4e4(%rip), %rax       # 0x1b2d
movq %rax, 0x298(%r14)
movq %r13, 0x2a0(%r14)
movq 0x9c72(%rip), %rdi      # 0xb2d0
movq %r14, %rsi
callq 0x26f8
testl %eax, %eax
je 0x1694
movl %eax, %ebp
leaq 0x59d2(%rip), %rdi      # 0x7045
leaq 0x59e1(%rip), %rsi      # 0x705b
leaq 0x59e8(%rip), %rdx      # 0x7069
movl $0xd5, %ecx
xorl %eax, %eax
callq 0x1030
movl %ebp, %ebx
jmp 0x13be
movq 0x9c35(%rip), %rdi      # 0xb2d0
callq 0x2ff7
movq 0x9c29(%rip), %rdi      # 0xb2d0
callq 0x3127
jmp 0x13be