// File: /workspace/github_c_makefile_star2_O1/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      # 0xb2c0
movq %rax, %rsi
callq 0x28e0
testl %eax, %eax
je 0x12f0
movl %eax, %ebx
leaq 0x6d74(%rip), %rdi      # 0x8045
leaq 0x6d83(%rip), %rsi      # 0x805b
leaq 0x6d8a(%rip), %rdx      # 0x8069
movl $0x3f, %ecx
xorl %eax, %eax
callq 0x1030
jmp 0x13c2
leaq 0x4(%rsp), %r15
movq %rsp, %rbx
xorl %ebp, %ebp
movl $0x2b8, %edx            # imm = 0x2B8
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1070
leaq 0x1324(%rip), %r12      # 0x2634
movq %r12, 0x2a0(%rbx)
leaq 0x135a(%rip), %r14      # 0x2678
movq %r14, 0x2a8(%rbx)
leaq 0x143f(%rip), %r13      # 0x276b
movq %r13, 0x2b0(%rbx)
movaps 0x6cd6(%rip), %xmm0     # 0x8010
movups %xmm0, 0x288(%rbx)
movl $0x1, 0x298(%rbx)
movl $0x766e6f63, %eax       # imm = 0x766E6F63
movl %eax, (%r15)
movb %bpl, 0x4(%r15)
movl %eax, 0x40(%r15)
movw $0x30, 0x44(%r15)
movslq 0x284(%rbx), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x284(%rbx)
shlq $0x6, %rax
movb %bpl, 0x88(%rsp,%rax)
movl $0x61746164, 0x84(%rsp,%rax) # imm = 0x61746164
movq 0x9f30(%rip), %rdi      # 0xb2c0
movq %rbx, %rsi
callq 0x28e0
testl %eax, %eax
je 0x13d6
leaq 0x6ca2(%rip), %rdi      # 0x8045
leaq 0x6cb1(%rip), %rsi      # 0x805b
leaq 0x6cb8(%rip), %rdx      # 0x8069
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), %rbp
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)
movslq 0x284(%rbx), %rax
leal 0x1(%rax), %edx
movl %edx, 0x284(%rbx)
shlq $0x6, %rax
movw %cx, 0x4(%rbp,%rax)
movl $0x766e6f63, (%rbp,%rax) # imm = 0x766E6F63
movq 0x9e84(%rip), %rdi      # 0xb2c0
movq %rbx, %rsi
callq 0x28e0
testl %eax, %eax
je 0x1469
movl %eax, %ebx
leaq 0x6bf4(%rip), %rdi      # 0x8045
leaq 0x6c03(%rip), %rsi      # 0x805b
leaq 0x6c0a(%rip), %rdx      # 0x8069
movl $0x75, %ecx
jmp 0x12e4
movq %rsp, %rbx
movl $0x2b8, %edx            # imm = 0x2B8
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1070
movq %r12, 0x2a0(%rbx)
movq %r14, 0x2a8(%rbx)
movq %r13, 0x2b0(%rbx)
movaps 0x6b89(%rip), %xmm0     # 0x8020
movups %xmm0, 0x288(%rbx)
movl $0x1, 0x298(%rbx)
movl $0x766e6f63, %eax       # imm = 0x766E6F63
movl %eax, (%r15)
movb $0x0, 0x4(%r15)
movl %eax, 0x40(%r15)
movw $0x31, 0x44(%r15)
movslq 0x284(%rbx), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x284(%rbx)
shlq $0x6, %rax
movw $0x30, 0x4(%rbp,%rax)
movl $0x706d6173, (%rbp,%rax) # imm = 0x706D6173
movq 0x9dd6(%rip), %rdi      # 0xb2c0
movq %rbx, %rsi
callq 0x28e0
testl %eax, %eax
je 0x1517
movl %eax, %ebx
leaq 0x6b46(%rip), %rdi      # 0x8045
leaq 0x6b55(%rip), %rsi      # 0x805b
leaq 0x6b5c(%rip), %rdx      # 0x8069
movl $0x97, %ecx
jmp 0x12e4
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)
movslq 0x284(%rbx), %rax
leal 0x1(%rax), %edx
movl %edx, 0x284(%rbx)
shlq $0x6, %rax
movw %cx, 0x4(%rbp,%rax)
movl $0x766e6f63, (%rbp,%rax) # imm = 0x766E6F63
movq 0x9d4b(%rip), %rdi      # 0xb2c0
movq %rbx, %rsi
callq 0x28e0
testl %eax, %eax
je 0x15a2
movl %eax, %ebx
leaq 0x6abb(%rip), %rdi      # 0x8045
leaq 0x6aca(%rip), %rsi      # 0x805b
leaq 0x6ad1(%rip), %rdx      # 0x8069
movl $0xac, %ecx
jmp 0x12e4
movabsq $0x307261656e696c, %r14 # 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 %r14, 0x44(%rbx)
movslq 0x284(%rbx), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x284(%rbx)
shlq $0x6, %rax
movw $0x31, 0x4(%rbp,%rax)
movl $0x706d6173, (%rbp,%rax) # imm = 0x706D6173
movq 0x9cc5(%rip), %rdi      # 0xb2c0
movq %rbx, %rsi
callq 0x28e0
testl %eax, %eax
je 0x1628
movl %eax, %ebx
leaq 0x6a35(%rip), %rdi      # 0x8045
leaq 0x6a44(%rip), %rsi      # 0x805b
leaq 0x6a4b(%rip), %rdx      # 0x8069
movl $0xbc, %ecx
jmp 0x12e4
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)
movslq 0x284(%r14), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x284(%r14)
shlq $0x6, %rax
movabsq $0x307261656e696c, %rcx # imm = 0x307261656E696C
movq %rcx, (%rbp,%rax)
movl $0xa, 0x288(%r14)
movq %r12, 0x290(%r14)
leaq 0x4ed(%rip), %rax       # 0x1b7f
movq %rax, 0x298(%r14)
movq %r13, 0x2a0(%r14)
movq 0x9c19(%rip), %rdi      # 0xb2c0
movq %r14, %rsi
callq 0x28e0
testl %eax, %eax
je 0x16dd
movl %eax, %ebp
leaq 0x6989(%rip), %rdi      # 0x8045
leaq 0x6998(%rip), %rsi      # 0x805b
leaq 0x699f(%rip), %rdx      # 0x8069
movl $0xd5, %ecx
xorl %eax, %eax
callq 0x1030
movl %ebp, %ebx
jmp 0x13c2
movq 0x9bdc(%rip), %rdi      # 0xb2c0
callq 0x32a6
movq 0x9bd0(%rip), %rdi      # 0xb2c0
callq 0x33d8
jmp 0x13c2