// File: btbujiangjun[P]abcdl/example/rnn.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);

/*
    abcdl::rnn::RNN rnn(28, 100);
    rnn.set_epoch(50);
   
    const int train_size = 100;
    const int test_size = 10;
    abcdl::utils::FashionMnistReader<real> helper("data");
    std::vector<abcdl::algebra::Mat*> train_data;
    std::vector<abcdl::algebra::Mat*> train_label;
    helper.read_train_images(&train_data, train_size);
    helper.read_train_vec_labels(&train_label, train_size);

    LOG(INFO) << "RNN Start training....";
    LOG(INFO) << "training size:" << train_data.size();
    rnn.train(train_data, train_label);
	
    for(auto&& d : train_data){
		delete d;
	}
	train_data.clear();
	
	for(auto&& d : train_label){
		delete d;
	}
	train_label.clear();
*/
	abcdl::utils::RNNHelper helper(8000);
	
	//std::map<std::string, size_t> map;
	//helper.read_word2index("data/rnn/word_to_index", map);

    const size_t sample_size = 1000;
	abcdl::algebra::MatSet data_seq_data;
	abcdl::algebra::MatSet data_seq_label;
	if(!helper.read_seq_data("data/rnn/train_seq_data", data_seq_data, "data/rnn/train_seq_label", data_seq_label, sample_size)){
		return -1;
	}

    LOG(INFO) << "RNN Start training....";

    abcdl::rnn::RNN rnn(8000, 100);
    rnn.set_epoch(50);
    rnn.load_model("./data/rnn_seq.model");

    LOG(INFO) << "training size:" << data_seq_data.size();
    rnn.train(data_seq_data, data_seq_label);
}

