docs.unity3d.com
  • Manual
  • Scripting API
  • Changelog
  • License
    Show / Hide Table of Contents
    • Unity.​Sentis
      • Alloc​Scope
      • Array​Tensor​Data
      • Backend​Type
      • Burst​Jobs​Cast​Tensor
      • Burst​Jobs​Cast​Tensor.​Bool​Bytes​As​Float​Job
      • Burst​Jobs​Cast​Tensor.​Double​Bytes​As​Float​Job
      • Burst​Jobs​Cast​Tensor.​Float16Bytes​As​Float​Job
      • Burst​Jobs​Cast​Tensor.​Int8Bytes​As​Float​Job
      • Burst​Jobs​Cast​Tensor.​Long​Bytes​As​Float​Job
      • Burst​Jobs​Cast​Tensor.​Uint8Bytes​As​Float​Job
      • Burst​Tensor​Data
      • Channel
      • Channel​Swizzle
      • Compute​Info
      • Compute​Shader​Singleton
      • Compute​Tensor​Data
      • Coord​Origin
      • CPUBackend
      • CPUOps
      • Data​Type
      • Device​Type
      • Dim​Type
      • Execution​Context
      • Generic​Worker
      • GPUCommand​Buffer​Backend
      • GPUCommand​Buffer​Ops
      • GPUCompute​Backend
      • GPUCompute​Ops
      • GPUPixel​Backend
      • GPUPixel​Burst​Jobs
      • GPUPixel​Burst​Jobs.​Float​Bytes​As​Int​Job
      • GPUPixel​Burst​Jobs.​Int​Bytes​As​Float​Job
      • GPUPixel​Ops
      • IBackend
      • IConvertible​To​Array​Tensor​Data
      • IConvertible​To​Burst​Tensor​Data
      • IConvertible​To​Compute​Tensor​Data
      • IDependable​Memory​Resource
      • IReadable​Tensor​Data
      • ITensor​Allocator
      • ITensor​Data
      • IVars
      • IWorker
      • Model
      • Model.​Importer​Warning
      • Model.​Input
      • Model.​Opset​Description
      • Model.​Warning​Type
      • Model​Asset
      • Model​Asset​Data
      • Model​Asset​Extensions
      • Model​Asset​Weights​Data
      • Model​Extensions
      • Model​Loader
      • Model​Writer
      • Native​Tensor​Array
      • Native​Tensor​Array​From​Managed​Array
      • Non​Deterministic​Output
      • Ops
      • Pixel​Shader​Singleton
      • Random
      • Shared​Array​Tensor​Data
      • Symbolic​Tensor​Dim
      • Symbolic​Tensor​Shape
      • Tensor
      • Tensor​Extensions
      • Tensor​Float
      • Tensor​Index
      • Tensor​Int
      • Tensor​Layout
      • Tensor​NDIterator
      • Tensor​Shape
      • Texture​Converter
      • Texture​Tensor​Data
      • Texture​Transform
      • Worker​Extensions
      • Worker​Factory
      • Worker​Factory.​Worker​Configuration
    • Unity.​Sentis.​Layers
      • Abs
      • Acos
      • Acosh
      • Activation
      • Add
      • And
      • Arg​Max
      • Arg​Min
      • Arg​Reduce
      • Asin
      • Asinh
      • Atan
      • Atanh
      • Auto​Pad
      • Average​Pool
      • Batch​Normalization
      • Bernoulli
      • Broadcast
      • Cast
      • Cast​Like
      • Ceil
      • Celu
      • Center​Point​Box
      • Clip
      • Comparison
      • Compress
      • Concat
      • Constant
      • Constant​Of​Shape
      • Conv
      • Conv​Transpose
      • Coord​Transform​Mode
      • Cos
      • Cosh
      • Cum​Sum
      • Custom​Layer
      • Dense
      • Depth​To​Space
      • Depth​To​Space​Mode
      • Div
      • Einsum
      • Elu
      • Equal
      • Erf
      • Exp
      • Expand
      • Flags
      • Flatten
      • Floor
      • Fusable​Activation
      • Fused​Activation
      • Gather
      • Gather​Elements
      • Gather​ND
      • Gelu
      • Global​Average​Pool
      • Global​Max​Pool
      • Global​Pool
      • Greater
      • Greater​Or​Equal
      • Hardmax
      • Hard​Sigmoid
      • Hard​Swish
      • Identity
      • Instance​Normalization
      • Interpolation​Mode
      • Is​Inf
      • Is​Na​N
      • Layer
      • Layer​Normalization
      • Leaky​Relu
      • Less
      • Less​Or​Equal
      • Local​Pool
      • Log
      • Log​Softmax
      • LRN
      • LSTM
      • Mat​Mul
      • Mat​Mul2D
      • Max
      • Max​Pool
      • Mean
      • Min
      • Mod
      • Mul
      • Multinomial
      • Nearest​Mode
      • Neg
      • Non​Max​Suppression
      • Non​Zero
      • Not
      • One​Hot
      • Or
      • Pad
      • Pad​Mode
      • Pow
      • PRelu
      • Random​Layer
      • Random​Normal
      • Random​Normal​Like
      • Random​Uniform
      • Random​Uniform​Like
      • Range
      • Reciprocal
      • Reduce
      • Reduce​L1
      • Reduce​L2
      • Reduce​Log​Sum
      • Reduce​Log​Sum​Exp
      • Reduce​Max
      • Reduce​Mean
      • Reduce​Min
      • Reduce​Prod
      • Reduce​Sum
      • Reduce​Sum​Square
      • Relu
      • Relu6
      • Reshape
      • Resize
      • Rnn​Activation
      • Rnn​Direction
      • Rnn​Layout
      • Roi​Align
      • Roi​Pooling​Mode
      • Round
      • Scalar​Mad
      • Scale​Bias
      • Scale​Mode
      • Scatter​Elements
      • Scatter​ND
      • Scatter​Reduction​Mode
      • Selu
      • Shape
      • Shrink
      • Sigmoid
      • Sign
      • Sin
      • Sinh
      • Size
      • Slice
      • Softmax
      • Softplus
      • Softsign
      • Space​To​Depth
      • Split
      • Sqrt
      • Square
      • Squeeze
      • Sub
      • Sum
      • Swish
      • Tan
      • Tanh
      • Thresholded​Relu
      • Tile
      • Top​K
      • Transpose
      • Trilu
      • Trilu​Mode
      • Unsqueeze
      • Where
      • Xor
    • Unity.​Sentis.​ONNX
      • IOp​Importer
      • Onnx​Import​Exception
      • Onnx​Layer​Import​Exception
      • ONNXModel​Converter
      • Operator​Node
      • Op​Import​Attribute
    • Scripting API
    • Unity.​Sentis
    • Shared​Array​Tensor​Data

    Class SharedArrayTensorData

    Represents internal Tensor data backed by a managed array and shared between multiple tensors.

    Inheritance
    Object
    SharedArrayTensorData
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.Sentis
    Syntax
    public class SharedArrayTensorData : ITensorData, IDisposable, IConvertibleToBurstTensorData, IConvertibleToComputeTensorData, IConvertibleToArrayTensorData, IReadableTensorData

    Constructors

    SharedArrayTensorData(TensorShape, Array)

    Initializes and returns an instance of SharedArrayTensorData with a given array of data.

    Declaration
    public SharedArrayTensorData(TensorShape shape, Array data)
    Parameters
    Type Name Description
    TensorShape shape

    The shape of the tensor data.

    Array data

    The data to use as backing data.

    SharedArrayTensorData(TensorShape, NativeTensorArray, Int32)

    Initializes and returns an instance of SharedArrayTensorData with a given NativeTensorArray of data.

    Declaration
    public SharedArrayTensorData(TensorShape shape, NativeTensorArray data, int offset = 0)
    Parameters
    Type Name Description
    TensorShape shape

    The shape of the tensor data.

    NativeTensorArray data

    The allocated data to use as backing data.

    Int32 offset

    The integer offset to use for the data.

    Properties

    array

    The data storage array

    Declaration
    public NativeTensorArray array { get; }
    Property Value
    Type Description
    NativeTensorArray

    count

    The number of data elements.

    Declaration
    public int count { get; }
    Property Value
    Type Description
    Int32

    deviceType

    On what device backend are the data elements stored.

    Declaration
    public DeviceType deviceType { get; }
    Property Value
    Type Description
    DeviceType
    Implements
    ITensorData.deviceType

    maxCapacity

    The maximum count of the stored data elements.

    Declaration
    public virtual int maxCapacity { get; }
    Property Value
    Type Description
    Int32
    Implements
    ITensorData.maxCapacity

    offset

    Offset in the storage array.

    Declaration
    public int offset { get; }
    Property Value
    Type Description
    Int32

    shape

    The shape of the tensor using this data as a TensorShape.

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

    Methods

    AsyncReadbackRequest(Action<Boolean>)

    Schedules asynchronous readback 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
    Implements
    ITensorData.AsyncReadbackRequest(Action<Boolean>)

    Clone()

    Returns a deep copy of the internal storage.

    Declaration
    public ITensorData Clone()
    Returns
    Type Description
    ITensorData
    Implements
    ITensorData.Clone()

    CompleteAllPendingOperations()

    Blocking call to make sure that internal data is correctly written to and available for CPU read back.

    Declaration
    public void CompleteAllPendingOperations()
    Implements
    ITensorData.CompleteAllPendingOperations()

    ConvertToArrayTensorData(TensorShape)

    Implement this method to convert to ArrayTensorData.

    Declaration
    public ArrayTensorData ConvertToArrayTensorData(TensorShape shape)
    Parameters
    Type Name Description
    TensorShape shape
    Returns
    Type Description
    ArrayTensorData
    Implements
    IConvertibleToArrayTensorData.ConvertToArrayTensorData(TensorShape)

    ConvertToBurstTensorData(TensorShape)

    Implement this method to convert to BurstTensorData.

    Declaration
    public BurstTensorData ConvertToBurstTensorData(TensorShape shape)
    Parameters
    Type Name Description
    TensorShape shape
    Returns
    Type Description
    BurstTensorData
    Implements
    IConvertibleToBurstTensorData.ConvertToBurstTensorData(TensorShape)

    ConvertToComputeTensorData(TensorShape)

    Implement this method to convert to ComputeTensorData.

    Declaration
    public ComputeTensorData ConvertToComputeTensorData(TensorShape shape)
    Parameters
    Type Name Description
    TensorShape shape
    Returns
    Type Description
    ComputeTensorData
    Implements
    IConvertibleToComputeTensorData.ConvertToComputeTensorData(TensorShape)

    Dispose()

    Disposes of the SharedArrayTensorData and any associated memory.

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

    Download<T>(Int32, Int32)

    Returns data from internal storage.

    Declaration
    public NativeArray<T> Download<T>(int dstCount, int srcOffset = 0)
        where T : struct
    Parameters
    Type Name Description
    Int32 dstCount
    Int32 srcOffset
    Returns
    Type Description
    NativeArray<T>
    Type Parameters
    Name Description
    T
    Implements
    ITensorData.Download<T>(Int32, Int32)

    Finalize()

    Finalizes the SharedArrayTensorData.

    Declaration
    protected void Finalize()

    Get<T>(Int32)

    Returns a data element at index.

    Declaration
    public T Get<T>(int index)
        where T : struct
    Parameters
    Type Name Description
    Int32 index
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T
    Implements
    IReadableTensorData.Get<T>(Int32)

    GetReadOnlyNativeArrayHandle<T>(Int32, Int32)

    Returns a ReadOnlyNativeArray handle on the linear memory data.

    Declaration
    public NativeArray<T>.ReadOnly GetReadOnlyNativeArrayHandle<T>(int dstCount, int srcOffset = 0)
        where T : struct
    Parameters
    Type Name Description
    Int32 dstCount
    Int32 srcOffset
    Returns
    Type Description
    NativeArray.ReadOnly<>
    Type Parameters
    Name Description
    T
    Implements
    IReadableTensorData.GetReadOnlyNativeArrayHandle<T>(Int32, Int32)

    IsAsyncReadbackRequestDone()

    Checks if asynchronous readback request it done.

    Returns true if async readback is successful.

    Declaration
    public bool IsAsyncReadbackRequestDone()
    Returns
    Type Description
    Boolean
    Implements
    ITensorData.IsAsyncReadbackRequestDone()

    Reserve(Int32)

    Reserves memory for count elements.

    Declaration
    public void Reserve(int count)
    Parameters
    Type Name Description
    Int32 count
    Implements
    ITensorData.Reserve(Int32)

    Set<T>(Int32, T)

    Sets value data element at index.

    Declaration
    public void Set<T>(int index, T value)
        where T : struct
    Parameters
    Type Name Description
    Int32 index
    T value
    Type Parameters
    Name Description
    T
    Implements
    IReadableTensorData.Set<T>(Int32, T)

    ToArray<T>(Int32, Int32)

    Returns a array that is a copy of the linear memory data.

    Declaration
    public T[] ToArray<T>(int dstCount, int srcOffset = 0)
        where T : struct
    Parameters
    Type Name Description
    Int32 dstCount
    Int32 srcOffset
    Returns
    Type Description
    T[]
    Type Parameters
    Name Description
    T
    Implements
    IReadableTensorData.ToArray<T>(Int32, Int32)

    ToReadOnlySpan<T>(Int32, Int32)

    Returns a ReadOnlySpan on the linear memory data.

    Declaration
    public ReadOnlySpan<T> ToReadOnlySpan<T>(int dstCount, int srcOffset = 0)
        where T : struct
    Parameters
    Type Name Description
    Int32 dstCount
    Int32 srcOffset
    Returns
    Type Description
    ReadOnlySpan<T>
    Type Parameters
    Name Description
    T
    Implements
    IReadableTensorData.ToReadOnlySpan<T>(Int32, Int32)

    ToString()

    Returns a string that represents the SharedArrayTensorData.

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

    Upload<T>(NativeArray<T>, Int32, Int32)

    Uploads the tensor data to internal storage.

    Declaration
    public void Upload<T>(NativeArray<T> data, int srcCount, int srcOffset = 0)
        where T : struct
    Parameters
    Type Name Description
    NativeArray<T> data
    Int32 srcCount
    Int32 srcOffset
    Type Parameters
    Name Description
    T
    Implements
    ITensorData.Upload<T>(NativeArray<T>, Int32, Int32)

    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Constructors
      • SharedArrayTensorData(TensorShape, Array)
      • SharedArrayTensorData(TensorShape, NativeTensorArray, Int32)
    • Properties
      • array
      • count
      • deviceType
      • maxCapacity
      • offset
      • shape
    • Methods
      • AsyncReadbackRequest(Action<Boolean>)
      • Clone()
      • CompleteAllPendingOperations()
      • ConvertToArrayTensorData(TensorShape)
      • ConvertToBurstTensorData(TensorShape)
      • ConvertToComputeTensorData(TensorShape)
      • Dispose()
      • Download<T>(Int32, Int32)
      • Finalize()
      • Get<T>(Int32)
      • GetReadOnlyNativeArrayHandle<T>(Int32, Int32)
      • IsAsyncReadbackRequestDone()
      • Reserve(Int32)
      • Set<T>(Int32, T)
      • ToArray<T>(Int32, Int32)
      • ToReadOnlySpan<T>(Int32, Int32)
      • ToString()
      • Upload<T>(NativeArray<T>, Int32, Int32)
    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