class ov::intel_gpu::ocl::D3DContext

Overview

This class represents an abstraction for GPU plugin remote context which is shared with Direct3D 11 device. The plugin object derived from this class can be obtained either with CompiledModel::get_context() or Core::create_context() calls. More…

#include <dx.hpp>

class D3DContext: public ov::intel_gpu::ocl::ClContext
{
public:
    // construction

    D3DContext(Core& core, ID3D11Device \* device, int target_tile_id = -1);

    // methods

    static void type_check(const RemoteContext& remote_context);
    operator ID3D11Device \* ();

    std::pair<D3DSurface2DTensor, D3DSurface2DTensor> create_tensor_nv12(
        const size_t height,
        const size_t width,
        ID3D11Texture2D \* nv12_surf
        );

    D3DBufferTensor create_tensor(
        const element::Type type,
        const Shape& shape,
        ID3D11Buffer \* buffer
        );

    D3DSurface2DTensor create_tensor(
        const element::Type type,
        const Shape& shape,
        ID3D11Texture2D \* surface,
        uint32_t plane = 0
        );

    ClBufferTensor create_tensor(
        const element::Type type,
        const Shape& shape,
        const cl_mem buffer
        );

    ClBufferTensor create_tensor(
        const element::Type type,
        const Shape& shape,
        const cl::Buffer& buffer
        );

    ClImage2DTensor create_tensor(
        const element::Type type,
        const Shape& shape,
        const cl::Image2D& image
        );

    USMTensor create_tensor(
        const element::Type type,
        const Shape& shape,
        void \* usm_ptr
        );
};

Inherited Members

public:
    // methods

    RemoteContext& operator = (const RemoteContext& other);
    RemoteContext& operator = (RemoteContext&& other);

    template <typename T>
    bool is() const;

    template <typename T>
    const T as() const;

    RemoteTensor create_tensor(
        const element::Type& type,
        const Shape& shape,
        const AnyMap& params = {}
        );

    AnyMap get_params() const;
    Tensor create_host_tensor(const element::Type type, const Shape& shape);

    static void type_check(
        const RemoteContext& remote_context,
        const std::map<std::string, std::vector<std::string>>& type_info = {}
        );

    static void type_check(const RemoteContext& remote_context);
    cl_context get();
    operator cl_context ();
    operator cl::Context ();

    std::pair<ClImage2DTensor, ClImage2DTensor> create_tensor_nv12(
        const cl::Image2D& nv12_image_plane_y,
        const cl::Image2D& nv12_image_plane_uv
        );

    ClBufferTensor create_tensor(
        const element::Type type,
        const Shape& shape,
        const cl_mem buffer
        );

    ClBufferTensor create_tensor(
        const element::Type type,
        const Shape& shape,
        const cl::Buffer& buffer
        );

    ClImage2DTensor create_tensor(
        const element::Type type,
        const Shape& shape,
        const cl::Image2D& image
        );

    USMTensor create_tensor(
        const element::Type type,
        const Shape& shape,
        void \* usm_ptr
        );

    USMTensor create_usm_host_tensor(const element::Type type, const Shape& shape);
    USMTensor create_usm_device_tensor(const element::Type type, const Shape& shape);

    RemoteTensor create_tensor(
        const element::Type& type,
        const Shape& shape,
        const AnyMap& params = {}
        );

Detailed Documentation

This class represents an abstraction for GPU plugin remote context which is shared with Direct3D 11 device. The plugin object derived from this class can be obtained either with CompiledModel::get_context() or Core::create_context() calls.

User can also obtain OpenCL context handle from this class.

Construction

D3DContext(Core& core, ID3D11Device \* device, int target_tile_id = -1)

Constructs D3DContext remote context object from ID3D11Device.

Parameters:

core

OpenVINO Runtime Core object instance

device

A pointer to ID3D11Device to be used to create a remote context

target_tile_id

Desired tile id within given context for multi-tile system. Default value (-1) means that root device should be used

Methods

static void type_check(const RemoteContext& remote_context)

Checks that type defined runtime parameters are presented in remote object.

Parameters:

remote_context

A remote context to check

operator ID3D11Device \* ()

ID3D11Device conversion operator for the D3DContext object.

Returns:

Pointer to underlying ID3D11Device interface

std::pair<D3DSurface2DTensor, D3DSurface2DTensor> create_tensor_nv12(
    const size_t height,
    const size_t width,
    ID3D11Texture2D \* nv12_surf
    )

This function is used to obtain a NV12 tensor from NV12 DXGI video decoder output. The resulting tensor contains two remote tensors for Y and UV planes of the surface.

Parameters:

height

Height of Y plane

width

Width of Y plane

nv12_surf

A ID3D11Texture2D instance to create NV12 tensor from

Returns:

A pair of remote tensors for each plane

D3DBufferTensor create_tensor(
    const element::Type type,
    const Shape& shape,
    ID3D11Buffer \* buffer
    )

This function is used to obtain remote tensor object from ID3D11Buffer.

Parameters:

type

Tensor element type

shape

Tensor shape

buffer

A pointer to ID3D11Buffer instance to create remote tensor based on

Returns:

A remote tensor instance

D3DSurface2DTensor create_tensor(
    const element::Type type,
    const Shape& shape,
    ID3D11Texture2D \* surface,
    uint32_t plane = 0
    )

This function is used to obtain remote tensor object from ID3D11Texture2D.

The underlying ID3D11Texture2D can also be a plane of output surface of DXGI video decoder

Parameters:

type

Tensor element type

shape

Tensor shape

surface

Pointer to ID3D11Texture2D interface of the objects that owns NV12 texture

plane

ID of the plane to be shared (0 or 1)

Returns:

D3DSurface2DTensor tensor

ClBufferTensor create_tensor(
    const element::Type type,
    const Shape& shape,
    const cl_mem buffer
    )

This function is used to obtain remote tensor object from user-supplied cl_mem object.

Parameters:

type

Tensor element type

shape

Tensor shape

buffer

A cl_mem object that should be wrapped by a remote tensor

Returns:

A remote tensor instance

ClBufferTensor create_tensor(
    const element::Type type,
    const Shape& shape,
    const cl::Buffer& buffer
    )

This function is used to obtain remote tensor object from user-supplied cl::Buffer object.

Parameters:

type

Tensor element type

shape

Tensor shape

buffer

A cl::Buffer object that should be wrapped by a remote tensor

Returns:

A remote tensor instance

ClImage2DTensor create_tensor(
    const element::Type type,
    const Shape& shape,
    const cl::Image2D& image
    )

This function is used to obtain remote tensor object from user-supplied cl::Image2D object.

Parameters:

type

Tensor element type

shape

Tensor shape

image

A cl::Image2D object that should be wrapped by a remote tensor

Returns:

A remote tensor instance

USMTensor create_tensor(
    const element::Type type,
    const Shape& shape,
    void \* usm_ptr
    )

This function is used to obtain remote tensor object from user-supplied USM pointer.

Parameters:

type

Tensor element type

shape

Tensor shape

usm_ptr

A USM pointer that should be wrapped by a remote tensor

Returns:

A remote tensor instance