22 #include "fastdeploy/runtime/backends/backend.h" 23 #include "fastdeploy/runtime/backends/poros/option.h" 24 #include "fastdeploy/runtime/backends/poros/common/compile.h" 25 #include "fastdeploy/runtime/backends/poros/common/poros_module.h" 30 at::ScalarType GetPorosDtype(
const FDDataType& fd_dtype);
33 FDDataType GetFdDtype(
const at::ScalarType& dtype);
36 std::string AtType2String(
const at::ScalarType& dtype);
41 at::Tensor CreatePorosValue(FDTensor& tensor,
bool is_backend_cuda =
false);
44 void CopyTensorToCpu(
const at::Tensor& tensor, FDTensor* fd_tensor,
45 bool is_backend_cuda =
false);
47 class PorosBackend :
public BaseBackend {
50 virtual ~PorosBackend() =
default;
52 void BuildOption(
const PorosBackendOption& option);
54 bool Init(
const RuntimeOption& option) {
59 if (option.model_from_memory_) {
60 FDERROR <<
"Poros backend doesn't support load model " 61 <<
"from memory, please load model from disk." 68 bool Compile(
const std::string& model_file,
69 std::vector<std::vector<FDTensor>>& prewarm_tensors,
70 const PorosBackendOption& option = PorosBackendOption());
72 bool Infer(std::vector<FDTensor>& inputs, std::vector<FDTensor>* outputs,
73 bool copy_to_fd =
true)
override;
75 int NumInputs()
const {
return _numinputs; }
77 int NumOutputs()
const {
return _numoutputs; }
79 TensorInfo GetInputInfo(
int index)
override;
80 TensorInfo GetOutputInfo(
int index)
override;
81 std::vector<TensorInfo> GetInputInfos()
override;
82 std::vector<TensorInfo> GetOutputInfos()
override;
85 baidu::mirana::poros::PorosOptions _options;
86 std::unique_ptr<baidu::mirana::poros::PorosModule> _poros_module;
87 std::vector<std::vector<c10::IValue>> _prewarm_datas;
Poros, support TorchScript format model, CPU / Nvidia GPU.
Definition: enum_variables.h:36
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16