forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexecutable.hpp
105 lines (85 loc) · 4.49 KB
/
executable.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright (C) 2018-2024 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <memory>
#include "openvino/core/model.hpp"
#include "openvino/core/node_vector.hpp"
#include "openvino/op/parameter.hpp"
#include "openvino/runtime/tensor.hpp"
namespace ov {
namespace runtime {
class Executable {
public:
Executable();
virtual ~Executable();
/// \param outputs vector of Tensor used as outputs
/// \param inputs vector of Tensor used as inputs
/// \param collect_performance Enable per operation performance statistic
/// \returns true if iteration is successful, false otherwise
virtual bool call(std::vector<ov::Tensor>& outputs,
const std::vector<ov::Tensor>& inputs,
bool collect_performance = false) = 0;
/// \param outputs vector of Tensor used as outputs
/// \param inputs vector of Tensor used as inputs
/// \param context Evaluation context
/// \param collect_performance Enable per operation performance statistic
/// \returns true if iteration is successful, false otherwise
virtual bool call(std::vector<ov::Tensor>& outputs,
const std::vector<ov::Tensor>& inputs,
const ov::EvaluationContext& context,
bool collect_performance = false) = 0;
/// \brief Cancel and terminate the current execution
virtual void cancel() = 0;
/// \brief Executes a single iteration of a Function.
/// \param outputs vector of Tensor used as outputs
/// \param inputs vector of Tensor used as inputs
/// \returns true if iteration is successful, false otherwise
bool call_with_validate(std::vector<ov::Tensor>& outputs, const std::vector<ov::Tensor>& inputs);
/// \brief Validates a Function.
/// \param outputs vector of Tensor used as outputs
/// \param inputs vector of Tensor used as inputs
void validate(const std::vector<ov::Tensor>& outputs, const std::vector<ov::Tensor>& inputs);
/// \brief Query the input Parameters
/// \returns an ov::op::ParameterVector of all input parameters
const ov::ParameterVector& get_parameters() const;
/// \brief Query the output Results
/// \returns an ov::ResultVector of all input parameters
const ov::ResultVector& get_results() const;
/// \brief Query the internal model
/// \returns model which is used inside executable
virtual std::shared_ptr<ov::Model> get_model() const = 0;
/// \brief Create an input Tensor
/// \param input_index The index position in the input Parameter vector. This would be the same
/// order of Parameters passed into the inputs in the call() method.
/// \returns A Tensor
virtual ov::Tensor create_input_tensor(size_t input_index);
/// \brief Create an output Tensor
/// \param output_index The index position in the output Result vector. This would be the same
/// order of Results passed into the outputs in the call() method.
/// \returns A Tensor
virtual ov::Tensor create_output_tensor(size_t output_index);
/// \brief Create a vector of input Tensors
/// \param input_index The index position in the input Parameter vector. This would be the same
/// order of Parameters passed into the inputs in the call() method.
/// \param pipeline_depth The number of stages in the input pipeline. For double-buffered input
/// you would specify pipeline_depth=2
/// \returns A vector of Tensors, one for each stage of the pipeline
virtual std::vector<ov::Tensor> create_input_tensor(size_t input_index, size_t pipeline_depth);
/// \brief Create a vector of output Tensors
/// \param output_index The index position in the output Result vector. This would be the same
/// order of Results passed into the outputs in the call() method.
/// \param pipeline_depth The number of stages in the output pipeline. For double-buffered
/// output you would specify pipeline_depth=2
/// \returns A vector of Tensors, one for each stage of the pipeline
virtual std::vector<ov::Tensor> create_output_tensor(size_t output_index, size_t pipeline_depth);
protected:
/// \brief Called at the end of compile to the values to be returned by get_parameters
/// and get_results
/// \param func The function with Results fully resolved.
void set_parameters_and_results(const ov::Model& model);
ov::ParameterVector m_parameters;
ov::ResultVector m_results;
};
} // namespace runtime
} // namespace ov