Class TensorArray

    • Field Detail

      • tensorArrayDataType

        protected DataType tensorArrayDataType
      • clearOnRead

        protected boolean clearOnRead
    • Method Detail

      • configureFromArguments

        public void configureFromArguments()
        Description copied from interface: CustomOp
        This allows a custom op to configure relevant fields from its arguments. This is needed when ops are created via reflection for things like model import.
        Specified by:
        configureFromArguments in interface CustomOp
        Overrides:
        configureFromArguments in class DynamicCustomOp
      • getSameDiff

        public SameDiff getSameDiff()
      • calculateOutputDataTypes

        public List<DataType> calculateOutputDataTypes​(List<DataType> inputDataType)
        Description copied from class: DifferentialFunction
        Calculate the data types for the output arrays. Though datatypes can also be inferred from DifferentialFunction.calculateOutputShape(), this method differs in that it does not require the input arrays to be populated. This is important as it allows us to do greedy datatype inference for the entire net - even if arrays are not available.
        Overrides:
        calculateOutputDataTypes in class DifferentialFunction
        Parameters:
        inputDataType - The data types of the inputs
        Returns:
        The data types of the outputs
      • itemAtIndex

        public static SDVariable itemAtIndex​(SameDiff sd,
                                             SDVariable[] inputs)
        Returns the item at the specified index in the specified list.
        Parameters:
        sd - the same diff instance to use
        inputs - the inputs including the relevant tensor array variable and position
        Returns:
      • itemAtIndex

        public static SDVariable itemAtIndex​(SameDiff sd,
                                             SDVariable[] inputs,
                                             String outputVarName)
        Returns the item at the specified index in the specified list. The output variable name to specify for the final output.
        Parameters:
        sd - the same diff instance to use
        inputs - the inputs including the relevant tensor array variable and position
        outputVarName - the name of the output variable for the read
        Returns:
      • requiredShape

        public long[] requiredShape()
        Returns the required shape for elements in this tensor array. If a second input is not present an IllegalArgumentException is thrown.
        Returns:
      • getTensorArray

        public static TensorArray getTensorArray​(SameDiff sd,
                                                 SDVariable sequenceVar)
        Get the associated TensorArray instance related to this op. Sometimes when a TensorArray op is returned it can be renamed or may not directly be the associated TensorArray instance. This helps discover the underlying TensorArray op for use to declare other operations to manipulate that instance such as read(int)
        Parameters:
        sd - the input instance
        sequenceVar - the relevant variable to discover the TensorArray for
        Returns:
      • removeFromTensorArray

        public static SDVariable removeFromTensorArray​(SameDiff sameDiff,
                                                       SDVariable inputSequence)
        Remove the last element from the relevant TensorArray
        Parameters:
        sameDiff - the samediff instance to use
        inputSequence - the relevant variable for the associated TensorArray
        Returns:
      • removeFromTensorArray

        public static SDVariable removeFromTensorArray​(SameDiff sameDiff,
                                                       SDVariable inputSequence,
                                                       SDVariable position)
        Remove an element from the relevant TensorArray
        Parameters:
        sameDiff - the samediff sinstance to use
        inputSequence - the relevant variable for the associated TensorArray
        position - the position to remove
        Returns:
      • removeFromTensorArray

        public static SDVariable removeFromTensorArray​(SameDiff sameDiff,
                                                       SDVariable inputSequence,
                                                       SDVariable position,
                                                       String outputVarName)
        Remove an element from the relevant TensorArray
        Parameters:
        sameDiff - the samediff instance to use
        inputSequence - the relevant variable for the associated TensorArray
        position - the position to remove
        outputVarName - the name of the output variable
        Returns:
      • sizeOfTensorArray

        public static SDVariable sizeOfTensorArray​(SameDiff sd,
                                                   SDVariable sequence)
        Create an empty sequence with the specified data type. An output variable name will be generated.
        Parameters:
        sd - the samediff instance to use
        sequence - the output variable of the sequence to get the size of
        Returns:
        the output variable of the created sequence
      • sizeOfTensorArray

        public static SDVariable sizeOfTensorArray​(SameDiff sd,
                                                   SDVariable sequence,
                                                   String outputVarName)
        Create an empty sequence with the specified data type. An output variable name will be generated.
        Parameters:
        sd - the samediff instance to use
        sequence - the output variable of the sequence to get the size of
        outputVarName - the output name of the size variable
        Returns:
        the output variable of the created sequence
      • createEmpty

        public static SDVariable createEmpty​(SameDiff sd,
                                             DataType dataType)
        Create an empty sequence with the specified data type. An output variable name will be generated.
        Parameters:
        sd - the samediff instance to use
        dataType - the data type of the sequence
        Returns:
        the output variable of the created sequence
      • createEmpty

        public static SDVariable createEmpty​(SameDiff sd,
                                             DataType dataType,
                                             String outputVarName)
        Create an empty sequence with the specified data type.
        Parameters:
        sd - the samediff instance to use
        dataType - the data type of the sequence
        outputVarName - the output variable name of the sequence
        Returns:
        the output variable of the created sequence
      • createTensorArrayFrom

        public static SDVariable createTensorArrayFrom​(SameDiff sd,
                                                       SDVariable[] inputs,
                                                       String outputVarName)
        Create an TensorArray op from the given inputs
        Parameters:
        sd - the SameDiff instance to use
        inputs - the input variables to create a TensorArray for
        outputVarName - the name of the output variable to use for the final output of the loop
        Returns:
        the output variable for the tensor array