public class MPSRNNMatrixInferenceLayer extends MPSKernel
The MPSRNNMatrixInferenceLayer specifies a recurrent neural network layer for inference on MPSMatrices. Currently two types of recurrent layers are supported: ones that operate with convolutions on images: @ref MPSRNNImageInferenceLayer and one that operates on matrices: @ref MPSRNNMatrixInferenceLayer. The former can be often used to implement the latter by using 1x1-matrices, but due to image size restrictions and performance, it is advisable to use @ref MPSRNNMatrixInferenceLayer for linear recurrent layers. A MPSRNNMatrixInferenceLayer is initialized using a @ref MPSRNNLayerDescriptor, which further specifies the recurrent network layer, or an array of @ref MPSRNNLayerDescriptors, which specifies a stack of recurrent layers, that can operate in parallel a subset of the inputs in a sequence of inputs and recurrent outputs. Note that currently stacks with bidirectionally traversing encode functions do not support starting from a previous set of recurrent states, but this can be achieved quite easily by defining two separate unidirectional stacks of layers, and running the same input sequence on them separately (one forwards and one backwards) and ultimately combining the two result sequences as desired with auxiliary functions. The input and output vectors in encode calls are stored as rows of the input and output matrices and MPSRNNMatrixInferenceLayer supports matrices with decreasing number of rows: The row-indices identify the different sequences that may be of different lengths - for example if we have three sequences: ( x1, x2, x3 ), ( y1, y2, y3, y4 ) and ( z1, z2 ) of vectors xi, yi and zi, then these can be inserted together as a batch to the sequence encoding kernel by using the matrices: [@code] ( y1 ) ( y2 ) ( y3 ) ( y4 ) m1 = ( x1 ), m2 = ( x2 ), m3 = ( x3 ), m4 = ( z1 ) ( z2 ) [@endcode] If a recurrent output state is requested then it will contain the state corresponding to last inputs to each sequence and if all the intermediate states are requested (see storeAllIntermediateStates), then the shorter sequences will be propagated by copying the state of the previous output if the input vector is not present in the sequence - in the example above the output states would be: [@code] ( s_y1 ) ( s_y2 ) ( s_y3 ) ( s_y4 ) s1 = ( s_x1 ), s2 = ( s_x2 ), s3 = ( s_x3 ), s4 = ( s_x3 ) ( s_z1 ) ( s_z2 ) ( s_z2 ) ( s_z2 ) [@endcode] The mathematical operation described in the linear transformations of @ref MPSRNNSingleGateDescriptor [@ref] MPSLSTMDescriptor and @ref MPSGRUDescriptor are y^T = W x^T <=> y = x W^T, where x is the matrix containing the input vectors as rows, y is the matrix containing the output vectors as rows and W is the weight matrix.
NSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_ret| Modifier | Constructor and Description |
|---|---|
protected |
MPSRNNMatrixInferenceLayer(org.moe.natj.general.Pointer peer) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
_supportsSecureCoding()
This property must return YES on all classes that allow secure coding.
|
static boolean |
accessInstanceVariablesDirectly() |
static MPSRNNMatrixInferenceLayer |
alloc() |
static MPSRNNMatrixInferenceLayer |
allocWithZone(org.moe.natj.general.ptr.VoidPtr zone) |
static boolean |
automaticallyNotifiesObserversForKey(java.lang.String key) |
long |
bidirectionalCombineMode()
[@property] bidirectionalCombineMode
|
static void |
cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget) |
static void |
cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget,
org.moe.natj.objc.SEL aSelector,
java.lang.Object anArgument) |
static NSArray<java.lang.String> |
classFallbacksForKeyedArchiver() |
static org.moe.natj.objc.Class |
classForKeyedUnarchiver() |
MPSRNNMatrixInferenceLayer |
copyWithZoneDevice(org.moe.natj.general.ptr.VoidPtr zone,
MTLDevice device)
Make a copy of this kernel for a new device - @see MPSKernel
|
static java.lang.String |
debugDescription_static() |
static java.lang.String |
description_static() |
void |
encodeBidirectionalSequenceToCommandBufferSourceSequenceDestinationForwardMatricesDestinationBackwardMatrices(MTLCommandBuffer commandBuffer,
NSArray<? extends MPSMatrix> sourceSequence,
NSArray<? extends MPSMatrix> destinationForwardMatrices,
NSArray<? extends MPSMatrix> destinationBackwardMatrices)
Encode an MPSRNNMatrixInferenceLayer kernel stack for an input matrix sequences into a command buffer bidirectionally.
|
void |
encodeSequenceToCommandBufferSourceMatricesDestinationMatricesRecurrentInputStateRecurrentOutputStates(MTLCommandBuffer commandBuffer,
NSArray<? extends MPSMatrix> sourceMatrices,
NSArray<? extends MPSMatrix> destinationMatrices,
MPSRNNRecurrentMatrixState recurrentInputState,
NSMutableArray<MPSRNNRecurrentMatrixState> recurrentOutputStates) |
void |
encodeSequenceToCommandBufferSourceMatricesSourceOffsetsDestinationMatricesDestinationOffsetsRecurrentInputStateRecurrentOutputStates(MTLCommandBuffer commandBuffer,
NSArray<? extends MPSMatrix> sourceMatrices,
org.moe.natj.general.ptr.NUIntPtr sourceOffsets,
NSArray<? extends MPSMatrix> destinationMatrices,
org.moe.natj.general.ptr.NUIntPtr destinationOffsets,
MPSRNNRecurrentMatrixState recurrentInputState,
NSMutableArray<MPSRNNRecurrentMatrixState> recurrentOutputStates)
Encode an MPSRNNMatrixInferenceLayer kernel (stack) for a sequence of inputs into a command buffer.
|
static long |
hash_static() |
MPSRNNMatrixInferenceLayer |
init() |
MPSRNNMatrixInferenceLayer |
initWithCoder(NSCoder aDecoder)
NS_DESIGNATED_INITIALIZER
|
MPSRNNMatrixInferenceLayer |
initWithCoderDevice(NSCoder aDecoder,
java.lang.Object device)
NSSecureCoding compatability
|
MPSRNNMatrixInferenceLayer |
initWithDevice(java.lang.Object device)
Standard init with default properties per filter type
|
MPSRNNMatrixInferenceLayer |
initWithDeviceRnnDescriptor(MTLDevice device,
MPSRNNDescriptor rnnDescriptor)
Initializes a linear (fully connected) RNN kernel
|
MPSRNNMatrixInferenceLayer |
initWithDeviceRnnDescriptors(MTLDevice device,
NSArray<? extends MPSRNNDescriptor> rnnDescriptors)
Initializes a kernel that implements a stack of linear (fully connected) RNN layers
|
long |
inputFeatureChannels()
[@property] inputFeatureChannels
|
static NSObject.Function_instanceMethodForSelector_ret |
instanceMethodForSelector(org.moe.natj.objc.SEL aSelector) |
static NSMethodSignature |
instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector) |
static boolean |
instancesRespondToSelector(org.moe.natj.objc.SEL aSelector) |
static boolean |
isSubclassOfClass(org.moe.natj.objc.Class aClass) |
static NSSet<java.lang.String> |
keyPathsForValuesAffectingValueForKey(java.lang.String key) |
static MPSRNNMatrixInferenceLayer |
new_objc() |
long |
numberOfLayers()
[@property] numberOfLayers
|
long |
outputFeatureChannels()
[@property] outputFeatureChannels
|
boolean |
recurrentOutputIsTemporary()
[@property] recurrentOutputIsTemporary
|
static boolean |
resolveClassMethod(org.moe.natj.objc.SEL sel) |
static boolean |
resolveInstanceMethod(org.moe.natj.objc.SEL sel) |
void |
setBidirectionalCombineMode(long value)
[@property] bidirectionalCombineMode
|
void |
setRecurrentOutputIsTemporary(boolean value)
[@property] recurrentOutputIsTemporary
|
void |
setStoreAllIntermediateStates(boolean value)
[@property] storeAllIntermediateStates
|
static void |
setVersion_static(long aVersion) |
boolean |
storeAllIntermediateStates()
[@property] storeAllIntermediateStates
|
static org.moe.natj.objc.Class |
superclass_static() |
static boolean |
supportsSecureCoding() |
static long |
version_static() |
copyWithZone, device, encodeWithCoder, label, options, setLabel, setOptionsaccessibilityActivate, accessibilityActivationPoint, accessibilityAssistiveTechnologyFocusedIdentifiers, accessibilityAttributedHint, accessibilityAttributedLabel, accessibilityAttributedUserInputLabels, accessibilityAttributedValue, accessibilityContainerType, accessibilityCustomActions, accessibilityCustomRotors, accessibilityDecrement, accessibilityDragSourceDescriptors, accessibilityDropPointDescriptors, accessibilityElementAtIndex, accessibilityElementCount, accessibilityElementDidBecomeFocused, accessibilityElementDidLoseFocus, accessibilityElementIsFocused, accessibilityElements, accessibilityElementsHidden, accessibilityFrame, accessibilityHint, accessibilityIncrement, accessibilityLabel, accessibilityLanguage, accessibilityNavigationStyle, accessibilityPath, accessibilityPerformEscape, accessibilityPerformMagicTap, accessibilityRespondsToUserInteraction, accessibilityScroll, accessibilityTextualContext, accessibilityTraits, accessibilityUserInputLabels, accessibilityValue, accessibilityViewIsModal, addObserverForKeyPathOptionsContext, attemptRecoveryFromErrorOptionIndex, attemptRecoveryFromErrorOptionIndexDelegateDidRecoverSelectorContextInfo, autoContentAccessingProxy, awakeAfterUsingCoder, awakeFromNib, class_objc, classForCoder, classForKeyedArchiver, copy, dealloc, debugDescription, description, dictionaryWithValuesForKeys, didChangeValueForKey, didChangeValueForKeyWithSetMutationUsingObjects, didChangeValuesAtIndexesForKey, doesNotRecognizeSelector, fileManagerShouldProceedAfterError, fileManagerWillProcessPath, finalize_objc, forwardingTargetForSelector, forwardInvocation, hash, indexOfAccessibilityElement, isAccessibilityElement, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableArrayValueForKey, mutableArrayValueForKeyPath, mutableCopy, mutableOrderedSetValueForKey, mutableOrderedSetValueForKeyPath, mutableSetValueForKey, mutableSetValueForKeyPath, observationInfo, observeValueForKeyPathOfObjectChangeContext, performSelector, performSelectorInBackgroundWithObject, performSelectorOnMainThreadWithObjectWaitUntilDone, performSelectorOnMainThreadWithObjectWaitUntilDoneModes, performSelectorOnThreadWithObjectWaitUntilDone, performSelectorOnThreadWithObjectWaitUntilDoneModes, performSelectorWithObject, performSelectorWithObjectAfterDelay, performSelectorWithObjectAfterDelayInModes, performSelectorWithObjectWithObject, prepareForInterfaceBuilder, provideImageDataBytesPerRowOrigin_Size_UserInfo, removeObserverForKeyPath, removeObserverForKeyPathContext, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, self, setAccessibilityActivationPoint, setAccessibilityAttributedHint, setAccessibilityAttributedLabel, setAccessibilityAttributedUserInputLabels, setAccessibilityAttributedValue, setAccessibilityContainerType, setAccessibilityCustomActions, setAccessibilityCustomRotors, setAccessibilityDragSourceDescriptors, setAccessibilityDropPointDescriptors, setAccessibilityElements, setAccessibilityElementsHidden, setAccessibilityFrame, setAccessibilityHint, setAccessibilityLabel, setAccessibilityLanguage, setAccessibilityNavigationStyle, setAccessibilityPath, setAccessibilityRespondsToUserInteraction, setAccessibilityTextualContext, setAccessibilityTraits, setAccessibilityUserInputLabels, setAccessibilityValue, setAccessibilityViewIsModal, setIsAccessibilityElement, setNilValueForKey, setObservationInfo, setShouldGroupAccessibilityChildren, setValueForKey, setValueForKeyPath, setValueForUndefinedKey, setValuesForKeysWithDictionary, shouldGroupAccessibilityChildren, superclass, validateValueForKeyError, validateValueForKeyPathError, valueForKey, valueForKeyPath, valueForUndefinedKey, willChangeValueForKey, willChangeValueForKeyWithSetMutationUsingObjects, willChangeValuesAtIndexesForKeyprotected MPSRNNMatrixInferenceLayer(org.moe.natj.general.Pointer peer)
public static boolean accessInstanceVariablesDirectly()
public static MPSRNNMatrixInferenceLayer alloc()
public static MPSRNNMatrixInferenceLayer allocWithZone(org.moe.natj.general.ptr.VoidPtr zone)
public static boolean automaticallyNotifiesObserversForKey(java.lang.String key)
public long bidirectionalCombineMode()
Defines how to combine the output-results, when encoding bidirectional layers using [@ref] encodeBidirectionalSequenceToCommandBuffer. Defaults to @ref MPSRNNBidirectionalCombineModeNone.
public static void cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)
public static void cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget,
org.moe.natj.objc.SEL aSelector,
java.lang.Object anArgument)
public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
public static org.moe.natj.objc.Class classForKeyedUnarchiver()
public MPSRNNMatrixInferenceLayer copyWithZoneDevice(org.moe.natj.general.ptr.VoidPtr zone, MTLDevice device)
copyWithZoneDevice in class MPSKernelzone - The NSZone in which to allocate the objectdevice - The device for the new MPSKernel. If nil, then use
self.device.public static java.lang.String debugDescription_static()
public static java.lang.String description_static()
public void encodeBidirectionalSequenceToCommandBufferSourceSequenceDestinationForwardMatricesDestinationBackwardMatrices(MTLCommandBuffer commandBuffer, NSArray<? extends MPSMatrix> sourceSequence, NSArray<? extends MPSMatrix> destinationForwardMatrices, NSArray<? extends MPSMatrix> destinationBackwardMatrices)
commandBuffer - A valid MTLCommandBuffer to receive the encoded filtersourceSequence - An array of valid MPSMatrix objects containing the source matrix sequence (x0, x1, ... x_n-1).destinationForwardMatrices - An array of valid MPSMatrices to be overwritten by result from forward input matrices. If bidirectionalCombineMode
is either MPSRNNBidirectionalCombineModeAdd or MPSRNNBidirectionalCombineModeConcatenate, then will
contain the combined results. destinationForwardMatrix may not alias with any of the source matrices.destinationBackwardMatrices - If bidirectionalCombineMode is MPSRNNBidirectionalCombineModeNone, then must be an array of valid MPSMatrices
that will be overwritten by result from backward input matrices. Otherwise this parameter is ignored
and can be nil. destinationBackwardMatrices may not alias to any of the source matrices.public void encodeSequenceToCommandBufferSourceMatricesDestinationMatricesRecurrentInputStateRecurrentOutputStates(MTLCommandBuffer commandBuffer, NSArray<? extends MPSMatrix> sourceMatrices, NSArray<? extends MPSMatrix> destinationMatrices, MPSRNNRecurrentMatrixState recurrentInputState, NSMutableArray<MPSRNNRecurrentMatrixState> recurrentOutputStates)
public static long hash_static()
public MPSRNNMatrixInferenceLayer init()
public MPSRNNMatrixInferenceLayer initWithCoder(NSCoder aDecoder)
NSCodinginitWithCoder in interface NSCodinginitWithCoder in class MPSKernelpublic MPSRNNMatrixInferenceLayer initWithCoderDevice(NSCoder aDecoder, java.lang.Object device)
See @ref MPSKernel#initWithCoder.
initWithCoderDevice in class MPSKernelaDecoder - The NSCoder subclass with your serialized MPSRNNMatrixInferenceLayerdevice - The MTLDevice on which to make the MPSRNNMatrixInferenceLayerpublic MPSRNNMatrixInferenceLayer initWithDevice(java.lang.Object device)
MPSKernelinitWithDevice in class MPSKerneldevice - The device that the filter will be used on. May not be NULL.public MPSRNNMatrixInferenceLayer initWithDeviceRnnDescriptor(MTLDevice device, MPSRNNDescriptor rnnDescriptor)
device - The MTLDevice on which this MPSRNNMatrixLayer filter will be usedrnnDescriptor - The descriptor that defines the RNN layerpublic MPSRNNMatrixInferenceLayer initWithDeviceRnnDescriptors(MTLDevice device, NSArray<? extends MPSRNNDescriptor> rnnDescriptors)
device - The MTLDevice on which this MPSRNNMatrixLayer filter will be usedrnnDescriptors - An array of RNN descriptors that defines a stack of RNN layers, starting at index zero.
The number of layers in stack is the number of entries in the array.
All entries in the array must be valid MPSRNNDescriptors.public long inputFeatureChannels()
The number of feature channels input vector/matrix.
public static NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(org.moe.natj.objc.SEL aSelector)
public static NSMethodSignature instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)
public static boolean instancesRespondToSelector(org.moe.natj.objc.SEL aSelector)
public static boolean isSubclassOfClass(org.moe.natj.objc.Class aClass)
public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey(java.lang.String key)
public static MPSRNNMatrixInferenceLayer new_objc()
public long numberOfLayers()
Number of layers in the filter-stack. This will be one when using initWithDevice:rnnDescriptor to initialize this filter and the number of entries in the array 'rnnDescriptors' when initializing this filter with initWithDevice:rnnDescriptors.
public long outputFeatureChannels()
The number of feature channels in the output vector/matrix.
public boolean recurrentOutputIsTemporary()
How output states from @ref encodeSequenceToCommandBuffer are constructed. Defaults to NO. For reference @see MPSState.
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
public void setBidirectionalCombineMode(long value)
Defines how to combine the output-results, when encoding bidirectional layers using [@ref] encodeBidirectionalSequenceToCommandBuffer. Defaults to @ref MPSRNNBidirectionalCombineModeNone.
public void setRecurrentOutputIsTemporary(boolean value)
How output states from @ref encodeSequenceToCommandBuffer are constructed. Defaults to NO. For reference @see MPSState.
public void setStoreAllIntermediateStates(boolean value)
If YES then calls to @ref encodeSequenceToCommandBuffer return every recurrent state in the array: recurrentOutputStates. Defaults to NO.
public static void setVersion_static(long aVersion)
public boolean storeAllIntermediateStates()
If YES then calls to @ref encodeSequenceToCommandBuffer return every recurrent state in the array: recurrentOutputStates. Defaults to NO.
public static org.moe.natj.objc.Class superclass_static()
public static boolean supportsSecureCoding()
public boolean _supportsSecureCoding()
NSSecureCoding_supportsSecureCoding in interface NSSecureCoding_supportsSecureCoding in class MPSKernelpublic static long version_static()
public void encodeSequenceToCommandBufferSourceMatricesSourceOffsetsDestinationMatricesDestinationOffsetsRecurrentInputStateRecurrentOutputStates(MTLCommandBuffer commandBuffer, NSArray<? extends MPSMatrix> sourceMatrices, org.moe.natj.general.ptr.NUIntPtr sourceOffsets, NSArray<? extends MPSMatrix> destinationMatrices, org.moe.natj.general.ptr.NUIntPtr destinationOffsets, MPSRNNRecurrentMatrixState recurrentInputState, NSMutableArray<MPSRNNRecurrentMatrixState> recurrentOutputStates)
commandBuffer - A valid MTLCommandBuffer to receive the encoded filtersourceMatrices - An array of valid MPSMatrix objects containing the sequence of source matrices.sourceOffsets - An array of byte-offsets into the sourceMatrices, if nil zeros are assumed and
if not nil must contain offset for every matrix in sourceMatrices.destinationMatrices - An array valid MPSMatrices to be overwritten by result matrix sequence.
destinationMatrices may not alias sourceMatrices.destinationOffsets - An array of byte-offsets into the destinationMatrices, if nil zeros are assumed and
if not nil must contain offset for every matrix in destinationMatrices.recurrentInputState - An optional state containing the output matrices and memory cells (for LSTMs)
of the layer obtained from the previous input matrices in a sequence of inputs.
Has to be the output of a previous call to this function or nil (assumed zero).
Note: can be one of the states returned in @ref intermediateRecurrentStates.recurrentOutputStates - An optional array that will contain the recurrent output states. If nil then
the recurrent output state is discarded.
If @ref storeAllIntermediateStates is YES, then all intermediate states of the sequence
are returned in the array, the first one corresponding to the first input in the sequence,
otherwise only the last recurrent output state is returned.
If recurrentOutputIsTemporary is YES and then all returned recurrent states
will be temporary. @see MPSState:isTemporary.
Example: In order to get a new state one can do the following: