mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 00:57:33 +08:00
[Functions] Add quantile function (#700)
* Add sort function * Add isfinite function * upgrade isinf isnan * Add Scalar to FDTensor * Add floor, ceil function * add cast functions * Update out_tmp * Update quantile * add gather scatter along axis * finish quantile function * Add quantile unittest * refresh code style for test source code * Add comments * Add full function * Add scalar to fd tensor * Add full unittest * Add functions headers * move fdtensor operators to fastdeploy namespace
This commit is contained in:
@@ -32,45 +32,21 @@ void Add(const FDTensor& x, const FDTensor& y, FDTensor* out) {
|
||||
([&] { AddRawKernel<data_t>()(x, y, -1, out); }));
|
||||
}
|
||||
|
||||
FDTensor operator+(const FDTensor& x, const FDTensor& y) {
|
||||
FDTensor out;
|
||||
Add(x, y, &out);
|
||||
return out;
|
||||
}
|
||||
|
||||
void Subtract(const FDTensor& x, const FDTensor& y, FDTensor* out) {
|
||||
FD_VISIT_ALL_TYPES(x.dtype, "SubtractRawKernel",
|
||||
([&] { SubtractRawKernel<data_t>()(x, y, -1, out); }));
|
||||
}
|
||||
|
||||
FDTensor operator-(const FDTensor& x, const FDTensor& y) {
|
||||
FDTensor out;
|
||||
Subtract(x, y, &out);
|
||||
return out;
|
||||
}
|
||||
|
||||
void Multiply(const FDTensor& x, const FDTensor& y, FDTensor* out) {
|
||||
FD_VISIT_ALL_TYPES(x.dtype, "MultiplyRawKernel",
|
||||
([&] { MultiplyRawKernel<data_t>()(x, y, -1, out); }));
|
||||
}
|
||||
|
||||
FDTensor operator*(const FDTensor& x, const FDTensor& y) {
|
||||
FDTensor out;
|
||||
Multiply(x, y, &out);
|
||||
return out;
|
||||
}
|
||||
|
||||
void Divide(const FDTensor& x, const FDTensor& y, FDTensor* out) {
|
||||
FD_VISIT_ALL_TYPES(x.dtype, "DivideRawKernel",
|
||||
([&] { DivideRawKernel<data_t>()(x, y, -1, out); }));
|
||||
}
|
||||
|
||||
FDTensor operator/(const FDTensor& x, const FDTensor& y) {
|
||||
FDTensor out;
|
||||
Divide(x, y, &out);
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename T> struct MaximumRawKernel {
|
||||
void operator()(const FDTensor& x, const FDTensor& y, int axis,
|
||||
FDTensor* out) {
|
||||
@@ -85,4 +61,29 @@ void Maximum(const FDTensor& x, const FDTensor& y, FDTensor* out) {
|
||||
}
|
||||
|
||||
} // namespace function
|
||||
|
||||
FDTensor operator+(const FDTensor& x, const FDTensor& y) {
|
||||
FDTensor out;
|
||||
function::Add(x, y, &out);
|
||||
return out;
|
||||
}
|
||||
|
||||
FDTensor operator-(const FDTensor& x, const FDTensor& y) {
|
||||
FDTensor out;
|
||||
function::Subtract(x, y, &out);
|
||||
return out;
|
||||
}
|
||||
|
||||
FDTensor operator*(const FDTensor& x, const FDTensor& y) {
|
||||
FDTensor out;
|
||||
function::Multiply(x, y, &out);
|
||||
return out;
|
||||
}
|
||||
|
||||
FDTensor operator/(const FDTensor& x, const FDTensor& y) {
|
||||
FDTensor out;
|
||||
function::Divide(x, y, &out);
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace fastdeploy
|
||||
|
Reference in New Issue
Block a user