// File: /workspace/github_cpp_makefile_star2_O1/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 %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rsi, %r14
movq %rdi, %rbx
addq $0x10, %rdi
callq 0x91b0
leaq 0x259da(%rip), %rsi     # 0x3bff0
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movl $0x98, %edx
xorl %ecx, %ecx
callq 0x3894e
leaq 0x25c93(%rip), %rsi     # 0x3c2c4
movl $0x13, %edx
movq %r15, %rdi
callq 0x93b0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
leaq 0x20(%rsp), %rdi
callq 0x93b0
leaq 0x20(%rsp), %rdi
callq 0x38b76
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x30(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x25c5f(%rip), %rsi     # 0x3c2d8
leaq 0x25c60(%rip), %rdx     # 0x3c2e0
leaq 0x20(%rsp), %rdi
callq 0x148b8
leaq 0x50(%rbx), %rdi
movq %rsp, %rdx
leaq 0x20(%rsp), %rcx
movq %r14, %rsi
callq 0x170aa
testb %al, %al
je 0x1678c
movq 0x8(%rsp), %r12
subq (%rsp), %r12
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x166be
callq 0x9350
testb $0x8, %r12b
jne 0x1679b
movq 0x8(%rsp), %r15
subq (%rsp), %r15
sarq $0x3, %r15
movq 0x38(%rbx), %rax
subq 0x30(%rbx), %rax
shrq %r15
sarq $0x3, %rax
decq %rax
cmpq %r15, %rax
jne 0x16887
movq 0x30(%rbx), %rax
movq 0x38(%rbx), %rcx
subq %rax, %rcx
cmpq $0x9, %rcx
jb 0x1675c
movl $0x1, %r15d
xorl %r12d, %r12d
movq (%rax,%r15,8), %rdi
movq (%rsp), %rax
movq (%rax,%r12), %rsi
callq 0x1748a
testb %al, %al
je 0x1697c
movq 0x30(%rbx), %rax
movq (%rax,%r15,8), %rdi
movq (%rsp), %rax
movq 0x8(%rax,%r12), %rsi
callq 0x175c6
testb %al, %al
je 0x169bf
incq %r15
movq 0x30(%rbx), %rax
movq 0x38(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
addq $0x10, %r12
cmpq %rcx, %r15
jb 0x1670a
movq (%rsp), %r15
movq 0x8(%rsp), %r12
cmpq %r12, %r15
je 0x1691f
movq (%r15), %rbx
testq %rbx, %rbx
je 0x16786
movq %rbx, %rdi
callq 0x19c8e
movq %rbx, %rdi
callq 0x9350
addq $0x8, %r15
jmp 0x16765
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x1679b
callq 0x9350
movq (%rsp), %r15
movq 0x8(%rsp), %r12
cmpq %r15, %r12
je 0x16857
movq (%r15), %r14
testq %r14, %r14
je 0x167c5
movq %r14, %rdi
callq 0x19c8e
movq %r14, %rdi
callq 0x9350
addq $0x8, %r15
cmpq %r12, %r15
jne 0x167ad
movq (%rsp), %rax
cmpq %rax, 0x8(%rsp)
je 0x167de
movq %rax, 0x8(%rsp)
leaq 0x2580b(%rip), %rsi     # 0x3bff0
leaq 0x20(%rsp), %rdi
movl $0xa3, %edx
movl $0x3, %ecx
callq 0x3894e
leaq 0x25af6(%rip), %rsi     # 0x3c2f6
leaq 0x20(%rsp), %rdi
movl $0x11, %edx
callq 0x93b0
movq 0x8(%rsp), %rsi
subq (%rsp), %rsi
sarq $0x3, %rsi
leaq 0x20(%rsp), %rdi
callq 0x9200
leaq 0x25adb(%rip), %rsi     # 0x3c308
leaq 0x20(%rsp), %rdi
movl $0x9, %edx
callq 0x93b0
movq 0x38(%rbx), %rsi
subq 0x30(%rbx), %rsi
sarq $0x3, %rsi
leaq 0x20(%rsp), %rdi
callq 0x9200
jmp 0x168f4
leaq 0x25792(%rip), %rsi     # 0x3bff0
leaq 0x20(%rsp), %rdi
movl $0x9c, %edx
xorl %ecx, %ecx
callq 0x3894e
leaq 0x25a6b(%rip), %rsi     # 0x3c2e1
leaq 0x20(%rsp), %rdi
movl $0x14, %edx
callq 0x93b0
jmp 0x168f4
leaq 0x25762(%rip), %rsi     # 0x3bff0
leaq 0x20(%rsp), %rdi
movl $0xa9, %edx
movl $0x3, %ecx
callq 0x3894e
leaq 0x25a69(%rip), %rsi     # 0x3c312
leaq 0x20(%rsp), %rdi
movl $0x14, %edx
callq 0x93b0
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x9200
leaq 0x25a3c(%rip), %rsi     # 0x3c308
leaq 0x20(%rsp), %rdi
movl $0x9, %edx
callq 0x93b0
movq 0x38(%rbx), %rsi
subq 0x30(%rbx), %rsi
sarq $0x3, %rsi
decq %rsi
leaq 0x20(%rsp), %rdi
callq 0x9200
leaq 0x20(%rsp), %rdi
callq 0x38b76
xorl %ebx, %ebx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1690e
callq 0x9350
movl %ebx, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq (%rsp), %rax
cmpq %rax, 0x8(%rsp)
je 0x1692f
movq %rax, 0x8(%rsp)
leaq 0x256ba(%rip), %rsi     # 0x3bff0
leaq 0x20(%rsp), %rdi
movl $0xbc, %edx
xorl %ecx, %ecx
callq 0x3894e
leaq 0x25a17(%rip), %rsi     # 0x3c365
leaq 0x20(%rsp), %rdi
movl $0x13, %edx
callq 0x93b0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
leaq 0x20(%rsp), %rdi
callq 0x93b0
leaq 0x20(%rsp), %rdi
callq 0x38b76
movb $0x1, %bl
jmp 0x16900
leaq 0x2566d(%rip), %rsi     # 0x3bff0
leaq 0x20(%rsp), %rdi
movl $0xaf, %edx
movl $0x3, %ecx
callq 0x3894e
leaq 0x25989(%rip), %rsi     # 0x3c327
leaq 0x20(%rsp), %rdi
movl $0x1f, %edx
callq 0x93b0
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x9200
jmp 0x168f4
leaq 0x2562a(%rip), %rsi     # 0x3bff0
leaq 0x20(%rsp), %rdi
movl $0xb3, %edx
movl $0x3, %ecx
callq 0x3894e
leaq 0x25966(%rip), %rsi     # 0x3c347
leaq 0x20(%rsp), %rdi
movl $0x1d, %edx
callq 0x93b0
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x9200
jmp 0x168f4
jmp 0x16a43
jmp 0x16a43
jmp 0x16a1e
jmp 0x16a1e
jmp 0x16a43
jmp 0x16a1e
jmp 0x16a43
jmp 0x16a1e
jmp 0x16a1e
jmp 0x16a43
jmp 0x16a1e
jmp 0x16a1e
jmp 0x16a1e
jmp 0x16a43
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x38b76
jmp 0x16a46
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x16a46
callq 0x9350
jmp 0x16a46
jmp 0x16a43
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x16a63
callq 0x9350
jmp 0x16a63
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x38b76
movq %rbx, %rdi
callq 0x95d0
nop