// File: /workspace/github_cpp_makefile_star2_O3/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 0x17cee(%rip), %rsi     # 0x290f1
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 0x1a0a8
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1a186
leaq 0x17cd2(%rip), %rsi     # 0x29113
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 0x1148d
callq 0x4230
movq 0x25b44(%rip), %rdi     # 0x36fd8
leaq 0x17c8e(%rip), %rsi     # 0x29129
movl $0x19, %edx
callq 0x4280
movq 0x25b2c(%rip), %rdi     # 0x36fd8
leaq 0x17c90(%rip), %rsi     # 0x29143
movl $0x30, %edx
callq 0x4280
movq 0x25b14(%rip), %rdi     # 0x36fd8
movl %ebp, %esi
callq 0x43c0
movq %rax, %r15
leaq 0x17c9f(%rip), %rsi     # 0x29174
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 0x116d8
movq 0x68(%rbx), %rax
cmpq 0x60(%rbx), %rax
je 0x1168e
leaq 0x1b8(%rsp), %r14
xorl %r13d, %r13d
leaq 0x18a76(%rip), %r12     # 0x29fb4
xorl %ebp, %ebp
movl $0x7, %edx
movq %r14, %rdi
leaq 0x17cb4(%rip), %rsi     # 0x29203
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 0x1ba81
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 0x17c2a(%rip), %rsi     # 0x2920b
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 0x1ba81
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 0x11540
leaq 0x1a8(%rsp), %rdi
callq 0x4060
leaq 0x1a8(%rsp), %rdi
callq 0x4070
movq 0x25921(%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 0x258f9(%rip), %rdi     # 0x36fd8
leaq 0x17a43(%rip), %rsi     # 0x29129
movl $0x19, %edx
callq 0x4280
movq 0x258e1(%rip), %rdi     # 0x36fd8
leaq 0x17a81(%rip), %rsi     # 0x2917f
movl $0x1a, %edx
callq 0x4280
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x4330
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x258b2(%rip), %rdi     # 0x36fd8
callq 0x4280
movq %rax, %rbx
leaq 0x17a65(%rip), %rsi     # 0x2919a
movl $0x1a, %edx
movq %rax, %rdi
callq 0x4280
movq %rbx, %rdi
callq 0x4100
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x11759
callq 0x4230
movq 0x25878(%rip), %rdi     # 0x36fd8
leaq 0x17a4e(%rip), %rsi     # 0x291b5
movl $0x4d, %edx
callq 0x4280
movq 0x25860(%rip), %rdi     # 0x36fd8
callq 0x4100
xorl %edi, %edi
callq 0x4290
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x117be
callq 0x4230
jmp 0x117be
jmp 0x117bb
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x117cb
callq 0x4230
jmp 0x117cb
jmp 0x117b4
movq %rax, %rbx
jmp 0x117cb
jmp 0x117bb
movq %rax, %rbx
leaq 0x1a8(%rsp), %rdi
callq 0x4070
movq 0x257fe(%rip), %rsi     # 0x36fd0
leaq 0x30(%rsp), %rdi
callq 0x4130
leaq 0xa0(%rsp), %rdi
callq 0x40b0
movq %rbx, %rdi
callq 0x43e0
nop