// File: /workspace/github_cpp_makefile_star2_O3/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 0x67e9
movq %r15, %rbx
movq %rbx, %rdi
callq 0x145c2
addq $0x18, %rbx
cmpq %r12, %rbx
jne 0x67d4
movq %r15, 0x48(%r14)
movq 0x400(%r14), %rax
testq %rax, %rax
je 0x68f8
movl 0x408(%r14), %ecx
cmpl $0x2, %ecx
je 0x6929
leaq 0x40(%r14), %rbx
movq 0x70(%rax), %r15
movq 0x78(%rax), %r12
cmpl $0x1, %ecx
je 0x688b
testl %ecx, %ecx
jne 0x68ea
cmpq $0x1, %r12
jne 0x6948
leaq 0x8(%rsp), %rdi
movl $0x1, %edx
movq %r15, %rsi
callq 0x13728
testq %r15, %r15
je 0x687c
xorl %r13d, %r13d
movl $0xa0, %edi
callq 0x4270
movq %rax, %r12
movq %rax, %rdi
callq 0x20124
movl 0x58(%r14), %esi
movq %r12, %rdi
callq 0x20956
movq 0x8(%rsp), %rax
movq (%rax,%r13), %rax
movq %r12, (%rax)
addq $0x18, %r13
decq %r15
jne 0x6846
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x137ba
jmp 0x68e0
imulq %r15, %r12
leaq 0x8(%rsp), %rdi
movl $0x1, %edx
movq %r12, %rsi
callq 0x13728
testq %r12, %r12
je 0x68d3
xorl %r15d, %r15d
movl $0xa0, %edi
callq 0x4270
movq %rax, %r14
movq %rax, %rdi
callq 0x20124
movq 0x8(%rsp), %rax
movq (%rax,%r15), %rax
movq %r14, (%rax)
addq $0x18, %r15
decq %r12
jne 0x68a9
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x137ba
leaq 0x8(%rsp), %rdi
callq 0x145c2
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x306d9(%rip), %rdi     # 0x36fd8
leaq 0x20f2d(%rip), %rsi     # 0x27833
callq 0x4260
leaq 0x20f37(%rip), %rsi     # 0x27849
movq %rax, %rdi
callq 0x4260
movq %rax, %rdi
callq 0x4100
xorl %edi, %edi
callq 0x4290
leaq 0x20f75(%rip), %rdi     # 0x278a5
leaq 0x20e13(%rip), %rsi     # 0x2774a
leaq 0x20f95(%rip), %rcx     # 0x278d3
movl $0x1ce, %edx            # imm = 0x1CE
callq 0x4160
leaq 0x2172c(%rip), %rdi     # 0x2807b
leaq 0x20df4(%rip), %rsi     # 0x2774a
leaq 0x20f76(%rip), %rcx     # 0x278d3
movl $0x1d7, %edx            # imm = 0x1D7
callq 0x4160
jmp 0x6982
jmp 0x6982
movq %rax, %rbx
movq %r12, %rdi
jmp 0x697b
jmp 0x6982
movq %rax, %rbx
movq %r14, %rdi
callq 0x4230
jmp 0x6985
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x145c2
movq %rbx, %rdi
callq 0x43e0
nop