// File: /workspace/github_cpp_makefile_star2_O3/btbujiangjun[P]abcdl/example/cnn.cpp
// Function: main
int main(int argc, char** argv){
    abcdl::utils::log::set_min_log_level(abcdl::utils::log::INFO);
    abcdl::utils::log::initialize_log(argc, argv);

    const std::string path = "./data/cnn.model";

    std::vector<abcdl::cnn::Layer*> layers;
    layers.push_back(new abcdl::cnn::InputLayer(28, 28));
    layers.push_back(new abcdl::cnn::ConvolutionLayer(3, 1, 5, new abcdl::framework::SigmoidActivateFunc()));
    layers.push_back(new abcdl::cnn::SubSamplingLayer(2, new abcdl::framework::MeanPooling()));
    layers.push_back(new abcdl::cnn::ConvolutionLayer(3, 1, 5, new abcdl::framework::SigmoidActivateFunc()));
//    layers.push_back(new abcdl::cnn::SubSamplingLayer(2, new abcdl::cnn::MeanPooling()));
    layers.push_back(new abcdl::cnn::OutputLayer(10, new abcdl::framework::SigmoidActivateFunc(), new abcdl::framework::CrossEntropyCost()));

    abcdl::cnn::CNN cnn;
    cnn.set_layers(layers);
	cnn.set_batch_size(1);
	cnn.set_alpha(0.1);

    //abcdl::utils::FashionMnistReader<real> helper("data");
    abcdl::utils::MnistReader<real> helper("data");
    const size_t train_size = 60000;
    const size_t test_size  = 10000;

    abcdl::algebra::MatSet train_data;
    helper.read_train_images(train_data, train_size, 30);

    abcdl::algebra::MatSet train_label;
    helper.read_train_vec_labels(train_label, train_size);

    abcdl::algebra::MatSet test_data;
    helper.read_test_images(test_data, test_size);

    abcdl::algebra::MatSet test_label;
    helper.read_test_vec_labels(test_label, test_size);

    cnn.train(train_data, train_label, test_data, test_label);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rsi, %rbx
movl %edi, %ebp
xorl %edi, %edi
callq 0x371d0
movl %ebp, %edi
movq %rbx, %rsi
callq 0x36d6c
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2f402(%rip), %rsi     # 0x380b8
leaq 0x2f40b(%rip), %rdx     # 0x380c8
leaq 0xc0(%rsp), %rdi
callq 0x130e4
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movl $0xd0, %edi
callq 0x8320
movq %rax, %r14
movl $0x1c, %esi
movl $0x1c, %edx
movl $0x1, %ecx
movl $0x1, %r8d
movq %rax, %rdi
xorl %r9d, %r9d
callq 0xfcc6
leaq 0x4b1a2(%rip), %rax     # 0x53eb0
movq %rax, (%r14)
movq %r14, 0x70(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x8d2d
movq %r14, (%rsi)
addq $0x8, 0x8(%rsp)
jmp 0x8d3a
movq %rsp, %rdi
leaq 0x70(%rsp), %rdx
callq 0x1317a
movl $0xe8, %edi
callq 0x8320
movq %rax, %r14
movl $0x18, %edi
callq 0x8320
movq %rax, %r15
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x4b237(%rip), %r12     # 0x53fa0
movq %r12, (%rax)
movq %rax, %rdi
addq $0x8, %rdi
callq 0xabb8
leaq 0x4b1c9(%rip), %rbp     # 0x53f48
movq %rbp, (%r15)
movl $0x1, %ecx
movl $0x5, %r8d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl $0x3, %r9d
callq 0xfcc6
leaq 0x4be52(%rip), %r13     # 0x54bf8
addq $0x10, %r13
movq %r13, (%r14)
movq $0x3, 0xd8(%r14)
movq $0x1, 0xd0(%r14)
movq %r15, 0xe0(%r14)
movq %r14, 0x70(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x8de6
movq %r14, (%rsi)
addq $0x8, 0x8(%rsp)
jmp 0x8df3
movq %rsp, %rdi
leaq 0x70(%rsp), %rdx
callq 0x1317a
movl $0xe0, %edi
callq 0x8320
movq %rax, %r14
movl $0x8, %edi
callq 0x8320
movq %rax, %rbx
leaq 0x4be84(%rip), %rax     # 0x54c98
addq $0x10, %rax
movq %rax, (%rbx)
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movl $0x2, %r9d
callq 0xfcc6
leaq 0x4bd6f(%rip), %rax     # 0x54ba8
addq $0x10, %rax
movq %rax, (%r14)
movq $0x2, 0xd0(%r14)
movq %rbx, 0xd8(%r14)
movq %r14, 0x70(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x8e6e
movq %r14, (%rsi)
addq $0x8, 0x8(%rsp)
jmp 0x8e7b
movq %rsp, %rdi
leaq 0x70(%rsp), %rdx
callq 0x1317a
movl $0xe8, %edi
callq 0x8320
movq %rax, %r14
movl $0x18, %edi
callq 0x8320
movq %rax, %r15
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %r12, (%rax)
movq %rax, %rdi
addq $0x8, %rdi
callq 0xabb8
movq %rbp, (%r15)
movl $0x1, %ecx
movl $0x5, %r8d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl $0x3, %r9d
callq 0xfcc6
movq %r13, (%r14)
movq $0x3, 0xd8(%r14)
movq $0x1, 0xd0(%r14)
movq %r15, 0xe0(%r14)
movq %r14, 0x70(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x8f0e
movq %r14, (%rsi)
addq $0x8, 0x8(%rsp)
jmp 0x8f1b
movq %rsp, %rdi
leaq 0x70(%rsp), %rdx
callq 0x1317a
movl $0x138, %edi            # imm = 0x138
callq 0x8320
movq %rax, %r14
movl $0x18, %edi
callq 0x8320
movq %rax, %r15
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %r12, (%rax)
movq %rax, %rdi
addq $0x8, %rdi
callq 0xabb8
movq %rbp, (%r15)
movl $0x18, %edi
callq 0x8320
movq %rax, %r12
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x4b0a9(%rip), %rax     # 0x54020
movq %rax, (%r12)
movq %r12, %rdi
addq $0x8, %rdi
callq 0xabb8
leaq 0x4b042(%rip), %rax     # 0x53fd0
movq %rax, (%r12)
movl $0xa, %esi
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0xf418
movq %r14, 0x70(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x8fc1
movq %r14, (%rsi)
addq $0x8, 0x8(%rsp)
jmp 0x8fce
movq %rsp, %rdi
leaq 0x70(%rsp), %rdx
callq 0x1317a
movq $0x32, 0x40(%rsp)
movq $0x1, 0x48(%rsp)
movl $0x3dcccccd, 0x50(%rsp) # imm = 0x3DCCCCCD
xorps %xmm0, %xmm0
movups %xmm0, 0x58(%rsp)
movq $0x0, 0x68(%rsp)
leaq 0x140(%rsp), %rdi
movq %rsp, %rsi
callq 0xf4a2
leaq 0x40(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x15758
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x902d
callq 0x8300
movq $0x1, 0x48(%rsp)
movl $0x3dcccccd, 0x50(%rsp) # imm = 0x3DCCCCCD
leaq 0x30(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x2f07b(%rip), %rsi     # 0x380c9
leaq 0x2f078(%rip), %rdx     # 0x380cd
leaq 0x20(%rsp), %rdi
callq 0x130e4
leaq 0x70(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xf522
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x907d
callq 0x8300
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rsi
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
leaq 0x70(%rsp), %rdi
movl $0x1e, %ecx
movl $0xea60, %edx           # imm = 0xEA60
callq 0xf5b2
leaq 0x120(%rsp), %rsi
xorps %xmm0, %xmm0
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
leaq 0x70(%rsp), %rdi
movl $0xa, %ecx
movl $0xea60, %edx           # imm = 0xEA60
callq 0xf762
xorps %xmm0, %xmm0
leaq 0x100(%rsp), %rsi
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
leaq 0x70(%rsp), %rdi
movl $0x2710, %edx           # imm = 0x2710
xorl %ecx, %ecx
callq 0xf8f8
leaq 0xe0(%rsp), %rsi
xorps %xmm0, %xmm0
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
leaq 0x70(%rsp), %rdi
movl $0xa, %ecx
movl $0x2710, %edx           # imm = 0x2710
callq 0xfaa8
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x120(%rsp), %rdx
leaq 0x100(%rsp), %rcx
leaq 0xe0(%rsp), %r8
callq 0x1587e
leaq 0xe0(%rsp), %rdi
callq 0x102fa
leaq 0x100(%rsp), %rdi
callq 0x102fa
leaq 0x120(%rsp), %rdi
callq 0x102fa
leaq 0x20(%rsp), %rdi
callq 0x102fa
leaq 0x4aeca(%rip), %rax     # 0x54048
leaq 0xa8(%rsp), %rcx
movq %rax, -0x38(%rcx)
movq -0x10(%rcx), %rdi
cmpq %rcx, %rdi
je 0x9198
callq 0x8300
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x91ae
callq 0x8300
leaq 0x40(%rsp), %rdi
callq 0xfc74
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x91c6
callq 0x8300
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x91e0
callq 0x8300
xorl %eax, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x926e
movq %rax, %rbx
jmp 0x927b
movq %rax, %rbx
jmp 0x9288
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
jne 0x922a
jmp 0x929c
jmp 0x9231
movq %rax, %rbx
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x929c
callq 0x8300
jmp 0x929c
movq %rax, %rbx
jmp 0x929c
movq %rax, %rbx
movq %r12, %rdi
jmp 0x9248
jmp 0x9242
jmp 0x9242
movq %rax, %rbx
movq %r15, %rdi
callq 0x8300
jmp 0x92b1
jmp 0x92ae
jmp 0x9259
jmp 0x9259
jmp 0x9259
jmp 0x9259
movq %rax, %rbx
jmp 0x92b9
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x102fa
leaq 0x100(%rsp), %rdi
callq 0x102fa
leaq 0x120(%rsp), %rdi
callq 0x102fa
leaq 0x20(%rsp), %rdi
callq 0x102fa
leaq 0x70(%rsp), %rdi
callq 0xfc3e
leaq 0x40(%rsp), %rdi
callq 0xfc74
jmp 0x92b9
jmp 0x92ae
jmp 0x92ae
jmp 0x92ae
movq %rax, %rbx
movq %r14, %rdi
callq 0x8300
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x92c7
callq 0x8300
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x92e1
callq 0x8300
movq %rbx, %rdi
callq 0x8500
nop