// File: /workspace/github_cpp_makefile_star2_O1/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
movq 0x40(%rdi), %r15
movq 0x48(%rdi), %r12
cmpq %r15, %r12
je 0x68b1
movq %r15, %rbx
movq %rbx, %rdi
callq 0x146fc
addq $0x18, %rbx
cmpq %r12, %rbx
jne 0x689c
movq %r15, 0x48(%r14)
movq 0x400(%r14), %rax
testq %rax, %rax
je 0x69c0
movl 0x408(%r14), %ecx
cmpl $0x2, %ecx
je 0x69f1
leaq 0x40(%r14), %rbx
movq 0x70(%rax), %r15
movq 0x78(%rax), %r12
cmpl $0x1, %ecx
je 0x6953
testl %ecx, %ecx
jne 0x69b2
cmpq $0x1, %r12
jne 0x6a10
leaq 0x8(%rsp), %rdi
movl $0x1, %edx
movq %r15, %rsi
callq 0x1387a
testq %r15, %r15
je 0x6944
xorl %r13d, %r13d
movl $0xa0, %edi
callq 0x4270
movq %rax, %r12
movq %rax, %rdi
callq 0x201f4
movl 0x58(%r14), %esi
movq %r12, %rdi
callq 0x20a3a
movq 0x8(%rsp), %rax
movq (%rax,%r13), %rax
movq %r12, (%rax)
addq $0x18, %r13
decq %r15
jne 0x690e
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x1390c
jmp 0x69a8
imulq %r15, %r12
leaq 0x8(%rsp), %rdi
movl $0x1, %edx
movq %r12, %rsi
callq 0x1387a
testq %r12, %r12
je 0x699b
xorl %r15d, %r15d
movl $0xa0, %edi
callq 0x4270
movq %rax, %r14
movq %rax, %rdi
callq 0x201f4
movq 0x8(%rsp), %rax
movq (%rax,%r15), %rax
movq %r14, (%rax)
addq $0x18, %r15
decq %r12
jne 0x6971
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x1390c
leaq 0x8(%rsp), %rdi
callq 0x146fc
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x30611(%rip), %rdi     # 0x36fd8
leaq 0x20ea4(%rip), %rsi     # 0x27872
callq 0x4260
leaq 0x20eae(%rip), %rsi     # 0x27888
movq %rax, %rdi
callq 0x4260
movq %rax, %rdi
callq 0x4100
xorl %edi, %edi
callq 0x4290
leaq 0x20eec(%rip), %rdi     # 0x278e4
leaq 0x20d4b(%rip), %rsi     # 0x2774a
leaq 0x20f0c(%rip), %rcx     # 0x27912
movl $0x1ce, %edx            # imm = 0x1CE
callq 0x4160
leaq 0x216a3(%rip), %rdi     # 0x280ba
leaq 0x20d2c(%rip), %rsi     # 0x2774a
leaq 0x20eed(%rip), %rcx     # 0x27912
movl $0x1d7, %edx            # imm = 0x1D7
callq 0x4160
jmp 0x6a4a
jmp 0x6a4a
movq %rax, %rbx
movq %r12, %rdi
jmp 0x6a43
jmp 0x6a4a
movq %rax, %rbx
movq %r14, %rdi
callq 0x4230
jmp 0x6a4d
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x146fc
movq %rbx, %rdi
callq 0x43e0
nop