mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 17:17:14 +08:00
@@ -187,11 +187,11 @@ struct ErnieForSequenceClassificationPredictor {
|
|||||||
std::vector<SeqClsResult>* seq_cls_results) {
|
std::vector<SeqClsResult>* seq_cls_results) {
|
||||||
const auto& logits = outputs[0];
|
const auto& logits = outputs[0];
|
||||||
fastdeploy::FDTensor probs;
|
fastdeploy::FDTensor probs;
|
||||||
fastdeploy::Softmax(logits, &probs);
|
fastdeploy::function::Softmax(logits, &probs);
|
||||||
|
|
||||||
fastdeploy::FDTensor labels, confidences;
|
fastdeploy::FDTensor labels, confidences;
|
||||||
fastdeploy::Max(probs, &confidences, {-1});
|
fastdeploy::function::Max(probs, &confidences, {-1});
|
||||||
fastdeploy::ArgMax(probs, &labels, -1);
|
fastdeploy::function::ArgMax(probs, &labels, -1);
|
||||||
if (labels.Numel() != confidences.Numel()) {
|
if (labels.Numel() != confidences.Numel()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -318,7 +318,7 @@ bool TrtBackend::Infer(std::vector<FDTensor>& inputs,
|
|||||||
|
|
||||||
casted_output_tensors_[(*outputs)[i].name].Resize((*outputs)[i].shape, (*outputs)[i].dtype,
|
casted_output_tensors_[(*outputs)[i].name].Resize((*outputs)[i].shape, (*outputs)[i].dtype,
|
||||||
(*outputs)[i].name, Device::GPU);
|
(*outputs)[i].name, Device::GPU);
|
||||||
CudaCast(output_tensor, &casted_output_tensors_[(*outputs)[i].name], stream_);
|
function::CudaCast(output_tensor, &casted_output_tensors_[(*outputs)[i].name], stream_);
|
||||||
} else {
|
} else {
|
||||||
casted_output_tensors_[(*outputs)[i].name].SetExternalData(
|
casted_output_tensors_[(*outputs)[i].name].SetExternalData(
|
||||||
(*outputs)[i].shape, model_output_dtype,
|
(*outputs)[i].shape, model_output_dtype,
|
||||||
@@ -392,7 +392,7 @@ void TrtBackend::SetInputs(const std::vector<FDTensor>& inputs) {
|
|||||||
input_tensor.SetExternalData(item.shape, FDDataType::INT32,
|
input_tensor.SetExternalData(item.shape, FDDataType::INT32,
|
||||||
inputs_device_buffer_[item.name].data(),
|
inputs_device_buffer_[item.name].data(),
|
||||||
Device::GPU);
|
Device::GPU);
|
||||||
CudaCast(item, &input_tensor, stream_);
|
function::CudaCast(item, &input_tensor, stream_);
|
||||||
} else {
|
} else {
|
||||||
// no copy
|
// no copy
|
||||||
inputs_device_buffer_[item.name].SetExternalData(dims, item.Data());
|
inputs_device_buffer_[item.name].SetExternalData(dims, item.Data());
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
#include "fastdeploy/utils/utils.h"
|
#include "fastdeploy/utils/utils.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
std::string Str(const std::vector<int64_t>& shape) {
|
std::string Str(const std::vector<int64_t>& shape) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "[ " << shape[0];
|
oss << "[ " << shape[0];
|
||||||
@@ -121,4 +121,5 @@ void Concat(const std::vector<FDTensor>& x, FDTensor* out, int axis) {
|
|||||||
*out = std::move(out_temp);
|
*out = std::move(out_temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace function
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -17,6 +17,7 @@
|
|||||||
#include "fastdeploy/core/fd_tensor.h"
|
#include "fastdeploy/core/fd_tensor.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
|
|
||||||
/** Excute the concatenate operation for input FDTensor along given axis.
|
/** Excute the concatenate operation for input FDTensor along given axis.
|
||||||
@param x The input tensor.
|
@param x The input tensor.
|
||||||
@@ -27,4 +28,5 @@ namespace fastdeploy {
|
|||||||
FASTDEPLOY_DECL void Concat(const std::vector<FDTensor>& x, FDTensor* out,
|
FASTDEPLOY_DECL void Concat(const std::vector<FDTensor>& x, FDTensor* out,
|
||||||
int axis = 0);
|
int axis = 0);
|
||||||
|
|
||||||
|
} // namespace function
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
#include "fastdeploy/function/cuda_cast.h"
|
#include "fastdeploy/function/cuda_cast.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
template <typename T_IN, typename T_OUT>
|
template <typename T_IN, typename T_OUT>
|
||||||
__global__ void CudaCastKernel(const T_IN* in, T_OUT* out, int edge) {
|
__global__ void CudaCastKernel(const T_IN* in, T_OUT* out, int edge) {
|
||||||
int position = blockDim.x * blockIdx.x + threadIdx.x;
|
int position = blockDim.x * blockIdx.x + threadIdx.x;
|
||||||
@@ -42,4 +42,5 @@ void CudaCast(const FDTensor& in, FDTensor* out, cudaStream_t stream) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace function
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
#include "fastdeploy/core/fd_tensor.h"
|
#include "fastdeploy/core/fd_tensor.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
/** Cast the type of the data in GPU buffer.
|
/** Cast the type of the data in GPU buffer.
|
||||||
@param in The input tensor.
|
@param in The input tensor.
|
||||||
@param out The output tensor
|
@param out The output tensor
|
||||||
@@ -25,5 +25,5 @@ namespace fastdeploy {
|
|||||||
*/
|
*/
|
||||||
FASTDEPLOY_DECL void CudaCast(const FDTensor& in, FDTensor* out,
|
FASTDEPLOY_DECL void CudaCast(const FDTensor& in, FDTensor* out,
|
||||||
cudaStream_t stream);
|
cudaStream_t stream);
|
||||||
|
} // namespace function
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
#include "fastdeploy/function/eigen.h"
|
#include "fastdeploy/function/eigen.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
std::shared_ptr<EigenDeviceWrapper> EigenDeviceWrapper::instance_ = nullptr;
|
std::shared_ptr<EigenDeviceWrapper> EigenDeviceWrapper::instance_ = nullptr;
|
||||||
|
|
||||||
std::shared_ptr<EigenDeviceWrapper> EigenDeviceWrapper::GetInstance() {
|
std::shared_ptr<EigenDeviceWrapper> EigenDeviceWrapper::GetInstance() {
|
||||||
@@ -29,4 +29,5 @@ const Eigen::DefaultDevice* EigenDeviceWrapper::GetDevice() const {
|
|||||||
return &device_;
|
return &device_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include "unsupported/Eigen/CXX11/Tensor"
|
#include "unsupported/Eigen/CXX11/Tensor"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
// EigenDim converts shape into Eigen::DSizes.
|
// EigenDim converts shape into Eigen::DSizes.
|
||||||
template <int D>
|
template <int D>
|
||||||
struct EigenDim {
|
struct EigenDim {
|
||||||
@@ -135,4 +136,5 @@ class EigenDeviceWrapper {
|
|||||||
static std::shared_ptr<EigenDeviceWrapper> instance_;
|
static std::shared_ptr<EigenDeviceWrapper> instance_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace function
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
#include "fastdeploy/utils/utils.h"
|
#include "fastdeploy/utils/utils.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
template <typename T, int Rank>
|
template <typename T, int Rank>
|
||||||
struct PadEigen {
|
struct PadEigen {
|
||||||
using Array = std::array<std::pair<int64_t, int64_t>, Rank>;
|
using Array = std::array<std::pair<int64_t, int64_t>, Rank>;
|
||||||
@@ -123,4 +123,5 @@ void Pad(const FDTensor& x, FDTensor* out, const std::vector<int>& pads, float v
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace function
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
#include "fastdeploy/core/fd_tensor.h"
|
#include "fastdeploy/core/fd_tensor.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
/** Excute the pad operation for input FDTensor along given dims.
|
/** Excute the pad operation for input FDTensor along given dims.
|
||||||
@param x The input tensor.
|
@param x The input tensor.
|
||||||
@param out The output tensor which stores the result.
|
@param out The output tensor which stores the result.
|
||||||
@@ -27,4 +27,5 @@ namespace fastdeploy {
|
|||||||
FASTDEPLOY_DECL void Pad(const FDTensor& x, FDTensor* out,
|
FASTDEPLOY_DECL void Pad(const FDTensor& x, FDTensor* out,
|
||||||
const std::vector<int>& pads, float pad_value = 0);
|
const std::vector<int>& pads, float pad_value = 0);
|
||||||
|
|
||||||
|
}
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
#include "fastdeploy/utils/utils.h"
|
#include "fastdeploy/utils/utils.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
template <typename T, size_t D, size_t R_D, typename Functor>
|
template <typename T, size_t D, size_t R_D, typename Functor>
|
||||||
void ReduceFunctor(const FDTensor& input, FDTensor* output,
|
void ReduceFunctor(const FDTensor& input, FDTensor* output,
|
||||||
const std::vector<int64_t>& dims, bool keep_dim) {
|
const std::vector<int64_t>& dims, bool keep_dim) {
|
||||||
@@ -402,4 +402,5 @@ void ArgMin(const FDTensor& x, FDTensor* out, int64_t axis,
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace function
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -17,7 +17,7 @@
|
|||||||
#include "fastdeploy/core/fd_tensor.h"
|
#include "fastdeploy/core/fd_tensor.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
/** Excute the maximum operation for input FDTensor along given dims.
|
/** Excute the maximum operation for input FDTensor along given dims.
|
||||||
@param x The input tensor.
|
@param x The input tensor.
|
||||||
@param out The output tensor which stores the result.
|
@param out The output tensor which stores the result.
|
||||||
@@ -123,4 +123,5 @@ FASTDEPLOY_DECL void ArgMin(const FDTensor& x, FDTensor* out, int64_t axis,
|
|||||||
FDDataType output_dtype = FDDataType::INT64,
|
FDDataType output_dtype = FDDataType::INT64,
|
||||||
bool keep_dim = false, bool flatten = false);
|
bool keep_dim = false, bool flatten = false);
|
||||||
|
|
||||||
|
} // namespace function
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include "fastdeploy/function/eigen.h"
|
#include "fastdeploy/function/eigen.h"
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
//////// Max Functor ///////
|
//////// Max Functor ///////
|
||||||
struct MaxFunctor {
|
struct MaxFunctor {
|
||||||
template <typename X, typename Y, typename Dim>
|
template <typename X, typename Y, typename Dim>
|
||||||
@@ -73,4 +73,5 @@ struct ProdFunctor {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace function
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
#include "fastdeploy/utils/utils.h"
|
#include "fastdeploy/utils/utils.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct ValueClip {
|
struct ValueClip {
|
||||||
T operator()(const T& x) const {
|
T operator()(const T& x) const {
|
||||||
@@ -124,4 +125,5 @@ void Softmax(const FDTensor& x, FDTensor* out, int axis) {
|
|||||||
([&] { SoftmaxKernel<data_t>(x, &out_tmp, axis); }));
|
([&] { SoftmaxKernel<data_t>(x, &out_tmp, axis); }));
|
||||||
*out = std::move(out_tmp);
|
*out = std::move(out_tmp);
|
||||||
}
|
}
|
||||||
|
} // namespace function
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
#include "fastdeploy/core/fd_tensor.h"
|
#include "fastdeploy/core/fd_tensor.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
/** Excute the softmax operation for input FDTensor along given dims.
|
/** Excute the softmax operation for input FDTensor along given dims.
|
||||||
@param x The input tensor.
|
@param x The input tensor.
|
||||||
@param out The output tensor which stores the result.
|
@param out The output tensor which stores the result.
|
||||||
@@ -25,4 +25,5 @@ namespace fastdeploy {
|
|||||||
*/
|
*/
|
||||||
FASTDEPLOY_DECL void Softmax(const FDTensor& x, FDTensor* out, int axis = -1);
|
FASTDEPLOY_DECL void Softmax(const FDTensor& x, FDTensor* out, int axis = -1);
|
||||||
|
|
||||||
|
} // namespace function
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
#include "fastdeploy/utils/utils.h"
|
#include "fastdeploy/utils/utils.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct TransposeNormalKernel {
|
struct TransposeNormalKernel {
|
||||||
void operator()(const FDTensor& in, FDTensor* out,
|
void operator()(const FDTensor& in, FDTensor* out,
|
||||||
@@ -121,4 +121,5 @@ void Transpose(const FDTensor& x, FDTensor* out,
|
|||||||
*out = std::move(out_temp);
|
*out = std::move(out_temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace function
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -17,7 +17,7 @@
|
|||||||
#include "fastdeploy/core/fd_tensor.h"
|
#include "fastdeploy/core/fd_tensor.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
/** Excute the transpose operation for input FDTensor along given dims.
|
/** Excute the transpose operation for input FDTensor along given dims.
|
||||||
@param x The input tensor.
|
@param x The input tensor.
|
||||||
@param out The output tensor which stores the result.
|
@param out The output tensor which stores the result.
|
||||||
@@ -25,4 +25,5 @@ namespace fastdeploy {
|
|||||||
*/
|
*/
|
||||||
FASTDEPLOY_DECL void Transpose(const FDTensor& x, FDTensor* out,
|
FASTDEPLOY_DECL void Transpose(const FDTensor& x, FDTensor* out,
|
||||||
const std::vector<int64_t>& dims);
|
const std::vector<int64_t>& dims);
|
||||||
|
} // namespace function
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
||||||
|
@@ -87,7 +87,7 @@ bool ResNet::Postprocess(FDTensor& infer_result,
|
|||||||
// 1. Softmax 2. Choose topk labels 3. Put the result into ClassifyResult variable.
|
// 1. Softmax 2. Choose topk labels 3. Put the result into ClassifyResult variable.
|
||||||
|
|
||||||
int num_classes = infer_result.shape[1];
|
int num_classes = infer_result.shape[1];
|
||||||
Softmax(infer_result, &infer_result);
|
function::Softmax(infer_result, &infer_result);
|
||||||
const float* infer_result_buffer = reinterpret_cast<float*>(infer_result.Data());
|
const float* infer_result_buffer = reinterpret_cast<float*>(infer_result.Data());
|
||||||
topk = std::min(num_classes, topk);
|
topk = std::min(num_classes, topk);
|
||||||
result->label_ids =
|
result->label_ids =
|
||||||
|
@@ -75,7 +75,7 @@ bool YOLOv5Cls::Postprocess(const FDTensor& infer_result,
|
|||||||
ClassifyResult* result, int topk) {
|
ClassifyResult* result, int topk) {
|
||||||
// Softmax
|
// Softmax
|
||||||
FDTensor infer_result_softmax;
|
FDTensor infer_result_softmax;
|
||||||
Softmax(infer_result, &infer_result_softmax, 1);
|
function::Softmax(infer_result, &infer_result_softmax, 1);
|
||||||
int num_classes = infer_result_softmax.shape[1];
|
int num_classes = infer_result_softmax.shape[1];
|
||||||
const float* infer_result_buffer =
|
const float* infer_result_buffer =
|
||||||
reinterpret_cast<const float*>(infer_result_softmax.Data());
|
reinterpret_cast<const float*>(infer_result_softmax.Data());
|
||||||
|
@@ -99,7 +99,11 @@ bool PaddleClasPreprocessor::Run(std::vector<FDMat>* images, std::vector<FDTenso
|
|||||||
(*images)[i].ShareWithTensor(&(tensors[i]));
|
(*images)[i].ShareWithTensor(&(tensors[i]));
|
||||||
tensors[i].ExpandDim(0);
|
tensors[i].ExpandDim(0);
|
||||||
}
|
}
|
||||||
Concat(tensors, &((*outputs)[0]), 0);
|
if (tensors.size() == 1) {
|
||||||
|
(*outputs)[0] = std::move(tensors[0]);
|
||||||
|
} else {
|
||||||
|
function::Concat(tensors, &((*outputs)[0]), 0);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -170,7 +170,7 @@ bool PPMatting::Postprocess(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::vector<int64_t> dim{0, 2, 3, 1};
|
std::vector<int64_t> dim{0, 2, 3, 1};
|
||||||
Transpose(alpha_tensor, &alpha_tensor, dim);
|
function::Transpose(alpha_tensor, &alpha_tensor, dim);
|
||||||
alpha_tensor.Squeeze(0);
|
alpha_tensor.Squeeze(0);
|
||||||
Mat mat = Mat::Create(alpha_tensor);
|
Mat mat = Mat::Create(alpha_tensor);
|
||||||
|
|
||||||
|
@@ -220,7 +220,7 @@ bool PaddleSegModel::Postprocess(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!is_with_softmax && apply_softmax) {
|
if (!is_with_softmax && apply_softmax) {
|
||||||
Softmax(*infer_result, infer_result, 1);
|
function::Softmax(*infer_result, infer_result, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_with_argmax) {
|
if (!is_with_argmax) {
|
||||||
@@ -228,7 +228,7 @@ bool PaddleSegModel::Postprocess(
|
|||||||
result->contain_score_map = true;
|
result->contain_score_map = true;
|
||||||
|
|
||||||
std::vector<int64_t> dim{0, 2, 3, 1};
|
std::vector<int64_t> dim{0, 2, 3, 1};
|
||||||
Transpose(*infer_result, infer_result, dim);
|
function::Transpose(*infer_result, infer_result, dim);
|
||||||
}
|
}
|
||||||
// batch always 1, so ignore
|
// batch always 1, so ignore
|
||||||
infer_result->shape = {infer_height, infer_width, infer_channel};
|
infer_result->shape = {infer_height, infer_width, infer_channel};
|
||||||
@@ -284,11 +284,11 @@ bool PaddleSegModel::Postprocess(
|
|||||||
std::vector<int64_t> reduce_dim{-1};
|
std::vector<int64_t> reduce_dim{-1};
|
||||||
// argmax
|
// argmax
|
||||||
if (is_resized) {
|
if (is_resized) {
|
||||||
ArgMax(new_infer_result, &argmax_infer_result, -1, FDDataType::INT32);
|
function::ArgMax(new_infer_result, &argmax_infer_result, -1, FDDataType::INT32);
|
||||||
Max(new_infer_result, &max_score_result, reduce_dim);
|
function::Max(new_infer_result, &max_score_result, reduce_dim);
|
||||||
} else {
|
} else {
|
||||||
ArgMax(*infer_result, &argmax_infer_result, -1, FDDataType::INT32);
|
function::ArgMax(*infer_result, &argmax_infer_result, -1, FDDataType::INT32);
|
||||||
Max(*infer_result, &max_score_result, reduce_dim);
|
function::Max(*infer_result, &max_score_result, reduce_dim);
|
||||||
}
|
}
|
||||||
argmax_infer_result_buffer =
|
argmax_infer_result_buffer =
|
||||||
static_cast<int32_t*>(argmax_infer_result.Data());
|
static_cast<int32_t*>(argmax_infer_result.Data());
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
#include "gtest_utils.h"
|
#include "gtest_utils.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
TEST(fastdeploy, concat1) {
|
TEST(fastdeploy, concat1) {
|
||||||
CheckShape check_shape;
|
CheckShape check_shape;
|
||||||
std::vector<FDTensor> inputs(3);
|
std::vector<FDTensor> inputs(3);
|
||||||
@@ -77,4 +77,5 @@ TEST(fastdeploy, concat5) {
|
|||||||
check_shape(output.shape, {5, 6, 4, 5});
|
check_shape(output.shape, {5, 6, 4, 5});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace function
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
#include "gtest_utils.h"
|
#include "gtest_utils.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
TEST(fastdeploy, pad_2d) {
|
TEST(fastdeploy, pad_2d) {
|
||||||
FDTensor input, output;
|
FDTensor input, output;
|
||||||
CheckShape check_shape;
|
CheckShape check_shape;
|
||||||
@@ -65,28 +65,5 @@ TEST(fastdeploy, pad_2d_int32_t) {
|
|||||||
check_type(input.dtype, output.dtype);
|
check_type(input.dtype, output.dtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TEST(fastdeploy, transpose_5d) {
|
} // namespace function
|
||||||
// FDTensor input, output;
|
|
||||||
// CheckShape check_shape;
|
|
||||||
// CheckData check_data;
|
|
||||||
//
|
|
||||||
// std::vector<int64_t> input_shape = {2, 1, 3, 1, 2};
|
|
||||||
// auto total_size = std::accumulate(input_shape.begin(), input_shape.end(), 1,
|
|
||||||
// std::multiplies<int64_t>());
|
|
||||||
// std::vector<int> inputs(total_size, 1);
|
|
||||||
// std::iota(inputs.begin(), inputs.end(), 1);
|
|
||||||
// std::vector<int> expected_result = {1, 3, 5, 2, 4, 6, 7, 9, 11, 8, 10, 12};
|
|
||||||
// input.SetExternalData(input_shape, FDDataType::INT32, inputs.data());
|
|
||||||
//
|
|
||||||
// Transpose(input, &output, {0, 1, 4, 3, 2});
|
|
||||||
// check_shape(output.shape, {2, 1, 2, 1, 3});
|
|
||||||
// check_data(reinterpret_cast<const int*>(output.Data()),
|
|
||||||
// expected_result.data(), expected_result.size());
|
|
||||||
//
|
|
||||||
// Transpose(input, &input, {0, 1, 4, 3, 2});
|
|
||||||
// check_shape(input.shape, {2, 1, 2, 1, 3});
|
|
||||||
// check_data(reinterpret_cast<const int*>(input.Data()), expected_result.data(),
|
|
||||||
// expected_result.size());
|
|
||||||
//}
|
|
||||||
|
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
#include "gtest_utils.h"
|
#include "gtest_utils.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
TEST(fastdeploy, reduce_max) {
|
TEST(fastdeploy, reduce_max) {
|
||||||
FDTensor input, output;
|
FDTensor input, output;
|
||||||
CheckShape check_shape;
|
CheckShape check_shape;
|
||||||
@@ -371,4 +371,5 @@ TEST(fastdeploy, reduce_argmin) {
|
|||||||
expected_result_noaxis.data(), expected_result_noaxis.size());
|
expected_result_noaxis.data(), expected_result_noaxis.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace function
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
#include "gtest_utils.h"
|
#include "gtest_utils.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
TEST(fastdeploy, softmax) {
|
TEST(fastdeploy, softmax) {
|
||||||
FDTensor input, input1, output;
|
FDTensor input, input1, output;
|
||||||
CheckShape check_shape;
|
CheckShape check_shape;
|
||||||
@@ -57,4 +57,5 @@ TEST(fastdeploy, softmax) {
|
|||||||
expected_result_axis1.data(), expected_result_axis1.size());
|
expected_result_axis1.data(), expected_result_axis1.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace function
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -22,7 +22,7 @@
|
|||||||
#include "gtest_utils.h"
|
#include "gtest_utils.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
namespace function {
|
||||||
TEST(fastdeploy, transpose_2d) {
|
TEST(fastdeploy, transpose_2d) {
|
||||||
FDTensor input, output;
|
FDTensor input, output;
|
||||||
CheckShape check_shape;
|
CheckShape check_shape;
|
||||||
@@ -67,4 +67,5 @@ TEST(fastdeploy, transpose_5d) {
|
|||||||
expected_result.size());
|
expected_result.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace function
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
||||||
|
Reference in New Issue
Block a user