// File: /workspace/github_cpp_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rsi, %r14
movq %rdi, %rbx
addq $0x10, %rdi
callq 0x91c0
leaq 0x1d115(%rip), %rsi     # 0x31fd0
leaq 0x28(%rsp), %r15
movq %r15, %rdi
movl $0x98, %edx
xorl %ecx, %ecx
callq 0x2ee18
leaq 0x1d3ce(%rip), %rsi     # 0x322a4
movq %r15, %rdi
callq 0x9370
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x9320
leaq 0x28(%rsp), %rdi
callq 0x2f054
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0x1d3ae(%rip), %rsi     # 0x322b8
leaq 0x28(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x9120
leaq 0x50(%rbx), %rdi
leaq 0x10(%rsp), %rdx
leaq 0x28(%rsp), %rcx
movq %r14, %rsi
callq 0x15896
testb %al, %al
je 0x14fe3
movl 0x18(%rsp), %ebp
subl 0x10(%rsp), %ebp
leaq 0x28(%rsp), %rdi
callq 0x9160
testb $0x8, %bpl
jne 0x14fed
movq 0x18(%rsp), %r15
subq 0x10(%rsp), %r15
sarq $0x3, %r15
shrq %r15
movq 0x30(%rbx), %rax
movq 0x38(%rbx), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
decq %rdx
cmpq %r15, %rdx
jne 0x150ca
pushq $0x1
popq %r15
xorl %r12d, %r12d
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rcx, %r15
jae 0x15130
movq (%rax,%r15,8), %rdi
movq 0x10(%rsp), %rax
movq (%rax,%r12), %rsi
callq 0x15bc6
testb %al, %al
je 0x151b2
movq 0x30(%rbx), %rax
movq (%rax,%r15,8), %rdi
movq 0x10(%rsp), %rax
movq 0x8(%rax,%r12), %rsi
callq 0x15ce6
testb %al, %al
je 0x151eb
incq %r15
movq 0x30(%rbx), %rax
movq 0x38(%rbx), %rcx
addq $0x10, %r12
jmp 0x14f89
leaq 0x28(%rsp), %rdi
callq 0x9160
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r12
cmpq %r15, %r12
jne 0x15046
leaq 0x1cfcd(%rip), %rsi     # 0x31fd0
leaq 0x28(%rsp), %rdi
movl $0x9c, %edx
xorl %ecx, %ecx
callq 0x2ee18
leaq 0x1d2a6(%rip), %rsi     # 0x322c1
leaq 0x28(%rsp), %rdi
callq 0x9370
jmp 0x15222
movq (%r15), %r14
testq %r14, %r14
je 0x1503a
movq %r14, %rdi
callq 0x17fd6
movq %r14, %rdi
callq 0x9360
addq $0x8, %r15
cmpq %r12, %r15
jne 0x1502a
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x1505c
movq %rax, 0x18(%rsp)
leaq 0x1cf6d(%rip), %rsi     # 0x31fd0
leaq 0x28(%rsp), %rdi
pushq $0x3
popq %rcx
movl $0xa3, %edx
callq 0x2ee18
leaq 0x1d25a(%rip), %rsi     # 0x322d6
leaq 0x28(%rsp), %rdi
callq 0x9370
movq 0x18(%rsp), %rsi
subq 0x10(%rsp), %rsi
sarq $0x3, %rsi
leaq 0x28(%rsp), %rdi
callq 0x9210
leaq 0x1d243(%rip), %rsi     # 0x322e8
leaq 0x28(%rsp), %rdi
callq 0x9370
movq 0x38(%rbx), %rsi
subq 0x30(%rbx), %rsi
sarq $0x3, %rsi
leaq 0x28(%rsp), %rdi
callq 0x9210
jmp 0x15222
leaq 0x1ceff(%rip), %rsi     # 0x31fd0
leaq 0x28(%rsp), %rdi
pushq $0x3
popq %rcx
movl $0xa9, %edx
callq 0x2ee18
leaq 0x1d208(%rip), %rsi     # 0x322f2
leaq 0x28(%rsp), %rdi
callq 0x9370
leaq 0x28(%rsp), %rdi
movq %r15, %rsi
callq 0x9210
leaq 0x1d1e0(%rip), %rsi     # 0x322e8
leaq 0x28(%rsp), %rdi
callq 0x9370
movq 0x38(%rbx), %rsi
subq 0x30(%rbx), %rsi
sarq $0x3, %rsi
decq %rsi
leaq 0x28(%rsp), %rdi
callq 0x9210
jmp 0x15222
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r12
cmpq %r12, %r15
je 0x1515d
movq (%r15), %rbx
testq %rbx, %rbx
je 0x1514f
movq %rbx, %rdi
callq 0x17fd6
movq %rbx, %rdi
callq 0x9360
addq $0x8, %r15
jmp 0x1513a
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x1516e
movq %rax, 0x18(%rsp)
leaq 0x1ce5b(%rip), %rsi     # 0x31fd0
leaq 0x28(%rsp), %rdi
movl $0xbc, %edx
xorl %ecx, %ecx
callq 0x2ee18
leaq 0x1d1b8(%rip), %rsi     # 0x32345
leaq 0x28(%rsp), %rdi
callq 0x9370
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x9320
leaq 0x28(%rsp), %rdi
callq 0x2f054
movb $0x1, %bl
jmp 0x1522e
leaq 0x1ce17(%rip), %rsi     # 0x31fd0
leaq 0x28(%rsp), %rdi
pushq $0x3
popq %rcx
movl $0xaf, %edx
callq 0x2ee18
leaq 0x1d135(%rip), %rsi     # 0x32307
leaq 0x28(%rsp), %rdi
callq 0x9370
leaq 0x28(%rsp), %rdi
movq %r15, %rsi
callq 0x9210
jmp 0x15222
leaq 0x1cdde(%rip), %rsi     # 0x31fd0
leaq 0x28(%rsp), %rdi
pushq $0x3
popq %rcx
movl $0xb3, %edx
callq 0x2ee18
leaq 0x1d11c(%rip), %rsi     # 0x32327
leaq 0x28(%rsp), %rdi
callq 0x9370
leaq 0x28(%rsp), %rdi
movq %r15, %rsi
callq 0x9210
leaq 0x28(%rsp), %rdi
callq 0x2f054
xorl %ebx, %ebx
leaq 0x10(%rsp), %rdi
callq 0x164c4
movl %ebx, %eax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x15295
jmp 0x15295
jmp 0x15295
jmp 0x15266
jmp 0x15266
jmp 0x15266
jmp 0x15266
jmp 0x15295
jmp 0x15266
jmp 0x15295
jmp 0x15266
jmp 0x15266
jmp 0x15266
jmp 0x15295
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2f054
jmp 0x15298
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x9160
jmp 0x15298
jmp 0x15295
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2f054
jmp 0x152a2
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x164c4
movq %rbx, %rdi
callq 0x95e0