.TH "MPSMatrixSum" 3 "Mon Jul 9 2018" "Version MetalPerformanceShaders-119.3" "MetalPerformanceShaders.framework" \" -*- nroff -*- .ad l .nh .SH NAME MPSMatrixSum .SH SYNOPSIS .br .PP .PP \fC#import \fP .PP Inherits \fBMPSKernel\fP\&. .SS "Instance Methods" .in +1c .ti -1c .RI "(nonnull instancetype) \- \fBinitWithDevice:\fP" .br .ti -1c .RI "(nonnull instancetype) \- \fBinitWithDevice:count:rows:columns:transpose:\fP" .br .ti -1c .RI "(void) \- \fBsetNeuronType:parameterA:parameterB:parameterC:\fP" .br .ti -1c .RI "(\fBMPSCNNNeuronType\fP) \- \fBneuronType\fP" .br .ti -1c .RI "(void) \- \fBencodeToCommandBuffer:sourceMatrices:resultMatrix:scaleVector:offsetVector:biasVector:startIndex:\fP" .br .ti -1c .RI "(nullable instancetype) \- \fBinitWithCoder:device:\fP" .br .in -1c .SS "Properties" .in +1c .ti -1c .RI "NSUInteger \fBrows\fP" .br .ti -1c .RI "NSUInteger \fBcolumns\fP" .br .ti -1c .RI "NSUInteger \fBcount\fP" .br .ti -1c .RI "BOOL \fBtranspose\fP" .br .ti -1c .RI "float \fBneuronParameterA\fP" .br .ti -1c .RI "float \fBneuronParameterB\fP" .br .ti -1c .RI "float \fBneuronParameterC\fP" .br .in -1c .SS "Additional Inherited Members" .SH "Detailed Description" .PP \fBMPSMatrixSum\&.h\fP MetalPerformanceShaders\&.framework .PP \fBCopyright:\fP .RS 4 Copyright (c) 2017 Apple Inc\&. All rights reserved\&. MetalPerformanceShaders filter base classes .RE .PP This depends on Metal\&.framework \fBMPSMatrixSum\fP performs a pointwise summation of N \fBMPSMatrix\fP objects and applies an optional bias term and neuron activation function\&. .PP \fBMPSMatrix\fP \fBA\fP = empty matrix; for (i = 0; i < N; ++i) \fBA\fP += alpha[i]*B[i]; .PP if (bias) \fBA\fP += broadcast(bias); .PP if (neuron) \fBA\fP = applyNeuron(A); .PP Where B is the array of \fBMPSMatrix\fP objects, \fBA\fP is the destination \fBMPSMatrix\fP, alpha is an array of scalar values, bias is a vector which is broadcast and accumulated across each row of the intermediate result, and applyNeuron is a neuron activation function\&. .PP Each matrix in the array may have an independent origin\&. .SH "Method Documentation" .PP .SS "\- (void) encodeToCommandBuffer: (nonnull id< MTLCommandBuffer >) buffer(NSArray< \fBMPSMatrix\fP * > *__nonnull) sourceMatrices(\fBMPSMatrix\fP *__nonnull) resultMatrix(\fBMPSVector\fP *__nullable) scaleVector(\fBMPSVector\fP *__nullable) offsetVector(\fBMPSVector\fP *__nullable) biasVector(NSUInteger) startIndex" Encode the operations to the command buffer .PP \fBParameters:\fP .RS 4 \fIbuffer\fP The command buffer in which to encode the operation\&. .br \fIsourceMatrices\fP \fBA\fP list of matrices from which the matrix data is read\&. .br \fIresultMatrix\fP The result matrix\&. .br \fIscaleVector\fP \fBA\fP \fBMPSVector\fP of type MPSDataTypeFloat32 containing the list of scale factors, specified in single precision\&. .br \fIoffsetVector\fP \fBA\fP \fBMPSVector\fP of type MPSDataTypeUInt32 containing the list of offsets, stored as a packed array of \fBMPSMatrixOffset\fP values\&. .br \fIbiasVector\fP \fBA\fP \fBMPSVector\fP containing the bias terms to add to the result prior to applying the neuron function, if any\&. May be nil\&. .br \fIstartIndex\fP The starting index into the scale and offset vectors\&. .RE .PP .SS "\- (nullable instancetype) \fBinitWithCoder:\fP (NSCoder *__nonnull) aDecoder(nonnull id< MTLDevice >) device" \fBNSSecureCoding\fP compatability See \fBMPSKernel::initWithCoder\fP\&. .PP \fBParameters:\fP .RS 4 \fIaDecoder\fP The NSCoder subclass with your serialized \fBMPSMatrixSum\fP kernel\&. .br \fIdevice\fP The MTLDevice on which to make the \fBMPSMatrixSum\fP object\&. .RE .PP \fBReturns:\fP .RS 4 \fBA\fP new \fBMPSMatrixSum\fP object, or nil if failure\&. .RE .PP .PP Reimplemented from \fBMPSKernel\fP\&. .SS "\- (nonnull instancetype) initWithDevice: (nonnull id< MTLDevice >) device" Standard init with default properties per filter type .PP \fBParameters:\fP .RS 4 \fIdevice\fP The device that the filter will be used on\&. May not be NULL\&. .RE .PP \fBReturns:\fP .RS 4 a pointer to the newly initialized object\&. This will fail, returning nil if the device is not supported\&. Devices must be MTLFeatureSet_iOS_GPUFamily2_v1 or later\&. .RE .PP .PP Reimplemented from \fBMPSKernel\fP\&. .SS "\- (nonnull instancetype) \fBinitWithDevice:\fP (nonnull id< MTLDevice >) device(NSUInteger) count(NSUInteger) rows(NSUInteger) columns(BOOL) transpose" Initialize a \fBMPSMatrixSum\fP kernel\&. .PP \fBParameters:\fP .RS 4 \fIdevice\fP The device on which to initialize the kernel\&. .br \fIcount\fP The number of matrices to be summed\&. .br \fIrows\fP The number of rows to use in the input matrices\&. .br \fIcolumns\fP The number of columns to use in the input matrices\&. .br \fItranspose\fP If YES the result of the summation is to be transposed prior to applying the bias and activation\&. .RE .PP .SS "\- (\fBMPSCNNNeuronType\fP) neuronType " Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method .SS "\- (void) setNeuronType: (\fBMPSCNNNeuronType\fP) neuronType(float) parameterA(float) parameterB(float) parameterC" Specifies a neuron activation function to be used\&. .PP This method can be used to add a neuron activation funtion of given type with associated scalar parameters \fBA\fP, B, and C that are shared across all output values\&. Note that this method can only be used to specify neurons which are specified by three (or fewer) parameters shared across all output values (or channels, in CNN nomenclature)\&. It is an error to call this method for neuron activation functions like MPSCNNNeuronTypePReLU, which require per-channel parameter values\&. An \fBMPSMatrixSum\fP kernel is initialized with a default neuron function of MPSCNNNeuronTypeNone\&. .PP \fBParameters:\fP .RS 4 \fIneuronType\fP Type of neuron activation function\&. For full list see \fBMPSCNNNeuronType\&.h\fP .br \fIparameterA\fP parameterA of neuron activation that is shared across all output values\&. .br \fIparameterB\fP parameterB of neuron activation that is shared across all output values\&. .br \fIparameterC\fP parameterC of neuron activation that is shared across all output values\&. .RE .PP .SH "Property Documentation" .PP .SS "\- (NSUInteger) columns\fC [read]\fP, \fC [nonatomic]\fP, \fC [assign]\fP" The number of columns to sum\&. .SS "\- (NSUInteger) count\fC [read]\fP, \fC [nonatomic]\fP, \fC [assign]\fP" The number of matrices to sum\&. .SS "\- (float) neuronParameterA\fC [read]\fP, \fC [nonatomic]\fP, \fC [assign]\fP" Neuron parameter \fBA\fP\&. .SS "\- (float) neuronParameterB\fC [read]\fP, \fC [nonatomic]\fP, \fC [assign]\fP" Neuron parameter B\&. .SS "\- (float) neuronParameterC\fC [read]\fP, \fC [nonatomic]\fP, \fC [assign]\fP" Neuron parameter C\&. .SS "\- (NSUInteger) rows\fC [read]\fP, \fC [nonatomic]\fP, \fC [assign]\fP" The number of rows to sum\&. .SS "\- (BOOL) transpose\fC [read]\fP, \fC [nonatomic]\fP, \fC [assign]\fP" The transposition used to initialize the kernel\&. .SH "Author" .PP Generated automatically by Doxygen for MetalPerformanceShaders\&.framework from the source code\&.