// File: btbujiangjun[P]abcdl/src/fnn/Layer.cpp
// Function: abcdl::fnn::BatchNormalizationLayer::forward(abcdl::fnn::Layer*)
void BatchNormalizationLayer::forward(Layer* pre_layer){
    auto input = pre_layer->get_activate_data();
    CHECK(input.cols() == this->_weight.cols());
    _means = input.mean(abcdl::algebra::Axis_type::COL);
    _variances = (input - _means).pow(2).mean(abcdl::algebra::Axis_type::COL);
    _scales = (_variances + _epsilon).sqrt().inverse();
    _normalize = (input - _means) * _scales;
    this->_activate_data = _normalize * this->_weight.get_row(0) + this->_weight.get_row(1); 
}

// Assembly:
subq $0x3c8, %rsp            # imm = 0x3C8
movq %rdi, 0x3c0(%rsp)
movq %rsi, 0x3b8(%rsp)
movq 0x3c0(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x3b8(%rsp), %rdi
callq 0x27c10
movq %rax, %rsi
leaq 0x390(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x193b0
movq 0x28(%rsp), %rdi
callq 0x1a3a0
movq %rax, 0x30(%rsp)
jmp 0x276c7
movq 0x20(%rsp), %rdi
addq $0x30, %rdi
callq 0x1a3a0
movq %rax, 0x18(%rsp)
jmp 0x276dc
movq 0x30(%rsp), %rax
movq 0x18(%rsp), %rcx
cmpq %rcx, %rax
sete %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x276f7
jmp 0x2777b
leaq 0x687e6(%rip), %rsi     # 0x8fee4
leaq 0x1f8(%rsp), %rdi
movl $0x3e, %edx
movl $0x3, %ecx
callq 0x89860
jmp 0x27717
leaq 0x687ff(%rip), %rsi     # 0x8ff1d
leaq 0x1f8(%rsp), %rdi
callq 0x27c60
jmp 0x2772d
leaq 0x1f8(%rsp), %rdi
callq 0x89c20
jmp 0x2777b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x27bb3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
leaq 0x1f8(%rsp), %rdi
callq 0x89c20
jmp 0x27bb3
leaq 0x1d0(%rsp), %rdi
leaq 0x390(%rsp), %rsi
movl $0x1, %edx
callq 0x5e020
jmp 0x27797
movq 0x20(%rsp), %rdi
addq $0x170, %rdi            # imm = 0x170
leaq 0x1d0(%rsp), %rsi
callq 0x429a0
jmp 0x277b2
leaq 0x1d0(%rsp), %rdi
callq 0x33e80
movq 0x20(%rsp), %rdx
addq $0x170, %rdx            # imm = 0x170
leaq 0x180(%rsp), %rdi
leaq 0x390(%rsp), %rsi
callq 0x43870
jmp 0x277e2
movl $0x40000000, 0x17c(%rsp) # imm = 0x40000000
leaq 0x180(%rsp), %rdi
leaq 0x17c(%rsp), %rsi
callq 0x5cfa0
movq %rax, 0x10(%rsp)
jmp 0x27809
movq 0x10(%rsp), %rsi
leaq 0x1a8(%rsp), %rdi
movl $0x1, %edx
callq 0x5e020
jmp 0x27822
movq 0x20(%rsp), %rdi
addq $0x198, %rdi            # imm = 0x198
leaq 0x1a8(%rsp), %rsi
callq 0x429a0
jmp 0x2783d
leaq 0x1a8(%rsp), %rdi
callq 0x33e80
leaq 0x180(%rsp), %rdi
callq 0x33e80
movq 0x20(%rsp), %rdx
movq %rdx, %rsi
addq $0x198, %rsi            # imm = 0x198
addq $0x168, %rdx            # imm = 0x168
leaq 0x128(%rsp), %rdi
callq 0x42aa0
jmp 0x2787c
leaq 0x128(%rsp), %rdi
callq 0x5d060
movq %rax, 0x8(%rsp)
jmp 0x27890
movq 0x8(%rsp), %rsi
leaq 0x150(%rsp), %rdi
callq 0x5e3a0
jmp 0x278a4
movq 0x20(%rsp), %rdi
addq $0x1c0, %rdi            # imm = 0x1C0
leaq 0x150(%rsp), %rsi
callq 0x429a0
jmp 0x278bf
leaq 0x150(%rsp), %rdi
callq 0x33e80
leaq 0x128(%rsp), %rdi
callq 0x33e80
movq 0x20(%rsp), %rdx
addq $0x170, %rdx            # imm = 0x170
leaq 0xd8(%rsp), %rdi
leaq 0x390(%rsp), %rsi
callq 0x43870
jmp 0x278fc
movq 0x20(%rsp), %rdx
addq $0x1c0, %rdx            # imm = 0x1C0
leaq 0x100(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x443f0
jmp 0x2791f
movq 0x20(%rsp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
leaq 0x100(%rsp), %rsi
callq 0x429a0
jmp 0x2793a
leaq 0x100(%rsp), %rdi
callq 0x33e80
leaq 0xd8(%rsp), %rdi
callq 0x33e80
movq 0x20(%rsp), %rsi
movq %rsi, %rax
addq $0x1e8, %rax            # imm = 0x1E8
movq %rax, (%rsp)
addq $0x30, %rsi
xorl %eax, %eax
movl %eax, %edx
leaq 0x60(%rsp), %rdi
movl $0x1, %ecx
callq 0x343d0
jmp 0x2797f
movq (%rsp), %rsi
leaq 0x88(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0x443f0
jmp 0x27997
movq 0x20(%rsp), %rsi
addq $0x30, %rsi
leaq 0x38(%rsp), %rdi
movl $0x1, %ecx
movq %rcx, %rdx
callq 0x343d0
jmp 0x279b4
leaq 0xb0(%rsp), %rdi
leaq 0x88(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x42c60
jmp 0x279d0
movq 0x20(%rsp), %rdi
addq $0xa0, %rdi
leaq 0xb0(%rsp), %rsi
callq 0x429a0
jmp 0x279eb
leaq 0xb0(%rsp), %rdi
callq 0x33e80
leaq 0x38(%rsp), %rdi
callq 0x33e80
leaq 0x88(%rsp), %rdi
callq 0x33e80
leaq 0x60(%rsp), %rdi
callq 0x33e80
leaq 0x390(%rsp), %rdi
callq 0x33e80
addq $0x3c8, %rsp            # imm = 0x3C8
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0x33e80
jmp 0x27bb3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x27a8b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
leaq 0x1a8(%rsp), %rdi
callq 0x33e80
leaq 0x180(%rsp), %rdi
callq 0x33e80
jmp 0x27bb3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x27ad4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x33e80
leaq 0x128(%rsp), %rdi
callq 0x33e80
jmp 0x27bb3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x27b1d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x33e80
leaq 0xd8(%rsp), %rdi
callq 0x33e80
jmp 0x27bb3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x27ba9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x27b9c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x27b92
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x33e80
leaq 0x38(%rsp), %rdi
callq 0x33e80
leaq 0x88(%rsp), %rdi
callq 0x33e80
leaq 0x60(%rsp), %rdi
callq 0x33e80
leaq 0x390(%rsp), %rdi
callq 0x33e80
movq 0x388(%rsp), %rdi
callq 0x9700
nopl (%rax)