函数 | |
| float | applyUnary (OpType t, float x, float s0, float s1) |
| bool | isElementwiseOp (OpType t) |
| bool | broadcastShape (const int *aDims, int aRank, const int *bDims, int bRank, int *outDims, int &outRank) |
| void | binaryOp (OpType type, const float *a, const int *aDims, int aRank, const float *b, const int *bDims, int bRank, float *out, const int *outDims, int outRank) |
| void | unaryOp (OpType type, const float *in, int count, float *out, float s0, float s1) |
| void | softmax (const float *in, const int *dims, int rank, int axis, bool logMode, float *out) |
| void | layernorm (const float *in, int rows, int cols, const float *scale, const float *bias, float eps, float *out) |
| void | rmsnorm (const float *in, int rows, int cols, const float *scale, float eps, float *out) |
| void | conv1d (const float *x, const int *xDims, const float *w, const int *wDims, const float *bias, int stride, int pad, float *out) |
| void | conv2d (const float *x, const int *xDims, const float *w, const int *wDims, const float *bias, int stride, int pad, float *out) |
| void | maxpool2d (const float *in, const int *dims, int ksize, int stride, int pad, float *out) |
| void | avgpool2d (const float *in, const int *dims, int ksize, int stride, int pad, float *out) |
| void | embedding (const float *table, int vocab, int dim, const float *indices, int count, float *out) |
| void | concat (const float *const *ins, const int *const *inDims, const int *inRanks, int n, int axis, float *out, const int *outDims, int outRank) |
| void | sliceOp (const float *in, const int *inDims, int inRank, int axis, int begin, int end, float *out, const int *outDims, int outRank) |
| void | permute (const float *in, const int *inDims, int rank, const int *order, float *out, const int *outDims) |
| void | reduceAxis (OpType type, const float *in, const int *dims, int rank, int axis, float *out, const int *outDims, int outRank) |
| void | argmax (const float *in, const int *dims, int rank, int axis, float *out, const int *outDims, int outRank) |
| void | sdpa (const float *q, const float *k, const float *v, const float *mask, int B, int H, int T, int S, int D, float scale, float *out) |
| void | resize2d (const float *in, const int *inDims, int outW, int outH, int mode, float *out) |
详细描述
CPU reference kernels shared by the eager path and the graph interpreter.
All shapes are static, row-major, rank <= Tensor::kMaxRank. Every entry point is a plain loop implementation: correctness / portability first, throughput is provided by the generated GPU kernels when a Vulkan device is available.
函数说明
◆ applyUnary()
| float eve::tensor::kernels::applyUnary | ( | OpType | type, |
| float | x, | ||
| float | s0, | ||
| float | s1 | ||
| ) |
Apply a scalar unary op (elementwise) to one value.
在文件 CpuKernels.cpp 第 55 行定义.
引用了 eve::tensor::Abs, eve::tensor::AddScalar, eve::tensor::Clamp, eve::tensor::Cos, eve::tensor::DivScalar, eve::tensor::Exp, eve::tensor::Gelu, eve::tensor::Log, eve::tensor::MaximumScalar, eve::tensor::MinimumScalar, eve::tensor::MulScalar, eve::tensor::Neg, eve::tensor::PowScalar, eve::tensor::Relu, eve::tensor::Sigmoid, eve::tensor::Silu, eve::tensor::Sin, eve::tensor::Sqrt, eve::tensor::SubScalar, eve::tensor::Tanh , 以及 x.
被这些函数引用 unaryOp().
◆ argmax()
| void eve::tensor::kernels::argmax | ( | const float * | in, |
| const int * | dims, | ||
| int | rank, | ||
| int | axis, | ||
| float * | out, | ||
| const int * | outDims, | ||
| int | outRank | ||
| ) |
◆ avgpool2d()
| void eve::tensor::kernels::avgpool2d | ( | const float * | in, |
| const int * | dims, | ||
| int | ksize, | ||
| int | stride, | ||
| int | pad, | ||
| float * | out | ||
| ) |
◆ binaryOp()
| void eve::tensor::kernels::binaryOp | ( | OpType | type, |
| const float * | a, | ||
| const int * | aDims, | ||
| int | aRank, | ||
| const float * | b, | ||
| const int * | bDims, | ||
| int | bRank, | ||
| float * | out, | ||
| const int * | outDims, | ||
| int | outRank | ||
| ) |
Elementwise binary op with broadcasting.
在文件 CpuKernels.cpp 第 136 行定义.
引用了 a, b, eve::tensor::Tensor::kMaxRank , 以及 type.
◆ broadcastShape()
| bool eve::tensor::kernels::broadcastShape | ( | const int * | aDims, |
| int | aRank, | ||
| const int * | bDims, | ||
| int | bRank, | ||
| int * | outDims, | ||
| int & | outRank | ||
| ) |
Broadcast two shapes to a common shape. Returns false when incompatible.
在文件 CpuKernels.cpp 第 120 行定义.
引用了 eve::tensor::Tensor::kMaxRank.
被这些函数引用 eve::tensor::Func::emitBinary().
◆ concat()
| void eve::tensor::kernels::concat | ( | const float *const * | ins, |
| const int *const * | inDims, | ||
| const int * | inRanks, | ||
| int | n, | ||
| int | axis, | ||
| float * | out, | ||
| const int * | outDims, | ||
| int | outRank | ||
| ) |
concat n (2..4) tensors along axis; all other dims must match out dims.
在文件 CpuKernels.cpp 第 336 行定义.
◆ conv1d()
| void eve::tensor::kernels::conv1d | ( | const float * | x, |
| const int * | xDims, | ||
| const float * | w, | ||
| const int * | wDims, | ||
| const float * | bias, | ||
| int | stride, | ||
| int | pad, | ||
| float * | out | ||
| ) |
◆ conv2d()
| void eve::tensor::kernels::conv2d | ( | const float * | x, |
| const int * | xDims, | ||
| const float * | w, | ||
| const int * | wDims, | ||
| const float * | bias, | ||
| int | stride, | ||
| int | pad, | ||
| float * | out | ||
| ) |
◆ embedding()
| void eve::tensor::kernels::embedding | ( | const float * | table, |
| int | vocab, | ||
| int | dim, | ||
| const float * | indices, | ||
| int | count, | ||
| float * | out | ||
| ) |
table [vocab x dim], indices [count] -> out [count x dim]. Indices are clamped.
在文件 CpuKernels.cpp 第 325 行定义.
被这些函数引用 eve::tensor::TF::embedding().
◆ isElementwiseOp()
| bool eve::tensor::kernels::isElementwiseOp | ( | OpType | type | ) |
Whether the op is a fusible elementwise op (also used by the optimizer).
在文件 CpuKernels.cpp 第 87 行定义.
引用了 eve::tensor::Abs, eve::tensor::Add, eve::tensor::AddScalar, eve::tensor::Clamp, eve::tensor::Cos, eve::tensor::Divide, eve::tensor::DivScalar, eve::tensor::Exp, eve::tensor::Gelu, eve::tensor::Log, eve::tensor::MaximumScalar, eve::tensor::MinimumScalar, eve::tensor::MulScalar, eve::tensor::Multiply, eve::tensor::Neg, eve::tensor::PowScalar, eve::tensor::Relu, eve::tensor::Sigmoid, eve::tensor::Silu, eve::tensor::Sin, eve::tensor::Sqrt, eve::tensor::Sub, eve::tensor::SubScalar, eve::tensor::Tanh , 以及 eve::tensor::Where.
被这些函数引用 eve::tensor::optimizeGraph().
◆ layernorm()
| void eve::tensor::kernels::layernorm | ( | const float * | in, |
| int | rows, | ||
| int | cols, | ||
| const float * | scale, | ||
| const float * | bias, | ||
| float | eps, | ||
| float * | out | ||
| ) |
在文件 CpuKernels.cpp 第 187 行定义.
被这些函数引用 eve::tensor::TF::layernorm() , 以及 eve::tensor::TF::layernormWB().
◆ maxpool2d()
| void eve::tensor::kernels::maxpool2d | ( | const float * | in, |
| const int * | dims, | ||
| int | ksize, | ||
| int | stride, | ||
| int | pad, | ||
| float * | out | ||
| ) |
◆ permute()
| void eve::tensor::kernels::permute | ( | const float * | in, |
| const int * | inDims, | ||
| int | rank, | ||
| const int * | order, | ||
| float * | out, | ||
| const int * | outDims | ||
| ) |
在文件 CpuKernels.cpp 第 382 行定义.
引用了 idx , 以及 eve::tensor::Tensor::kMaxRank.
被这些函数引用 eve::tensor::Tensor::permute().
◆ reduceAxis()
| void eve::tensor::kernels::reduceAxis | ( | OpType | type, |
| const float * | in, | ||
| const int * | dims, | ||
| int | rank, | ||
| int | axis, | ||
| float * | out, | ||
| const int * | outDims, | ||
| int | outRank | ||
| ) |
sum/mean/min/max along axis (out dims must already be computed by caller).
在文件 CpuKernels.cpp 第 401 行定义.
引用了 reduce, eve::tensor::ReduceMax, eve::tensor::ReduceMean, eve::tensor::ReduceMin, eve::tensor::ReduceSum, type , 以及 v.
◆ resize2d()
| void eve::tensor::kernels::resize2d | ( | const float * | in, |
| const int * | inDims, | ||
| int | outW, | ||
| int | outH, | ||
| int | mode, | ||
| float * | out | ||
| ) |
resize2d NCHW; mode: 0 = nearest, 1 = bilinear.
在文件 CpuKernels.cpp 第 488 行定义.
被这些函数引用 eve::tensor::TF::resize2d().
◆ rmsnorm()
| void eve::tensor::kernels::rmsnorm | ( | const float * | in, |
| int | rows, | ||
| int | cols, | ||
| const float * | scale, | ||
| float | eps, | ||
| float * | out | ||
| ) |
在文件 CpuKernels.cpp 第 211 行定义.
被这些函数引用 eve::tensor::TF::rmsnorm() , 以及 eve::tensor::TF::rmsnormW().
◆ sdpa()
| void eve::tensor::kernels::sdpa | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| const float * | mask, | ||
| int | B, | ||
| int | H, | ||
| int | T, | ||
| int | S, | ||
| int | D, | ||
| float | scale, | ||
| float * | out | ||
| ) |
Scaled dot-product attention over the last two dims: q [B,H,T,D], k [B,H,S,D], v [B,H,S,D], mask [B,H,T,S] (optional, may be null).
在文件 CpuKernels.cpp 第 454 行定义.
被这些函数引用 eve::tensor::TF::sdpaMasked().
◆ sliceOp()
| void eve::tensor::kernels::sliceOp | ( | const float * | in, |
| const int * | inDims, | ||
| int | inRank, | ||
| int | axis, | ||
| int | begin, | ||
| int | end, | ||
| float * | out, | ||
| const int * | outDims, | ||
| int | outRank | ||
| ) |
在文件 CpuKernels.cpp 第 365 行定义.
被这些函数引用 eve::tensor::TF::slice().
◆ softmax()
| void eve::tensor::kernels::softmax | ( | const float * | in, |
| const int * | dims, | ||
| int | rank, | ||
| int | axis, | ||
| bool | logMode, | ||
| float * | out | ||
| ) |
在文件 CpuKernels.cpp 第 163 行定义.
被这些函数引用 eve::tensor::TF::logSoftmax() , 以及 eve::tensor::TF::softmax().
◆ unaryOp()
| void eve::tensor::kernels::unaryOp | ( | OpType | type, |
| const float * | in, | ||
| int | count, | ||
| float * | out, | ||
| float | s0, | ||
| float | s1 | ||
| ) |
Elementwise unary / scalar op.
在文件 CpuKernels.cpp 第 159 行定义.
引用了 applyUnary() , 以及 type.
被这些函数引用 eve::tensor::Tensor::addScalar(), eve::tensor::Tensor::clamp(), eve::tensor::Tensor::divScalar(), eve::tensor::Tensor::maximumScalar(), eve::tensor::Tensor::minimumScalar(), eve::tensor::Tensor::mulScalar(), eve::tensor::Tensor::powScalar() , 以及 eve::tensor::Tensor::subScalar().