// File: /workspace/github_cpp_makefile_star2_O1/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::InitNeurons()
void ConstructLayer::InitNeurons()
{
    if(__type == LayerType::cnn)
        InitNeuronsCNN();
    else if(__type == LayerType::pooling)
        InitNeuronsPooling();
    else if(__type == LayerType::input)
        InitNeuronsInputLayer();
    else if(__type == LayerType::fullyConnected)
        InitNeuronsFC();
    else if(__type == LayerType::output)
        InitNeuronsFC();
    else
    {
        std::cout<<"Error: Init neurons, unrecognized layer type."<<std::endl;
        exit(0);
    }
    //std::cout<<"Debug: Layer:"<<GetID()<<" init neruons done."<<std::endl;

    // after initializing all neurons, setup neuron dimension information
    // setup total neuron dimension
    size_t k = __neurons.size();
    size_t i = 0;
    size_t j = 0;
    if(k > 0)
    {
        i = __neurons[0].Dimension().first;
        j = __neurons[0].Dimension().second;

        __neuronDim.k = k;
        __neuronDim.i = i;
        __neuronDim.j = j;
    }

    // setup neuron layer information
    for(size_t kk=0;kk<k;kk++)
    {
        for(size_t ii=0;ii<i;ii++)
            for(size_t jj=0;jj<j;jj++)
            {
                __neurons[kk][ii][jj]->SetLayer(dynamic_cast<Layer*>(this));
                //__neurons[kk][ii][jj]->SetPreviousLayer(__prevLayer); // obsolete
                //__neurons[kk][ii][jj]->SetNextLayer(__nextLayer);     // obsolete
            }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl 0xc(%rdi), %eax
cmpq $0x4, %rax
ja 0x6463
movq %rdi, %rbx
leaq 0x20dcf(%rip), %rcx     # 0x27104
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
callq 0x6a60
jmp 0x6364
movq %rbx, %rdi
callq 0x687c
jmp 0x6364
movq %rbx, %rdi
callq 0x6486
jmp 0x6364
movq %rbx, %rdi
callq 0x66a6
movq 0x40(%rbx), %rax
movq 0x48(%rbx), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rdi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdi, %rdx
movq %rdx, %r8
cmpq %rax, %rcx
je 0x63a5
movq (%rax), %rdx
movq 0x8(%rax), %rsi
movq %rsi, %r9
subq %rdx, %r9
je 0x63ad
sarq $0x3, %r9
imulq %rdi, %r9
jmp 0x63b0
xorl %r12d, %r12d
xorl %r9d, %r9d
jmp 0x63da
xorl %r9d, %r9d
cmpq %rdx, %rsi
je 0x63c2
movq 0x8(%rdx), %r12
subq (%rdx), %r12
sarq $0x3, %r12
jmp 0x63c5
xorl %r12d, %r12d
movq %r8, 0x3a8(%rbx)
movq %r9, 0x398(%rbx)
movq %r12, 0x3a0(%rbx)
cmpq %rax, %rcx
je 0x6454
cmpq $0x1, %r8
adcq $0x0, %r8
movq %r8, 0x8(%rsp)
movq $0x0, (%rsp)
movq %r9, 0x10(%rsp)
testq %r9, %r9
je 0x6442
movq (%rsp), %rax
leaq (%rax,%rax,2), %rbp
xorl %r14d, %r14d
testq %r12, %r12
je 0x6435
leaq (%r14,%r14,2), %r13
xorl %r15d, %r15d
movq 0x40(%rbx), %rax
movq (%rax,%rbp,8), %rax
movq (%rax,%r13,8), %rax
movq (%rax,%r15,8), %rdi
movq %rbx, %rsi
callq 0x20a34
incq %r15
cmpq %r15, %r12
jne 0x6415
incq %r14
movq 0x10(%rsp), %r9
cmpq %r9, %r14
jne 0x6409
movq (%rsp), %rcx
incq %rcx
movq %rcx, (%rsp)
cmpq 0x8(%rsp), %rcx
jne 0x63f9
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x30b6e(%rip), %rdi     # 0x36fd8
leaq 0x21294(%rip), %rsi     # 0x27705
callq 0x4260
movq %rax, %rdi
callq 0x4100
xorl %edi, %edi
callq 0x4290
nop