// File: /workspace/github_cpp_makefile_star2_O1/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::SaveTrainedWeightsAndBias()
void ConstructLayer::SaveTrainedWeightsAndBias()
{
    int layer_id = GetID();
    LayerType layer_type = GetType();
    LayerDimension layer_dimension = GetLayerDimension();

    // parse file name
    std::ostringstream oss;
    oss<<"weights_and_bias_trained/LayerID=";
    oss<<layer_id;
    oss<<layer_type;
    oss<<layer_dimension;
    oss<<"_weights_and_bias.txt";

    // save weights and bias
    std::fstream ff(oss.str(), std::ios::out);
    std::cout<<__func__<<"(): Saving trained weights and bias from layer: "<<layer_id<<" to files."<<std::endl;
    if(!ff.is_open())
    {
        std::cout<<__func__<<" Error: cannot open file: "<<oss.str()<<" to save weights and bias."
            <<std::endl;
        std::cout<<"           please make sure you have 'weights_and_bias_trained' folder exsit."
            <<std::endl;
        exit(0);
    }
    for(size_t i=0;i<__weightMatrix.size();i++)
    {
        ff<<"weight "<<i<<":"<<std::endl;
        //cout<<"weight "<<i<<":"<<std::endl;
        ff<<__weightMatrix[i]<<std::endl;
        //cout<<__weightMatrix[i]<<endl;
        ff<<"bias "<<i<<":"<<std::endl;
        //cout<<"bias: "<<i<<":"<<std::endl;
        ff<<__biasVector[i]<<std::endl;
        //cout<<__biasVector[i]<<endl;
    }
    ff.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3b8, %rsp            # imm = 0x3B8
movq %rdi, %rbx
movq (%rdi), %rax
callq *0x298(%rax)
movl %eax, %ebp
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x250(%rax)
movl %eax, 0xc(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x258(%rax)
movl %eax, 0x8(%rsp)
leaq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x42c0
leaq 0x17be5(%rip), %rsi     # 0x29130
movl $0x21, %edx
movq %r14, %rdi
callq 0x4280
leaq 0x30(%rsp), %rdi
movl %ebp, %esi
callq 0x43c0
leaq 0x30(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x1a124
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1a202
leaq 0x17bc9(%rip), %rsi     # 0x29152
leaq 0x30(%rsp), %rdi
movl $0x15, %edx
callq 0x4280
leaq 0x38(%rsp), %r14
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x4330
leaq 0x1a8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl $0x10, %edx
callq 0x4380
leaq 0x20(%rsp), %r12
movq -0x10(%r12), %rdi
cmpq %r12, %rdi
je 0x115d5
callq 0x4230
movq 0x259fc(%rip), %rdi     # 0x36fd8
leaq 0x17b85(%rip), %rsi     # 0x29168
movl $0x19, %edx
callq 0x4280
movq 0x259e4(%rip), %rdi     # 0x36fd8
leaq 0x17b87(%rip), %rsi     # 0x29182
movl $0x30, %edx
callq 0x4280
movq 0x259cc(%rip), %rdi     # 0x36fd8
movl %ebp, %esi
callq 0x43c0
movq %rax, %r15
leaq 0x17b96(%rip), %rsi     # 0x291b3
movl $0xa, %edx
movq %rax, %rdi
callq 0x4280
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4250
movsbl %al, %esi
movq %r15, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4190
leaq 0x228(%rsp), %rdi
callq 0x4080
testb %al, %al
je 0x11820
movq 0x68(%rbx), %rax
cmpq 0x60(%rbx), %rax
je 0x117d6
leaq 0x1b8(%rsp), %r14
xorl %r13d, %r13d
leaq 0x1896e(%rip), %r12     # 0x29ff4
xorl %ebp, %ebp
movl $0x7, %edx
movq %r14, %rdi
leaq 0x17bab(%rip), %rsi     # 0x29242
callq 0x4280
movq %r14, %rdi
movq %rbp, %rsi
callq 0x4180
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x4280
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4250
movsbl %al, %esi
movq %r15, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4190
movq 0x60(%rbx), %rsi
addq %r13, %rsi
movq %r14, %rdi
callq 0x1bb59
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4250
movsbl %al, %esi
movq %r15, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4190
movl $0x5, %edx
movq %r14, %rdi
leaq 0x17b21(%rip), %rsi     # 0x2924a
callq 0x4280
movq %r14, %rdi
movq %rbp, %rsi
callq 0x4180
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x4280
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4250
movsbl %al, %esi
movq %r15, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4190
movq 0x78(%rbx), %rsi
addq %r13, %rsi
movq %r14, %rdi
callq 0x1bb59
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4250
movsbl %al, %esi
movq %r15, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4190
incq %rbp
movq 0x68(%rbx), %rax
subq 0x60(%rbx), %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
addq $0x18, %r13
cmpq %rax, %rbp
jb 0x11688
leaq 0x1a8(%rsp), %rdi
callq 0x4060
leaq 0x1a8(%rsp), %rdi
callq 0x4070
movq 0x257d9(%rip), %rsi     # 0x36fd0
leaq 0x30(%rsp), %rdi
callq 0x4130
leaq 0xa0(%rsp), %rdi
callq 0x40b0
addq $0x3b8, %rsp            # imm = 0x3B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x257b1(%rip), %rdi     # 0x36fd8
leaq 0x1793a(%rip), %rsi     # 0x29168
movl $0x19, %edx
callq 0x4280
movq 0x25799(%rip), %rdi     # 0x36fd8
leaq 0x17978(%rip), %rsi     # 0x291be
movl $0x1a, %edx
callq 0x4280
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x4330
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x2576a(%rip), %rdi     # 0x36fd8
callq 0x4280
movq %rax, %rbx
leaq 0x1795c(%rip), %rsi     # 0x291d9
movl $0x1a, %edx
movq %rax, %rdi
callq 0x4280
movq %rbx, %rdi
callq 0x4100
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x118a1
callq 0x4230
movq 0x25730(%rip), %rdi     # 0x36fd8
leaq 0x17945(%rip), %rsi     # 0x291f4
movl $0x4d, %edx
callq 0x4280
movq 0x25718(%rip), %rdi     # 0x36fd8
callq 0x4100
xorl %edi, %edi
callq 0x4290
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x11906
callq 0x4230
jmp 0x11906
jmp 0x11903
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11913
callq 0x4230
jmp 0x11913
jmp 0x118fc
movq %rax, %rbx
jmp 0x11913
jmp 0x11903
movq %rax, %rbx
leaq 0x1a8(%rsp), %rdi
callq 0x4070
movq 0x256b6(%rip), %rsi     # 0x36fd0
leaq 0x30(%rsp), %rdi
callq 0x4130
leaq 0xa0(%rsp), %rdi
callq 0x40b0
movq %rbx, %rdi
callq 0x43e0
nop