// File: xbai0624[P]dnn/./include/Layer.h
// Function: Images::Tensorization(unsigned long, unsigned long) const
Images Tensorization(size_t I, size_t J) const
    {
        // this is the inverse operation for vectorization
        // used for backward propagation, 1D layer to 2D layer
        //     [I J] is the dimension of tensorized kernel matrix
        assert(OutputImageFromKernel.size() == 1); // make sure this is from 1D layer (only one kernel)
        Matrix tmp = OutputImageFromKernel[0];
        auto dim = tmp.Dimension();
        assert(dim.second == 1); // make sure it is a one-collumn matrix
        size_t unit_quantity = I * J; //  number of elements in each tensorized kernel
        assert(dim.first%unit_quantity == 0);

        int nKernels = dim.first/unit_quantity;
        Images Ret;
        for(size_t i=0;i<(size_t)nKernels;i++)
        {
            Matrix _tmp = tmp.GetSection(i*unit_quantity, (i+1)*unit_quantity, 0, 1);
            Matrix _t = _tmp.Reshape(I, J);
            Ret.OutputImageFromKernel.push_back(_t);
        }
        //std::cout<<"before return: "<<&Ret<<std::endl;
        return Ret;
    }

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0x20(%rsp)
movq %rdi, %rax
movq %rax, 0x28(%rsp)
movq %rdi, 0xd0(%rsp)
movq %rsi, 0xc8(%rsp)
movq %rdx, 0xc0(%rsp)
movq %rcx, 0xb8(%rsp)
movq 0xc8(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x1f9c0
cmpq $0x1, %rax
jne 0x514ee
jmp 0x5150d
leaq 0x1669(%rip), %rdi      # 0x52b5e
leaq 0x2c20(%rip), %rsi      # 0x5411c
movl $0x169, %edx            # imm = 0x169
leaq 0x5151(%rip), %rcx      # 0x56659
callq 0x4170
movq 0x30(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x29840
movq %rax, %rsi
leaq 0xa0(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x3b810
movq 0x8(%rsp), %rdi
callq 0x3bae0
movq %rdx, 0x10(%rsp)
movq %rax, 0x18(%rsp)
jmp 0x51546
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, 0x90(%rsp)
movq %rax, 0x98(%rsp)
cmpq $0x1, 0x98(%rsp)
jne 0x5156d
jmp 0x515a5
leaq 0x15ce(%rip), %rdi      # 0x52b42
leaq 0x2ba1(%rip), %rsi      # 0x5411c
movl $0x16c, %edx            # imm = 0x16C
leaq 0x50d2(%rip), %rcx      # 0x56659
callq 0x4170
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
jmp 0x51762
movq 0xc0(%rsp), %rax
imulq 0xb8(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x90(%rsp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq 0x78(%rsp)
cmpq $0x0, %rdx
jne 0x515d4
jmp 0x515f3
leaq 0x50b1(%rip), %rdi      # 0x5668c
leaq 0x2b3a(%rip), %rsi      # 0x5411c
movl $0x16e, %edx            # imm = 0x16E
leaq 0x506b(%rip), %rcx      # 0x56659
callq 0x4170
movq 0x20(%rsp), %rdi
movq 0x90(%rsp), %rax
movq 0x78(%rsp), %rcx
xorl %edx, %edx
divq %rcx
movl %eax, 0x74(%rsp)
movb $0x0, 0x73(%rsp)
callq 0x1fda0
jmp 0x5161a
movq $0x0, 0x68(%rsp)
movq 0x68(%rsp), %rax
movslq 0x74(%rsp), %rcx
cmpq %rcx, %rax
jae 0x51728
movq 0x68(%rsp), %rcx
movq 0x78(%rsp), %rax
movq %rcx, %rdx
imulq %rax, %rdx
incq %rcx
imulq %rax, %rcx
movq %rsp, %rax
movl $0x0, (%rax)
xorl %eax, %eax
movl %eax, %r8d
leaq 0x50(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
movl $0x1, %r9d
xorps %xmm0, %xmm0
callq 0x3ee40
jmp 0x51679
movq 0xc0(%rsp), %rdx
movq 0xb8(%rsp), %rcx
leaq 0x38(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x3df60
jmp 0x5169a
movq 0x20(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x1fa50
jmp 0x516ab
leaq 0x38(%rsp), %rdi
callq 0x3bb80
leaq 0x50(%rsp), %rdi
callq 0x3bb80
movq 0x68(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x68(%rsp)
jmp 0x51623
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
jmp 0x51758
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
jmp 0x5171c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x3bb80
leaq 0x50(%rsp), %rdi
callq 0x3bb80
jmp 0x51758
movb $0x1, 0x73(%rsp)
testb $0x1, 0x73(%rsp)
jne 0x5173e
movq 0x20(%rsp), %rdi
callq 0x1fde0
leaq 0xa0(%rsp), %rdi
callq 0x3bb80
movq 0x28(%rsp), %rax
addq $0xd8, %rsp
retq
movq 0x20(%rsp), %rdi
callq 0x1fde0
leaq 0xa0(%rsp), %rdi
callq 0x3bb80
movq 0x88(%rsp), %rdi
callq 0x43f0
nopl (%rax)