// Assembly:
subq $0x548, %rsp            # imm = 0x548
movl $0x0, 0x544(%rsp)
movl %edi, 0x540(%rsp)
movq %rsi, 0x538(%rsp)
xorl %edi, %edi
callq 0xb0ef0
movl 0x540(%rsp), %edi
movq 0x538(%rsp), %rsi
callq 0xb09e0
leaq 0x530(%rsp), %rdi
movl $0x1f40, %esi           # imm = 0x1F40
callq 0x193d0
movq $0x3e8, 0x528(%rsp) # imm = 0x3E8
leaq 0x510(%rsp), %rdi
callq 0x193f0
leaq 0x4f8(%rsp), %rdi
callq 0x193f0
leaq 0x4d7(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0xb990
movq 0x30(%rsp), %rdx
leaq 0xa7fdb(%rip), %rsi     # 0xb528d
leaq 0x4d8(%rsp), %rdi
callq 0xb760
jmp 0xd2c1
leaq 0x49f(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0xb990
movq 0x28(%rsp), %rdx
leaq 0xa7fc6(%rip), %rsi     # 0xb52a5
leaq 0x4a0(%rsp), %rdi
callq 0xb760
jmp 0xd2ee
leaq 0x530(%rsp), %rdi
leaq 0x4d8(%rsp), %rsi
leaq 0x510(%rsp), %rdx
leaq 0x4a0(%rsp), %rcx
leaq 0x4f8(%rsp), %r8
movl $0x3e8, %r9d            # imm = 0x3E8
callq 0xcce0
movb %al, 0x27(%rsp)
jmp 0xd327
movb 0x27(%rsp), %al
xorb $-0x1, %al
movb %al, 0x26(%rsp)
leaq 0x4a0(%rsp), %rdi
callq 0xb330
leaq 0x49f(%rsp), %rdi
callq 0xb5f0
leaq 0x4d8(%rsp), %rdi
callq 0xb330
leaq 0x4d7(%rsp), %rdi
callq 0xb5f0
movb 0x26(%rsp), %al
testb $0x1, %al
jne 0xd372
jmp 0xd406
movl $0xffffffff, 0x544(%rsp) # imm = 0xFFFFFFFF
movl $0x1, 0x498(%rsp)
jmp 0xd573
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4c8(%rsp)
movl %eax, 0x4c4(%rsp)
jmp 0xd3f4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4c8(%rsp)
movl %eax, 0x4c4(%rsp)
jmp 0xd3da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4c8(%rsp)
movl %eax, 0x4c4(%rsp)
leaq 0x4a0(%rsp), %rdi
callq 0xb330
leaq 0x49f(%rsp), %rdi
callq 0xb5f0
leaq 0x4d8(%rsp), %rdi
callq 0xb330
leaq 0x4d7(%rsp), %rdi
callq 0xb5f0
jmp 0xd662
leaq 0xa7eb1(%rip), %rsi     # 0xb52be
leaq 0x310(%rsp), %rdi
movl $0x38, %edx
xorl %ecx, %ecx
callq 0xb0f80
jmp 0xd423
leaq 0xa7ea4(%rip), %rsi     # 0xb52ce
leaq 0x310(%rsp), %rdi
callq 0x19400
jmp 0xd439
leaq 0x310(%rsp), %rdi
callq 0xb1340
leaq 0x1f0(%rsp), %rdi
movl $0x1f40, %esi           # imm = 0x1F40
movl $0x64, %edx
callq 0x19430
jmp 0xd45f
leaq 0x1f0(%rsp), %rdi
movl $0x32, %esi
callq 0x19b10
jmp 0xd473
leaq 0x1cf(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0xb990
movq 0x18(%rsp), %rdx
leaq 0xa7e54(%rip), %rsi     # 0xb52e5
leaq 0x1d0(%rsp), %rdi
callq 0xb760
jmp 0xd4a0
leaq 0x1f0(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
callq 0x55590
jmp 0xd4b7
leaq 0x1d0(%rsp), %rdi
callq 0xb330
leaq 0x1cf(%rsp), %rdi
callq 0xb5f0
leaq 0xa7de6(%rip), %rsi     # 0xb52be
leaq 0x40(%rsp), %rdi
movl $0x3e, %edx
xorl %ecx, %ecx
callq 0xb0f80
jmp 0xd4eb
leaq 0xa7e08(%rip), %rsi     # 0xb52fa
leaq 0x40(%rsp), %rdi
callq 0x19b60
movq %rax, 0x10(%rsp)
jmp 0xd503
leaq 0x510(%rsp), %rdi
callq 0x193c0
movq %rax, 0x8(%rsp)
jmp 0xd517
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x38(%rsp), %rsi
callq 0x19b30
jmp 0xd532
leaq 0x40(%rsp), %rdi
callq 0xb1340
leaq 0x1f0(%rsp), %rdi
leaq 0x510(%rsp), %rsi
leaq 0x4f8(%rsp), %rdx
callq 0x54370
jmp 0xd55b
leaq 0x1f0(%rsp), %rdi
callq 0x19b90
movl $0x0, 0x498(%rsp)
leaq 0x4f8(%rsp), %rdi
callq 0x19c20
leaq 0x510(%rsp), %rdi
callq 0x19c20
movl 0x544(%rsp), %eax
addq $0x548, %rsp            # imm = 0x548
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4c8(%rsp)
movl %eax, 0x4c4(%rsp)
jmp 0xd662
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4c8(%rsp)
movl %eax, 0x4c4(%rsp)
leaq 0x310(%rsp), %rdi
callq 0xb1340
jmp 0xd662
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4c8(%rsp)
movl %eax, 0x4c4(%rsp)
jmp 0xd655
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4c8(%rsp)
movl %eax, 0x4c4(%rsp)
jmp 0xd628
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4c8(%rsp)
movl %eax, 0x4c4(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0xb330
leaq 0x1cf(%rsp), %rdi
callq 0xb5f0
jmp 0xd655
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4c8(%rsp)
movl %eax, 0x4c4(%rsp)
leaq 0x40(%rsp), %rdi
callq 0xb1340
leaq 0x1f0(%rsp), %rdi
callq 0x19b90
leaq 0x4f8(%rsp), %rdi
callq 0x19c20
leaq 0x510(%rsp), %rdi
callq 0x19c20
movq 0x4c8(%rsp), %rdi
callq 0xb980
nopl (%rax)