// File: xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::UpdateCoordsForActiveNeuronFC()
void ConstructLayer::UpdateCoordsForActiveNeuronFC()
{
    // enable/disable neuron; and
    // update coords for active neuron
    assert(__neurons.size() == 1); 
    auto dim = __neurons[0].Dimension();
    //cout<<"Neuron dimension in FC layer: "<<dim<<endl;
    assert(dim.second == 1);

    // get filter
    assert(__activeFlag.size() == 1);

    size_t active_i = 0;
    for(size_t i=0;i<dim.first;i++)
    {
        // first reset coords back
        //__neurons[0][i][0]->SetCoord(0, i, 0); //SetCoord(i, j, k), please note the sequence of the coordinates
        __neurons[0][i][0]->SetCoord(i, 0, 0);   //SetCoord(i, j, k), 

        // then set coord according to filter mask
        if(!__activeFlag[0][i][0]){
            __neurons[0][i][0]->Disable();
            continue;
        }
        __neurons[0][i][0]->Enable();
        //__neurons[0][i][0]->SetCoord(0, active_i, 0);
        __neurons[0][i][0]->SetCoord(active_i, 0, 0); // SetCoord(i, j, k)
        active_i++;
    }
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq 0x40(%rsp), %rdi
movq %rdi, 0x8(%rsp)
addq $0x40, %rdi
callq 0x1f630
cmpq $0x1, %rax
jne 0x13534
jmp 0x13553
leaq 0x3ee8c(%rip), %rdi     # 0x523c7
leaq 0x3ec90(%rip), %rsi     # 0x521d2
movl $0xa04, %edx            # imm = 0xA04
leaq 0x3f863(%rip), %rcx     # 0x52db1
callq 0x4170
movq 0x8(%rsp), %rdi
addq $0x40, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f650
movq %rax, %rdi
callq 0x1f530
movq %rax, 0x30(%rsp)
movq %rdx, 0x38(%rsp)
cmpq $0x1, 0x38(%rsp)
jne 0x13581
jmp 0x135a0
leaq 0x3f5ba(%rip), %rdi     # 0x52b42
leaq 0x3ec43(%rip), %rsi     # 0x521d2
movl $0xa07, %edx            # imm = 0xA07
leaq 0x3f816(%rip), %rcx     # 0x52db1
callq 0x4170
movq 0x8(%rsp), %rdi
addq $0x108, %rdi            # imm = 0x108
callq 0x1ffd0
cmpq $0x1, %rax
jne 0x135b9
jmp 0x135d8
leaq 0x3f82e(%rip), %rdi     # 0x52dee
leaq 0x3ec0b(%rip), %rsi     # 0x521d2
movl $0xa0a, %edx            # imm = 0xA0A
leaq 0x3f7de(%rip), %rcx     # 0x52db1
callq 0x4170
movq $0x0, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x20(%rsp), %rax
cmpq 0x30(%rsp), %rax
jae 0x1374e
movq 0x8(%rsp), %rdi
addq $0x40, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f650
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x1f5c0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f5f0
movq (%rax), %rdi
movq 0x20(%rsp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x4a1b0
movq 0x8(%rsp), %rdi
addq $0x108, %rdi            # imm = 0x108
xorl %eax, %eax
movl %eax, %esi
callq 0x1ff80
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x1fff0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x20020
movq %rax, 0x10(%rsp)
movq %rdx, 0x18(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x20080
xorb $-0x1, %al
testb $0x1, %al
jne 0x13683
jmp 0x136bb
movq 0x8(%rsp), %rdi
addq $0x40, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f650
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x1f5c0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f5f0
movq (%rax), %rdi
callq 0x47fa0
jmp 0x1373b
movq 0x8(%rsp), %rdi
addq $0x40, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f650
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x1f5c0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f5f0
movq (%rax), %rdi
callq 0x47fc0
movq 0x8(%rsp), %rdi
addq $0x40, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f650
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x1f5c0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f5f0
movq (%rax), %rdi
movq 0x28(%rsp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x4a1b0
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
movq 0x20(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20(%rsp)
jmp 0x135ea
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)