Added documentation for RemoteTensor and RemoteContext (#16391)
* Added documentation for RemoteTensor and RemoteContext * Fixed documentation build * Fixed some build issues
This commit is contained in:
parent
73bedced87
commit
9c69e2f694
@ -4,8 +4,8 @@ ov::CompiledModel class functionality:
|
||||
- Compile an ov::Model instance to a backend specific graph representation
|
||||
- Create an arbitrary number of ov::InferRequest objects
|
||||
- Hold some common resources shared between different instances of ov::InferRequest. For example:
|
||||
- ov::ICompiledModel::m_task_executor task executor to implement asynchronous execution
|
||||
- ov::ICompiledModel::m_callback_executor task executor to run an asynchronous inference request callback in a separate thread
|
||||
- ov::ICompiledModel::m_task_executor task executor to implement asynchronous execution
|
||||
- ov::ICompiledModel::m_callback_executor task executor to run an asynchronous inference request callback in a separate thread
|
||||
|
||||
CompiledModel Class
|
||||
------------------------
|
||||
|
@ -11,6 +11,8 @@
|
||||
Implement Compiled Model Functionality <openvino_docs_ov_plugin_dg_compiled_model>
|
||||
Implement Synchronous Inference Request <openvino_docs_ov_plugin_dg_infer_request>
|
||||
Implement Asynchronous Inference Request <openvino_docs_ie_plugin_dg_async_infer_request>
|
||||
Implement Remote Context <openvino_docs_ov_plugin_dg_remote_context>
|
||||
Implement Remote Tensor <openvino_docs_ov_plugin_dg_remote_tensor>
|
||||
openvino_docs_ov_plugin_dg_plugin_build
|
||||
openvino_docs_ov_plugin_dg_plugin_testing
|
||||
openvino_docs_ie_plugin_detailed_guides
|
||||
@ -28,23 +30,25 @@ OpenVINO Plugin Library
|
||||
OpenVINO plugin dynamic library consists of several main components:
|
||||
|
||||
1. [Plugin class](@ref openvino_docs_ov_plugin_dg_plugin):
|
||||
- Provides information about devices of a specific type.
|
||||
- Can create an [compiled model](@ref openvino_docs_ov_plugin_dg_compiled_model) instance which represents a Neural
|
||||
Network backend specific graph structure for a particular device in opposite to the ov::Model
|
||||
which is backend-independent.
|
||||
- Can import an already compiled graph structure from an input stream to an
|
||||
[compiled model](@ref openvino_docs_ov_plugin_dg_compiled_model) object.
|
||||
2. [Compiled Modek class](@ref openvino_docs_ov_plugin_dg_compiled_model):
|
||||
- Is an execution configuration compiled for a particular device and takes into account its capabilities.
|
||||
- Holds a reference to a particular device and a task executor for this device.
|
||||
- Can create several instances of [Inference Request](@ref openvino_docs_ov_plugin_dg_infer_request).
|
||||
- Can export an internal backend specific graph structure to an output stream.
|
||||
- Provides information about devices of a specific type.
|
||||
- Can create an [compiled model](@ref openvino_docs_ov_plugin_dg_compiled_model) instance which represents a Neural Network backend specific graph structure for a particular device in opposite to the ov::Model
|
||||
which is backend-independent.
|
||||
- Can import an already compiled graph structure from an input stream to an
|
||||
[compiled model](@ref openvino_docs_ov_plugin_dg_compiled_model) object.
|
||||
2. [Compiled Model class](@ref openvino_docs_ov_plugin_dg_compiled_model):
|
||||
- Is an execution configuration compiled for a particular device and takes into account its capabilities.
|
||||
- Holds a reference to a particular device and a task executor for this device.
|
||||
- Can create several instances of [Inference Request](@ref openvino_docs_ov_plugin_dg_infer_request).
|
||||
- Can export an internal backend specific graph structure to an output stream.
|
||||
3. [Inference Request class](@ref openvino_docs_ov_plugin_dg_infer_request):
|
||||
- Runs an inference pipeline serially.
|
||||
- Can extract performance counters for an inference pipeline execution profiling.
|
||||
4. [Asynchronous Inference Request class](@ref openvino_docs_ie_plugin_dg_async_infer_request):
|
||||
- Wraps the [Inference Request](@ref openvino_docs_ov_plugin_dg_infer_request) class and runs pipeline stages in parallel
|
||||
on several task executors based on a device-specific pipeline structure.
|
||||
- Wraps the [Inference Request](@ref openvino_docs_ov_plugin_dg_infer_request) class and runs pipeline stages in parallel on several task executors based on a device-specific pipeline structure.
|
||||
5. [Remote Context](@ref openvino_docs_ov_plugin_dg_remote_context):
|
||||
- Provides the device specific remote context. Context allows to create remote tensors.
|
||||
6. [Remote Tensor](@ref openvino_docs_ov_plugin_dg_remote_tensor)
|
||||
- Provides the device specific remote tensor API and implementation.
|
||||
|
||||
> **NOTE**: This documentation is written based on the `Template` plugin, which demonstrates plugin
|
||||
|
||||
|
49
docs/IE_PLUGIN_DG/RemoteContext.md
Normal file
49
docs/IE_PLUGIN_DG/RemoteContext.md
Normal file
@ -0,0 +1,49 @@
|
||||
# Remote Context {#openvino_docs_ov_plugin_dg_remote_context}
|
||||
|
||||
ov::RemoteContext class functionality:
|
||||
- Represents device specific inference context.
|
||||
- Allows to create remote device specific tensor.
|
||||
|
||||
> **NOTE**: If plugin provides a public API for own Remote Context, the API should be header only and doesn't depend on the plugin library.
|
||||
|
||||
|
||||
RemoteContext Class
|
||||
------------------------
|
||||
|
||||
OpenVINO Plugin API provides the interface ov::IRemoteContext which should be used as a base class for a plugin specific remote context. Based on that, a declaration of an compiled model class can look as follows:
|
||||
|
||||
@snippet src/remote_context.hpp remote_context:header
|
||||
|
||||
### Class Fields
|
||||
|
||||
The example class has several fields:
|
||||
|
||||
- `m_name` - Device name.
|
||||
- `m_property` - Device specific context properties. It can be used to cast RemoteContext to device specific type.
|
||||
|
||||
### RemoteContext Constructor
|
||||
|
||||
This constructor should initialize the remote context device name and properties.
|
||||
|
||||
@snippet src/remote_context.cpp remote_context:ctor
|
||||
|
||||
### get_device_name()
|
||||
|
||||
The function returns the device name from the remote context.
|
||||
|
||||
@snippet src/remote_context.cpp remote_context:get_device_name
|
||||
|
||||
### get_property()
|
||||
|
||||
The implementation returns the remote context properties.
|
||||
|
||||
@snippet src/remote_context.cpp remote_context:get_property
|
||||
|
||||
|
||||
### create_tensor()
|
||||
|
||||
The method creates device specific remote tensor.
|
||||
|
||||
@snippet src/remote_context.cpp remote_context:create_tensor
|
||||
|
||||
The next step to support device specific tensors is a creation of device specific [Remote Tensor](@ref openvino_docs_ov_plugin_dg_remote_tensor) class.
|
87
docs/IE_PLUGIN_DG/RemoteTensor.md
Normal file
87
docs/IE_PLUGIN_DG/RemoteTensor.md
Normal file
@ -0,0 +1,87 @@
|
||||
# Remote Tensor {#openvino_docs_ov_plugin_dg_remote_tensor}
|
||||
|
||||
ov::RemoteTensor class functionality:
|
||||
- Provide an interface to work with device specific memory.
|
||||
|
||||
> **NOTE**: If plugin provides a public API for own Remote Tensor, the API should be header only and doesn't depend on the plugin library.
|
||||
|
||||
|
||||
Device Specific Remote Tensor Public API
|
||||
------------------------------------------
|
||||
|
||||
The public interface to work with device specific remote tensors should have header only implementation and doesn't depend on the plugin library.
|
||||
|
||||
@snippet include/template/remote_tensor.hpp remote_tensor:public_header
|
||||
|
||||
The implementation below has several methods:
|
||||
|
||||
### type_check()
|
||||
|
||||
Static method is used to understand that some abstract remote tensor can be casted to this particular remote tensor type.
|
||||
|
||||
### get_data()
|
||||
|
||||
The set of methods (specific for the example, other implementation can have another API) which are helpers to get an access to remote data.
|
||||
|
||||
Device Specific Internal tensor implementation
|
||||
-----------------------------------------------
|
||||
|
||||
The plugin should have the internal implementation of remote tensor which can communicate with public API.
|
||||
The example contains the implementation of remote tensor which wraps memory from stl vector.
|
||||
|
||||
OpenVINO Plugin API provides the interface ov::IRemoteTensor which should be used as a base class for remote tensors.
|
||||
|
||||
The example implementation have two remote tensor classes:
|
||||
|
||||
- Internal type dependent implementation which has as an template argument the vector type and create the type specific tensor.
|
||||
- The type independent implementation which works with type dependent tensor inside.
|
||||
|
||||
Based on that, an implementation of a type independent remote tensor class can look as follows:
|
||||
|
||||
@snippet src/remote_context.cpp vector_impl:implementation
|
||||
|
||||
The implementation provides a helper to get wrapped stl tensor and overrides all important methods of ov::IRemoteTensor class and recall the type dependent implementation.
|
||||
|
||||
The type dependent remote tensor has the next implementation:
|
||||
|
||||
@snippet src/remote_context.cpp vector_impl_t:implementation
|
||||
|
||||
### Class Fields
|
||||
|
||||
The class has several fields:
|
||||
|
||||
- `m_element_type` - Tensor element type.
|
||||
- `m_shape` - Tensor shape.
|
||||
- `m_strides` - Tensor strides.
|
||||
- `m_data` - Wrapped vector.
|
||||
- `m_dev_name` - Device name.
|
||||
- `m_properties` - Remote tensor specific properties which can be used to detect the type of the remote tensor.
|
||||
|
||||
### VectorTensorImpl()
|
||||
|
||||
The constructor of remote tensor implementation. Creates a vector with data, initialize device name and properties, updates shape, element type and strides.
|
||||
|
||||
|
||||
### get_element_type()
|
||||
|
||||
The method returns tensor element type.
|
||||
|
||||
### get_shape()
|
||||
|
||||
The method returns tensor shape.
|
||||
|
||||
### get_strides()
|
||||
|
||||
The method returns tensor strides.
|
||||
|
||||
### set_shape()
|
||||
|
||||
The method allows to set new shapes for the remote tensor.
|
||||
|
||||
### get_properties()
|
||||
|
||||
The method returns tensor specific properties.
|
||||
|
||||
### get_device_name()
|
||||
|
||||
The method returns tensor specific device name.
|
@ -4,7 +4,7 @@
|
||||
<tab type="usergroup" url="index.html" visibile="yes" title="GUIDE">
|
||||
<tab type="usergroup" url="index.html" title="Developer Guide for OpenVINO Plugin Library">
|
||||
<tab type="user" url="@ref plugin" visibile="yes" title="Implement Plugin Functionality"/>
|
||||
<tab type="user" url="@ref executable_network" visibile="yes" title="Implement Executable Network Functionality">
|
||||
<tab type="user" url="@ref compiled_model" visibile="yes" title="Implement Executable Network Functionality">
|
||||
<tab type="usergroup" title="Low Precision Transformations" url="@ref openvino_docs_OV_UG_lpt">
|
||||
<tab type="user" title="Attributes" url="@ref openvino_docs_OV_UG_lpt_attributes">
|
||||
<tab type="user" title="AvgPoolPrecisionPreserved" url="@ref openvino_docs_OV_UG_lpt_AvgPoolPrecisionPreserved"/>
|
||||
@ -79,6 +79,8 @@
|
||||
</tab>
|
||||
<tab type="user" url="@ref infer_request" visibile="yes" title="Implement Synchronous Inference Request"/>
|
||||
<tab type="user" url="@ref async_infer_request" visibile="yes" title="Implement Asynchronous Inference Request"/>
|
||||
<tab type="user" url="@ref remote_context" visibile="yes" title="Implement Remote Context"/>
|
||||
<tab type="user" url="@ref remote_tensor" visibile="yes" title="Implement Remote Tensor"/>
|
||||
</tab>
|
||||
</tab>
|
||||
<!-- Additional resources -->
|
||||
|
@ -17,6 +17,7 @@ namespace template_plugin {
|
||||
/**
|
||||
* @brief Template plugin remote tensor which wraps memory from the vector
|
||||
*/
|
||||
// ! [remote_tensor:public_header]
|
||||
class VectorTensor : public ov::RemoteTensor {
|
||||
public:
|
||||
/**
|
||||
@ -93,6 +94,7 @@ public:
|
||||
}
|
||||
}
|
||||
};
|
||||
// ! [remote_tensor:public_header]
|
||||
|
||||
} // namespace template_plugin
|
||||
} // namespace ov
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
// ! [vector_impl_t:implementation]
|
||||
template <class T>
|
||||
class VectorTensorImpl : public ov::IRemoteTensor {
|
||||
void update_strides() {
|
||||
@ -78,9 +79,11 @@ public:
|
||||
return m_dev_name;
|
||||
}
|
||||
};
|
||||
// ! [vector_impl_t:implementation]
|
||||
|
||||
} // namespace
|
||||
|
||||
// ! [vector_impl:implementation]
|
||||
class VectorImpl : public ov::IRemoteTensor {
|
||||
private:
|
||||
std::shared_ptr<ov::IRemoteTensor> m_tensor;
|
||||
@ -127,16 +130,25 @@ public:
|
||||
return m_tensor->get_device_name();
|
||||
}
|
||||
};
|
||||
// ! [vector_impl:implementation]
|
||||
|
||||
// ! [remote_context:ctor]
|
||||
ov::template_plugin::RemoteContext::RemoteContext() : m_name("TEMPLATE") {}
|
||||
// ! [remote_context:ctor]
|
||||
|
||||
// ! [remote_context:get_device_name]
|
||||
const std::string& ov::template_plugin::RemoteContext::get_device_name() const {
|
||||
return m_name;
|
||||
}
|
||||
// ! [remote_context:get_device_name]
|
||||
|
||||
// ! [remote_context:get_property]
|
||||
const ov::AnyMap& ov::template_plugin::RemoteContext::get_property() const {
|
||||
return m_property;
|
||||
}
|
||||
// ! [remote_context:get_property]
|
||||
|
||||
// ! [remote_context:create_tensor]
|
||||
std::shared_ptr<ov::IRemoteTensor> ov::template_plugin::RemoteContext::create_tensor(const ov::element::Type& type,
|
||||
const ov::Shape& shape,
|
||||
const ov::AnyMap& params) {
|
||||
@ -189,3 +201,4 @@ std::shared_ptr<ov::IRemoteTensor> ov::template_plugin::RemoteContext::create_te
|
||||
}
|
||||
return std::make_shared<VectorImpl>(tensor);
|
||||
}
|
||||
// ! [remote_context:create_tensor]
|
||||
|
@ -7,6 +7,7 @@
|
||||
namespace ov {
|
||||
namespace template_plugin {
|
||||
|
||||
// ! [remote_context:header]
|
||||
class RemoteContext : public ov::IRemoteContext {
|
||||
public:
|
||||
RemoteContext();
|
||||
@ -20,6 +21,7 @@ private:
|
||||
std::string m_name;
|
||||
ov::AnyMap m_property;
|
||||
};
|
||||
// ! [remote_context:header]
|
||||
|
||||
} // namespace template_plugin
|
||||
} // namespace ov
|
||||
|
Loading…
Reference in New Issue
Block a user