Please use. NET 5,. NET 6, NET 7,. NET 8, NET Framework 4.6, NET Framework 4.61, NET Framework 4.7, NET Framework 4.72, NET Framework 4.8, NET Framework 4.81, and. NET Core 3.1 versions

Tensor Class

Tensor API holding host memory. It can throw exceptions safely for the application, where it is properly handled.

Definition

Namespace: OpenVinoSharp
Assembly: OpenVINO_CSharp_API (in OpenVINO_CSharp_API.dll) Version: 2024.3.0.2+a9617c0f8f80882646d0eba11b88ae6cb17b3fb8
C#
public class Tensor : IDisposable
Inheritance
Object    Tensor
Implements
IDisposable

Constructors

Tensor Default Constructor
Tensor(IntPtr) Constructs Tensor from the initialized pointer.
Tensor(Tensor) Default copy constructor
Tensor(OvType, Shape) Initializes a new instance of the Tensor class
Tensor(Shape, Double) Constructs Tensor using element type ,shape and input data.
Tensor(Shape, Int16) Constructs Tensor using element type ,shape and input data.
Tensor(Shape, Int32) Constructs Tensor using element type ,shape and input data.
Tensor(Shape, Int64) Constructs Tensor using element type ,shape and input data.
Tensor(Shape, Single) Constructs Tensor using element type ,shape and input data.
Tensor(Type, Shape) Constructs Tensor using element type and shape. Allocate internal host storage using default allocator
Tensor(OvType, Shape, Byte) Initializes a new instance of the Tensor class
Tensor(OvType, Shape, IntPtr) Initializes a new instance of the Tensor class
Tensor(Type, Shape, Byte) Constructs Tensor using element type ,shape and image data.
Tensor(Type, Shape, IntPtr) Constructs Tensor using element type and shape. Wraps allocated host memory.

Properties

Ptr [public]Tensor class pointer.

Methods

copy_toT Copy tensor, destination tensor should have the same element type and shape
data Provides an access to the underlaying host memory.
Dispose Release unmanaged resources
Finalize Tensor's destructor
(Overrides ObjectFinalize)
get_byte_size Returns the size of the current Tensor in bytes.
get_dataT Read data of the specified type from the underlying host memory.
get_element_type Get tensor element type
get_shape Get tensor shape
get_size Returns the total number of elements (a product of all the dims or 1 for scalar).
set_dataT Load the specified type of data into the underlying host memory.
set_shape Set new shape for tensor, deallocate/allocate if new total size is bigger than previous one.

Fields

m_ptr [private]Tensor class pointer.

See Also