docs.unity3d.com
    Show / Hide Table of Contents

    Class TopK

    Represents a TopK layer. This calculates the top-K largest or smallest elements of an input tensor along a given axis.

    This layer calculates both the values tensor of the top-K elements and the indices tensor of the top-K elements as outputs.

    Inheritance
    Object
    Layer
    TopK
    Inherited Members
    Layer.inputs
    Layer.name
    Layer.outputs
    Layer.flags
    Layer.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.Sentis.Layers
    Syntax
    [Serializable]
    public class TopK : Layer

    Constructors

    TopK(String, String, String, Int32, Boolean, Boolean, String[])

    Initializes and returns an instance of TopK layer.

    Declaration
    public TopK(string name, string input, string k, int axis, bool largest, bool sorted, string[] outputNames)
    Parameters
    Type Name Description
    String name

    The name to use for the values tensor of the layer.

    String input

    The name to use for the input tensor of the layer.

    String k

    The name to use for the single value 1D tensor containing the number of elements to calculate.

    Int32 axis

    The axis along which to perform the top-K operation.

    Boolean largest

    Whether to calculate the top-K largest elements. If this is false the layer calculates the top-K smallest elements.

    Boolean sorted

    Whether to return the elements in sorted order in the output tensor.

    String[] outputNames

    A two-element array containing the names to use for the values and indices output tensors of the layer respectively.

    Fields

    axis

    The axis along which to perform the top-K operation.

    Declaration
    public int axis
    Field Value
    Type Description
    Int32

    largest

    Whether to calculate the top-K largest elements. If this is false the layer calculates the top-K smallest elements.

    Declaration
    public bool largest
    Field Value
    Type Description
    Boolean

    sorted

    Whether to return the elements in sorted order in the output tensor.

    Declaration
    public bool sorted
    Field Value
    Type Description
    Boolean

    Methods

    Execute(Tensor[], ExecutionContext)

    Executes the layer using the operations and variables from the ExecutionContext and returns the output tensor.

    If the layer has more than one output, output tensors are saved to variables.

    Declaration
    public override Tensor Execute(Tensor[] inputTensors, ExecutionContext ctx)
    Parameters
    Type Name Description
    Tensor[] inputTensors
    ExecutionContext ctx
    Returns
    Type Description
    Tensor
    Overrides
    Layer.Execute(Tensor[], ExecutionContext)
    In This Article
    • Constructors
      • TopK(String, String, String, Int32, Boolean, Boolean, String[])
    • Fields
      • axis
      • largest
      • sorted
    • Methods
      • Execute(Tensor[], ExecutionContext)
    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