// File: /workspace/github_cpp_makefile_star2_O3/btbujiangjun[P]abcdl/src/fnn/FNN.cpp
// Function: abcdl::fnn::FNN::load_model(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool FNN::load_model(const std::string& path){
    _path = path;
    LOG(INFO) << "loading model from:" << path;
    std::vector<abcdl::algebra::Mat*> params;
    if(!_model_loader.read<real>(path, &params, "FNNMODEL") || params.size() % 2 != 0){
        if(params.size() == 0){
            LOG(INFO) << "Train with new model";
            return false;
        }
        for(auto& param : params){
            delete param;
        }
        params.clear();
        LOG(FATAL) << "Load model error:" << params.size() << " must be:" << _layers.size();
        return false;
    }
    
    size_t size = params.size() / 2;
    if(_layers.size() - 1 != size){
        LOG(FATAL) << "Model size is error:" << size << " must be:" << _layers.size() - 1;
        return false;
    }

    for(size_t i = 1; i < _layers.size(); i++){
        if(!_layers[i]->set_weight(*params[2 * (i-1)])){
            LOG(FATAL) << "Set Layer weight error, layer: " << i;
            return false;
        }
        if(!_layers[i]->set_bias(*params[2 * (i - 1) + 1])){
            LOG(FATAL) << "Set Layer bias error, layer: " << i;
            return false;
        }
    }

    for(auto& param : params){
        delete param;
    }
    params.clear();
    LOG(INFO) << "Load model success:" << path;
    
    return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rsi, %r14
