23 #include "fastdeploy/runtime/backends/backend.h" 24 #include "fastdeploy/runtime/backends/ort/option.h" 25 #include "onnxruntime_cxx_api.h" 28 #include "dml_provider_factory.h" 35 std::vector<int64_t> shape;
36 ONNXTensorElementDataType dtype;
39 class OrtBackend :
public BaseBackend {
42 virtual ~OrtBackend() =
default;
44 bool BuildOption(
const OrtBackendOption& option);
46 bool Init(
const RuntimeOption& option);
48 bool Infer(std::vector<FDTensor>& inputs, std::vector<FDTensor>* outputs,
49 bool copy_to_fd =
true)
override;
51 int NumInputs()
const override {
return inputs_desc_.size(); }
53 int NumOutputs()
const override {
return outputs_desc_.size(); }
55 TensorInfo GetInputInfo(
int index)
override;
56 TensorInfo GetOutputInfo(
int index)
override;
57 std::vector<TensorInfo> GetInputInfos()
override;
58 std::vector<TensorInfo> GetOutputInfos()
override;
59 static std::vector<OrtCustomOp*> custom_operators_;
60 void InitCustomOperators();
63 bool InitFromPaddle(
const std::string& model_buffer,
64 const std::string& params_buffer,
65 const OrtBackendOption& option = OrtBackendOption(),
66 bool verbose =
false);
68 bool InitFromOnnx(
const std::string& model_buffer,
69 const OrtBackendOption& option = OrtBackendOption());
72 Ort::Session session_{
nullptr};
73 Ort::SessionOptions session_options_;
74 std::shared_ptr<Ort::IoBinding> binding_;
75 std::vector<OrtValueInfo> inputs_desc_;
76 std::vector<OrtValueInfo> outputs_desc_;
80 std::string model_file_name;
81 #ifndef NON_64_PLATFORM 82 Ort::CustomOpDomain custom_op_domain_ = Ort::CustomOpDomain(
"Paddle");
84 OrtBackendOption option_;
85 void OrtValueToFDTensor(
const Ort::Value& value, FDTensor* tensor,
86 const std::string& name,
bool copy_to_fd);
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16