Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*++
 
Copyright (c) Microsoft Corporation. All rights reserved.
 
Licensed under the MIT License.
 
Module Name:
 
    silu.cpp
 
Abstract:
 
    This module implements routines to compute the SiLU function.
 
--*/
 
#include "mlasi.h"
 
void
MLASCALL
MlasSiluKernel(
    const float* Input,
    float* Output,
    size_t N
    )
{
    // This kernel is not buffer alias safe because it is implemented in two
    // passes: first compute logistic(Input) into Output, then multiply that
    // intermediate by the original Input values. Callers must guarantee that
    // Input and Output do not overlap (see mlas.h for aliasing requirements).
    MlasComputeLogistic(Input, Output, N);
    MlasEltwiseMul<float>(Input, Output, Output, N);
}
 
void
MLASCALL
MlasComputeSilu(
    const float* Input,
    float* Output,
    size_t N
    )
{
#if defined(MLAS_TARGET_AMD64) || defined(MLAS_TARGET_RISCV64)
    // TODO: Add an intermediate fused AVX2/FMA3 SiLU path on AMD64. Today the
    // dispatch jumps from the generic two-pass implementation to AVX512F, so
    // non-AVX512 x64 machines fall back to the generic kernel.
    GetMlasPlatform().SiluKernelRoutine(Input, Output, N);
#else
    MlasSiluKernel(Input, Output, N);
#endif
}