movq %rdi, %rbx
addq $0x10, %rdi
callq 0x91b0
leaq 0x25c74(%rip), %rsi     # 0x3bff0
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movl $0x98, %edx
xorl %ecx, %ecx
callq 0x387b6
leaq 0x25f2d(%rip), %rsi     # 0x3c2c4
movl $0x13, %edx
movq %r15, %rdi
callq 0x93b0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
leaq 0x18(%rsp), %rdi
callq 0x93b0
leaq 0x18(%rsp), %rdi
callq 0x389de
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x28(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x25ef9(%rip), %rsi     # 0x3c2d8
leaq 0x25efa(%rip), %rdx     # 0x3c2e0
leaq 0x18(%rsp), %rdi
callq 0x145ac
leaq 0x50(%rbx), %rdi
movq %rsp, %rdx
leaq 0x18(%rsp), %rcx
movq %r14, %rsi
callq 0x16e5e
testb %al, %al
je 0x16559
movq (%rsp), %r12
movq 0x8(%rsp), %r13
subq %r12, %r13
movq 0x18(%rsp), %rdi
cmpq %r15, %rdi
je 0x1642b
callq 0x9350
movq (%rsp), %r12
testb $0x8, %r13b
jne 0x1656c
movq 0x8(%rsp), %r13
movq %r13, %r15
subq %r12, %r15
sarq $0x3, %r15
shrq %r15
movq 0x30(%rbx), %rax
movq 0x38(%rbx), %rcx
subq %rax, %rcx
movq %rcx, %rdx
sarq $0x3, %rdx
decq %rdx
cmpq %r15, %rdx
jne 0x16655
cmpq $0x9, %rcx
jb 0x164cf
movl $0x1, %r15d
xorl %r12d, %r12d
movq (%rax,%r15,8), %rdi
movq (%rsp), %rax
movq (%rax,%r12), %rsi
callq 0x1722a
testb %al, %al
je 0x166ef
movq 0x30(%rbx), %rax
movq (%rax,%r15,8), %rdi
movq (%rsp), %rax
movq 0x8(%rax,%r12), %rsi
callq 0x17366
testb %al, %al
je 0x1672f
incq %r15
movq 0x30(%rbx), %rax
movq 0x38(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
addq $0x10, %r12
cmpq %rcx, %r15
jb 0x16474
movq (%rsp), %r12
movq 0x8(%rsp), %r13
cmpq %r13, %r12
je 0x164ff
movq (%r12), %rbx
testq %rbx, %rbx
je 0x164e5
movq %rbx, %rdi
callq 0x19a36
movq %rbx, %rdi
callq 0x9350
addq $0x8, %r12
cmpq %r13, %r12
jne 0x164d4
movq (%rsp), %r12
movq 0x8(%rsp), %r13
cmpq %r12, %r13
je 0x16509
movq %r12, 0x8(%rsp)
leaq 0x25ae0(%rip), %rsi     # 0x3bff0
leaq 0x18(%rsp), %rdi
movl $0xbc, %edx
xorl %ecx, %ecx
callq 0x387b6
leaq 0x25e3d(%rip), %rsi     # 0x3c365
leaq 0x18(%rsp), %rdi
movl $0x13, %edx
callq 0x93b0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
leaq 0x18(%rsp), %rdi
callq 0x93b0
leaq 0x18(%rsp), %rdi
callq 0x389de
movb $0x1, %bl
jmp 0x166ce
movq 0x18(%rsp), %rdi
cmpq %r15, %rdi
je 0x16568
callq 0x9350
movq (%rsp), %r12
movq 0x8(%rsp), %r15
cmpq %r12, %r15
je 0x16625
movq (%r12), %r14
testq %r14, %r14
je 0x1658b
movq %r14, %rdi
callq 0x19a36
movq %r14, %rdi
callq 0x9350
addq $0x8, %r12
cmpq %r15, %r12
jne 0x1657a
movq (%rsp), %rax
cmpq %rax, 0x8(%rsp)
je 0x165ac
movq %rax, 0x8(%rsp)
leaq 0x25a3d(%rip), %rsi     # 0x3bff0
leaq 0x18(%rsp), %rdi
movl $0xa3, %edx
movl $0x3, %ecx
callq 0x387b6
leaq 0x25d28(%rip), %rsi     # 0x3c2f6
leaq 0x18(%rsp), %rdi
movl $0x11, %edx
callq 0x93b0
movq 0x8(%rsp), %rsi
subq (%rsp), %rsi
sarq $0x3, %rsi
leaq 0x18(%rsp), %rdi
callq 0x9200
leaq 0x25d0d(%rip), %rsi     # 0x3c308
leaq 0x18(%rsp), %rdi
movl $0x9, %edx
callq 0x93b0
movq 0x38(%rbx), %rsi
subq 0x30(%rbx), %rsi
sarq $0x3, %rsi
leaq 0x18(%rsp), %rdi
callq 0x9200
jmp 0x166c2
leaq 0x259c4(%rip), %rsi     # 0x3bff0
leaq 0x18(%rsp), %rdi
movl $0x9c, %edx
xorl %ecx, %ecx
callq 0x387b6
leaq 0x25c9d(%rip), %rsi     # 0x3c2e1
leaq 0x18(%rsp), %rdi
movl $0x14, %edx
callq 0x93b0
jmp 0x166c2
leaq 0x25994(%rip), %rsi     # 0x3bff0
leaq 0x18(%rsp), %rdi
movl $0xa9, %edx
movl $0x3, %ecx
callq 0x387b6
leaq 0x25c9b(%rip), %rsi     # 0x3c312
leaq 0x18(%rsp), %rdi
movl $0x14, %edx
callq 0x93b0
leaq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0x9200
leaq 0x25c6e(%rip), %rsi     # 0x3c308
leaq 0x18(%rsp), %rdi
movl $0x9, %edx
callq 0x93b0
movq 0x38(%rbx), %rsi
subq 0x30(%rbx), %rsi
sarq $0x3, %rsi
decq %rsi
leaq 0x18(%rsp), %rdi
callq 0x9200
leaq 0x18(%rsp), %rdi
callq 0x389de
xorl %ebx, %ebx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x166dc
callq 0x9350
movl %ebx, %eax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x258fa(%rip), %rsi     # 0x3bff0
leaq 0x18(%rsp), %rdi
movl $0xaf, %edx
movl $0x3, %ecx
callq 0x387b6
leaq 0x25c16(%rip), %rsi     # 0x3c327
leaq 0x18(%rsp), %rdi
movl $0x1f, %edx
callq 0x93b0
leaq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0x9200
jmp 0x166c2
leaq 0x258ba(%rip), %rsi     # 0x3bff0
leaq 0x18(%rsp), %rdi
movl $0xb3, %edx
movl $0x3, %ecx
callq 0x387b6
leaq 0x25bf6(%rip), %rsi     # 0x3c347
leaq 0x18(%rsp), %rdi
movl $0x1d, %edx
callq 0x93b0
leaq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0x9200
jmp 0x166c2
jmp 0x167b3
jmp 0x167b3
jmp 0x1678e
jmp 0x1678e
jmp 0x167b3
jmp 0x1678e
jmp 0x167b3
jmp 0x1678e
jmp 0x1678e
jmp 0x167b3
jmp 0x1678e
jmp 0x1678e
jmp 0x1678e
jmp 0x167b3
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x389de
jmp 0x167b6
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r15, %rdi
je 0x167b6
callq 0x9350
jmp 0x167b6
jmp 0x167b3
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x167d3
callq 0x9350
jmp 0x167d3
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x389de
movq %rbx, %rdi
callq 0x95d0
nop