// File: btbujiangjun[P]abcdl/src/rnn/RNN.cpp
// Function: abcdl::rnn::RNN::load_model(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool RNN::load_model(const std::string& path){
    std::vector<abcdl::algebra::Mat*> models;
    if(!loader.read<real>(path, &models,"RNNMODEL") || models.size() != 3){
        for(auto&& model : models){
            delete model;
        }
        return false;
    }
    
    _U = *(models[0]);
    _W = *(models[1]);
    _U = *(models[2]);

    _feature_dim    = _U.cols();
    _hidden_dim     = _U.rows();
    _path           = path;

    if(_layer != nullptr){
        delete _layer;
    }
    _layer = new abcdl::rnn::Layer(_hidden_dim, _bptt_truncate, new abcdl::framework::CrossEntropyCost(), new abcdl::framework::TanhActivateFunc());

    for(auto&& mat : models){
        delete mat;
    }
    models.clear();

    return true;
}

// Assembly:
subq $0x128, %rsp            # imm = 0x128
movq %rdi, 0x118(%rsp)
movq %rsi, 0x110(%rsp)
movq 0x118(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x56020
movq 0x58(%rsp), %rax
addq $0x50, %rax
movq %rax, 0x60(%rsp)
movq 0x110(%rsp), %rax
movq %rax, 0x68(%rsp)
leaq 0xd7(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0xb990
movq 0x70(%rsp), %rdx
leaq 0x6274d(%rip), %rsi     # 0xb7d47
leaq 0xd8(%rsp), %rdi
callq 0xb760
jmp 0x55609
movq 0x68(%rsp), %rsi
movq 0x60(%rsp), %rdi
leaq 0xf8(%rsp), %rdx
leaq 0xd8(%rsp), %rcx
callq 0x56030
movb %al, 0x57(%rsp)
jmp 0x5562e
movb 0x57(%rsp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, 0x56(%rsp)
jne 0x5563f
jmp 0x55657
leaq 0xf8(%rsp), %rdi
callq 0x565b0
cmpq $0x3, %rax
setne %al
movb %al, 0x56(%rsp)
movb 0x56(%rsp), %al
movb %al, 0x55(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0xb330
leaq 0xd7(%rsp), %rdi
callq 0xb5f0
movb 0x55(%rsp), %al
testb $0x1, %al
jne 0x55686
jmp 0x5578f
leaq 0xf8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x565d0
movq %rax, 0xb0(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x56600
movq %rax, 0xa8(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x56630
testb $0x1, %al
jne 0x556de
jmp 0x55777
leaq 0xb0(%rsp), %rdi
callq 0x56670
movq %rax, 0xa0(%rsp)
movq 0xa0(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x48(%rsp)
cmpq $0x0, %rax
je 0x5571d
movq 0x48(%rsp), %rdi
callq 0x5bc10
movq 0x48(%rsp), %rdi
callq 0xb560
jmp 0x5571f
leaq 0xb0(%rsp), %rdi
callq 0x56680
jmp 0x556c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
jmp 0x55765
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0xb330
leaq 0xd7(%rsp), %rdi
callq 0xb5f0
jmp 0x55a94
movb $0x0, 0x127(%rsp)
movl $0x1, 0x9c(%rsp)
jmp 0x55a76
xorl %eax, %eax
movl %eax, %esi
leaq 0xf8(%rsp), %rdi
callq 0x566a0
movq 0x58(%rsp), %rdi
movq (%rax), %rsi
addq $0x70, %rdi
callq 0x566c0
jmp 0x557b3
leaq 0xf8(%rsp), %rdi
movl $0x1, %esi
callq 0x566a0
movq 0x58(%rsp), %rdi
movq (%rax), %rsi
addq $0xa8, %rdi
callq 0x566c0
jmp 0x557db
leaq 0xf8(%rsp), %rdi
movl $0x2, %esi
callq 0x566a0
movq 0x58(%rsp), %rdi
movq (%rax), %rsi
addq $0x70, %rdi
callq 0x566c0
jmp 0x55800
movq 0x58(%rsp), %rdi
addq $0x70, %rdi
callq 0x531f0
movq %rax, 0x40(%rsp)
jmp 0x55815
movq 0x58(%rsp), %rdi
movq 0x40(%rsp), %rax
movq %rax, (%rdi)
addq $0x70, %rdi
callq 0x531e0
movq %rax, 0x38(%rsp)
jmp 0x55832
movq 0x58(%rsp), %rdi
movq 0x38(%rsp), %rax
movq %rax, 0x8(%rdi)
movq 0x110(%rsp), %rsi
addq $0x30, %rdi
callq 0xb060
jmp 0x55853
movq 0x58(%rsp), %rax
cmpq $0x0, 0x118(%rax)
je 0x558a8
movq 0x58(%rsp), %rax
movq 0x118(%rax), %rax
movq %rax, 0x30(%rsp)
cmpq $0x0, %rax
je 0x5588d
movq 0x30(%rsp), %rdi
callq 0x1a4c0
movq 0x30(%rsp), %rdi
callq 0xb560
jmp 0x558a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
jmp 0x55a94
movl $0x30, %edi
callq 0xb590
movq %rax, 0x28(%rsp)
jmp 0x558b9
movq 0x58(%rsp), %rax
movq 0x8(%rax), %rcx
movq %rcx, 0x10(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x18(%rsp)
movl $0x18, %edi
callq 0xb590
movq %rax, 0x20(%rsp)
jmp 0x558e1
movq 0x20(%rsp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
callq 0x1a1d0
jmp 0x558fb
movl $0x18, %edi
callq 0xb590
movq %rax, 0x8(%rsp)
jmp 0x5590c
movq 0x8(%rsp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
callq 0x1a200
jmp 0x55926
movq 0x8(%rsp), %r8
movq 0x20(%rsp), %rcx
movq 0x18(%rsp), %rdx
movq 0x10(%rsp), %rsi
movq 0x28(%rsp), %rdi
callq 0x1a230
jmp 0x55946
movq 0x58(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, 0x118(%rax)
leaq 0xf8(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x90(%rsp), %rdi
callq 0x565d0
movq %rax, 0x88(%rsp)
movq 0x90(%rsp), %rdi
callq 0x56600
movq %rax, 0x80(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x56630
testb $0x1, %al
jne 0x559af
jmp 0x55a56
leaq 0x88(%rsp), %rdi
callq 0x56670
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x559e5
movq (%rsp), %rdi
callq 0x5bc10
movq (%rsp), %rdi
callq 0xb560
jmp 0x559e7
leaq 0x88(%rsp), %rdi
callq 0x56680
jmp 0x55991
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
jmp 0x55a4a
movq 0x20(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
callq 0xb560
jmp 0x55a4a
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
callq 0xb560
movq 0x28(%rsp), %rdi
callq 0xb560
jmp 0x55a94
leaq 0xf8(%rsp), %rdi
callq 0x567d0
movb $0x1, 0x127(%rsp)
movl $0x1, 0x9c(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x567f0
movb 0x127(%rsp), %al
andb $0x1, %al
addq $0x128, %rsp            # imm = 0x128
retq
leaq 0xf8(%rsp), %rdi
callq 0x567f0
movq 0xc8(%rsp), %rdi
callq 0xb980
nop