// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::InitNeuronsInputLayer()
void ConstructLayer::InitNeuronsInputLayer()
{
    __neurons.clear();

    if(__p_data_interface == nullptr)
    {
        std::cout<<__func__<<" Error: must implement/pass DataInterface class before initializing neurons for input layer"
            <<std::endl;
        exit(0);
    }

    assert(__layerDimension != LayerDimension::Undefined);

    auto dim = __p_data_interface->GetDataDimension();

    // 1):
    // for 1D (fc) input layer; 1D input layer needs fake neurons, which will be used by
    //     its following layer to setup weight matrix dimension
    if(__layerDimension == LayerDimension::_1D)
    {
        assert(dim.second == 1); // make sure matrix transformation has been done
        //cout<<"Info::input layer dimension: "<<dim<<endl;
        Pixel2D<Neuron*> image(dim.first, dim.second);
        for(size_t i=0;i<dim.first;i++)
        {
            for(size_t j=0;j<dim.second;j++)
            {
                Neuron *n = new Neuron();
                // n->SetCoord(i, j, k); // input layer neuron does not need coord
                n->SetActuationFuncType(__neuron_actuation_func_type);
                image[i][0] = n;
            }
        }
        __neurons.push_back(image);
    }

    // 2):
    // for 2D input layer, 2D input layer does not need fake neurons, instead
    //     its following layers will directly get 'A' images from 2D input layer
    else if(__layerDimension == LayerDimension::_2D)
    {
        // 2D layers neurons number should equal to dim.first * dim.second
        size_t total_neurons = dim.first * dim.second;
        Pixel2D<Neuron*> image(total_neurons, 1);
        for(size_t i=0;i<total_neurons;i++)
        {
            for(size_t j=0;j<1;j++)
            {
                Neuron *n = new Neuron();
                // n->SetCoord(i, j, k); // input layer neuron does not need coord
                image[i][0] = n;
            }
        }
        __neurons.push_back(image);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdi, %r14
leaq 0x40(%rdi), %rbx
movq %rbx, %rdi
callq 0x11226
movq 0x400(%r14), %rax
testq %rax, %rax
je 0x65e7
movl 0x408(%r14), %ecx
cmpl $0x2, %ecx
je 0x6618
movq 0x70(%rax), %r15
movq 0x78(%rax), %r12
cmpl $0x1, %ecx
je 0x656f
testl %ecx, %ecx
jne 0x65d9
cmpq $0x1, %r12
jne 0x6637
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rdx
movq %r15, %rsi
callq 0x1122e
xorl %r13d, %r13d
subq $0x1, %r15
jb 0x65c2
movl $0xa0, %edi
callq 0x4250
movq %rax, %r12
movq %rax, %rdi
callq 0x1bbb8
movl 0x58(%r14), %esi
movq %r12, %rdi
callq 0x1c312
movq 0x8(%rsp), %rax
movq (%rax,%r13), %rax
movq %r12, (%rax)
addq $0x18, %r13
jmp 0x6532
imulq %r15, %r12
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rdx
movq %r12, %rsi
callq 0x1122e
xorl %r15d, %r15d
subq $0x1, %r12
jb 0x65b3
movl $0xa0, %edi
callq 0x4250
movq %rax, %r14
movq %rax, %rdi
callq 0x1bbb8
movq 0x8(%rsp), %rax
movq (%rax,%r15), %rax
movq %r14, (%rax)
addq $0x18, %r15
jmp 0x6586
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x112b2
jmp 0x65cf
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x112b2
leaq 0x8(%rsp), %rdi
callq 0x11d84
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x2c9ea(%rip), %rdi     # 0x32fd8
leaq 0x1b1ce(%rip), %rsi     # 0x217c3
callq 0x4240
leaq 0x1b1d8(%rip), %rsi     # 0x217d9
movq %rax, %rdi
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
leaq 0x1b216(%rip), %rdi     # 0x21835
leaq 0x1b0b4(%rip), %rsi     # 0x216da
leaq 0x1b236(%rip), %rcx     # 0x21863
movl $0x1ce, %edx            # imm = 0x1CE
callq 0x4180
leaq 0x1b9cd(%rip), %rdi     # 0x2200b
leaq 0x1b095(%rip), %rsi     # 0x216da
leaq 0x1b217(%rip), %rcx     # 0x21863
movl $0x1d7, %edx            # imm = 0x1D7
callq 0x4180
jmp 0x6671
jmp 0x6671
movq %rax, %rbx
movq %r12, %rdi
jmp 0x666a
jmp 0x6671
movq %rax, %rbx
movq %r14, %rdi
callq 0x4220
jmp 0x6674
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x11d84
movq %rbx, %rdi
callq 0x43b0