FastDeploy
latest
Fast & Easy to Deploy!
|
All C++ FDTensor Operation APIs are defined inside this namespace. More...
Functions | |
void | Cast (const FDTensor &x, FDTensor *out, FDDataType output_dtype) |
void | Clip (const FDTensor &x, double min, double max, FDTensor *out) |
void | Concat (const std::vector< FDTensor > &x, FDTensor *out, int axis) |
FASTDEPLOY_DECL void | CudaCast (const FDTensor &in, FDTensor *out, cudaStream_t stream) |
void | Cumprod (const FDTensor &x, FDTensor *out, int axis) |
void | Add (const FDTensor &x, const FDTensor &y, FDTensor *out) |
void | Subtract (const FDTensor &x, const FDTensor &y, FDTensor *out) |
void | Multiply (const FDTensor &x, const FDTensor &y, FDTensor *out) |
void | Divide (const FDTensor &x, const FDTensor &y, FDTensor *out) |
void | Maximum (const FDTensor &x, const FDTensor &y, FDTensor *out) |
void | Full (const Scalar &value, const std::vector< int64_t > &shape, FDTensor *out, FDDataType dtype) |
void | FullLike (const FDTensor &x, const Scalar &value, FDTensor *out, FDDataType dtype) |
void | GatherAlongAxis (const FDTensor &x, const FDTensor &index, FDTensor *result, int axis) |
void | GaussianRandom (const std::vector< int64_t > &shape, FDTensor *out, FDDataType dtype, float mean, float std, int seed) |
void | IsNan (const FDTensor &x, FDTensor *out, FDDataType dtype) |
void | IsInf (const FDTensor &x, FDTensor *out, FDDataType dtype) |
void | IsFinite (const FDTensor &x, FDTensor *out, FDDataType dtype) |
void | Linspace (double start, double end, int num, FDTensor *out, FDDataType dtype) |
void | Sqrt (const FDTensor &x, FDTensor *out) |
void | Log (const FDTensor &x, FDTensor *out) |
void | Round (const FDTensor &x, FDTensor *out) |
void | Exp (const FDTensor &x, FDTensor *out) |
void | Abs (const FDTensor &x, FDTensor *out) |
void | Ceil (const FDTensor &x, FDTensor *out) |
void | Floor (const FDTensor &x, FDTensor *out) |
void | Pad (const FDTensor &x, FDTensor *out, const std::vector< int > &pads, float value) |
void | Quantile (const FDTensor &x, const std::vector< double > &q, const std::vector< int > &axis, FDTensor *out) |
void | Max (const FDTensor &x, FDTensor *out, const std::vector< int64_t > &dims, bool keep_dim, bool reduce_all) |
void | Min (const FDTensor &x, FDTensor *out, const std::vector< int64_t > &dims, bool keep_dim, bool reduce_all) |
void | Sum (const FDTensor &x, FDTensor *out, const std::vector< int64_t > &dims, bool keep_dim, bool reduce_all) |
void | All (const FDTensor &x, FDTensor *out, const std::vector< int64_t > &dims, bool keep_dim, bool reduce_all) |
void | Any (const FDTensor &x, FDTensor *out, const std::vector< int64_t > &dims, bool keep_dim, bool reduce_all) |
void | Mean (const FDTensor &x, FDTensor *out, const std::vector< int64_t > &dims, bool keep_dim, bool reduce_all) |
void | Prod (const FDTensor &x, FDTensor *out, const std::vector< int64_t > &dims, bool keep_dim, bool reduce_all) |
void | ArgMax (const FDTensor &x, FDTensor *out, int64_t axis, FDDataType output_dtype, bool keep_dim, bool flatten) |
void | ArgMin (const FDTensor &x, FDTensor *out, int64_t axis, FDDataType output_dtype, bool keep_dim, bool flatten) |
void | Slice (const FDTensor &x, const std::vector< int64_t > &axes, const std::vector< int64_t > &starts, const std::vector< int64_t > &ends, FDTensor *out) |
void | Softmax (const FDTensor &x, FDTensor *out, int axis) |
void | Sort (const FDTensor &x, FDTensor *out, FDTensor *indices, int axis=0, bool descending=false, FDDataType indices_type=FDDataType::INT64) |
Performs sorting on the input tensor along the given axis and outputs two tensors, Output(Out) and Output(Indices). They reserve the same shape with Input(X), and Output(Out) represents the sorted tensor while Output(Indices) gives the sorted order along the given axis Attr(axis). More... | |
void | Split (const FDTensor &x, const std::vector< int > &num_or_sections, std::vector< FDTensor > *out, int axis) |
void | Tile (const FDTensor &x, const std::vector< int64_t > &repeat_times, FDTensor *out) |
void | Transpose (const FDTensor &x, FDTensor *out, const std::vector< int64_t > &dims) |
All C++ FDTensor Operation APIs are defined inside this namespace.
This operator is used to perform elementwise abs for input X. Only for float type FDTensor
x | The input tensor. |
out | The output tensor which stores the result. |
FASTDEPLOY_DECL void fastdeploy::function::Add | ( | const FDTensor & | x, |
const FDTensor & | y, | ||
FDTensor * | out | ||
) |
Excute the add operation for input FDTensors. *out = x + y.
x | The input tensor. |
y | The input tensor. |
out | The output tensor which stores the result. |
FASTDEPLOY_DECL void fastdeploy::function::All | ( | const FDTensor & | x, |
FDTensor * | out, | ||
const std::vector< int64_t > & | dims, | ||
bool | keep_dim = false , |
||
bool | reduce_all = false |
||
) |
Excute the all operation for input FDTensor along given dims.
x | The input tensor. |
out | The output tensor which stores the result. |
dims | The vector of axis which will be reduced. |
keep_dim | Whether to keep the reduced dims, default false. |
reduce_all | Whether to reduce all dims, default false. |
FASTDEPLOY_DECL void fastdeploy::function::Any | ( | const FDTensor & | x, |
FDTensor * | out, | ||
const std::vector< int64_t > & | dims, | ||
bool | keep_dim = false , |
||
bool | reduce_all = false |
||
) |
Excute the any operation for input FDTensor along given dims.
x | The input tensor. |
out | The output tensor which stores the result. |
dims | The vector of axis which will be reduced. |
keep_dim | Whether to keep the reduced dims, default false. |
reduce_all | Whether to reduce all dims, default false. |
FASTDEPLOY_DECL void fastdeploy::function::ArgMax | ( | const FDTensor & | x, |
FDTensor * | out, | ||
int64_t | axis, | ||
FDDataType | output_dtype = FDDataType::INT64 , |
||
bool | keep_dim = false , |
||
bool | flatten = false |
||
) |
Excute the argmax operation for input FDTensor along given dims.
x | The input tensor. |
out | The output tensor which stores the result. |
axis | The axis which will be reduced. |
output_dtype | The data type of output FDTensor, INT64 or INT32, default to INT64. |
keep_dim | Whether to keep the reduced dims, default false. |
flatten | Whether to flatten FDTensor to get the argmin index, default false. |
FASTDEPLOY_DECL void fastdeploy::function::ArgMin | ( | const FDTensor & | x, |
FDTensor * | out, | ||
int64_t | axis, | ||
FDDataType | output_dtype = FDDataType::INT64 , |
||
bool | keep_dim = false , |
||
bool | flatten = false |
||
) |
Excute the argmin operation for input FDTensor along given dims.
x | The input tensor. |
out | The output tensor which stores the result. |
axis | The axis which will be reduced. |
output_dtype | The data type of output FDTensor, INT64 or INT32, default to INT64. |
keep_dim | Whether to keep the reduced dims, default false. |
flatten | Whether to flatten FDTensor to get the argmin index, default false. |
FASTDEPLOY_DECL void fastdeploy::function::Cast | ( | const FDTensor & | x, |
FDTensor * | out, | ||
FDDataType | output_dtype | ||
) |
Cast x to output data type element-wise. Only for float type FDTensor
x | The input tensor. |
out | The output tensor which stores the result. |
output_dtype | The type of output tensor. |
Computes ceil of x element-wise. Only for float type FDTensor
x | The input tensor. |
out | The output tensor which stores the result. |
FASTDEPLOY_DECL void fastdeploy::function::Clip | ( | const FDTensor & | x, |
double | min, | ||
double | max, | ||
FDTensor * | out | ||
) |
This operator clip all elements in input into the range [ min, max ]. Support float32, float64, int32, int64
x | The input tensor. |
min | The lower bound |
max | The uppper bound |
out | The output tensor which stores the result. |
FASTDEPLOY_DECL void fastdeploy::function::Concat | ( | const std::vector< FDTensor > & | x, |
FDTensor * | out, | ||
int | axis = 0 |
||
) |
Excute the concatenate operation for input FDTensor along given axis.
x | The input tensor. |
out | The output tensor which stores the result. |
axis | Axis which will be concatenated. |
FASTDEPLOY_DECL void fastdeploy::function::CudaCast | ( | const FDTensor & | in, |
FDTensor * | out, | ||
cudaStream_t | stream | ||
) |
Cast the type of the data in GPU buffer.
in | The input tensor. |
out | The output tensor |
stream | CUDA stream |
FASTDEPLOY_DECL void fastdeploy::function::Cumprod | ( | const FDTensor & | x, |
FDTensor * | out, | ||
int | axis = 0 |
||
) |
Excute the concatenate operation for input FDTensor along given axis.
x | The input tensor. |
out | The output tensor which stores the result. |
axisi | Axis which will be concatenated. |
FASTDEPLOY_DECL void fastdeploy::function::Divide | ( | const FDTensor & | x, |
const FDTensor & | y, | ||
FDTensor * | out | ||
) |
Excute the divide operation for input FDTensors. *out = x / y.
x | The input tensor. |
y | The input tensor. |
out | The output tensor which stores the result. |
Computes exp of x element-wise with a natural number e as the base, element-wise. Only for float type FDTensor
x | The input tensor. |
out | The output tensor which stores the result. |
Computes floor of x element-wise. Only for float type FDTensor
x | The input tensor. |
out | The output tensor which stores the result. |
FASTDEPLOY_DECL void fastdeploy::function::Full | ( | const Scalar & | value, |
const std::vector< int64_t > & | shape, | ||
FDTensor * | out, | ||
FDDataType | dtype = FDDataType::FP32 |
||
) |
Fill the value to tensor
value | The value to be filled in tensor |
shape | The shape of output tensor. |
out | The output tensor which stores the result. |
dtype | The data type of output tensor. Default to float32 |
FASTDEPLOY_DECL void fastdeploy::function::FullLike | ( | const FDTensor & | x, |
const Scalar & | value, | ||
FDTensor * | out, | ||
FDDataType | dtype = FDDataType::FP32 |
||
) |
Fill the value to tensor
x | The input tensor. |
value | The value to be filled in tensor |
out | The output tensor which stores the result. |
dtype | The data type of output tensor. Default to float32 |
FASTDEPLOY_DECL void fastdeploy::function::GatherAlongAxis | ( | const FDTensor & | x, |
const FDTensor & | index, | ||
FDTensor * | result, | ||
int | axis | ||
) |
Output is obtained by gathering entries of axis of x indexed by index and concatenate them together.
x | The input tensor. |
index | The index of a tensor to gather. |
out | The output tensor which stores the result. |
axis | Axis which will be gathered. |
void fastdeploy::function::GaussianRandom | ( | const std::vector< int64_t > & | shape, |
FDTensor * | out, | ||
FDDataType | dtype = FDDataType::FP32 , |
||
float | mean = 0.0f , |
||
float | std = 1.0f , |
||
int | seed = 0 |
||
) |
Output is obtained by gathering entries of axis of x indexed by index and concatenate them together.
shape | The output tensor shape. |
out | the output tensor. |
mean | mean value of gaussian random |
std | standard value of gaussian random |
seed | The seed of random generator. |
dtype | The data type of the output Tensor. |
FASTDEPLOY_DECL void fastdeploy::function::IsFinite | ( | const FDTensor & | x, |
FDTensor * | out, | ||
FDDataType | dtype = FDDataType::BOOL |
||
) |
Return whether every element of input tensor is finite or not.
x | The input tensor. |
out | The output tensor which stores the result. |
dtype | The output data type |
FASTDEPLOY_DECL void fastdeploy::function::IsInf | ( | const FDTensor & | x, |
FDTensor * | out, | ||
FDDataType | dtype = FDDataType::BOOL |
||
) |
Return whether every element of input tensor is Inf or not.
x | The input tensor. |
out | The output tensor which stores the result. |
dtype | The output data type |
FASTDEPLOY_DECL void fastdeploy::function::IsNan | ( | const FDTensor & | x, |
FDTensor * | out, | ||
FDDataType | dtype = FDDataType::BOOL |
||
) |
Return whether every element of input tensor is NaN or not.
x | The input tensor. |
out | The output tensor which stores the result. |
dtype | The output data type |
FASTDEPLOY_DECL void fastdeploy::function::Linspace | ( | double | start, |
double | end, | ||
int | num, | ||
FDTensor * | out, | ||
FDDataType | dtype = FDDataType::FP32 |
||
) |
Return fixed number of evenly spaced values within a given interval.
start | The input start is start variable of range. |
end | The input stop is start variable of range. |
num | The input num is given num of the sequence. |
out | The output tensor which stores the result. |
dtype | The data type of output tensor, default to float32. |
Calculates the natural log of the given input Tensor, element-wise. Only for float type FDTensor
x | The input tensor. |
out | The output tensor which stores the result. |
FASTDEPLOY_DECL void fastdeploy::function::Max | ( | const FDTensor & | x, |
FDTensor * | out, | ||
const std::vector< int64_t > & | dims, | ||
bool | keep_dim = false , |
||
bool | reduce_all = false |
||
) |
Excute the maximum operation for input FDTensor along given dims.
x | The input tensor. |
out | The output tensor which stores the result. |
dims | The vector of axis which will be reduced. |
keep_dim | Whether to keep the reduced dims, default false. |
reduce_all | Whether to reduce all dims, default false. |
FASTDEPLOY_DECL void fastdeploy::function::Maximum | ( | const FDTensor & | x, |
const FDTensor & | y, | ||
FDTensor * | out | ||
) |
Excute the maximum operation for input FDTensors. *out = max(x, y).
x | The input tensor. |
y | The input tensor. |
out | The output tensor which stores the result. |
FASTDEPLOY_DECL void fastdeploy::function::Mean | ( | const FDTensor & | x, |
FDTensor * | out, | ||
const std::vector< int64_t > & | dims, | ||
bool | keep_dim = false , |
||
bool | reduce_all = false |
||
) |
Excute the mean operation for input FDTensor along given dims.
x | The input tensor. |
out | The output tensor which stores the result. |
dims | The vector of axis which will be reduced. |
keep_dim | Whether to keep the reduced dims, default false. |
reduce_all | Whether to reduce all dims, default false. |
FASTDEPLOY_DECL void fastdeploy::function::Min | ( | const FDTensor & | x, |
FDTensor * | out, | ||
const std::vector< int64_t > & | dims, | ||
bool | keep_dim = false , |
||
bool | reduce_all = false |
||
) |
Excute the minimum operation for input FDTensor along given dims.
x | The input tensor. |
out | The output tensor which stores the result. |
dims | The vector of axis which will be reduced. |
keep_dim | Whether to keep the reduced dims, default false. |
reduce_all | Whether to reduce all dims, default false. |
FASTDEPLOY_DECL void fastdeploy::function::Multiply | ( | const FDTensor & | x, |
const FDTensor & | y, | ||
FDTensor * | out | ||
) |
Excute the multiply operation for input FDTensors. *out = x * y.
x | The input tensor. |
y | The input tensor. |
out | The output tensor which stores the result. |
FASTDEPLOY_DECL void fastdeploy::function::Pad | ( | const FDTensor & | x, |
FDTensor * | out, | ||
const std::vector< int > & | pads, | ||
float | pad_value = 0 |
||
) |
Excute the pad operation for input FDTensor along given dims.
x | The input tensor. |
out | The output tensor which stores the result. |
pads | The size of padding for each dimension, for 3-D tensor, the pads should be [1d-left, 1d-right, 2d-left, 2d-right, 3d-left, 3d-right] |
pad_value | The value which will fill into out tensor |
FASTDEPLOY_DECL void fastdeploy::function::Prod | ( | const FDTensor & | x, |
FDTensor * | out, | ||
const std::vector< int64_t > & | dims, | ||
bool | keep_dim = false , |
||
bool | reduce_all = false |
||
) |
Excute the product operation for input FDTensor along given dims.
x | The input tensor. |
out | The output tensor which stores the result. |
dims | The vector of axis which will be reduced. |
keep_dim | Whether to keep the reduced dims, default false. |
reduce_all | Whether to reduce all dims, default false. |
FASTDEPLOY_DECL void fastdeploy::function::Quantile | ( | const FDTensor & | x, |
const std::vector< double > & | q, | ||
const std::vector< int > & | axis, | ||
FDTensor * | out | ||
) |
Compute the quantile of the input along the specified axis. If any values in a reduced row are NaN, then the quantiles for that reduction will be NaN.
x | The input tensor. |
q | The q for calculate quantile, which should be in range [0, 1]. |
axis | The axis along which to calculate quantile. axis should be int or list of int. |
out | The output tensor which stores the result. |
Rounds the values in the input to the nearest integer value, element-wise. Only for float type FDTensor
x | The input tensor. |
out | The output tensor which stores the result. |
FASTDEPLOY_DECL void fastdeploy::function::Slice | ( | const FDTensor & | x, |
const std::vector< int64_t > & | axes, | ||
const std::vector< int64_t > & | starts, | ||
const std::vector< int64_t > & | ends, | ||
FDTensor * | out | ||
) |
This operator produces a slice of input along multiple axes.
x | The input tensor. |
axes | Axes that starts and ends apply to. |
starts | If starts is a list or tuple, the elements of it should be integers or Tensors with shape [1]. If starts is an Tensor, it should be an 1-D Tensor. It represents starting indices of corresponding axis in axes |
ends | If ends is a list or tuple, the elements of it should be integers or Tensors with shape [1]. If ends is an Tensor, it should be an 1-D Tensor . It represents ending indices of corresponding axis in axes. |
out | The output tensor which stores the result. |
FASTDEPLOY_DECL void fastdeploy::function::Softmax | ( | const FDTensor & | x, |
FDTensor * | out, | ||
int | axis = -1 |
||
) |
Excute the softmax operation for input FDTensor along given dims.
x | The input tensor. |
out | The output tensor which stores the result. |
axis | The axis to be computed softmax value. |
FASTDEPLOY_DECL void fastdeploy::function::Sort | ( | const FDTensor & | x, |
FDTensor * | out, | ||
FDTensor * | indices, | ||
int | axis = 0 , |
||
bool | descending = false , |
||
FDDataType | indices_type = FDDataType::INT64 |
||
) |
Performs sorting on the input tensor along the given axis and outputs two tensors, Output(Out) and Output(Indices). They reserve the same shape with Input(X), and Output(Out) represents the sorted tensor while Output(Indices) gives the sorted order along the given axis Attr(axis).
x | The input of sort |
out | The sorted tensor of sort op, with the same shape as x |
indices | The indices of a tensor giving the sorted order, with the same shape as x |
axis | The axis along which to sort the tensor. When axis < 0, the actual axis will be the |axis|'th counting backwards |
descending | The descending attribute is a flag to tell algorithm how to sort the input data. If descending is true, will sort by descending order, else if false, sort by ascending order |
indices_type | The data type of indices, default to int64 |
FASTDEPLOY_DECL void fastdeploy::function::Split | ( | const FDTensor & | x, |
const std::vector< int > & | num_or_sections, | ||
std::vector< FDTensor > * | out, | ||
int | axis = 0 |
||
) |
Split the input tensor into multiple sub-Tensors.
x | The input tensor. |
num_or_sections | f num_or_sections is an int, then num_or_sections indicates the number of equal sized sub-Tensors that the x will be divided into. |
out | The output vector tensor which stores the result. |
axis | Axis which will be splitted. |
Calculates the sqrt of the given input Tensor, element-wise. Only for float type FDTensor
x | The input tensor. |
out | The output tensor which stores the result. |
FASTDEPLOY_DECL void fastdeploy::function::Subtract | ( | const FDTensor & | x, |
const FDTensor & | y, | ||
FDTensor * | out | ||
) |
Excute the subtract operation for input FDTensors. *out = x - y.
x | The input tensor. |
y | The input tensor. |
out | The output tensor which stores the result. |
FASTDEPLOY_DECL void fastdeploy::function::Sum | ( | const FDTensor & | x, |
FDTensor * | out, | ||
const std::vector< int64_t > & | dims, | ||
bool | keep_dim = false , |
||
bool | reduce_all = false |
||
) |
Excute the sum operation for input FDTensor along given dims.
x | The input tensor. |
out | The output tensor which stores the result. |
dims | The vector of axis which will be reduced. |
keep_dim | Whether to keep the reduced dims, default false. |
reduce_all | Whether to reduce all dims, default false. |
FASTDEPLOY_DECL void fastdeploy::function::Tile | ( | const FDTensor & | x, |
const std::vector< int64_t > & | repeat_times, | ||
FDTensor * | out | ||
) |
Construct a new Tensor by repeating x the number of times given by repeat_times. After tiling, the value of the i’th dimension of the output is equal to x.shape[i]*repeat_times[i]. Both the number of dimensions of x and the number of elements in repeat_times should be less than or equal to 6.Support all data types.
x | The input tensor. |
repeat_times | The lower bound |
out | The output tensor which stores the result. |
FASTDEPLOY_DECL void fastdeploy::function::Transpose | ( | const FDTensor & | x, |
FDTensor * | out, | ||
const std::vector< int64_t > & | dims | ||
) |
Excute the transpose operation for input FDTensor along given dims.
x | The input tensor. |
out | The output tensor which stores the result. |
dims | The vector of axis which the input tensor will transpose. |