docs.unity3d.com
    Show / Hide Table of Contents

    Class Tensor

    Represents data in a multidimensional array-like structure.

    Inheritance
    Object
    Tensor
    TensorFloat
    TensorInt
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.Sentis
    Syntax
    public abstract class Tensor : IDisposable

    Constructors

    Tensor(TensorShape, ITensorData, ITensorAllocator)

    Create a Tensor with the specified shape, an ITensorData data and an ITensorAllocator allocator.

    Declaration
    protected Tensor(TensorShape shape, ITensorData data = null, ITensorAllocator allocator = null)
    Parameters
    Type Name Description
    TensorShape shape
    ITensorData data
    ITensorAllocator allocator

    Fields

    m_Disposed

    Declaration
    protected bool m_Disposed
    Field Value
    Type Description
    Boolean

    m_Shape

    Declaration
    protected TensorShape m_Shape
    Field Value
    Type Description
    TensorShape

    m_TensorAllocator

    Declaration
    protected ITensorAllocator m_TensorAllocator
    Field Value
    Type Description
    ITensorAllocator

    m_TensorOnDevice

    Declaration
    protected ITensorData m_TensorOnDevice
    Field Value
    Type Description
    ITensorData

    Properties

    allocator

    The allocator for the tensor. Refer to ITensorAllocator.

    Declaration
    public ITensorAllocator allocator { get; }
    Property Value
    Type Description
    ITensorAllocator

    dataType

    The data type of the elements of the tensor.

    Declaration
    public abstract DataType dataType { get; }
    Property Value
    Type Description
    DataType

    shape

    The shape of the tensor, as a TensorShape.

    Declaration
    public TensorShape shape { get; protected set; }
    Property Value
    Type Description
    TensorShape

    tensorOnDevice

    The device-specific internal representation of the tensor data.

    Declaration
    public ITensorData tensorOnDevice { get; protected set; }
    Property Value
    Type Description
    ITensorData

    Methods

    AsyncReadbackRequest(Action<Boolean>)

    Schedules asynchronous download of the internal data.

    Invokes callback when async readback is finished.

    Boolean indicates if async readback is successful.

    Declaration
    public void AsyncReadbackRequest(Action<bool> callback = null)
    Parameters
    Type Name Description
    Action<Boolean> callback

    AttachToDevice(ITensorData)

    Associates a tensor with the block of data on a device. Sentis downloads from source on first access.

    Make sure source contains initialized and valid data that represents tensor values.

    Declaration
    public void AttachToDevice(ITensorData source)
    Parameters
    Type Name Description
    ITensorData source

    CompleteAllPendingOperations()

    Declaration
    public void CompleteAllPendingOperations()

    DeepCopy()

    Returns a deep copy of the current Tensor.

    Declaration
    public abstract Tensor DeepCopy()
    Returns
    Type Description
    Tensor

    DetachFromDevice(Boolean)

    Synchronizes the tensor data with the data on the device, then remove the tensor from the device.

    Declaration
    public ITensorData DetachFromDevice(bool disposeDeviceData = true)
    Parameters
    Type Name Description
    Boolean disposeDeviceData
    Returns
    Type Description
    ITensorData

    Dispose()

    Disposes of the tensor and any associated memory.

    Declaration
    public virtual void Dispose()
    Implements
    IDisposable.Dispose()

    Finalize()

    Dispose of the tensor and any associated memory.

    Declaration
    protected void Finalize()

    IsAsyncReadbackRequestDone()

    Checks if asynchronous readback request it done.

    Returns true if async readback is successful.

    Declaration
    public bool IsAsyncReadbackRequestDone()
    Returns
    Type Description
    Boolean

    MakeReadable()

    Blocking call to make tensor data read write.

    Issues a blocking download of the internal data. And converts tensorData to ArrayTensorData

    Declaration
    public void MakeReadable()

    PinToDevice(ITensorData, Boolean)

    Declaration
    protected void PinToDevice(ITensorData onDevice, bool disposeUnpinned = true)
    Parameters
    Type Name Description
    ITensorData onDevice
    Boolean disposeUnpinned

    ShallowCopy()

    Returns a shallow copy of the current Tensor. The copy shares data storage with original tensor.

    Declaration
    public Tensor ShallowCopy()
    Returns
    Type Description
    Tensor

    ShallowReshape(TensorShape)

    Returns a shallow copy of the Tensor with a new shape. The copy shares data storage with the original tensor.

    newShape.length must be equal to this.shape.length.

    Declaration
    public abstract Tensor ShallowReshape(TensorShape newShape)
    Parameters
    Type Name Description
    TensorShape newShape
    Returns
    Type Description
    Tensor

    TakeOwnership()

    Removes system references to the tensor. The caller assumes ownership.

    Declaration
    public void TakeOwnership()

    ToString()

    Returns a string that represents the Tensor.

    Declaration
    public override string ToString()
    Returns
    Type Description
    String
    Overrides
    Object.ToString()

    UploadToDevice(ITensorData)

    Declaration
    public abstract void UploadToDevice(ITensorData destination)
    Parameters
    Type Name Description
    ITensorData destination

    Extension Methods

    TensorExtensions.PrintDataPart(Tensor, Int32, String)
    In This Article
    • Constructors
      • Tensor(TensorShape, ITensorData, ITensorAllocator)
    • Fields
      • m_Disposed
      • m_Shape
      • m_TensorAllocator
      • m_TensorOnDevice
    • Properties
      • allocator
      • dataType
      • shape
      • tensorOnDevice
    • Methods
      • AsyncReadbackRequest(Action<Boolean>)
      • AttachToDevice(ITensorData)
      • CompleteAllPendingOperations()
      • DeepCopy()
      • DetachFromDevice(Boolean)
      • Dispose()
      • Finalize()
      • IsAsyncReadbackRequestDone()
      • MakeReadable()
      • PinToDevice(ITensorData, Boolean)
      • ShallowCopy()
      • ShallowReshape(TensorShape)
      • TakeOwnership()
      • ToString()
      • UploadToDevice(ITensorData)
    • Extension Methods
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023