public class MPSCNNFullyConnected extends MPSCNNConvolution
The MPSCNNFullyConnected specifies a fully connected convolution layer a.k.a. Inner product layer. A fully connected CNN layer is one where every input channel is connected to every output channel. The kernel width is equal to width of source image and the kernel height is equal to the height of source image. Width and height of the output is 1x1. Thus, it takes a srcW x srcH x Ni MPSCNNImage, convolves it with Weights[No][SrcW][srcH][Ni] and produces a 1 x 1 x No output. The following must be true: [@code] kernelWidth == source.width kernelHeight == source.height clipRect.size.width == 1 clipRect.size.height == 1 [@endcode] One can think of a fully connected layer as a matrix multiplication that flattens an image into a vector of length srcW*srcH*Ni. The weights are arragned in a matrix of dimension No x (srcW*srcH*Ni) for product output vectors of length No. The strideInPixelsX, strideInPixelsY, and group must be 1. Offset is not applicable and is ignored. Since clipRect is clamped to the destination image bounds, if the destination is 1x1, one doesn't need to set the clipRect.
Note that one can implement an inner product using MPSCNNConvolution by setting [@code] offset = (kernelWidth/2,kernelHeight/2) clipRect.origin = (ox,oy), clipRect.size = (1,1) strideX = strideY = group = 1 [@endcode] However, using the MPSCNNFullyConnected for this is better for performance as it lets us choose the most performant method which may not be possible when using a general convolution. For example, we may internally use matrix multiplication or special reduction kernels for a specific platform.
NSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_ret| Modifier | Constructor and Description |
|---|---|
protected |
MPSCNNFullyConnected(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 MPSCNNFullyConnected |
alloc() |
static MPSCNNFullyConnected |
allocWithZone(org.moe.natj.general.ptr.VoidPtr zone) |
static boolean |
automaticallyNotifiesObserversForKey(java.lang.String key) |
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() |
static java.lang.String |
debugDescription_static() |
static java.lang.String |
description_static() |
static long |
hash_static() |
MPSCNNFullyConnected |
init() |
MPSCNNFullyConnected |
initWithCoder(NSCoder aDecoder)
NS_DESIGNATED_INITIALIZER
|
MPSCNNFullyConnected |
initWithCoderDevice(NSCoder aDecoder,
java.lang.Object device)
NSSecureCoding compatability
|
MPSCNNFullyConnected |
initWithDevice(java.lang.Object device)
Standard init with default properties per filter type
|
MPSCNNFullyConnected |
initWithDeviceConvolutionDescriptorKernelWeightsBiasTermsFlags(MTLDevice device,
MPSCNNConvolutionDescriptor convolutionDescriptor,
org.moe.natj.general.ptr.ConstFloatPtr kernelWeights,
org.moe.natj.general.ptr.ConstFloatPtr biasTerms,
long flags)
Initializes a convolution kernel
WARNING: This API is depreated and will be removed in the future.
|
MPSCNNFullyConnected |
initWithDeviceWeights(MTLDevice device,
MPSCNNConvolutionDataSource weights)
Initializes a fully connected kernel
|
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 MPSCNNFullyConnected |
new_objc() |
static boolean |
resolveClassMethod(org.moe.natj.objc.SEL sel) |
static boolean |
resolveInstanceMethod(org.moe.natj.objc.SEL sel) |
static void |
setVersion_static(long aVersion) |
static org.moe.natj.objc.Class |
superclass_static() |
static boolean |
supportsSecureCoding() |
static long |
version_static() |
accumulatorPrecisionOption, channelMultiplier, dataSource, exportWeightsAndBiasesWithCommandBufferResultStateCanBeTemporary, fusedNeuronDescriptor, groups, inputFeatureChannels, neuron, neuronParameterA, neuronParameterB, neuronParameterC, neuronType, outputFeatureChannels, reloadWeightsAndBiasesFromDataSource, reloadWeightsAndBiasesWithCommandBufferState, reloadWeightsAndBiasesWithDataSource, resultStateForSourceImageSourceStatesDestinationImage, setAccumulatorPrecisionOption, subPixelScaleFactor, temporaryResultStateForCommandBufferSourceImageSourceStatesDestinationImageappendBatchBarrier, clipRect, destinationFeatureChannelOffset, destinationImageAllocator, destinationImageDescriptorForSourceImagesSourceStates, dilationRateX, dilationRateY, edgeMode, encodeToCommandBufferSourceImage, encodeToCommandBufferSourceImageDestinationImage, encodeToCommandBufferSourceImageDestinationStateDestinationImage, encodeToCommandBufferSourceImageDestinationStateDestinationStateIsTemporary, encodingStorageSizeForSourceImageSourceStatesDestinationImage, isBackwards, isResultStateReusedAcrossBatch, isStateModified, kernelHeight, kernelWidth, offset, padding, setClipRect, setDestinationFeatureChannelOffset, setDestinationImageAllocator, setEdgeMode, setOffset, setPadding, setSourceFeatureChannelMaxCount, setSourceFeatureChannelOffset, sourceFeatureChannelMaxCount, sourceFeatureChannelOffset, strideInPixelsX, strideInPixelsYcopyWithZone, copyWithZoneDevice, 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 MPSCNNFullyConnected(org.moe.natj.general.Pointer peer)
public static boolean accessInstanceVariablesDirectly()
public static MPSCNNFullyConnected alloc()
public static MPSCNNFullyConnected allocWithZone(org.moe.natj.general.ptr.VoidPtr zone)
public static boolean automaticallyNotifiesObserversForKey(java.lang.String key)
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 static java.lang.String debugDescription_static()
public static java.lang.String description_static()
public static long hash_static()
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 MPSCNNFullyConnected new_objc()
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
public static void setVersion_static(long aVersion)
public static org.moe.natj.objc.Class superclass_static()
public static long version_static()
public MPSCNNFullyConnected init()
init in class MPSCNNConvolutionpublic MPSCNNFullyConnected initWithDevice(java.lang.Object device)
MPSCNNKernelinitWithDevice in class MPSCNNConvolutiondevice - The device that the filter will be used on. May not be NULL.public MPSCNNFullyConnected initWithDeviceConvolutionDescriptorKernelWeightsBiasTermsFlags(MTLDevice device, MPSCNNConvolutionDescriptor convolutionDescriptor, org.moe.natj.general.ptr.ConstFloatPtr kernelWeights, org.moe.natj.general.ptr.ConstFloatPtr biasTerms, long flags)
initWithDeviceConvolutionDescriptorKernelWeightsBiasTermsFlags in class MPSCNNConvolutiondevice - The MTLDevice on which this MPSCNNConvolution filter will be usedconvolutionDescriptor - A pointer to a MPSCNNConvolutionDescriptor.kernelWeights - A pointer to a weights array. Each entry is a float value. The number of entries is =
inputFeatureChannels * outputFeatureChannels * kernelHeight * kernelWidth
The layout of filter weight is so that it can be reinterpreted as 4D tensor (array)
weight[ outputChannels ][ kernelHeight ][ kernelWidth ][ inputChannels / groups ]
Weights are converted to half float (fp16) internally for best performance.biasTerms - A pointer to bias terms to be applied to the convolution output. Each entry is a float value.
The number of entries is = numberOfOutputFeatureMapsflags - Currently unused. Pass MPSCNNConvolutionFlagsNonepublic MPSCNNFullyConnected initWithCoder(NSCoder aDecoder)
NSCodinginitWithCoder in interface NSCodinginitWithCoder in class MPSCNNConvolutionpublic MPSCNNFullyConnected initWithCoderDevice(NSCoder aDecoder, java.lang.Object device)
While the standard NSSecureCoding/NSCoding method -initWithCoder: should work, since the file can't know which device your data is allocated on, we have to guess and may guess incorrectly. To avoid that problem, use initWithCoder:device instead.
initWithCoderDevice in class MPSCNNConvolutionaDecoder - The NSCoder subclass with your serialized MPSKerneldevice - The MTLDevice on which to make the MPSKernelpublic MPSCNNFullyConnected initWithDeviceWeights(MTLDevice device, MPSCNNConvolutionDataSource weights)
initWithDeviceWeights in class MPSCNNConvolutiondevice - The MTLDevice on which this MPSCNNFullyConnected filter will be usedweights - A pointer to a object that conforms to the MPSCNNConvolutionDataSource
protocol. The MPSCNNConvolutionDataSource protocol declares the methods that an
instance of MPSCNNFullyConnected uses to obtain the weights and bias terms
for the CNN fully connected filter.public static boolean supportsSecureCoding()
public boolean _supportsSecureCoding()
NSSecureCoding_supportsSecureCoding in interface NSSecureCoding_supportsSecureCoding in class MPSCNNConvolution