mpsneuralnetwork

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation ¶

Rendered for darwin/amd64

Overview ¶

Package mpsneuralnetwork provides purego-based Go bindings for the macOS MPSNeuralNetwork framework.

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork

Index ¶

Constants ¶

This section is empty.

Variables ¶

This section is empty.

Functions ¶

func MPSCNNConvolutionDescriptorSupportsSecureCoding ¶

func MPSCNNConvolutionDescriptorSupportsSecureCoding() bool

@abstract <NSSecureCoding> support

Types ¶

type Acl_entry_id_t ¶

type Acl_entry_id_t int64
const (
	ACL_FIRST_ENTRY Acl_entry_id_t = 0
	ACL_NEXT_ENTRY  Acl_entry_id_t = -1
	ACL_LAST_ENTRY  Acl_entry_id_t = -2
)

func (Acl_entry_id_t) String ¶

func (e Acl_entry_id_t) String() string

type Acl_flag_t ¶

type Acl_flag_t int64
const (
	ACL_FLAG_DEFER_INHERIT      Acl_flag_t = 1
	ACL_FLAG_NO_INHERIT         Acl_flag_t = 131072
	ACL_ENTRY_INHERITED         Acl_flag_t = 16
	ACL_ENTRY_FILE_INHERIT      Acl_flag_t = 32
	ACL_ENTRY_DIRECTORY_INHERIT Acl_flag_t = 64
	ACL_ENTRY_LIMIT_INHERIT     Acl_flag_t = 128
	ACL_ENTRY_ONLY_INHERIT      Acl_flag_t = 256
)

func (Acl_flag_t) String ¶

func (e Acl_flag_t) String() string

type Acl_perm_t ¶

type Acl_perm_t int64
const (
	ACL_READ_DATA           Acl_perm_t = 2
	ACL_LIST_DIRECTORY      Acl_perm_t = 2
	ACL_WRITE_DATA          Acl_perm_t = 4
	ACL_ADD_FILE            Acl_perm_t = 4
	ACL_EXECUTE             Acl_perm_t = 8
	ACL_SEARCH              Acl_perm_t = 8
	ACL_DELETE              Acl_perm_t = 16
	ACL_APPEND_DATA         Acl_perm_t = 32
	ACL_ADD_SUBDIRECTORY    Acl_perm_t = 32
	ACL_DELETE_CHILD        Acl_perm_t = 64
	ACL_READ_ATTRIBUTES     Acl_perm_t = 128
	ACL_WRITE_ATTRIBUTES    Acl_perm_t = 256
	ACL_READ_EXTATTRIBUTES  Acl_perm_t = 512
	ACL_WRITE_EXTATTRIBUTES Acl_perm_t = 1024
	ACL_READ_SECURITY       Acl_perm_t = 2048
	ACL_WRITE_SECURITY      Acl_perm_t = 4096
	ACL_CHANGE_OWNER        Acl_perm_t = 8192
	ACL_SYNCHRONIZE         Acl_perm_t = 1048576
)

func (Acl_perm_t) String ¶

func (e Acl_perm_t) String() string

type Acl_tag_t ¶

type Acl_tag_t int64
const (
	ACL_UNDEFINED_TAG  Acl_tag_t = 0
	ACL_EXTENDED_ALLOW Acl_tag_t = 1
	ACL_EXTENDED_DENY  Acl_tag_t = 2
)

func (Acl_tag_t) String ¶

func (e Acl_tag_t) String() string

type Acl_type_t ¶

type Acl_type_t int64
const (
	ACL_TYPE_EXTENDED Acl_type_t = 256
	ACL_TYPE_ACCESS   Acl_type_t = 0
	ACL_TYPE_DEFAULT  Acl_type_t = 1
	ACL_TYPE_AFS      Acl_type_t = 2
	ACL_TYPE_CODA     Acl_type_t = 3
	ACL_TYPE_NTFS     Acl_type_t = 4
	ACL_TYPE_NWFS     Acl_type_t = 5
)

func (Acl_type_t) String ¶

func (e Acl_type_t) String() string

type Clockid_t ¶

type Clockid_t int64

func (Clockid_t) String ¶

func (e Clockid_t) String() string

type Dispatch_autorelease_frequency_t ¶

type Dispatch_autorelease_frequency_t uint64
const (
	DISPATCH_AUTORELEASE_FREQUENCY_INHERIT   Dispatch_autorelease_frequency_t = 0
	DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM Dispatch_autorelease_frequency_t = 1
	DISPATCH_AUTORELEASE_FREQUENCY_NEVER     Dispatch_autorelease_frequency_t = 2
)

func (Dispatch_autorelease_frequency_t) String ¶

type Dispatch_block_flags_t ¶

type Dispatch_block_flags_t uint64
const (
	DISPATCH_BLOCK_BARRIER           Dispatch_block_flags_t = 1
	DISPATCH_BLOCK_DETACHED          Dispatch_block_flags_t = 2
	DISPATCH_BLOCK_ASSIGN_CURRENT    Dispatch_block_flags_t = 4
	DISPATCH_BLOCK_NO_QOS_CLASS      Dispatch_block_flags_t = 8
	DISPATCH_BLOCK_INHERIT_QOS_CLASS Dispatch_block_flags_t = 16
	DISPATCH_BLOCK_ENFORCE_QOS_CLASS Dispatch_block_flags_t = 32
)

func (Dispatch_block_flags_t) String ¶

func (e Dispatch_block_flags_t) String() string

type Filesec_property_t ¶

type Filesec_property_t int64
const (
	FILESEC_OWNER         Filesec_property_t = 1
	FILESEC_GROUP         Filesec_property_t = 2
	FILESEC_UUID          Filesec_property_t = 3
	FILESEC_MODE          Filesec_property_t = 4
	FILESEC_ACL           Filesec_property_t = 5
	FILESEC_GRPUUID       Filesec_property_t = 6
	FILESEC_ACL_RAW       Filesec_property_t = 100
	FILESEC_ACL_ALLOCSIZE Filesec_property_t = 101
)

func (Filesec_property_t) String ¶

func (e Filesec_property_t) String() string

type Idtype_t ¶

type Idtype_t int64
const (
	P_ALL  Idtype_t = 0
	P_PID  Idtype_t = 1
	P_PGID Idtype_t = 2
)

func (Idtype_t) String ¶

func (e Idtype_t) String() string

type Ipc_info_object_type_t ¶

type Ipc_info_object_type_t int64
const (
	IPC_OTYPE_NONE                 Ipc_info_object_type_t = 0
	IPC_OTYPE_THREAD_CONTROL       Ipc_info_object_type_t = 1
	IPC_OTYPE_TASK_CONTROL         Ipc_info_object_type_t = 2
	IPC_OTYPE_HOST                 Ipc_info_object_type_t = 3
	IPC_OTYPE_HOST_PRIV            Ipc_info_object_type_t = 4
	IPC_OTYPE_PROCESSOR            Ipc_info_object_type_t = 5
	IPC_OTYPE_PROCESSOR_SET        Ipc_info_object_type_t = 6
	IPC_OTYPE_PROCESSOR_SET_NAME   Ipc_info_object_type_t = 7
	IPC_OTYPE_TIMER                Ipc_info_object_type_t = 8
	IPC_OTYPE_PORT_SUBST_ONCE      Ipc_info_object_type_t = 9
	IPC_OTYPE_MIG                  Ipc_info_object_type_t = 10
	IPC_OTYPE_MEMORY_OBJECT        Ipc_info_object_type_t = 11
	IPC_OTYPE_XMM_PAGER            Ipc_info_object_type_t = 12
	IPC_OTYPE_XMM_KERNEL           Ipc_info_object_type_t = 13
	IPC_OTYPE_XMM_REPLY            Ipc_info_object_type_t = 14
	IPC_OTYPE_UND_REPLY            Ipc_info_object_type_t = 15
	IPC_OTYPE_HOST_NOTIFY          Ipc_info_object_type_t = 16
	IPC_OTYPE_HOST_SECURITY        Ipc_info_object_type_t = 17
	IPC_OTYPE_LEDGER               Ipc_info_object_type_t = 18
	IPC_OTYPE_MAIN_DEVICE          Ipc_info_object_type_t = 19
	IPC_OTYPE_TASK_NAME            Ipc_info_object_type_t = 20
	IPC_OTYPE_SUBSYSTEM            Ipc_info_object_type_t = 21
	IPC_OTYPE_IO_DONE_QUEUE        Ipc_info_object_type_t = 22
	IPC_OTYPE_SEMAPHORE            Ipc_info_object_type_t = 23
	IPC_OTYPE_LOCK_SET             Ipc_info_object_type_t = 24
	IPC_OTYPE_CLOCK                Ipc_info_object_type_t = 25
	IPC_OTYPE_CLOCK_CTRL           Ipc_info_object_type_t = 26
	IPC_OTYPE_IOKIT_IDENT          Ipc_info_object_type_t = 27
	IPC_OTYPE_NAMED_ENTRY          Ipc_info_object_type_t = 28
	IPC_OTYPE_IOKIT_CONNECT        Ipc_info_object_type_t = 29
	IPC_OTYPE_IOKIT_OBJECT         Ipc_info_object_type_t = 30
	IPC_OTYPE_UPL                  Ipc_info_object_type_t = 31
	IPC_OTYPE_MEM_OBJ_CONTROL      Ipc_info_object_type_t = 32
	IPC_OTYPE_AU_SESSIONPORT       Ipc_info_object_type_t = 33
	IPC_OTYPE_FILEPORT             Ipc_info_object_type_t = 34
	IPC_OTYPE_LABELH               Ipc_info_object_type_t = 35
	IPC_OTYPE_TASK_RESUME          Ipc_info_object_type_t = 36
	IPC_OTYPE_VOUCHER              Ipc_info_object_type_t = 37
	IPC_OTYPE_VOUCHER_ATTR_CONTROL Ipc_info_object_type_t = 38
	IPC_OTYPE_WORK_INTERVAL        Ipc_info_object_type_t = 39
	IPC_OTYPE_UX_HANDLER           Ipc_info_object_type_t = 40
	IPC_OTYPE_UEXT_OBJECT          Ipc_info_object_type_t = 41
	IPC_OTYPE_ARCADE_REG           Ipc_info_object_type_t = 42
	IPC_OTYPE_EVENTLINK            Ipc_info_object_type_t = 43
	IPC_OTYPE_TASK_INSPECT         Ipc_info_object_type_t = 44
	IPC_OTYPE_TASK_READ            Ipc_info_object_type_t = 45
	IPC_OTYPE_THREAD_INSPECT       Ipc_info_object_type_t = 46
	IPC_OTYPE_THREAD_READ          Ipc_info_object_type_t = 47
	IPC_OTYPE_SUID_CRED            Ipc_info_object_type_t = 48
	IPC_OTYPE_HYPERVISOR           Ipc_info_object_type_t = 49
	IPC_OTYPE_TASK_ID_TOKEN        Ipc_info_object_type_t = 50
	IPC_OTYPE_TASK_FATAL           Ipc_info_object_type_t = 51
	IPC_OTYPE_KCDATA               Ipc_info_object_type_t = 52
	IPC_OTYPE_EXCLAVES_RESOURCE    Ipc_info_object_type_t = 53
	IPC_OTYPE_THREAD_RESUME        Ipc_info_object_type_t = 54
	IPC_OTYPE_UNKNOWN              Ipc_info_object_type_t = 4294967295
)

func (Ipc_info_object_type_t) String ¶

func (e Ipc_info_object_type_t) String() string

type Launch_data_type_t ¶

type Launch_data_type_t int64
const (
	LAUNCH_DATA_DICTIONARY Launch_data_type_t = 1
	LAUNCH_DATA_ARRAY      Launch_data_type_t = 2
	LAUNCH_DATA_FD         Launch_data_type_t = 3
	LAUNCH_DATA_INTEGER    Launch_data_type_t = 4
	LAUNCH_DATA_REAL       Launch_data_type_t = 5
	LAUNCH_DATA_BOOL       Launch_data_type_t = 6
	LAUNCH_DATA_STRING     Launch_data_type_t = 7
	LAUNCH_DATA_OPAQUE     Launch_data_type_t = 8
	LAUNCH_DATA_ERRNO      Launch_data_type_t = 9
	LAUNCH_DATA_MACHPORT   Launch_data_type_t = 10
)

func (Launch_data_type_t) String ¶

func (e Launch_data_type_t) String() string

type MDLabelDomain ¶

type MDLabelDomain int64

@typedef MDLabelDomain @abstract These constants are used to specify a domain to MDLabelCreate().

const (
	KMDLabelUserDomain  MDLabelDomain = 0
	KMDLabelLocalDomain MDLabelDomain = 1
)

func (MDLabelDomain) String ¶

func (e MDLabelDomain) String() string

type MDQueryOptionFlags ¶

type MDQueryOptionFlags int64
const (
	KMDQuerySynchronous        MDQueryOptionFlags = 1
	KMDQueryWantsUpdates       MDQueryOptionFlags = 4
	KMDQueryAllowFSTranslation MDQueryOptionFlags = 8
)

func (MDQueryOptionFlags) String ¶

func (e MDQueryOptionFlags) String() string

type MDQuerySortOptionFlags ¶

type MDQuerySortOptionFlags int64

@enum MDQuerySortOptionFlags @constant kMDQueryReverseSortOrderFlag Sort the attribute in reverse order.

const (
	KMDQueryReverseSortOrderFlag MDQuerySortOptionFlags = 1
)

func (MDQuerySortOptionFlags) String ¶

func (e MDQuerySortOptionFlags) String() string

type MPSCNNAdd ¶

type MPSCNNAdd struct {
	MPSCNNArithmetic
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnadd

func MPSCNNAddFromID ¶

func MPSCNNAddFromID(id objc.ID) *MPSCNNAdd

func (*MPSCNNAdd) InitWithDevice ¶

func (o *MPSCNNAdd) InitWithDevice(device metal.MTLDevice) *MPSCNNAdd

@abstract Initialize the addition operator. @param device The device the filter will run on. @return A valid MPSCNNAdd object or nil, if failure.

type MPSCNNAddGradient ¶

type MPSCNNAddGradient struct {
	MPSCNNArithmeticGradient
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnaddgradient

func MPSCNNAddGradientFromID ¶

func MPSCNNAddGradientFromID(id objc.ID) *MPSCNNAddGradient

func (*MPSCNNAddGradient) InitWithDeviceIsSecondarySourceFilter ¶

func (o *MPSCNNAddGradient) InitWithDeviceIsSecondarySourceFilter(device metal.MTLDevice, isSecondarySourceFilter bool) *MPSCNNAddGradient

@abstract Initialize the addition gradient operator. @param device The device the filter will run on. @param isSecondarySourceFilter A boolean indicating whether the arithmetic gradient filter is operating on the primary or secondary source image from the forward pass. @return A valid MPSCNNAddGradient object or nil, if failure.

type MPSCNNArithmetic ¶

type MPSCNNArithmetic struct {
	MPSCNNBinaryKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnarithmetic

func MPSCNNArithmeticFromID ¶

func MPSCNNArithmeticFromID(id objc.ID) *MPSCNNArithmetic

func (*MPSCNNArithmetic) Bias ¶

func (o *MPSCNNArithmetic) Bias() float32

func (*MPSCNNArithmetic) EncodeBatchToCommandBufferPrimaryImagesSecondaryImagesDestinationStatesDestinationImages ¶

func (o *MPSCNNArithmetic) EncodeBatchToCommandBufferPrimaryImagesSecondaryImagesDestinationStatesDestinationImages(commandBuffer metal.MTLCommandBuffer, primaryImages unsafe.Pointer, secondaryImages unsafe.Pointer, destinationStates unsafe.Pointer, destinationImages unsafe.Pointer)

@abstract Encode call that operates on a state for later consumption by a gradient kernel in training @discussion This is the older style of encode which reads the offset, doesn't change it, and ignores the padding method. Multiple images are processed concurrently. All images must have MPSImage.numberOfImages = 1. @param commandBuffer A valid MTLCommandBuffer to receive the encoded filter @param primaryImages An array of MPSImage objects containing the primary source images. @param secondaryImages An array MPSImage objects containing the secondary source images. @param destinationStates An array of MPSCNNArithmeticGradientStateBatch to be consumed by the gradient layer @param destinationImages An array of MPSImage objects to contain the result images. destinationImages may not alias primarySourceImages or secondarySourceImages in any manner.

func (*MPSCNNArithmetic) EncodeToCommandBufferPrimaryImageSecondaryImageDestinationStateDestinationImage ¶

func (o *MPSCNNArithmetic) EncodeToCommandBufferPrimaryImageSecondaryImageDestinationStateDestinationImage(commandBuffer metal.MTLCommandBuffer, primaryImage *mpscore.MPSImage, secondaryImage *mpscore.MPSImage, destinationState *MPSCNNArithmeticGradientState, destinationImage *mpscore.MPSImage)

@abstract Encode call that operates on a state for later consumption by a gradient kernel in training @discussion This is the older style of encode which reads the offset, doesn't change it, and ignores the padding method. @param commandBuffer The command buffer @param primaryImage A MPSImage to use as the source images for the filter. @param secondaryImage A MPSImage to use as the source images for the filter. @param destinationState MPSCNNArithmeticGradientState to be consumed by the gradient layer @param destinationImage A valid MPSImage to be overwritten by result image. destinationImage may not alias primarySourceImage or secondarySourceImage.

func (*MPSCNNArithmetic) MaximumValue ¶

func (o *MPSCNNArithmetic) MaximumValue() float32

@property maximumValue @abstract maximumValue is used to clamp the result of an arithmetic operation: result = clamp(result, minimumValue, maximumValue). The default value of maximumValue is FLT_MAX.

func (*MPSCNNArithmetic) MinimumValue ¶

func (o *MPSCNNArithmetic) MinimumValue() float32

@property minimumValue @abstract minimumValue is to clamp the result of an arithmetic operation: result = clamp(result, minimumValue, maximumValue). The default value of minimumValue is -FLT_MAX.

func (*MPSCNNArithmetic) PrimaryScale ¶

func (o *MPSCNNArithmetic) PrimaryScale() float32

func (*MPSCNNArithmetic) PrimaryStrideInFeatureChannels ¶

func (o *MPSCNNArithmetic) PrimaryStrideInFeatureChannels() uint

@property primaryStrideInPixels @abstract The primarySource stride in the feature channel dimension. The only supported values are 0 or 1. The default value for each dimension is 1.

func (*MPSCNNArithmetic) SecondaryScale ¶

func (o *MPSCNNArithmetic) SecondaryScale() float32

func (*MPSCNNArithmetic) SecondaryStrideInFeatureChannels ¶

func (o *MPSCNNArithmetic) SecondaryStrideInFeatureChannels() uint

@property secondaryStrideInPixels @abstract The secondarySource stride in the feature channel dimension. The only supported values are 0 or 1. The default value for each dimension is 1.

func (*MPSCNNArithmetic) SetBias ¶

func (o *MPSCNNArithmetic) SetBias(bias float32)

func (*MPSCNNArithmetic) SetMaximumValue ¶

func (o *MPSCNNArithmetic) SetMaximumValue(maximumValue float32)

func (*MPSCNNArithmetic) SetMinimumValue ¶

func (o *MPSCNNArithmetic) SetMinimumValue(minimumValue float32)

func (*MPSCNNArithmetic) SetPrimaryScale ¶

func (o *MPSCNNArithmetic) SetPrimaryScale(primaryScale float32)

func (*MPSCNNArithmetic) SetPrimaryStrideInFeatureChannels ¶

func (o *MPSCNNArithmetic) SetPrimaryStrideInFeatureChannels(primaryStrideInFeatureChannels uint)

func (*MPSCNNArithmetic) SetSecondaryScale ¶

func (o *MPSCNNArithmetic) SetSecondaryScale(secondaryScale float32)

func (*MPSCNNArithmetic) SetSecondaryStrideInFeatureChannels ¶

func (o *MPSCNNArithmetic) SetSecondaryStrideInFeatureChannels(secondaryStrideInFeatureChannels uint)

type MPSCNNArithmeticGradient ¶

type MPSCNNArithmeticGradient struct {
	MPSCNNGradientKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnarithmeticgradient

func MPSCNNArithmeticGradientFromID ¶

func MPSCNNArithmeticGradientFromID(id objc.ID) *MPSCNNArithmeticGradient

func (*MPSCNNArithmeticGradient) Bias ¶

func (*MPSCNNArithmeticGradient) IsSecondarySourceFilter ¶

func (o *MPSCNNArithmeticGradient) IsSecondarySourceFilter() bool

@property isSecondarySourceFilter @abstract The isSecondarySourceFilter property is used to indicate whether the arithmetic gradient filter is operating on the primary or secondary source image from the forward pass.

func (*MPSCNNArithmeticGradient) MaximumValue ¶

func (o *MPSCNNArithmeticGradient) MaximumValue() float32

@property maximumValue @abstract maximumValue is used to clamp the result of an arithmetic operation: result = clamp(result, minimumValue, maximumValue). The default value of maximumValue is FLT_MAX.

func (*MPSCNNArithmeticGradient) MinimumValue ¶

func (o *MPSCNNArithmeticGradient) MinimumValue() float32

@property minimumValue @abstract minimumValue is to clamp the result of an arithmetic operation: result = clamp(result, minimumValue, maximumValue). The default value of minimumValue is -FLT_MAX.

func (*MPSCNNArithmeticGradient) PrimaryScale ¶

func (o *MPSCNNArithmeticGradient) PrimaryScale() float32

func (*MPSCNNArithmeticGradient) SecondaryScale ¶

func (o *MPSCNNArithmeticGradient) SecondaryScale() float32

func (*MPSCNNArithmeticGradient) SecondaryStrideInFeatureChannels ¶

func (o *MPSCNNArithmeticGradient) SecondaryStrideInFeatureChannels() uint

@property secondaryStrideInPixels @abstract The secondarySource stride in the feature channel dimension. The only supported values are 0 or 1. The default value for each dimension is 1.

func (*MPSCNNArithmeticGradient) SetBias ¶

func (o *MPSCNNArithmeticGradient) SetBias(bias float32)

func (*MPSCNNArithmeticGradient) SetMaximumValue ¶

func (o *MPSCNNArithmeticGradient) SetMaximumValue(maximumValue float32)

func (*MPSCNNArithmeticGradient) SetMinimumValue ¶

func (o *MPSCNNArithmeticGradient) SetMinimumValue(minimumValue float32)

func (*MPSCNNArithmeticGradient) SetPrimaryScale ¶

func (o *MPSCNNArithmeticGradient) SetPrimaryScale(primaryScale float32)

func (*MPSCNNArithmeticGradient) SetSecondaryScale ¶

func (o *MPSCNNArithmeticGradient) SetSecondaryScale(secondaryScale float32)

func (*MPSCNNArithmeticGradient) SetSecondaryStrideInFeatureChannels ¶

func (o *MPSCNNArithmeticGradient) SetSecondaryStrideInFeatureChannels(secondaryStrideInFeatureChannels uint)

type MPSCNNBatchNormalization ¶

type MPSCNNBatchNormalization struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnbatchnormalization

func MPSCNNBatchNormalizationFromID ¶

func MPSCNNBatchNormalizationFromID(id objc.ID) *MPSCNNBatchNormalization

func (*MPSCNNBatchNormalization) DataSource ¶

@abstract The data source the batch normalization was initialized with

func (*MPSCNNBatchNormalization) EncodeBatchToCommandBufferSourceImagesBatchNormalizationStateDestinationImages ¶

func (o *MPSCNNBatchNormalization) EncodeBatchToCommandBufferSourceImagesBatchNormalizationStateDestinationImages(commandBuffer metal.MTLCommandBuffer, sourceImages unsafe.Pointer, batchNormalizationState *MPSCNNBatchNormalizationState, destinationImages unsafe.Pointer)

@abstract Encode this kernel to a command buffer for a batch of images using a batch normalization state. @param commandBuffer A valid command buffer to receive the kernel. @param sourceImages The batch of source images. @param batchNormalizationState A MPSCNNBatchNormalizationState containing weights and/or statistics to use for the batch normalization. If the state is temporary its read count will be decremented. @param destinationImages The batch of images to contain the normalized and scaled result images.

func (*MPSCNNBatchNormalization) EncodeToCommandBufferSourceImageBatchNormalizationStateDestinationImage ¶

func (o *MPSCNNBatchNormalization) EncodeToCommandBufferSourceImageBatchNormalizationStateDestinationImage(commandBuffer metal.MTLCommandBuffer, sourceImage *mpscore.MPSImage, batchNormalizationState *MPSCNNBatchNormalizationState, destinationImage *mpscore.MPSImage)

@abstract Encode this kernel to a command buffer for a single image using a batch normalization state. @param commandBuffer A valid command buffer to receive the kernel. @param sourceImage The source MPSImage. @param batchNormalizationState A MPSCNNBatchNormalizationState containing weights and/or statistics to use for the batch normalization. If the state is temporary its read count will be decremented. @param destinationImage An MPSImage to contain the resulting normalized and scaled image.

func (*MPSCNNBatchNormalization) Epsilon ¶

func (o *MPSCNNBatchNormalization) Epsilon() float32

@property epsilon @abstract The epsilon value used in the batch normalization formula to bias the variance when normalizing.

func (*MPSCNNBatchNormalization) InitWithCoderDevice ¶

func (o *MPSCNNBatchNormalization) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNBatchNormalization

@abstract NSSecureCoding compatability @discussion 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 a subclass of NSCoder that implements the <MPSDeviceProvider> protocol to tell MPS the MTLDevice to use. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSCNNBatchNormalization object, or nil if failure.

func (*MPSCNNBatchNormalization) InitWithDeviceDataSource ¶

@abstract Initializes a batch normalization kernel using a data source. @param device The MTLDevice on which this filter will be used @param dataSource A pointer to a object that conforms to the MPSCNNBatchNormalizationDataSource protocol. The data source provides filter weights and bias terms and, optionally, image statistics which may be used to perform the normalization. @return A valid MPSCNNBatchNormalization object or nil, if failure.

func (*MPSCNNBatchNormalization) InitWithDeviceDataSourceFusedNeuronDescriptor ¶

func (o *MPSCNNBatchNormalization) InitWithDeviceDataSourceFusedNeuronDescriptor(device metal.MTLDevice, dataSource MPSCNNBatchNormalizationDataSource, fusedNeuronDescriptor *MPSNNNeuronDescriptor) *MPSCNNBatchNormalization

@abstract Initializes a batch normalization kernel using a data source and a neuron descriptor. @param device The MTLDevice on which this filter will be used @param dataSource A pointer to a object that conforms to the MPSCNNBatchNormalizationDataSource protocol. The data source provides filter weights and bias terms and, optionally, image statistics which may be used to perform the normalization. @param fusedNeuronDescriptor A MPSNNNeuronDescriptor object which specifies a neuron activation function to be applied to the result of the batch normalization. @return A valid MPSCNNBatchNormalization object or nil, if failure.

func (*MPSCNNBatchNormalization) NumberOfFeatureChannels ¶

func (o *MPSCNNBatchNormalization) NumberOfFeatureChannels() uint

@property numberOfFeatureChannels @abstract The number of feature channels in an image to be normalized.

func (*MPSCNNBatchNormalization) ReloadDataSource ¶

func (o *MPSCNNBatchNormalization) ReloadDataSource(dataSource MPSCNNBatchNormalizationDataSource)

@abstract Reinitialize the filter using a data source. @param dataSource The data source which will provide the weights and, optionally, the image batch statistics with which to normalize.

func (*MPSCNNBatchNormalization) ReloadGammaAndBetaFromDataSource ¶

func (o *MPSCNNBatchNormalization) ReloadGammaAndBetaFromDataSource()

@abstract Reinitialize the filter's gamma and beta values using the data source provided at kernel initialization.

func (*MPSCNNBatchNormalization) ReloadGammaAndBetaWithCommandBufferGammaAndBetaState ¶

func (o *MPSCNNBatchNormalization) ReloadGammaAndBetaWithCommandBufferGammaAndBetaState(commandBuffer metal.MTLCommandBuffer, gammaAndBetaState *MPSCNNNormalizationGammaAndBetaState)

@abstract Reload data using new gamma and beta terms contained within an MPSCNNNormalizationGammaAndBetaState object. @param commandBuffer The command buffer on which to encode the reload. @param gammaAndBetaState The state containing the updated weights which are to be reloaded.

func (*MPSCNNBatchNormalization) ReloadMeanAndVarianceFromDataSource ¶

func (o *MPSCNNBatchNormalization) ReloadMeanAndVarianceFromDataSource()

@abstract Reinitialize the filter's mean and variance values using the data source provided at kernel initialization.

func (*MPSCNNBatchNormalization) ReloadMeanAndVarianceWithCommandBufferMeanAndVarianceState ¶

func (o *MPSCNNBatchNormalization) ReloadMeanAndVarianceWithCommandBufferMeanAndVarianceState(commandBuffer metal.MTLCommandBuffer, meanAndVarianceState *MPSCNNNormalizationMeanAndVarianceState)

@abstract Reload data using new mean and variance terms contained within an MPSCNNNormalizationMeanAndVarianceState object. @param commandBuffer The command buffer on which to encode the reload. @param meanAndVarianceState The state containing the updated statistics which are to be reloaded.

func (*MPSCNNBatchNormalization) SetEpsilon ¶

func (o *MPSCNNBatchNormalization) SetEpsilon(epsilon float32)

type MPSCNNBatchNormalizationDataSource ¶

type MPSCNNBatchNormalizationDataSource interface {
	foundation.NSCopying
}

MPSCNNBatchNormalizationDataSource wraps the ObjC protocol MPSCNNBatchNormalizationDataSource.

type MPSCNNBatchNormalizationFlags ¶

type MPSCNNBatchNormalizationFlags uint64
const (
	// Default Settings
	MPSCNNBatchNormalizationFlagsDefault MPSCNNBatchNormalizationFlags = 0
	// Statistics are calculated if another node consumes the gradient node (training). The data source is used otherwise.
	MPSCNNBatchNormalizationFlagsCalculateStatisticsAutomatic MPSCNNBatchNormalizationFlags = 0
	// Statistics are calculated always
	MPSCNNBatchNormalizationFlagsCalculateStatisticsAlways MPSCNNBatchNormalizationFlags = 1
	// Statistics are never calculated. Predefined values from the data source are used instead
	MPSCNNBatchNormalizationFlagsCalculateStatisticsNever MPSCNNBatchNormalizationFlags = 2
	// Bits used for  MPSCNNBatchNormalizationFlagsCalculateStatistics
	MPSCNNBatchNormalizationFlagsCalculateStatisticsMask MPSCNNBatchNormalizationFlags = 3
)

func (MPSCNNBatchNormalizationFlags) String ¶

type MPSCNNBatchNormalizationGradient ¶

type MPSCNNBatchNormalizationGradient struct {
	MPSCNNGradientKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnbatchnormalizationgradient

func MPSCNNBatchNormalizationGradientFromID ¶

func MPSCNNBatchNormalizationGradientFromID(id objc.ID) *MPSCNNBatchNormalizationGradient

func (*MPSCNNBatchNormalizationGradient) EncodeBatchToCommandBufferSourceGradientsSourceImagesBatchNormalizationState ¶

func (o *MPSCNNBatchNormalizationGradient) EncodeBatchToCommandBufferSourceGradientsSourceImagesBatchNormalizationState(commandBuffer metal.MTLCommandBuffer, sourceGradients unsafe.Pointer, sourceImages unsafe.Pointer, batchNormalizationState *MPSCNNBatchNormalizationState) unsafe.Pointer

@abstract Encode this operation to a command buffer. Create an MPSImageBatch to contain the result and return it. See encodeBatchToCommandBuffer:sourceGradients:sourceImages:batchNormalizationState:destinationGradients for further details.

func (*MPSCNNBatchNormalizationGradient) EncodeBatchToCommandBufferSourceGradientsSourceImagesBatchNormalizationStateDestinationGradients ¶

func (o *MPSCNNBatchNormalizationGradient) EncodeBatchToCommandBufferSourceGradientsSourceImagesBatchNormalizationStateDestinationGradients(commandBuffer metal.MTLCommandBuffer, sourceGradients unsafe.Pointer, sourceImages unsafe.Pointer, batchNormalizationState *MPSCNNBatchNormalizationState, destinationGradients unsafe.Pointer)

@abstract Encode this operation to a command buffer. @param commandBuffer The command buffer. @param sourceGradients An MPSImageBatch containing the gradient of the loss function with respect to the results of batch normalization on the source images. @param sourceImages An MPSImageBatch containing the source images for batch normalization. @param batchNormalizationState A valid MPSCNNBatchNormalizationState object which has been previously updated using a MPSCNNBatchNormalizationStatisticsGradient kernel and the source images. If the state is temporary its read count will be decremented. @param destinationGradients An MPSImageBatch whose images will contain the gradient of the loss function with respect to the source images.

func (*MPSCNNBatchNormalizationGradient) EncodeToCommandBufferSourceGradientSourceImageBatchNormalizationState ¶

func (o *MPSCNNBatchNormalizationGradient) EncodeToCommandBufferSourceGradientSourceImageBatchNormalizationState(commandBuffer metal.MTLCommandBuffer, sourceGradient *mpscore.MPSImage, sourceImage *mpscore.MPSImage, batchNormalizationState *MPSCNNBatchNormalizationState) *mpscore.MPSImage

@abstract Encode this operation to a command buffer. Create an MPSImage to contain the result and return it. See encodeToCommandBuffer:sourceImage:sourceGradient:sourceImage:batchNormalizationState:destinationGradient for further details.

func (*MPSCNNBatchNormalizationGradient) EncodeToCommandBufferSourceGradientSourceImageBatchNormalizationStateDestinationGradient ¶

func (o *MPSCNNBatchNormalizationGradient) EncodeToCommandBufferSourceGradientSourceImageBatchNormalizationStateDestinationGradient(commandBuffer metal.MTLCommandBuffer, sourceGradient *mpscore.MPSImage, sourceImage *mpscore.MPSImage, batchNormalizationState *MPSCNNBatchNormalizationState, destinationGradient *mpscore.MPSImage)

@abstract Encode this operation to a command buffer for a single image. @param commandBuffer The command buffer. @param sourceGradient An MPSImage containing the gradient of the loss function with respect to the results of batch normalization on the source image. @param sourceImage An MPSImage containing the source image for batch normalization. @param batchNormalizationState A valid MPSCNNBatchNormalizationState object which has been previously updated using a MPSCNNBatchNormalizationStatisticsGradient kernel and the source images. If the state is temporary its read count will be decremented. @param destinationGradient An MPSImage which contains the gradient of the loss function with respect to the source image.

func (*MPSCNNBatchNormalizationGradient) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion 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 a subclass of NSCoder that implements the <MPSDeviceProvider> protocol to tell MPS the MTLDevice to use. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSCNNBatchNormalizationGradient object, or nil if failure.

func (*MPSCNNBatchNormalizationGradient) InitWithDeviceFusedNeuronDescriptor ¶

func (o *MPSCNNBatchNormalizationGradient) InitWithDeviceFusedNeuronDescriptor(device metal.MTLDevice, fusedNeuronDescriptor *MPSNNNeuronDescriptor) *MPSCNNBatchNormalizationGradient

@abstract Initializes a batch normalization gradient kernel using a device and neuron descriptor. @param device The MTLDevice on which this filter will be used @param fusedNeuronDescriptor A MPSNNNeuronDescriptor object which specifies a neuron activation function whose gradient should be applied prior to computing the resulting gradient. This neuron descriptor should match that used in the corresponding forward batch normalization kernel as well as the preceeding batch normalization statistics gradient kernel. @return A valid MPSCNNBatchNormalizationGradient object or nil, if failure.

type MPSCNNBatchNormalizationGradientNode ¶

type MPSCNNBatchNormalizationGradientNode struct {
	MPSNNGradientFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnbatchnormalizationgradientnode

func MPSCNNBatchNormalizationGradientNodeFromID ¶

func MPSCNNBatchNormalizationGradientNodeFromID(id objc.ID) *MPSCNNBatchNormalizationGradientNode

func MPSCNNBatchNormalizationGradientNodeNodeWithSourceGradientSourceImageGradientState ¶

func MPSCNNBatchNormalizationGradientNodeNodeWithSourceGradientSourceImageGradientState(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSCNNBatchNormalizationGradientNode

func (*MPSCNNBatchNormalizationGradientNode) InitWithSourceGradientSourceImageGradientState ¶

func (o *MPSCNNBatchNormalizationGradientNode) InitWithSourceGradientSourceImageGradientState(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSCNNBatchNormalizationGradientNode

type MPSCNNBatchNormalizationNode ¶

type MPSCNNBatchNormalizationNode struct {
	MPSNNFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnbatchnormalizationnode

func MPSCNNBatchNormalizationNodeFromID ¶

func MPSCNNBatchNormalizationNodeFromID(id objc.ID) *MPSCNNBatchNormalizationNode

func MPSCNNBatchNormalizationNodeNodeWithSourceDataSource ¶

func MPSCNNBatchNormalizationNodeNodeWithSourceDataSource(source *MPSNNImageNode, dataSource MPSCNNBatchNormalizationDataSource) *MPSCNNBatchNormalizationNode

func (*MPSCNNBatchNormalizationNode) Flags ¶

@abstract Options controlling how batch normalization is calculated @discussion Default: MPSCNNBatchNormalizationFlagsDefault

func (*MPSCNNBatchNormalizationNode) InitWithSourceDataSource ¶

func (*MPSCNNBatchNormalizationNode) SetFlags ¶

func (*MPSCNNBatchNormalizationNode) SetTrainingStyle ¶

func (o *MPSCNNBatchNormalizationNode) SetTrainingStyle(trainingStyle MPSNNTrainingStyle)

@abstract The training style of the forward node will be propagated to gradient nodes made from it

func (*MPSCNNBatchNormalizationNode) TrainingStyle ¶

@abstract The training style of the forward node will be propagated to gradient nodes made from it

type MPSCNNBatchNormalizationState ¶

type MPSCNNBatchNormalizationState struct {
	MPSNNGradientState
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnbatchnormalizationstate

func MPSCNNBatchNormalizationStateFromID ¶

func MPSCNNBatchNormalizationStateFromID(id objc.ID) *MPSCNNBatchNormalizationState

func (*MPSCNNBatchNormalizationState) BatchNormalization ¶

func (*MPSCNNBatchNormalizationState) Beta ¶

@abstract Return an MTLBuffer object with the state's current beta values..

func (*MPSCNNBatchNormalizationState) Gamma ¶

@abstract Return an MTLBuffer object with the state's current gamma values.

func (*MPSCNNBatchNormalizationState) GradientForBeta ¶

func (o *MPSCNNBatchNormalizationState) GradientForBeta() metal.MTLBuffer

@abstract Return an MTLBuffer object containing the values of the gradient of the loss function with respect to the bias terms. If a MPSCNNBatchNormalizationGradient kernel has not successfully generated these values nil will be returned.

func (*MPSCNNBatchNormalizationState) GradientForGamma ¶

func (o *MPSCNNBatchNormalizationState) GradientForGamma() metal.MTLBuffer

@abstract Return an MTLBuffer object containing the values of the gradient of the loss function with respect to the scale factors. If a MPSCNNBatchNormalizationGradient kernel has not successfully generated these values nil will be returned.

func (*MPSCNNBatchNormalizationState) Mean ¶

@abstract Return an MTLBuffer object with the most recently computed batch mean values.

func (*MPSCNNBatchNormalizationState) Reset ¶

func (o *MPSCNNBatchNormalizationState) Reset()

@abstract Reset any accumulated state data to its initial values.

func (*MPSCNNBatchNormalizationState) Variance ¶

@abstract Return an MTLBuffer object with the most recently computed batch variance values.

type MPSCNNBatchNormalizationStatistics ¶

type MPSCNNBatchNormalizationStatistics struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnbatchnormalizationstatistics

func MPSCNNBatchNormalizationStatisticsFromID ¶

func MPSCNNBatchNormalizationStatisticsFromID(id objc.ID) *MPSCNNBatchNormalizationStatistics

func (*MPSCNNBatchNormalizationStatistics) EncodeBatchToCommandBufferSourceImagesBatchNormalizationState ¶

func (o *MPSCNNBatchNormalizationStatistics) EncodeBatchToCommandBufferSourceImagesBatchNormalizationState(commandBuffer metal.MTLCommandBuffer, sourceImages unsafe.Pointer, batchNormalizationState *MPSCNNBatchNormalizationState)

@abstract Encode this operation to a command buffer. @param commandBuffer The command buffer. @param sourceImages An MPSImageBatch containing the source images. @param batchNormalizationState A valid MPSCNNBatchNormalizationState object which will be updated with the image batch statistics.

func (*MPSCNNBatchNormalizationStatistics) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSCNNBatchNormalizationStatistics object, or nil if failure.

func (*MPSCNNBatchNormalizationStatistics) InitWithDevice ¶

@abstract Initialize this kernel on a device. @param device The MTLDevice on which to initialize the kernel.

type MPSCNNBatchNormalizationStatisticsGradient ¶

type MPSCNNBatchNormalizationStatisticsGradient struct {
	MPSCNNGradientKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnbatchnormalizationstatisticsgradient

func MPSCNNBatchNormalizationStatisticsGradientFromID ¶

func MPSCNNBatchNormalizationStatisticsGradientFromID(id objc.ID) *MPSCNNBatchNormalizationStatisticsGradient

func (*MPSCNNBatchNormalizationStatisticsGradient) EncodeBatchToCommandBufferSourceGradientsSourceImagesBatchNormalizationState ¶

func (o *MPSCNNBatchNormalizationStatisticsGradient) EncodeBatchToCommandBufferSourceGradientsSourceImagesBatchNormalizationState(commandBuffer metal.MTLCommandBuffer, sourceGradients unsafe.Pointer, sourceImages unsafe.Pointer, batchNormalizationState *MPSCNNBatchNormalizationState)

@abstract Encode this operation to a command buffer. @param commandBuffer The command buffer. @param sourceGradients An MPSImageBatch containing the gradient of the loss function with respect to the results of batch normalization on the source images. @param sourceImages An MPSImageBatch containing the source images for batch normalization. @param batchNormalizationState A valid MPSCNNBatchNormalizationState object which has been previously updated using a MPSCNNBatchNormalizationStatistics kernel and the source images. Upon completion of the command buffer, will contain the (possibly partially updated) gradients for the loss function with respect to the scale and bias parameters used to compute the batch normalization. The state will be considered to be completely updated when all MPSImages in the training batch have been processed. If the state is temporary its read count will be decremented.

func (*MPSCNNBatchNormalizationStatisticsGradient) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion 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 a subclass of NSCoder that implements the <MPSDeviceProvider> protocol to tell MPS the MTLDevice to use. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSCNNBatchNormalizationStatisticsGradient object, or nil if failure.

func (*MPSCNNBatchNormalizationStatisticsGradient) InitWithDeviceFusedNeuronDescriptor ¶

func (o *MPSCNNBatchNormalizationStatisticsGradient) InitWithDeviceFusedNeuronDescriptor(device metal.MTLDevice, fusedNeuronDescriptor *MPSNNNeuronDescriptor) *MPSCNNBatchNormalizationStatisticsGradient

@abstract Initializes a batch normalization statistics gradient kernel using a device and neuron descriptor. @param device The MTLDevice on which this filter will be used @param fusedNeuronDescriptor A MPSNNNeuronDescriptor object which specifies a neuron activation function whose gradient should be applied prior to computing the statistics of the input gradient. This neuron descriptor should match that used in the corresponding forward batch normalization kernel. @return A valid MPSCNNBatchNormalizationStatisticsGradient object or nil, if failure.

type MPSCNNBinaryConvolution ¶

type MPSCNNBinaryConvolution struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnbinaryconvolution

func MPSCNNBinaryConvolutionFromID ¶

func MPSCNNBinaryConvolutionFromID(id objc.ID) *MPSCNNBinaryConvolution

func (*MPSCNNBinaryConvolution) InitWithCoderDevice ¶

func (o *MPSCNNBinaryConvolution) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNBinaryConvolution

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNBinaryConvolution) InitWithDeviceConvolutionDataOutputBiasTermsOutputScaleTermsInputBiasTermsInputScaleTermsTypeFlags ¶

func (o *MPSCNNBinaryConvolution) InitWithDeviceConvolutionDataOutputBiasTermsOutputScaleTermsInputBiasTermsInputScaleTermsTypeFlags(device metal.MTLDevice, convolutionData MPSCNNConvolutionDataSource, outputBiasTerms *float32, outputScaleTerms *float32, inputBiasTerms *float32, inputScaleTerms *float32, type_ MPSCNNBinaryConvolutionType, flags MPSCNNBinaryConvolutionFlags) *MPSCNNBinaryConvolution

@abstract Initializes a binary convolution kernel with binary weights as well as both pre and post scaling terms. @param device The MTLDevice on which this MPSCNNBinaryConvolution filter will be used @param convolutionData A pointer to a object that conforms to the MPSCNNConvolutionDataSource protocol. The MPSCNNConvolutionDataSource protocol declares the methods that an instance of MPSCNNBinaryConvolution uses to obtain the weights and the convolution descriptor. Each entry in the convolutionData:weights array is a 32-bit unsigned integer value and each bit represents one filter weight (given in machine byte order). The featurechannel indices increase from the least significant bit within the 32-bits. The number of entries is = ceil( inputFeatureChannels/32.0 ) * outputFeatureChannels * kernelHeight * kernelWidth The layout of filter weight is so that it can be reinterpreted as a 4D tensor (array) weight[ outputChannels ][ kernelHeight ][ kernelWidth ][ ceil( inputChannels / 32.0 ) ] (The ordering of the reduction from 4D tensor to 1D is per C convention. The index based on inputchannels varies most rapidly, followed by kernelWidth, then kernelHeight and finally outputChannels varies least rapidly.) @param outputBiasTerms A pointer to bias terms to be applied to the convolution output. Each entry is a float value. The number of entries is = numberOfOutputFeatureMaps. If nil then 0.0 is used for bias. The values stored in the pointer are copied in and the array can be freed after this function returns. @param outputScaleTerms A pointer to scale terms to be applied to binary convolution results per output feature channel. Each entry is a float value. The number of entries is = numberOfOutputFeatureMaps. If nil then 1.0 is used. The values stored in the pointer are copied in and the array can be freed after this function returns. @param inputBiasTerms A pointer to offset terms to be applied to the input before convolution and before input scaling. Each entry is a float value. The number of entries is 'inputFeatureChannels'. If NULL then 0.0 is used for bias. The values stored in the pointer are copied in and the array can be freed after this function returns. @param inputScaleTerms A pointer to scale terms to be applied to the input before convolution, but after input biasing. Each entry is a float value. The number of entries is 'inputFeatureChannels'. If nil then 1.0 is used. The values stored in the pointer are copied in and the array can be freed after this function returns. @param type What kind of binarization strategy is to be used. @param flags See documentation above and documentation of MPSCNNBinaryConvolutionFlags. @return A valid MPSCNNBinaryConvolution object or nil, if failure.

func (*MPSCNNBinaryConvolution) InitWithDeviceConvolutionDataScaleValueTypeFlags ¶

func (o *MPSCNNBinaryConvolution) InitWithDeviceConvolutionDataScaleValueTypeFlags(device metal.MTLDevice, convolutionData MPSCNNConvolutionDataSource, scaleValue float32, type_ MPSCNNBinaryConvolutionType, flags MPSCNNBinaryConvolutionFlags) *MPSCNNBinaryConvolution

@abstract Initializes a binary convolution kernel with binary weights and a single scaling term. @param device The MTLDevice on which this MPSCNNBinaryConvolution filter will be used @param convolutionData A pointer to a object that conforms to the MPSCNNConvolutionDataSource protocol. The MPSCNNConvolutionDataSource protocol declares the methods that an instance of MPSCNNBinaryConvolution uses to obtain the weights and bias terms as well as the convolution descriptor. Each entry in the convolutionData:weights array is a 32-bit unsigned integer value and each bit represents one filter weight (given in machine byte order). The featurechannel indices increase from the least significant bit within the 32-bits. The number of entries is = ceil( inputFeatureChannels/32.0 ) * outputFeatureChannels * kernelHeight * kernelWidth The layout of filter weight is so that it can be reinterpreted as a 4D tensor (array) weight[ outputChannels ][ kernelHeight ][ kernelWidth ][ ceil( inputChannels / 32.0 ) ] (The ordering of the reduction from 4D tensor to 1D is per C convention. The index based on inputchannels varies most rapidly, followed by kernelWidth, then kernelHeight and finally outputChannels varies least rapidly.) @param scaleValue A floating point value used to scale the entire convolution. @param type What kind of binarization strategy is to be used. @param flags See documentation above and documentation of MPSCNNBinaryConvolutionFlags. @return A valid MPSCNNBinaryConvolution object or nil, if failure.

func (*MPSCNNBinaryConvolution) InputFeatureChannels ¶

func (o *MPSCNNBinaryConvolution) InputFeatureChannels() uint

func (*MPSCNNBinaryConvolution) OutputFeatureChannels ¶

func (o *MPSCNNBinaryConvolution) OutputFeatureChannels() uint

@property outputFeatureChannels @abstract The number of feature channels per pixel in the output image.

type MPSCNNBinaryConvolutionFlags ¶

type MPSCNNBinaryConvolutionFlags uint64
const (
	// Use default in binary convolution options
	MPSCNNBinaryConvolutionFlagsNone MPSCNNBinaryConvolutionFlags = 0
	// Scale the binary convolution operation using the beta-image option as detailed in MPSCNNBinaryConvolution
	MPSCNNBinaryConvolutionFlagsUseBetaScaling MPSCNNBinaryConvolutionFlags = 1
)

func (MPSCNNBinaryConvolutionFlags) String ¶

type MPSCNNBinaryConvolutionNode ¶

type MPSCNNBinaryConvolutionNode struct {
	MPSCNNConvolutionNode
}

@abstract A MPSNNFilterNode representing a MPSCNNBinaryConvolution kernel

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnbinaryconvolutionnode

func MPSCNNBinaryConvolutionNodeFromID ¶

func MPSCNNBinaryConvolutionNodeFromID(id objc.ID) *MPSCNNBinaryConvolutionNode

func MPSCNNBinaryConvolutionNodeNodeWithSourceWeightsOutputBiasTermsOutputScaleTermsInputBiasTermsInputScaleTermsTypeFlags ¶

func MPSCNNBinaryConvolutionNodeNodeWithSourceWeightsOutputBiasTermsOutputScaleTermsInputBiasTermsInputScaleTermsTypeFlags(sourceNode *MPSNNImageNode, weights MPSCNNConvolutionDataSource, outputBiasTerms *float32, outputScaleTerms *float32, inputBiasTerms *float32, inputScaleTerms *float32, type_ MPSCNNBinaryConvolutionType, flags MPSCNNBinaryConvolutionFlags) *MPSCNNBinaryConvolutionNode

@abstract Init an autoreleased node representing a MPSCNNBinaryConvolution kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param weights A pointer to a valid object conforming to the MPSCNNConvolutionDataSource protocol. This object is provided by you to encapsulate storage for convolution weights and biases. @param outputBiasTerms A pointer to bias terms to be applied to the convolution output. See MPSCNNBinaryConvolution for more details. @param outputScaleTerms A pointer to scale terms to be applied to binary convolution results per output feature channel. See MPSCNNBinaryConvolution for more details. @param inputBiasTerms A pointer to offset terms to be applied to the input before convolution and before input scaling. See MPSCNNBinaryConvolution for more details. @param inputScaleTerms A pointer to scale terms to be applied to the input before convolution, but after input biasing. See MPSCNNBinaryConvolution for more details. @param type What kind of binarization strategy is to be used. @param flags See documentation of MPSCNNBinaryConvolutionFlags. @return A new MPSNNFilter node for a MPSCNNBinaryConvolution kernel.

func MPSCNNBinaryConvolutionNodeNodeWithSourceWeightsScaleValueTypeFlags ¶

func MPSCNNBinaryConvolutionNodeNodeWithSourceWeightsScaleValueTypeFlags(sourceNode *MPSNNImageNode, weights MPSCNNConvolutionDataSource, scaleValue float32, type_ MPSCNNBinaryConvolutionType, flags MPSCNNBinaryConvolutionFlags) *MPSCNNBinaryConvolutionNode

@abstract Init an autoreleased node representing a MPSCNNBinaryConvolution kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param weights A pointer to a valid object conforming to the MPSCNNConvolutionDataSource protocol. This object is provided by you to encapsulate storage for convolution weights and biases. @param scaleValue A floating point value used to scale the entire convolution. @param type What kind of binarization strategy is to be used. @param flags See documentation of MPSCNNBinaryConvolutionFlags. @return A new MPSNNFilter node for a MPSCNNBinaryConvolution kernel.

func (*MPSCNNBinaryConvolutionNode) InitWithSourceWeightsOutputBiasTermsOutputScaleTermsInputBiasTermsInputScaleTermsTypeFlags ¶

func (o *MPSCNNBinaryConvolutionNode) InitWithSourceWeightsOutputBiasTermsOutputScaleTermsInputBiasTermsInputScaleTermsTypeFlags(sourceNode *MPSNNImageNode, weights MPSCNNConvolutionDataSource, outputBiasTerms *float32, outputScaleTerms *float32, inputBiasTerms *float32, inputScaleTerms *float32, type_ MPSCNNBinaryConvolutionType, flags MPSCNNBinaryConvolutionFlags) *MPSCNNBinaryConvolutionNode

@abstract Init a node representing a MPSCNNBinaryConvolution kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param weights A pointer to a valid object conforming to the MPSCNNConvolutionDataSource protocol. This object is provided by you to encapsulate storage for convolution weights and biases. @param outputBiasTerms A pointer to bias terms to be applied to the convolution output. See MPSCNNBinaryConvolution for more details. @param outputScaleTerms A pointer to scale terms to be applied to binary convolution results per output feature channel. See MPSCNNBinaryConvolution for more details. @param inputBiasTerms A pointer to offset terms to be applied to the input before convolution and before input scaling. See MPSCNNBinaryConvolution for more details. @param inputScaleTerms A pointer to scale terms to be applied to the input before convolution, but after input biasing. See MPSCNNBinaryConvolution for more details. @param type What kind of binarization strategy is to be used. @param flags See documentation of MPSCNNBinaryConvolutionFlags. @return A new MPSNNFilter node for a MPSCNNBinaryConvolution kernel.

func (*MPSCNNBinaryConvolutionNode) InitWithSourceWeightsScaleValueTypeFlags ¶

func (o *MPSCNNBinaryConvolutionNode) InitWithSourceWeightsScaleValueTypeFlags(sourceNode *MPSNNImageNode, weights MPSCNNConvolutionDataSource, scaleValue float32, type_ MPSCNNBinaryConvolutionType, flags MPSCNNBinaryConvolutionFlags) *MPSCNNBinaryConvolutionNode

@abstract Init a node representing a MPSCNNBinaryConvolution kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param weights A pointer to a valid object conforming to the MPSCNNConvolutionDataSource protocol. This object is provided by you to encapsulate storage for convolution weights and biases. @param scaleValue A floating point value used to scale the entire convolution. @param type What kind of binarization strategy is to be used. @param flags See documentation of MPSCNNBinaryConvolutionFlags. @return A new MPSNNFilter node for a MPSCNNBinaryConvolution kernel.

type MPSCNNBinaryConvolutionType ¶

type MPSCNNBinaryConvolutionType uint64
const (
	// Otherwise a normal convolution operation, except that the weights are binary values
	MPSCNNBinaryConvolutionTypeBinaryWeights MPSCNNBinaryConvolutionType = 0
	// Use input image binarization and the XNOR-operation to perform the actual convolution - See MPSCNNBinaryConvolution for details
	MPSCNNBinaryConvolutionTypeXNOR MPSCNNBinaryConvolutionType = 1
	// Use input image binarization and the AND-operation to perform the actual convolution - See MPSCNNBinaryConvolution for details
	MPSCNNBinaryConvolutionTypeAND MPSCNNBinaryConvolutionType = 2
)

func (MPSCNNBinaryConvolutionType) String ¶

type MPSCNNBinaryFullyConnected ¶

type MPSCNNBinaryFullyConnected struct {
	MPSCNNBinaryConvolution
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnbinaryfullyconnected

func MPSCNNBinaryFullyConnectedFromID ¶

func MPSCNNBinaryFullyConnectedFromID(id objc.ID) *MPSCNNBinaryFullyConnected

func (*MPSCNNBinaryFullyConnected) InitWithCoderDevice ¶

func (o *MPSCNNBinaryFullyConnected) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNBinaryFullyConnected

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNBinaryFullyConnected) InitWithDeviceConvolutionDataOutputBiasTermsOutputScaleTermsInputBiasTermsInputScaleTermsTypeFlags ¶

func (o *MPSCNNBinaryFullyConnected) InitWithDeviceConvolutionDataOutputBiasTermsOutputScaleTermsInputBiasTermsInputScaleTermsTypeFlags(device metal.MTLDevice, convolutionData MPSCNNConvolutionDataSource, outputBiasTerms *float32, outputScaleTerms *float32, inputBiasTerms *float32, inputScaleTerms *float32, type_ MPSCNNBinaryConvolutionType, flags MPSCNNBinaryConvolutionFlags) *MPSCNNBinaryFullyConnected

@abstract Initializes a binary fully connected kernel with binary weights as well as both pre and post scaling terms. @param device The MTLDevice on which this MPSCNNBinaryFullyConnected filter will be used @param convolutionData A pointer to a object that conforms to the MPSCNNConvolutionDataSource protocol. The MPSCNNConvolutionDataSource protocol declares the methods that an instance of MPSCNNBinaryFullyConnected uses to obtain the weights and the convolution descriptor. Each entry in the convolutionData:weights array is a 32-bit unsigned integer value and each bit represents one filter weight (given in machine byte order). The featurechannel indices increase from the least significant bit within the 32-bits. The number of entries is = ceil( inputFeatureChannels/32.0 ) * outputFeatureChannels * kernelHeight * kernelWidth The layout of filter weight is so that it can be reinterpreted as a 4D tensor (array) weight[ outputChannels ][ kernelHeight ][ kernelWidth ][ ceil( inputChannels / 32.0 ) ] (The ordering of the reduction from 4D tensor to 1D is per C convention. The index based on inputchannels varies most rapidly, followed by kernelWidth, then kernelHeight and finally outputChannels varies least rapidly.) @param outputBiasTerms A pointer to bias terms to be applied to the convolution output. Each entry is a float value. The number of entries is = numberOfOutputFeatureMaps. If nil then 0.0 is used for bias. The values stored in the pointer are copied in and the array can be freed after this function returns. @param outputScaleTerms A pointer to scale terms to be applied to binary convolution results per output feature channel. Each entry is a float value. The number of entries is = numberOfOutputFeatureMaps. If nil then 1.0 is used. The values stored in the pointer are copied in and the array can be freed after this function returns. @param inputBiasTerms A pointer to offset terms to be applied to the input before convolution and before input scaling. Each entry is a float value. The number of entries is 'inputFeatureChannels'. If NULL then 0.0 is used for bias. The values stored in the pointer are copied in and the array can be freed after this function returns. @param inputScaleTerms A pointer to scale terms to be applied to the input before convolution, but after input biasing. Each entry is a float value. The number of entries is 'inputFeatureChannels'. If nil then 1.0 is used. The values stored in the pointer are copied in and the array can be freed after this function returns. @param type What kind of binarization strategy is to be used. @param flags See documentation above and documentation of MPSCNNBinaryConvolutionFlags. @return A valid MPSCNNBinaryFullyConnected object or nil, if failure.

func (*MPSCNNBinaryFullyConnected) InitWithDeviceConvolutionDataScaleValueTypeFlags ¶

func (o *MPSCNNBinaryFullyConnected) InitWithDeviceConvolutionDataScaleValueTypeFlags(device metal.MTLDevice, convolutionData MPSCNNConvolutionDataSource, scaleValue float32, type_ MPSCNNBinaryConvolutionType, flags MPSCNNBinaryConvolutionFlags) *MPSCNNBinaryFullyConnected

@abstract Initializes a binary fully connected kernel with binary weights and a single scaling term. @param device The MTLDevice on which this MPSCNNBinaryFullyConnected filter will be used @param convolutionData A pointer to a object that conforms to the MPSCNNConvolutionDataSource protocol. The MPSCNNConvolutionDataSource protocol declares the methods that an instance of MPSCNNBinaryFullyConnected uses to obtain the weights and bias terms as well as the convolution descriptor. Each entry in the convolutionData:weights array is a 32-bit unsigned integer value and each bit represents one filter weight (given in machine byte order). The featurechannel indices increase from the least significant bit within the 32-bits. The number of entries is = ceil( inputFeatureChannels/32.0 ) * outputFeatureChannels * kernelHeight * kernelWidth The layout of filter weight is so that it can be reinterpreted as a 4D tensor (array) weight[ outputChannels ][ kernelHeight ][ kernelWidth ][ ceil( inputChannels / 32.0 ) ] (The ordering of the reduction from 4D tensor to 1D is per C convention. The index based on inputchannels varies most rapidly, followed by kernelWidth, then kernelHeight and finally outputChannels varies least rapidly.) @param scaleValue A single floating point value used to scale the entire convolution. Each entry is a float value. The number of entries is 'inputFeatureChannels'. If nil then 1.0 is used. @param type What kind of binarization strategy is to be used. @param flags See documentation above and documentation of MPSCNNBinaryConvolutionFlags. @return A valid MPSCNNBinaryFullyConnected object or nil, if failure.

type MPSCNNBinaryFullyConnectedNode ¶

type MPSCNNBinaryFullyConnectedNode struct {
	MPSCNNBinaryConvolutionNode
}

@abstract A MPSNNFilterNode representing a MPSCNNBinaryFullyConnected kernel

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnbinaryfullyconnectednode

func MPSCNNBinaryFullyConnectedNodeFromID ¶

func MPSCNNBinaryFullyConnectedNodeFromID(id objc.ID) *MPSCNNBinaryFullyConnectedNode

func MPSCNNBinaryFullyConnectedNodeNodeWithSourceWeightsOutputBiasTermsOutputScaleTermsInputBiasTermsInputScaleTermsTypeFlags ¶

func MPSCNNBinaryFullyConnectedNodeNodeWithSourceWeightsOutputBiasTermsOutputScaleTermsInputBiasTermsInputScaleTermsTypeFlags(sourceNode *MPSNNImageNode, weights MPSCNNConvolutionDataSource, outputBiasTerms *float32, outputScaleTerms *float32, inputBiasTerms *float32, inputScaleTerms *float32, type_ MPSCNNBinaryConvolutionType, flags MPSCNNBinaryConvolutionFlags) *MPSCNNBinaryFullyConnectedNode

@abstract Init an autoreleased node representing a MPSCNNBinaryFullyConnected kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param weights A pointer to a valid object conforming to the MPSCNNConvolutionDataSource protocol. This object is provided by you to encapsulate storage for convolution weights and biases. @param outputBiasTerms A pointer to bias terms to be applied to the convolution output. See MPSCNNBinaryConvolution for more details. @param outputScaleTerms A pointer to scale terms to be applied to binary convolution results per output feature channel. See MPSCNNBinaryConvolution for more details. @param inputBiasTerms A pointer to offset terms to be applied to the input before convolution and before input scaling. See MPSCNNBinaryConvolution for more details. @param inputScaleTerms A pointer to scale terms to be applied to the input before convolution, but after input biasing. See MPSCNNBinaryConvolution for more details. @param type What kind of binarization strategy is to be used. @param flags See documentation of MPSCNNBinaryConvolutionFlags. @return A new MPSNNFilter node for a MPSCNNBinaryFullyConnected kernel.

func MPSCNNBinaryFullyConnectedNodeNodeWithSourceWeightsScaleValueTypeFlags ¶

func MPSCNNBinaryFullyConnectedNodeNodeWithSourceWeightsScaleValueTypeFlags(sourceNode *MPSNNImageNode, weights MPSCNNConvolutionDataSource, scaleValue float32, type_ MPSCNNBinaryConvolutionType, flags MPSCNNBinaryConvolutionFlags) *MPSCNNBinaryFullyConnectedNode

@abstract Init an autoreleased node representing a MPSCNNBinaryFullyConnected kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param weights A pointer to a valid object conforming to the MPSCNNConvolutionDataSource protocol. This object is provided by you to encapsulate storage for convolution weights and biases. @param scaleValue A floating point value used to scale the entire convolution. @param type What kind of binarization strategy is to be used. @param flags See documentation of MPSCNNBinaryConvolutionFlags. @return A new MPSNNFilter node for a MPSCNNBinaryFullyConnected kernel.

func (*MPSCNNBinaryFullyConnectedNode) InitWithSourceWeightsOutputBiasTermsOutputScaleTermsInputBiasTermsInputScaleTermsTypeFlags ¶

func (o *MPSCNNBinaryFullyConnectedNode) InitWithSourceWeightsOutputBiasTermsOutputScaleTermsInputBiasTermsInputScaleTermsTypeFlags(sourceNode *MPSNNImageNode, weights MPSCNNConvolutionDataSource, outputBiasTerms *float32, outputScaleTerms *float32, inputBiasTerms *float32, inputScaleTerms *float32, type_ MPSCNNBinaryConvolutionType, flags MPSCNNBinaryConvolutionFlags) *MPSCNNBinaryFullyConnectedNode

@abstract Init a node representing a MPSCNNBinaryFullyConnected kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param weights A pointer to a valid object conforming to the MPSCNNConvolutionDataSource protocol. This object is provided by you to encapsulate storage for convolution weights and biases. @param outputBiasTerms A pointer to bias terms to be applied to the convolution output. See MPSCNNBinaryConvolution for more details. @param outputScaleTerms A pointer to scale terms to be applied to binary convolution results per output feature channel. See MPSCNNBinaryConvolution for more details. @param inputBiasTerms A pointer to offset terms to be applied to the input before convolution and before input scaling. See MPSCNNBinaryConvolution for more details. @param inputScaleTerms A pointer to scale terms to be applied to the input before convolution, but after input biasing. See MPSCNNBinaryConvolution for more details. @param type What kind of binarization strategy is to be used. @param flags See documentation of MPSCNNBinaryConvolutionFlags. @return A new MPSNNFilter node for a MPSCNNBinaryFullyConnected kernel.

func (*MPSCNNBinaryFullyConnectedNode) InitWithSourceWeightsScaleValueTypeFlags ¶

@abstract Init a node representing a MPSCNNBinaryFullyConnected kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param weights A pointer to a valid object conforming to the MPSCNNConvolutionDataSource protocol. This object is provided by you to encapsulate storage for convolution weights and biases. @param scaleValue A floating point value used to scale the entire convolution. @param type What kind of binarization strategy is to be used. @param flags See documentation of MPSCNNBinaryConvolutionFlags. @return A new MPSNNFilter node for a MPSCNNBinaryFullyConnected kernel.

type MPSCNNBinaryKernel ¶

type MPSCNNBinaryKernel struct {
	mpscore.MPSKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnbinarykernel

func MPSCNNBinaryKernelFromID ¶

func MPSCNNBinaryKernelFromID(id objc.ID) *MPSCNNBinaryKernel

func (*MPSCNNBinaryKernel) AppendBatchBarrier ¶

func (o *MPSCNNBinaryKernel) AppendBatchBarrier() bool

@abstract Returns YES if the filter must be run over the entire batch before its results may be considered complete @discussion The MPSNNGraph may split batches into sub-batches to save memory. However, some filters, like batch statistics calculations, need to operate over the entire batch to calculate a valid result, in this case, the mean and variance per channel over the set of images. In such cases, the accumulated result is commonly stored in a MPSState containing a MTLBuffer. (MTLTextures may not be able to be read from and written to in the same filter on some devices.) -isResultStateReusedAcrossBatch is set to YES, so that the state is allocated once and passed in for each sub-batch and the filter accumulates its results into it, one sub-batch at a time. Note that sub-batches may frequently be as small as 1. Default: NO

func (*MPSCNNBinaryKernel) BatchEncodingStorageSizeForPrimaryImageSecondaryImageSourceStatesDestinationImage ¶

func (o *MPSCNNBinaryKernel) BatchEncodingStorageSizeForPrimaryImageSecondaryImageSourceStatesDestinationImage(primaryImage unsafe.Pointer, secondaryImage unsafe.Pointer, sourceStates *foundation.NSArray[objc.ID], destinationImage unsafe.Pointer) uint

@abstract The size of extra MPS heap storage allocated while the kernel is encoding a batch @discussion This is best effort and just describes things that are likely to end up on the MPS heap. It does not describe all allocation done by the -encode call. It is intended for use with high water calculations for MTLHeap sizing. Allocations are typically for temporary storage needed for multipass algorithms. This interface should not be used to detect multipass algorithms.

func (*MPSCNNBinaryKernel) ClipRect ¶

func (o *MPSCNNBinaryKernel) ClipRect() metal.MTLRegion

@property clipRect @abstract An optional clip rectangle to use when writing data. Only the pixels in the rectangle will be overwritten. @discussion A MTLRegion that indicates which part of the destination to overwrite. If the clipRect does not lie completely within the destination image, the intersection between clip rectangle and destination bounds is used. Default: MPSRectNoClip (MPSKernel::MPSRectNoClip) indicating the entire image. clipRect.origin.z is the index of starting destination image in batch processing mode. clipRect.size.depth is the number of images to process in batch processing mode. See Also: @ref subsubsection_clipRect

func (*MPSCNNBinaryKernel) DestinationFeatureChannelOffset ¶

func (o *MPSCNNBinaryKernel) DestinationFeatureChannelOffset() uint

@property destinationFeatureChannelOffset @abstract The number of channels in the destination MPSImage to skip before writing output. @discussion This is the starting offset into the destination image in the feature channel dimension at which destination data is written. This allows an application to pass a subset of all the channels in MPSImage as output of MPSKernel. E.g. Suppose MPSImage has 24 channels and a MPSKernel outputs 8 channels. If we want channels 8 to 15 of this MPSImage to be used as output, we can set destinationFeatureChannelOffset = 8. Note that this offset applies independently to each image when the MPSImage is a container for multiple images and the MPSCNNKernel is processing multiple images (clipRect.size.depth > 1). The default value is 0 and any value specifed shall be a multiple of 4. If MPSKernel outputs N channels, destination image MUST have at least destinationFeatureChannelOffset + N channels. Using a destination image with insufficient number of feature channels result in an error. E.g. if the MPSCNNConvolution outputs 32 channels, and destination has 64 channels, then it is an error to set destinationFeatureChannelOffset > 32.

func (*MPSCNNBinaryKernel) DestinationImageAllocator ¶

func (o *MPSCNNBinaryKernel) DestinationImageAllocator() mpscore.MPSImageAllocator

@abstract Method to allocate the result image for -encodeToCommandBuffer:sourceImage: @discussion Default: MPSTemporaryImage.defaultAllocator

func (*MPSCNNBinaryKernel) DestinationImageDescriptorForSourceImagesSourceStates ¶

func (o *MPSCNNBinaryKernel) DestinationImageDescriptorForSourceImagesSourceStates(sourceImages *foundation.NSArray[*mpscore.MPSImage], sourceStates *foundation.NSArray[*mpscore.MPSState]) *mpscore.MPSImageDescriptor

@abstract Get a suggested destination image descriptor for a source image @discussion Your application is certainly free to pass in any destinationImage it likes to encodeToCommandBuffer:sourceImage:destinationImage, within reason. This is the basic design for iOS 10. This method is therefore not required. However, calculating the MPSImage size and MPSCNNBinaryKernel properties for each filter can be tedious and complicated work, so this method is made available to automate the process. The application may modify the properties of the descriptor before a MPSImage is made from it, so long as the choice is sensible for the kernel in question. Please see individual kernel descriptions for restrictions. The expected timeline for use is as follows: 1) This method is called: a) The default MPS padding calculation is applied. It uses the MPSNNPaddingMethod of the .padding property to provide a consistent addressing scheme over the graph. It creates the MPSImageDescriptor and adjusts the .offset property of the MPSNNKernel. When using a MPSNNGraph, the padding is set using the MPSNNFilterNode as a proxy. b) This method may be overridden by MPSCNNBinaryKernel subclass to achieve any customization appropriate to the object type. c) Source states are then applied in order. These may modify the descriptor and may update other object properties. See: -destinationImageDescriptorForSourceImages:sourceStates: forKernel:suggestedDescriptor: This is the typical way in which MPS may attempt to influence the operation of its kernels. d) If the .padding property has a custom padding policy method of the same name, it is called. Similarly, it may also adjust the descriptor and any MPSCNNBinaryKernel properties. This is the typical way in which your application may attempt to influence the operation of the MPS kernels. 2) A result is returned from this method and the caller may further adjust the descriptor and kernel properties directly. 3) The caller uses the descriptor to make a new MPSImage to use as the destination image for the -encode call in step 5. 4) The caller calls -resultStateForSourceImage:sourceStates:destinationImage: to make any result states needed for the kernel. If there isn't one, it will return nil. A variant is available to return a temporary state instead. 5) a -encode method is called to encode the kernel. The entire process 1-5 is more simply achieved by just calling an -encode... method that returns a MPSImage out the left hand sid of the method. Simpler still, use the MPSNNGraph to coordinate the entire process from end to end. Opportunities to influence the process are of course reduced, as (2) is no longer possible with either method. Your application may opt to use the five step method if it requires greater customization as described, or if it would like to estimate storage in advance based on the sum of MPSImageDescriptors before processing a graph. Storage estimation is done by using the MPSImageDescriptor to create a MPSImage (without passing it a texture), and then call -resourceSize. As long as the MPSImage is not used in an encode call and the .texture property is not invoked, the underlying MTLTexture is not created. No destination state or destination image is provided as an argument to this function because it is expected they will be made / configured after this is called. This method is expected to auto-configure important object properties that may be needed in the ensuing destination image and state creation steps. @param sourceImages A array of source images that will be passed into the -encode call Since MPSCNNBinaryKernel is a binary kernel, it is an array of length 2. @param sourceStates An optional array of source states that will be passed into the -encode call @return an image descriptor allocated on the autorelease pool

func (*MPSCNNBinaryKernel) EncodeBatchToCommandBufferPrimaryImagesSecondaryImages ¶

func (o *MPSCNNBinaryKernel) EncodeBatchToCommandBufferPrimaryImagesSecondaryImages(commandBuffer metal.MTLCommandBuffer, primaryImage unsafe.Pointer, secondaryImage unsafe.Pointer) unsafe.Pointer

@abstract Encode a MPSCNNKernel into a command Buffer. Create textures to hold the results and return them. @discussion In the first iteration on this method, encodeBatchToCommandBuffer:sourceImage:destinationImage: some work was left for the developer to do in the form of correctly setting the offset property and sizing the result buffer. With the introduction of the padding policy (see padding property) the filter can do this work itself. If you would like to have some input into what sort of MPSImage (e.g. temporary vs. regular) or what size it is or where it is allocated, you may set the destinationImageAllocator to allocate the image yourself. This method uses the MPSNNPadding padding property to figure out how to size the result image and to set the offset property. See discussion in MPSNeuralNetworkTypes.h. All images in a batch must have MPSImage.numberOfImages = 1. @param commandBuffer The command buffer @param primaryImage A MPSImages to use as the primary source images for the filter. @param secondaryImage A MPSImages to use as the secondary source images for the filter. @result A MPSImage or MPSTemporaryImage allocated per the destinationImageAllocator containing the output of the graph. The returned image will be automatically released when the command buffer completes. If you want to keep it around for longer, retain the image. (ARC will do this for you if you use it later.)

func (*MPSCNNBinaryKernel) EncodeBatchToCommandBufferPrimaryImagesSecondaryImagesDestinationImages ¶

func (o *MPSCNNBinaryKernel) EncodeBatchToCommandBufferPrimaryImagesSecondaryImagesDestinationImages(commandBuffer metal.MTLCommandBuffer, primaryImages unsafe.Pointer, secondaryImages unsafe.Pointer, destinationImages unsafe.Pointer)

@abstract Encode a MPSCNNKernel into a command Buffer. The operation shall proceed out-of-place. @discussion This is the older style of encode which reads the offset, doesn't change it, and ignores the padding method. Multiple images are processed concurrently. All images must have MPSImage.numberOfImages = 1. @param commandBuffer A valid MTLCommandBuffer to receive the encoded filter @param primaryImages An array of MPSImage objects containing the primary source images. @param secondaryImages An array MPSImage objects containing the secondary source images. @param destinationImages An array of MPSImage objects to contain the result images. destinationImages may not alias primarySourceImages or secondarySourceImages in any manner.

func (*MPSCNNBinaryKernel) EncodeBatchToCommandBufferPrimaryImagesSecondaryImagesDestinationStatesDestinationStateIsTemporary ¶

func (o *MPSCNNBinaryKernel) EncodeBatchToCommandBufferPrimaryImagesSecondaryImagesDestinationStatesDestinationStateIsTemporary(commandBuffer metal.MTLCommandBuffer, primaryImages unsafe.Pointer, secondaryImages unsafe.Pointer, outState unsafe.Pointer, isTemporary bool) unsafe.Pointer

@abstract Encode a MPSCNNKernel into a command Buffer. Create a texture and state to hold the results and return them. @discussion In the first iteration on this method, encodeToCommandBuffer:sourceImage:destinationState:destinationImage: some work was left for the developer to do in the form of correctly setting the offset property and sizing the result buffer. With the introduction of the padding policy (see padding property) the filter can do this work itself. If you would like to have some input into what sort of MPSImage (e.g. temporary vs. regular) or what size it is or where it is allocated, you may set the destinationImageAllocator to allocate the image yourself. This method uses the MPSNNPadding padding property to figure out how to size the result image and to set the offset property. See discussion in MPSNeuralNetworkTypes.h. All images in a batch must have MPSImage.numberOfImages = 1. @param commandBuffer The command buffer @param primaryImages A MPSImage to use as the source images for the filter. @param secondaryImages A MPSImage to use as the source images for the filter. @param outState A new state object is returned here. @param isTemporary YES if the outState should be a temporary object @result A MPSImage or MPSTemporaryImage allocated per the destinationImageAllocator containing the output of the graph. The offset property will be adjusted to reflect the offset used during the encode. The returned image will be automatically released when the command buffer completes. If you want to keep it around for longer, retain the image. (ARC will do this for you if you use it later.)

func (*MPSCNNBinaryKernel) EncodeToCommandBufferPrimaryImageSecondaryImage ¶

func (o *MPSCNNBinaryKernel) EncodeToCommandBufferPrimaryImageSecondaryImage(commandBuffer metal.MTLCommandBuffer, primaryImage *mpscore.MPSImage, secondaryImage *mpscore.MPSImage) *mpscore.MPSImage

@abstract Encode a MPSCNNKernel into a command Buffer. Create a texture to hold the result and return it. @discussion In the first iteration on this method, encodeToCommandBuffer:sourceImage:destinationImage: some work was left for the developer to do in the form of correctly setting the offset property and sizing the result buffer. With the introduction of the padding policy (see padding property) the filter can do this work itself. If you would like to have some input into what sort of MPSImage (e.g. temporary vs. regular) or what size it is or where it is allocated, you may set the destinationImageAllocator to allocate the image yourself. This method uses the MPSNNPadding padding property to figure out how to size the result image and to set the offset property. See discussion in MPSNeuralNetworkTypes.h. @param commandBuffer The command buffer @param primaryImage A MPSImages to use as the primary source images for the filter. @param secondaryImage A MPSImages to use as the secondary source images for the filter. @result A MPSImage or MPSTemporaryImage allocated per the destinationImageAllocator containing the output of the graph. The returned image will be automatically released when the command buffer completes. If you want to keep it around for longer, retain the image. (ARC will do this for you if you use it later.)

func (*MPSCNNBinaryKernel) EncodeToCommandBufferPrimaryImageSecondaryImageDestinationImage ¶

func (o *MPSCNNBinaryKernel) EncodeToCommandBufferPrimaryImageSecondaryImageDestinationImage(commandBuffer metal.MTLCommandBuffer, primaryImage *mpscore.MPSImage, secondaryImage *mpscore.MPSImage, destinationImage *mpscore.MPSImage)

@abstract Encode a MPSCNNKernel into a command Buffer. The operation shall proceed out-of-place. @discussion This is the older style of encode which reads the offset, doesn't change it, and ignores the padding method. @param commandBuffer A valid MTLCommandBuffer to receive the encoded filter @param primaryImage A valid MPSImage object containing the primary source image. @param secondaryImage A valid MPSImage object containing the secondary source image. @param destinationImage A valid MPSImage to be overwritten by result image. destinationImage may not alias primarySourceImage or secondarySourceImage.

func (*MPSCNNBinaryKernel) EncodeToCommandBufferPrimaryImageSecondaryImageDestinationStateDestinationStateIsTemporary ¶

func (o *MPSCNNBinaryKernel) EncodeToCommandBufferPrimaryImageSecondaryImageDestinationStateDestinationStateIsTemporary(commandBuffer metal.MTLCommandBuffer, primaryImage *mpscore.MPSImage, secondaryImage *mpscore.MPSImage, outState *mpscore.MPSState, isTemporary bool) *mpscore.MPSImage

@abstract Encode a MPSCNNKernel into a command Buffer. Create a texture and state to hold the results and return them. @discussion In the first iteration on this method, encodeToCommandBuffer:sourceImage:destinationState:destinationImage: some work was left for the developer to do in the form of correctly setting the offset property and sizing the result buffer. With the introduction of the padding policy (see padding property) the filter can do this work itself. If you would like to have some input into what sort of MPSImage (e.g. temporary vs. regular) or what size it is or where it is allocated, you may set the destinationImageAllocator to allocate the image yourself. This method uses the MPSNNPadding padding property to figure out how to size the result image and to set the offset property. See discussion in MPSNeuralNetworkTypes.h. All images in a batch must have MPSImage.numberOfImages = 1. @param commandBuffer The command buffer @param primaryImage A MPSImage to use as the source images for the filter. @param secondaryImage A MPSImage to use as the source images for the filter. @param outState The address of location to write the pointer to the result state of the operation @param isTemporary YES if the outState should be a temporary object @result A MPSImage or MPSTemporaryImage allocated per the destinationImageAllocator containing the output of the graph. The offset property will be adjusted to reflect the offset used during the encode. The returned image will be automatically released when the command buffer completes. If you want to keep it around for longer, retain the image. (ARC will do this for you if you use it later.)

func (*MPSCNNBinaryKernel) EncodingStorageSizeForPrimaryImageSecondaryImageSourceStatesDestinationImage ¶

func (o *MPSCNNBinaryKernel) EncodingStorageSizeForPrimaryImageSecondaryImageSourceStatesDestinationImage(primaryImage *mpscore.MPSImage, secondaryImage *mpscore.MPSImage, sourceStates *foundation.NSArray[*mpscore.MPSState], destinationImage *mpscore.MPSImage) uint

@abstract The size of extra MPS heap storage allocated while the kernel is encoding @discussion This is best effort and just describes things that are likely to end up on the MPS heap. It does not describe all allocation done by the -encode call. It is intended for use with high water calculations for MTLHeap sizing. Allocations are typically for temporary storage needed for multipass algorithms. This interface should not be used to detect multipass algorithms.

func (*MPSCNNBinaryKernel) InitWithCoderDevice ¶

func (o *MPSCNNBinaryKernel) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNBinaryKernel

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNBinaryKernel) InitWithDevice ¶

func (o *MPSCNNBinaryKernel) InitWithDevice(device metal.MTLDevice) *MPSCNNBinaryKernel

@abstract Standard init with default properties per filter type @param device The device that the filter will be used on. May not be NULL. @result 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.

func (*MPSCNNBinaryKernel) IsBackwards ¶

func (o *MPSCNNBinaryKernel) IsBackwards() bool

@property isBackwards @abstract YES if the filter operates backwards. @discussion This influences how strideInPixelsX/Y should be interpreted.

func (*MPSCNNBinaryKernel) IsResultStateReusedAcrossBatch ¶

func (o *MPSCNNBinaryKernel) IsResultStateReusedAcrossBatch() bool

@abstract Returns YES if the same state is used for every operation in a batch @discussion If NO, then each image in a MPSImageBatch will need a corresponding (and different) state to go with it. Set to YES to avoid allocating redundant state in the case when the same state is used all the time. Default: NO

func (*MPSCNNBinaryKernel) IsStateModified ¶

func (o *MPSCNNBinaryKernel) IsStateModified() bool

@abstract Returns true if the -encode call modifies the state object it accepts.

func (*MPSCNNBinaryKernel) Padding ¶

func (o *MPSCNNBinaryKernel) Padding() MPSNNPadding

@property padding @abstract The padding method used by the filter @discussion This influences how strideInPixelsX/Y should be interpreted. Default: MPSNNPaddingMethodAlignCentered | MPSNNPaddingMethodAddRemainderToTopLeft | MPSNNPaddingMethodSizeSame Some object types (e.g. MPSCNNFullyConnected) may override this default with something appropriate to its operation.

func (*MPSCNNBinaryKernel) PrimaryDilationRateX ¶

func (o *MPSCNNBinaryKernel) PrimaryDilationRateX() uint

@property dilationRateX @abstract Stride in source coordinates from one kernel tap to the next in the X dimension.

func (*MPSCNNBinaryKernel) PrimaryDilationRateY ¶

func (o *MPSCNNBinaryKernel) PrimaryDilationRateY() uint

@property dilationRate @abstract Stride in source coordinates from one kernel tap to the next in the Y dimension.

func (*MPSCNNBinaryKernel) PrimaryEdgeMode ¶

func (o *MPSCNNBinaryKernel) PrimaryEdgeMode() mpscore.MPSImageEdgeMode

@property primaryEdgeMode @abstract The MPSImageEdgeMode to use when texture reads stray off the edge of the primary source image @discussion Most MPSKernel objects can read off the edge of the source image. This can happen because of a negative offset property, because the offset + clipRect.size is larger than the source image or because the filter looks at neighboring pixels, such as a Convolution filter. Default: MPSImageEdgeModeZero. See Also: @ref subsubsection_edgemode

func (*MPSCNNBinaryKernel) PrimaryKernelHeight ¶

func (o *MPSCNNBinaryKernel) PrimaryKernelHeight() uint

@property primaryKernelHeight @abstract The height of the MPSCNNBinaryKernel filter window @discussion This is the vertical diameter of the region read by the filter for each result pixel. If the MPSCNNKernel does not have a filter window, then 1 will be returned.

func (*MPSCNNBinaryKernel) PrimaryKernelWidth ¶

func (o *MPSCNNBinaryKernel) PrimaryKernelWidth() uint

@property primaryKernelWidth @abstract The width of the MPSCNNBinaryKernel filter window @discussion This is the horizontal diameter of the region read by the filter for each result pixel. If the MPSCNNKernel does not have a filter window, then 1 will be returned.

func (*MPSCNNBinaryKernel) PrimaryOffset ¶

func (o *MPSCNNBinaryKernel) PrimaryOffset() mpscore.MPSOffset

@property primaryOffset @abstract The position of the destination clip rectangle origin relative to the primary source buffer. @discussion The offset is defined to be the position of clipRect.origin in source coordinates. Default: {0,0,0}, indicating that the top left corners of the clipRect and primary source image align. offset.z is the index of starting source image in batch processing mode. See Also: @ref subsubsection_mpsoffset

func (*MPSCNNBinaryKernel) PrimarySourceFeatureChannelMaxCount ¶

func (o *MPSCNNBinaryKernel) PrimarySourceFeatureChannelMaxCount() uint

@property primarySourceFeatureChannelMaxCount @abstract The maximum number of channels in the primary source MPSImage to use @discussion Most filters can insert a slice operation into the filter for free. Use this to limit the size of the feature channel slice taken from the input image. If the value is too large, it is truncated to be the remaining size in the image after the sourceFeatureChannelOffset is taken into account. Default: ULONG_MAX

func (*MPSCNNBinaryKernel) PrimarySourceFeatureChannelOffset ¶

func (o *MPSCNNBinaryKernel) PrimarySourceFeatureChannelOffset() uint

@property primarySourceFeatureChannelOffset @abstract The number of channels in the primary source MPSImage to skip before reading the input. @discussion This is the starting offset into the primary source image in the feature channel dimension at which source data is read. Unit: feature channels This allows an application to read a subset of all the channels in MPSImage as input of MPSKernel. E.g. Suppose MPSImage has 24 channels and a MPSKernel needs to read 8 channels. If we want channels 8 to 15 of this MPSImage to be used as input, we can set primarySourceFeatureChannelOffset = 8. Note that this offset applies independently to each image when the MPSImage is a container for multiple images and the MPSCNNKernel is processing multiple images (clipRect.size.depth > 1). The default value is 0 and any value specifed shall be a multiple of 4. If MPSKernel inputs N channels, the source image MUST have at least primarySourceFeatureChannelOffset + N channels. Using a source image with insufficient number of feature channels will result in an error. E.g. if the MPSCNNConvolution inputs 32 channels, and the source has 64 channels, then it is an error to set primarySourceFeatureChannelOffset > 32.

func (*MPSCNNBinaryKernel) PrimaryStrideInPixelsX ¶

func (o *MPSCNNBinaryKernel) PrimaryStrideInPixelsX() uint

@property primaryStrideInPixelsX @abstract The downsampling (or upsampling if a backwards filter) factor in the horizontal dimension for the primary source image @discussion If the filter does not do up or downsampling, 1 is returned.

func (*MPSCNNBinaryKernel) PrimaryStrideInPixelsY ¶

func (o *MPSCNNBinaryKernel) PrimaryStrideInPixelsY() uint

@property primaryStrideInPixelsY @abstract The downsampling (or upsampling if a backwards filter) factor in the vertical dimension for the primary source image @discussion If the filter does not do up or downsampling, 1 is returned.

func (*MPSCNNBinaryKernel) ResultStateBatchForPrimaryImageSecondaryImageSourceStatesDestinationImage ¶

func (o *MPSCNNBinaryKernel) ResultStateBatchForPrimaryImageSecondaryImageSourceStatesDestinationImage(primaryImage unsafe.Pointer, secondaryImage unsafe.Pointer, sourceStates *foundation.NSArray[objc.ID], destinationImage unsafe.Pointer) unsafe.Pointer

func (*MPSCNNBinaryKernel) ResultStateForPrimaryImageSecondaryImageSourceStatesDestinationImage ¶

func (o *MPSCNNBinaryKernel) ResultStateForPrimaryImageSecondaryImageSourceStatesDestinationImage(primaryImage *mpscore.MPSImage, secondaryImage *mpscore.MPSImage, sourceStates *foundation.NSArray[*mpscore.MPSState], destinationImage *mpscore.MPSImage) *mpscore.MPSState

@abstract Allocate a MPSState (subclass) to hold the results from a -encodeBatchToCommandBuffer... operation @discussion A graph may need to allocate storage up front before executing. This may be necessary to avoid using too much memory and to manage large batches. The function should allocate a MPSState object (if any) that will be produced by an -encode call with the indicated sourceImages and sourceStates inputs. Though the states can be further adjusted in the ensuing -encode call, the states should be initialized with all important data and all MTLResource storage allocated. The data stored in the MTLResource need not be initialized, unless the ensuing -encode call expects it to be. The MTLDevice used by the result is derived from the source image. The padding policy will be applied to the filter before this is called to give it the chance to configure any properties like MPSCNNKernel.offset. CAUTION: the result state should be made after the kernel properties are configured for the -encode call that will write to the state, and after -destinationImageDescriptorForSourceImages:sourceStates: is called (if it is called). Otherwise, behavior is undefined. Please see the description of -[MPSCNNKernel resultStateForSourceImage:sourceStates:destinationImage:] for more. Default: returns nil @param primaryImage The MPSImage consumed by the associated -encode call. @param secondaryImage The MPSImage consumed by the associated -encode call. @param sourceStates The list of MPSStates consumed by the associated -encode call, for a batch size of 1. @return The list of states produced by the -encode call for batch size of 1. When the batch size is not 1, this function will be called repeatedly unless -isResultStateReusedAcrossBatch returns YES. If -isResultStateReusedAcrossBatch returns YES, then it will be called once per batch and the MPSStateBatch array will contain MPSStateBatch.length references to the same object.

func (*MPSCNNBinaryKernel) SecondaryDilationRateX ¶

func (o *MPSCNNBinaryKernel) SecondaryDilationRateX() uint

@property dilationRateX @abstract Stride in source coordinates from one kernel tap to the next in the X dimension. @discussion As applied to the secondary source image.

func (*MPSCNNBinaryKernel) SecondaryDilationRateY ¶

func (o *MPSCNNBinaryKernel) SecondaryDilationRateY() uint

@property dilationRate @abstract Stride in source coordinates from one kernel tap to the next in the Y dimension. @discussion As applied to the secondary source image.

func (*MPSCNNBinaryKernel) SecondaryEdgeMode ¶

func (o *MPSCNNBinaryKernel) SecondaryEdgeMode() mpscore.MPSImageEdgeMode

@property secondaryEdgeMode @abstract The MPSImageEdgeMode to use when texture reads stray off the edge of the primary source image @discussion Most MPSKernel objects can read off the edge of the source image. This can happen because of a negative offset property, because the offset + clipRect.size is larger than the source image or because the filter looks at neighboring pixels, such as a Convolution filter. Default: MPSImageEdgeModeZero. See Also: @ref subsubsection_edgemode

func (*MPSCNNBinaryKernel) SecondaryKernelHeight ¶

func (o *MPSCNNBinaryKernel) SecondaryKernelHeight() uint

@property kernelHeight @abstract The height of the MPSCNNBinaryKernel filter window for the second image source @discussion This is the vertical diameter of the region read by the filter for each result pixel. If the MPSCNNBinaryKernel does not have a filter window, then 1 will be returned.

func (*MPSCNNBinaryKernel) SecondaryKernelWidth ¶

func (o *MPSCNNBinaryKernel) SecondaryKernelWidth() uint

@property kernelWidth @abstract The width of the MPSCNNBinaryKernel filter window for the second image source @discussion This is the horizontal diameter of the region read by the filter for each result pixel. If the MPSCNNBinaryKernel does not have a filter window, then 1 will be returned.

func (*MPSCNNBinaryKernel) SecondaryOffset ¶

func (o *MPSCNNBinaryKernel) SecondaryOffset() mpscore.MPSOffset

@property secondaryOffset @abstract The position of the destination clip rectangle origin relative to the secondary source buffer. @discussion The offset is defined to be the position of clipRect.origin in source coordinates. Default: {0,0,0}, indicating that the top left corners of the clipRect and secondary source image align. offset.z is the index of starting source image in batch processing mode. See Also: @ref subsubsection_mpsoffset

func (*MPSCNNBinaryKernel) SecondarySourceFeatureChannelMaxCount ¶

func (o *MPSCNNBinaryKernel) SecondarySourceFeatureChannelMaxCount() uint

@property secondarySourceFeatureChannelMaxCount @abstract The maximum number of channels in the secondary source MPSImage to use @discussion Most filters can insert a slice operation into the filter for free. Use this to limit the size of the feature channel slice taken from the input image. If the value is too large, it is truncated to be the remaining size in the image after the sourceFeatureChannelOffset is taken into account. Default: ULONG_MAX

func (*MPSCNNBinaryKernel) SecondarySourceFeatureChannelOffset ¶

func (o *MPSCNNBinaryKernel) SecondarySourceFeatureChannelOffset() uint

@property secondarySourceFeatureChannelOffset @abstract The number of channels in the secondary source MPSImage to skip before reading the input. @discussion This is the starting offset into the secondary source image in the feature channel dimension at which source data is read. Unit: feature channels This allows an application to read a subset of all the channels in MPSImage as input of MPSKernel. E.g. Suppose MPSImage has 24 channels and a MPSKernel needs to read 8 channels. If we want channels 8 to 15 of this MPSImage to be used as input, we can set secondarySourceFeatureChannelOffset = 8. Note that this offset applies independently to each image when the MPSImage is a container for multiple images and the MPSCNNKernel is processing multiple images (clipRect.size.depth > 1). The default value is 0 and any value specifed shall be a multiple of 4. If MPSKernel inputs N channels, the source image MUST have at least primarySourceFeatureChannelOffset + N channels. Using a source image with insufficient number of feature channels will result in an error. E.g. if the MPSCNNConvolution inputs 32 channels, and the source has 64 channels, then it is an error to set primarySourceFeatureChannelOffset > 32.

func (*MPSCNNBinaryKernel) SecondaryStrideInPixelsX ¶

func (o *MPSCNNBinaryKernel) SecondaryStrideInPixelsX() uint

@property secondaryStrideInPixelsX @abstract The downsampling (or upsampling if a backwards filter) factor in the horizontal dimension for the secondary source image @discussion If the filter does not do up or downsampling, 1 is returned.

func (*MPSCNNBinaryKernel) SecondaryStrideInPixelsY ¶

func (o *MPSCNNBinaryKernel) SecondaryStrideInPixelsY() uint

@property secondaryStrideInPixelsY @abstract The downsampling (or upsampling if a backwards filter) factor in the vertical dimension for the secondary source image @discussion If the filter does not do up or downsampling, 1 is returned.

func (*MPSCNNBinaryKernel) SetClipRect ¶

func (o *MPSCNNBinaryKernel) SetClipRect(clipRect metal.MTLRegion)

func (*MPSCNNBinaryKernel) SetDestinationFeatureChannelOffset ¶

func (o *MPSCNNBinaryKernel) SetDestinationFeatureChannelOffset(destinationFeatureChannelOffset uint)

func (*MPSCNNBinaryKernel) SetDestinationImageAllocator ¶

func (o *MPSCNNBinaryKernel) SetDestinationImageAllocator(destinationImageAllocator mpscore.MPSImageAllocator)

func (*MPSCNNBinaryKernel) SetPadding ¶

func (o *MPSCNNBinaryKernel) SetPadding(padding MPSNNPadding)

func (*MPSCNNBinaryKernel) SetPrimaryEdgeMode ¶

func (o *MPSCNNBinaryKernel) SetPrimaryEdgeMode(primaryEdgeMode mpscore.MPSImageEdgeMode)

func (*MPSCNNBinaryKernel) SetPrimaryOffset ¶

func (o *MPSCNNBinaryKernel) SetPrimaryOffset(primaryOffset mpscore.MPSOffset)

func (*MPSCNNBinaryKernel) SetPrimarySourceFeatureChannelMaxCount ¶

func (o *MPSCNNBinaryKernel) SetPrimarySourceFeatureChannelMaxCount(primarySourceFeatureChannelMaxCount uint)

func (*MPSCNNBinaryKernel) SetPrimarySourceFeatureChannelOffset ¶

func (o *MPSCNNBinaryKernel) SetPrimarySourceFeatureChannelOffset(primarySourceFeatureChannelOffset uint)

func (*MPSCNNBinaryKernel) SetPrimaryStrideInPixelsX ¶

func (o *MPSCNNBinaryKernel) SetPrimaryStrideInPixelsX(primaryStrideInPixelsX uint)

func (*MPSCNNBinaryKernel) SetPrimaryStrideInPixelsY ¶

func (o *MPSCNNBinaryKernel) SetPrimaryStrideInPixelsY(primaryStrideInPixelsY uint)

func (*MPSCNNBinaryKernel) SetSecondaryEdgeMode ¶

func (o *MPSCNNBinaryKernel) SetSecondaryEdgeMode(secondaryEdgeMode mpscore.MPSImageEdgeMode)

func (*MPSCNNBinaryKernel) SetSecondaryOffset ¶

func (o *MPSCNNBinaryKernel) SetSecondaryOffset(secondaryOffset mpscore.MPSOffset)

func (*MPSCNNBinaryKernel) SetSecondarySourceFeatureChannelMaxCount ¶

func (o *MPSCNNBinaryKernel) SetSecondarySourceFeatureChannelMaxCount(secondarySourceFeatureChannelMaxCount uint)

func (*MPSCNNBinaryKernel) SetSecondarySourceFeatureChannelOffset ¶

func (o *MPSCNNBinaryKernel) SetSecondarySourceFeatureChannelOffset(secondarySourceFeatureChannelOffset uint)

func (*MPSCNNBinaryKernel) SetSecondaryStrideInPixelsX ¶

func (o *MPSCNNBinaryKernel) SetSecondaryStrideInPixelsX(secondaryStrideInPixelsX uint)

func (*MPSCNNBinaryKernel) SetSecondaryStrideInPixelsY ¶

func (o *MPSCNNBinaryKernel) SetSecondaryStrideInPixelsY(secondaryStrideInPixelsY uint)

func (*MPSCNNBinaryKernel) TemporaryResultStateBatchForCommandBufferPrimaryImageSecondaryImageSourceStatesDestinationImage ¶

func (o *MPSCNNBinaryKernel) TemporaryResultStateBatchForCommandBufferPrimaryImageSecondaryImageSourceStatesDestinationImage(commandBuffer metal.MTLCommandBuffer, primaryImage unsafe.Pointer, secondaryImage unsafe.Pointer, sourceStates *foundation.NSArray[objc.ID], destinationImage unsafe.Pointer) unsafe.Pointer

func (*MPSCNNBinaryKernel) TemporaryResultStateForCommandBufferPrimaryImageSecondaryImageSourceStatesDestinationImage ¶

func (o *MPSCNNBinaryKernel) TemporaryResultStateForCommandBufferPrimaryImageSecondaryImageSourceStatesDestinationImage(commandBuffer metal.MTLCommandBuffer, primaryImage *mpscore.MPSImage, secondaryImage *mpscore.MPSImage, sourceStates *foundation.NSArray[*mpscore.MPSState], destinationImage *mpscore.MPSImage) *mpscore.MPSState

@abstract Allocate a temporary MPSState (subclass) to hold the results from a -encodeBatchToCommandBuffer... operation @discussion A graph may need to allocate storage up front before executing. This may be necessary to avoid using too much memory and to manage large batches. The function should allocate any MPSState objects that will be produced by an -encode call with the indicated sourceImages and sourceStates inputs. Though the states can be further adjusted in the ensuing -encode call, the states should be initialized with all important data and all MTLResource storage allocated. The data stored in the MTLResource need not be initialized, unless the ensuing -encode call expects it to be. The MTLDevice used by the result is derived from the command buffer. The padding policy will be applied to the filter before this is called to give it the chance to configure any properties like MPSCNNKernel.offset. CAUTION: the result state should be made after the kernel properties are configured for the -encode call that will write to the state, and after -destinationImageDescriptorForSourceImages:sourceStates: is called (if it is called). Otherwise, behavior is undefined. Please see the description of -[MPSCNNKernel resultStateForSourceImage:sourceStates:destinationImage] for more. Default: returns nil @param commandBuffer The command buffer to allocate the temporary storage against The state will only be valid on this command buffer. @param primaryImage The MPSImage consumed by the associated -encode call. @param secondaryImage The MPSImage consumed by the associated -encode call. @param sourceStates The list of MPSStates consumed by the associated -encode call, for a batch size of 1. @return The list of states produced by the -encode call for batch size of 1. When the batch size is not 1, this function will be called repeatedly unless -isResultStateReusedAcrossBatch returns YES. If -isResultStateReusedAcrossBatch returns YES, then it will be called once per batch and the MPSStateBatch array will contain MPSStateBatch.length references to the same object.

type MPSCNNConvolution ¶

type MPSCNNConvolution struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnconvolution

func MPSCNNConvolutionFromID ¶

func MPSCNNConvolutionFromID(id objc.ID) *MPSCNNConvolution

func (*MPSCNNConvolution) AccumulatorPrecisionOption ¶

func (o *MPSCNNConvolution) AccumulatorPrecisionOption() MPSNNConvolutionAccumulatorPrecisionOption

@abstract Precision of accumulator used in convolution. @discussion See MPSNeuralNetworkTypes.h for discussion. Default is MPSNNConvolutionAccumulatorPrecisionOptionFloat.

func (*MPSCNNConvolution) ChannelMultiplier ¶

func (o *MPSCNNConvolution) ChannelMultiplier() uint

@abstract Channel multiplier. @discussion For convolution created with MPSCNNDepthWiseConvolutionDescriptor, it is the number of output feature channels for each input channel. See MPSCNNDepthWiseConvolutionDescriptor for more details. Default is 0 which means regular CNN convolution.

func (*MPSCNNConvolution) DataSource ¶

@property dataSource @abstract dataSource with which convolution object was created

func (*MPSCNNConvolution) ExportWeightsAndBiasesWithCommandBufferResultStateCanBeTemporary ¶

func (o *MPSCNNConvolution) ExportWeightsAndBiasesWithCommandBufferResultStateCanBeTemporary(commandBuffer metal.MTLCommandBuffer, resultStateCanBeTemporary bool) *MPSCNNConvolutionWeightsAndBiasesState

@abstract GPU side export. Enqueue a kernel to export current weights and biases stored in MPSCNNConvoltion's internal buffers into weights and biases MTLBuffer returned in MPSCNNConvolutionWeightsAndBiasesState. @param commandBuffer Metal command buffer on which export kernel is enqueued. @param resultStateCanBeTemporary If FALSE, state returned will be non-temporary. If TRUE, returned state may or may not be temporary. @return MPSCNNConvolutionWeightsAndBiasesState containing weights and biases buffer to which weights got exported. This state and be temporary or non-temporary depending on the flag resultStateCanBeTemporary

func (*MPSCNNConvolution) FusedNeuronDescriptor ¶

func (o *MPSCNNConvolution) FusedNeuronDescriptor() *MPSNNNeuronDescriptor

@abstract Fused neuron descritor passed in convolution descriptor for fusion with convolution. @discussion Please see class description for interpretation of c.

func (*MPSCNNConvolution) Groups ¶

func (o *MPSCNNConvolution) Groups() uint

@property groups @abstract Number of groups input and output channels are divided into.

func (*MPSCNNConvolution) InitWithCoderDevice ¶

func (o *MPSCNNConvolution) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNConvolution

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNConvolution) InitWithDeviceConvolutionDescriptorKernelWeightsBiasTermsFlags ¶

func (o *MPSCNNConvolution) InitWithDeviceConvolutionDescriptorKernelWeightsBiasTermsFlags(device metal.MTLDevice, convolutionDescriptor *MPSCNNConvolutionDescriptor, kernelWeights *float32, biasTerms *float32, flags MPSCNNConvolutionFlags) *MPSCNNConvolution

@abstract Initializes a convolution kernel WARNING: This API is depreated and will be removed in the future. It cannot be used when training. Also serialization/unserialization wont work for MPSCNNConvolution objects created with this init. Please move onto using initWithDevice:weights:. @param device The MTLDevice on which this MPSCNNConvolution filter will be used @param convolutionDescriptor A pointer to a MPSCNNConvolutionDescriptor. @param 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. @param biasTerms A pointer to bias terms to be applied to the convolution output. Each entry is a float value. The number of entries is = numberOfOutputFeatureMaps @param flags Currently unused. Pass MPSCNNConvolutionFlagsNone @return A valid MPSCNNConvolution object or nil, if failure.

func (*MPSCNNConvolution) InitWithDeviceWeights ¶

func (o *MPSCNNConvolution) InitWithDeviceWeights(device metal.MTLDevice, weights MPSCNNConvolutionDataSource) *MPSCNNConvolution

@abstract Initializes a convolution kernel @param device The MTLDevice on which this MPSCNNConvolution filter will be used @param weights A pointer to a object that conforms to the MPSCNNConvolutionDataSource protocol. The MPSCNNConvolutionDataSource protocol declares the methods that an instance of MPSCNNConvolution uses to obtain the weights and bias terms for the CNN convolution filter. @return A valid MPSCNNConvolution object or nil, if failure.

func (*MPSCNNConvolution) InputFeatureChannels ¶

func (o *MPSCNNConvolution) InputFeatureChannels() uint

@property inputFeatureChannels @abstract The number of feature channels per pixel in the input image.

func (*MPSCNNConvolution) Neuron ¶

func (o *MPSCNNConvolution) Neuron() unsafe.Pointer

@property neuron @abstract MPSCNNNeuron filter to be applied as part of convolution. Can be nil in wich case no neuron activation fuction is applied.

func (*MPSCNNConvolution) NeuronParameterA ¶

func (o *MPSCNNConvolution) NeuronParameterA() float32

@abstract Parameter "a" for the neuron. Default: 1.0f @discussion Please see class description for interpretation of a.

func (*MPSCNNConvolution) NeuronParameterB ¶

func (o *MPSCNNConvolution) NeuronParameterB() float32

@abstract Parameter "b" for the neuron. Default: 1.0f @discussion Please see class description for interpretation of b.

func (*MPSCNNConvolution) NeuronParameterC ¶

func (o *MPSCNNConvolution) NeuronParameterC() float32

@abstract Parameter "c" for the neuron. Default: 1.0f @discussion Please see class description for interpretation of c.

func (*MPSCNNConvolution) NeuronType ¶

func (o *MPSCNNConvolution) NeuronType() MPSCNNNeuronType

@abstract The type of neuron to append to the convolution @discussion Please see class description for a full list. Default is MPSCNNNeuronTypeNone.

func (*MPSCNNConvolution) OutputFeatureChannels ¶

func (o *MPSCNNConvolution) OutputFeatureChannels() uint

@property outputFeatureChannels @abstract The number of feature channels per pixel in the output image.

func (*MPSCNNConvolution) ReloadWeightsAndBiasesFromDataSource ¶

func (o *MPSCNNConvolution) ReloadWeightsAndBiasesFromDataSource()

@abstract CPU side reload. Reload the updated weights and biases from data provider into internal weights and bias buffers. Weights and biases gradients needed for update are obtained from MPSCNNConvolutionGradientState object. Data provider passed in init call is used for this purpose.

func (*MPSCNNConvolution) ReloadWeightsAndBiasesWithCommandBufferState ¶

func (o *MPSCNNConvolution) ReloadWeightsAndBiasesWithCommandBufferState(commandBuffer metal.MTLCommandBuffer, state *MPSCNNConvolutionWeightsAndBiasesState)

@abstract GPU side reload. Reload the updated weights and biases from update buffer produced by application enqueued metal kernel into internal weights and biases buffer. Weights and biases gradients needed for update are obtained from MPSCNNConvolutionGradientState object's gradientForWeights and gradientForBiases metal buffer. @param commandBuffer Metal command buffer on which application update kernel was enqueued consuming MPSCNNConvolutionGradientState's gradientForWeights and gradientForBiases buffers and producing updateBuffer metal buffer. @param state MPSCNNConvolutionWeightsAndBiasesState containing weights and biases buffers which have updated weights produced by application's update kernel. The state readcount will be decremented.

func (*MPSCNNConvolution) ReloadWeightsAndBiasesWithDataSource ¶

func (o *MPSCNNConvolution) ReloadWeightsAndBiasesWithDataSource(dataSource MPSCNNConvolutionDataSource)

Deprecated. dataSource will be ignored.

func (*MPSCNNConvolution) SetAccumulatorPrecisionOption ¶

func (o *MPSCNNConvolution) SetAccumulatorPrecisionOption(accumulatorPrecisionOption MPSNNConvolutionAccumulatorPrecisionOption)

@abstract Precision of accumulator used in convolution. @discussion See MPSNeuralNetworkTypes.h for discussion. Default is MPSNNConvolutionAccumulatorPrecisionOptionFloat.

func (*MPSCNNConvolution) SubPixelScaleFactor ¶

func (o *MPSCNNConvolution) SubPixelScaleFactor() uint

@property subPixelScaleFactor @abstract Sub pixel scale factor which was passed in as part of MPSCNNConvolutionDescriptor when creating this MPSCNNConvolution object.

type MPSCNNConvolutionDataSource ¶

type MPSCNNConvolutionDataSource interface {
	foundation.NSCopying
}

MPSCNNConvolutionDataSource wraps the ObjC protocol MPSCNNConvolutionDataSource.

type MPSCNNConvolutionDescriptor ¶

type MPSCNNConvolutionDescriptor struct {
	foundation.NSObject
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnconvolutiondescriptor

func MPSCNNConvolutionDescriptorCnnConvolutionDescriptorWithKernelWidthKernelHeightInputFeatureChannelsOutputFeatureChannels ¶

func MPSCNNConvolutionDescriptorCnnConvolutionDescriptorWithKernelWidthKernelHeightInputFeatureChannelsOutputFeatureChannels(kernelWidth uint, kernelHeight uint, inputFeatureChannels uint, outputFeatureChannels uint) *MPSCNNConvolutionDescriptor

@abstract Creates a convolution descriptor. @param kernelWidth The width of the filter window. Must be > 0. Large values will take a long time. @param kernelHeight The height of the filter window. Must be > 0. Large values will take a long time. @param inputFeatureChannels The number of feature channels in the input image. Must be >= 1. @param outputFeatureChannels The number of feature channels in the output image. Must be >= 1. @return A valid MPSCNNConvolutionDescriptor object or nil, if failure.

func MPSCNNConvolutionDescriptorCnnConvolutionDescriptorWithKernelWidthKernelHeightInputFeatureChannelsOutputFeatureChannelsNeuronFilter ¶

func MPSCNNConvolutionDescriptorCnnConvolutionDescriptorWithKernelWidthKernelHeightInputFeatureChannelsOutputFeatureChannelsNeuronFilter(kernelWidth uint, kernelHeight uint, inputFeatureChannels uint, outputFeatureChannels uint, neuronFilter *MPSCNNNeuron) *MPSCNNConvolutionDescriptor

@abstract This method is deprecated. Please use neuronType, neuronParameterA and neuronParameterB properites to fuse neuron with convolution. @param kernelWidth The width of the filter window. Must be > 0. Large values will take a long time. @param kernelHeight The height of the filter window. Must be > 0. Large values will take a long time. @param inputFeatureChannels The number of feature channels in the input image. Must be >= 1. @param outputFeatureChannels The number of feature channels in the output image. Must be >= 1. @param neuronFilter An optional neuron filter that can be applied to the output of convolution. @return A valid MPSCNNConvolutionDescriptor object or nil, if failure.

func MPSCNNConvolutionDescriptorFromID ¶

func MPSCNNConvolutionDescriptorFromID(id objc.ID) *MPSCNNConvolutionDescriptor

func (*MPSCNNConvolutionDescriptor) DilationRateX ¶

func (o *MPSCNNConvolutionDescriptor) DilationRateX() uint

@property dilationRateX @discussion dilationRateX property can be used to implement dilated convolution as described in https://arxiv.org/pdf/1511.07122v3.pdf to aggregate global information in dense prediction problems. Default value is 1. When set to value > 1, original kernel width, kW is dilated to kW_Dilated = (kW-1)*dilationRateX + 1 by inserting d-1 zeros between consecutive entries in each row of the original kernel. The kernel is centered based on kW_Dilated.

func (*MPSCNNConvolutionDescriptor) DilationRateY ¶

func (o *MPSCNNConvolutionDescriptor) DilationRateY() uint

@property dilationRateY @discussion dilationRateY property can be used to implement dilated convolution as described in https://arxiv.org/pdf/1511.07122v3.pdf to aggregate global information in dense prediction problems. Default value is 1. When set to value > 1, original kernel height, kH is dilated to kH_Dilated = (kH-1)*dilationRateY + 1 by inserting d-1 rows of zeros between consecutive row of the original kernel. The kernel is centered based on kH_Dilated.

func (*MPSCNNConvolutionDescriptor) EncodeWithCoder ¶

func (o *MPSCNNConvolutionDescriptor) EncodeWithCoder(aCoder *foundation.NSCoder)

@abstract <NSSecureCoding> support

func (*MPSCNNConvolutionDescriptor) FusedNeuronDescriptor ¶

func (o *MPSCNNConvolutionDescriptor) FusedNeuronDescriptor() *MPSNNNeuronDescriptor

@property fusedNeuronDescriptor @discussion This mathod can be used to add a neuron activation funtion of given type with associated scalar parameters A and B that are shared across all output channels. Neuron activation fucntion is applied to output of convolution. This is a per-pixel operation that is fused with convolution kernel itself for best performance. Note that this method can only be used to fuse neuron of kind for which parameters A and B are shared across all channels of convoution output. It is an error to call this method for neuron activation functions like MPSCNNNeuronTypePReLU, which require per-channel parameter values. For those kind of neuron activation functions, use appropriate setter functions. Default is descriptor with neuronType MPSCNNNeuronTypeNone. Note: in certain cases the neuron descriptor will be cached by the MPSNNGraph or the MPSCNNConvolution. If the neuron type changes after either is made, behavior is undefined.

func (*MPSCNNConvolutionDescriptor) Groups ¶

func (o *MPSCNNConvolutionDescriptor) Groups() uint

@property groups @abstract Number of groups input and output channels are divided into. The default value is 1. Groups lets you reduce the parameterization. If groups is set to n, input is divided into n groups with inputFeatureChannels/n channels in each group. Similarly output is divided into n groups with outputFeatureChannels/n channels in each group. ith group in input is only connected to ith group in output so number of weights (parameters) needed is reduced by factor of n. Both inputFeatureChannels and outputFeatureChannels must be divisible by n and number of channels in each group must be multiple of 4.

func (*MPSCNNConvolutionDescriptor) InitWithCoder ¶

@abstract <NSSecureCoding> support

func (*MPSCNNConvolutionDescriptor) InputFeatureChannels ¶

func (o *MPSCNNConvolutionDescriptor) InputFeatureChannels() uint

@property inputFeatureChannels @abstract The number of feature channels per pixel in the input image.

func (*MPSCNNConvolutionDescriptor) KernelHeight ¶

func (o *MPSCNNConvolutionDescriptor) KernelHeight() uint

@property kernelHeight @abstract The height of the filter window. The default value is 3. Any positive non-zero value is valid, including even values. The position of the top edge of the filter window is given by offset.y - (kernelHeight>>1)

func (*MPSCNNConvolutionDescriptor) KernelWidth ¶

func (o *MPSCNNConvolutionDescriptor) KernelWidth() uint

@property kernelWidth @abstract The width of the filter window. The default value is 3. Any positive non-zero value is valid, including even values. The position of the left edge of the filter window is given by offset.x - (kernelWidth>>1)

func (*MPSCNNConvolutionDescriptor) Neuron ¶

@property neuron @abstract MPSCNNNeuron filter to be applied as part of convolution. This is applied after BatchNormalization in the end. Default is nil. This is deprecated. You dont need to create MPSCNNNeuron object to fuse with convolution. Use neuron properties in this descriptor.

func (*MPSCNNConvolutionDescriptor) NeuronParameterA ¶

func (o *MPSCNNConvolutionDescriptor) NeuronParameterA() float32

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB method

func (*MPSCNNConvolutionDescriptor) NeuronParameterB ¶

func (o *MPSCNNConvolutionDescriptor) NeuronParameterB() float32

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB method

func (*MPSCNNConvolutionDescriptor) NeuronType ¶

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB method

func (*MPSCNNConvolutionDescriptor) OutputFeatureChannels ¶

func (o *MPSCNNConvolutionDescriptor) OutputFeatureChannels() uint

@property outputFeatureChannels @abstract The number of feature channels per pixel in the output image.

func (*MPSCNNConvolutionDescriptor) SetBatchNormalizationParametersForInferenceWithMeanVarianceGammaBetaEpsilon ¶

func (o *MPSCNNConvolutionDescriptor) SetBatchNormalizationParametersForInferenceWithMeanVarianceGammaBetaEpsilon(mean *float32, variance *float32, gamma *float32, beta *float32, epsilon unsafe.Pointer)

@abstract Adds batch normalization for inference, it copies all the float arrays provided, expecting outputFeatureChannels elements in each. @discussion This method will be used to pass in batch normalization parameters to the convolution during the init call. For inference we modify weights and bias going in convolution or Fully Connected layer to combine and optimize the layers. w: weights for a corresponding output feature channel b: bias for a corresponding output feature channel W: batch normalized weights for a corresponding output feature channel B: batch normalized bias for a corresponding output feature channel I = gamma / sqrt(variance + epsilon), J = beta - ( I * mean ) W = w * I B = b * I + J Every convolution has (OutputFeatureChannel * kernelWidth * kernelHeight * InputFeatureChannel) weights I, J are calculated, for every output feature channel separately to get the corresponding weights and bias Thus, I, J are calculated and then used for every (kernelWidth * kernelHeight * InputFeatureChannel) weights, and this is done OutputFeatureChannel number of times for each output channel. thus, internally, batch normalized weights are computed as: W[no][i][j][ni] = w[no][i][j][ni] * I[no] no: index into outputFeatureChannel i : index into kernel Height j : index into kernel Width ni: index into inputFeatureChannel One usually doesn't see a bias term and batch normalization together as batch normalization potentially cancels out the bias term after training, but in MPS if the user provides it, batch normalization will use the above formula to incorporate it, if user does not have bias terms then put a float array of zeroes in the convolution init for bias terms of each output feature channel. this comes from: https://arxiv.org/pdf/1502.03167v3.pdf Note: in certain cases the batch normalization parameters will be cached by the MPSNNGraph or the MPSCNNConvolution. If the batch normalization parameters change after either is made, behavior is undefined. @param mean Pointer to an array of floats of mean for each output feature channel @param variance Pointer to an array of floats of variance for each output feature channel @param gamma Pointer to an array of floats of gamma for each output feature channel @param beta Pointer to an array of floats of beta for each output feature channel @param epsilon A small float value used to have numerical stability in the code

func (*MPSCNNConvolutionDescriptor) SetDilationRateX ¶

func (o *MPSCNNConvolutionDescriptor) SetDilationRateX(dilationRateX uint)

func (*MPSCNNConvolutionDescriptor) SetDilationRateY ¶

func (o *MPSCNNConvolutionDescriptor) SetDilationRateY(dilationRateY uint)

func (*MPSCNNConvolutionDescriptor) SetFusedNeuronDescriptor ¶

func (o *MPSCNNConvolutionDescriptor) SetFusedNeuronDescriptor(fusedNeuronDescriptor *MPSNNNeuronDescriptor)

@property fusedNeuronDescriptor @discussion This mathod can be used to add a neuron activation funtion of given type with associated scalar parameters A and B that are shared across all output channels. Neuron activation fucntion is applied to output of convolution. This is a per-pixel operation that is fused with convolution kernel itself for best performance. Note that this method can only be used to fuse neuron of kind for which parameters A and B are shared across all channels of convoution output. It is an error to call this method for neuron activation functions like MPSCNNNeuronTypePReLU, which require per-channel parameter values. For those kind of neuron activation functions, use appropriate setter functions. Default is descriptor with neuronType MPSCNNNeuronTypeNone. Note: in certain cases the neuron descriptor will be cached by the MPSNNGraph or the MPSCNNConvolution. If the neuron type changes after either is made, behavior is undefined.

func (*MPSCNNConvolutionDescriptor) SetGroups ¶

func (o *MPSCNNConvolutionDescriptor) SetGroups(groups uint)

func (*MPSCNNConvolutionDescriptor) SetInputFeatureChannels ¶

func (o *MPSCNNConvolutionDescriptor) SetInputFeatureChannels(inputFeatureChannels uint)

func (*MPSCNNConvolutionDescriptor) SetKernelHeight ¶

func (o *MPSCNNConvolutionDescriptor) SetKernelHeight(kernelHeight uint)

func (*MPSCNNConvolutionDescriptor) SetKernelWidth ¶

func (o *MPSCNNConvolutionDescriptor) SetKernelWidth(kernelWidth uint)

func (*MPSCNNConvolutionDescriptor) SetNeuron ¶

func (o *MPSCNNConvolutionDescriptor) SetNeuron(neuron unsafe.Pointer)

@property neuron @abstract MPSCNNNeuron filter to be applied as part of convolution. This is applied after BatchNormalization in the end. Default is nil. This is deprecated. You dont need to create MPSCNNNeuron object to fuse with convolution. Use neuron properties in this descriptor.

func (*MPSCNNConvolutionDescriptor) SetNeuronToPReLUWithParametersA ¶

func (o *MPSCNNConvolutionDescriptor) SetNeuronToPReLUWithParametersA(a *foundation.NSData)

@abstract Add per-channel neuron parameters A for PReLu neuron activation functions. @discussion This method sets the neuron to PReLU, zeros parameters A and B and sets the per-channel neuron parameters A to an array containing a unique value of A for each output feature channel. If the neuron function is f(v,a,b), it will apply OutputImage(x,y,i) = f( ConvolutionResult(x,y,i), A[i], B[i] ) where i in [0,outputFeatureChannels-1] See https://arxiv.org/pdf/1502.01852.pdf for details. All other neuron types, where parameter A and parameter B are shared across channels must be set using -setNeuronOfType:parameterA:parameterB: If batch normalization parameters are set, batch normalization will occur before neuron application i.e. output of convolution is first batch normalized followed by neuron activation. This function automatically sets neuronType to MPSCNNNeuronTypePReLU. Note: in certain cases the neuron descriptor will be cached by the MPSNNGraph or the MPSCNNConvolution. If the neuron type changes after either is made, behavior is undefined. @param A An array containing per-channel float values for neuron parameter A. Number of entries must be equal to outputFeatureChannels.

func (*MPSCNNConvolutionDescriptor) SetNeuronTypeParameterAParameterB ¶

func (o *MPSCNNConvolutionDescriptor) SetNeuronTypeParameterAParameterB(neuronType MPSCNNNeuronType, parameterA float32, parameterB float32)

@abstract Adds a neuron activation function to convolution descriptor. @discussion This mathod can be used to add a neuron activation funtion of given type with associated scalar parameters A and B that are shared across all output channels. Neuron activation fucntion is applied to output of convolution. This is a per-pixel operation that is fused with convolution kernel itself for best performance. Note that this method can only be used to fuse neuron of kind for which parameters A and B are shared across all channels of convoution output. It is an error to call this method for neuron activation functions like MPSCNNNeuronTypePReLU, which require per-channel parameter values. For those kind of neuron activation functions, use appropriate setter functions. Note: in certain cases, the neuron descriptor will be cached by the MPSNNGraph or the MPSCNNConvolution. If the neuron type changes after either is made, behavior is undefined. @param neuronType type of neuron activation function. For full list see MPSCNNNeuronType.h @param parameterA parameterA of neuron activation that is shared across all channels of convolution output. @param parameterB parameterB of neuron activation that is shared across all channels of convolution output.

func (*MPSCNNConvolutionDescriptor) SetOutputFeatureChannels ¶

func (o *MPSCNNConvolutionDescriptor) SetOutputFeatureChannels(outputFeatureChannels uint)

func (*MPSCNNConvolutionDescriptor) SetStrideInPixelsX ¶

func (o *MPSCNNConvolutionDescriptor) SetStrideInPixelsX(strideInPixelsX uint)

func (*MPSCNNConvolutionDescriptor) SetStrideInPixelsY ¶

func (o *MPSCNNConvolutionDescriptor) SetStrideInPixelsY(strideInPixelsY uint)

func (*MPSCNNConvolutionDescriptor) StrideInPixelsX ¶

func (o *MPSCNNConvolutionDescriptor) StrideInPixelsX() uint

@property strideInPixelsX @abstract The output stride (downsampling factor) in the x dimension. The default value is 1.

func (*MPSCNNConvolutionDescriptor) StrideInPixelsY ¶

func (o *MPSCNNConvolutionDescriptor) StrideInPixelsY() uint

@property strideInPixelsY @abstract The output stride (downsampling factor) in the y dimension. The default value is 1.

type MPSCNNConvolutionFlags ¶

type MPSCNNConvolutionFlags uint64
const (
	// Use default options
	MPSCNNConvolutionFlagsNone MPSCNNConvolutionFlags = 0
)

func (MPSCNNConvolutionFlags) String ¶

func (e MPSCNNConvolutionFlags) String() string

type MPSCNNConvolutionGradient ¶

type MPSCNNConvolutionGradient struct {
	MPSCNNGradientKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnconvolutiongradient

func MPSCNNConvolutionGradientFromID ¶

func MPSCNNConvolutionGradientFromID(id objc.ID) *MPSCNNConvolutionGradient

func (*MPSCNNConvolutionGradient) ChannelMultiplier ¶

func (o *MPSCNNConvolutionGradient) ChannelMultiplier() uint

@abstract Channel multiplier. @discussion For convolution created with MPSCNNDepthWiseConvolutionDescriptor, it is the number of output feature channels for each input channel. See MPSCNNDepthWiseConvolutionDescriptor for more details. Default is 0 which means regular CNN convolution. Currently only channelMultiplier of 1 is supported i.e. inputChannels == outputChannels

func (*MPSCNNConvolutionGradient) DataSource ¶

@property dataSource @abstract dataSource with which gradient object was created

func (*MPSCNNConvolutionGradient) GradientOption ¶

@property gradientOption @abstract Option to control which gradient to compute. Default is MPSCNNConvolutionGradientOptionAll which means both gradient with respect to data and gradient with respect to weight and bias are computed.

func (*MPSCNNConvolutionGradient) Groups ¶

func (o *MPSCNNConvolutionGradient) Groups() uint

@property groups @abstract Number of groups input and output channels are divided into.

func (*MPSCNNConvolutionGradient) InitWithCoderDevice ¶

func (o *MPSCNNConvolutionGradient) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNConvolutionGradient

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNConvolutionGradient) InitWithDeviceWeights ¶

@abstract Initializes a convolution gradient (with respect to weights and bias) object. @param device The MTLDevice on which this MPSCNNConvolutionGradient filter will be used @param weights A pointer to a object that conforms to the MPSCNNConvolutionDataSource protocol. Note that same data source as provided to forward convolution should be used. @return A valid MPSCNNConvolutionGradient object or nil, if failure.

func (*MPSCNNConvolutionGradient) ReloadWeightsAndBiasesFromDataSource ¶

func (o *MPSCNNConvolutionGradient) ReloadWeightsAndBiasesFromDataSource()

@abstract CPU side reload. Reload the updated weights and biases from data provider into internal weights and bias buffers. Weights and biases gradients needed for update are obtained from MPSCNNConvolutionGradientState object. Data provider passed in init call is used for this purpose.

func (*MPSCNNConvolutionGradient) ReloadWeightsAndBiasesWithCommandBufferState ¶

func (o *MPSCNNConvolutionGradient) ReloadWeightsAndBiasesWithCommandBufferState(commandBuffer metal.MTLCommandBuffer, state *MPSCNNConvolutionWeightsAndBiasesState)

@abstract GPU side reload. Reload the updated weights and biases from update buffer produced by application enqueued metal kernel into internal weights and biases buffer. Weights and biases gradients needed for update are obtained from MPSCNNConvolutionGradientState object's gradientForWeights and gradientForBiases metal buffer. @param commandBuffer Metal command buffer on which application update kernel was enqueued consuming MPSCNNConvolutionGradientState's gradientForWeights and gradientForBiases buffer and producing updateBuffer metal buffer. @param state MPSCNNConvolutionWeightsAndBiasesState containing weights and biases buffers which have updated weights produced by application's update kernel.

func (*MPSCNNConvolutionGradient) SerializeWeightsAndBiases ¶

func (o *MPSCNNConvolutionGradient) SerializeWeightsAndBiases() bool

@abstract Property to control serialization of weights and bias. @discussion During serialization of convolution object in -encodeWithCoder call, weights and biases are saved so that convolution object can be properly unserialized/restored in -initWithCoder call. If data source provied is NSSecureCoding compliant, data source is serialized else weights and biases are serialized. As weights/biases data may be several MB and these are same for both gradient and forward convolution object, application may already have weights/biases on disk through convolution, it can save disk space by setting this property false so convolution gradient object does not end up storing another copy of weights/biases. Default is NO. When application decides to set it to NO, it MUST call -(void) reloadWeightsAndBiasesFromDataSource after initWithCoder has initialized convolution object.

func (*MPSCNNConvolutionGradient) SetGradientOption ¶

func (o *MPSCNNConvolutionGradient) SetGradientOption(gradientOption MPSCNNConvolutionGradientOption)

func (*MPSCNNConvolutionGradient) SetSerializeWeightsAndBiases ¶

func (o *MPSCNNConvolutionGradient) SetSerializeWeightsAndBiases(serializeWeightsAndBiases bool)

@abstract Property to control serialization of weights and bias. @discussion During serialization of convolution object in -encodeWithCoder call, weights and biases are saved so that convolution object can be properly unserialized/restored in -initWithCoder call. If data source provied is NSSecureCoding compliant, data source is serialized else weights and biases are serialized. As weights/biases data may be several MB and these are same for both gradient and forward convolution object, application may already have weights/biases on disk through convolution, it can save disk space by setting this property false so convolution gradient object does not end up storing another copy of weights/biases. Default is NO. When application decides to set it to NO, it MUST call -(void) reloadWeightsAndBiasesFromDataSource after initWithCoder has initialized convolution object.

func (*MPSCNNConvolutionGradient) SourceGradientFeatureChannels ¶

func (o *MPSCNNConvolutionGradient) SourceGradientFeatureChannels() uint

@property sourceGradientFeatureChannels @abstract The number of feature channels per pixel in the gradient image (primarySource) of encode call. This is same is outputFeatureChannels or the feature channels of destination image in forward convolution i.e. dataSource.descriptor.outputFeatureChannels

func (*MPSCNNConvolutionGradient) SourceImageFeatureChannels ¶

func (o *MPSCNNConvolutionGradient) SourceImageFeatureChannels() uint

@property sourceImageFeatureChannels @abstract The number of feature channels per pixel in the input image to forward convolution which is used here as secondarySource. This is same as dataSource.descriptor.inputFeatureChannels. This is also the number of feature channels in destinatin image here i.e. gradient with respect to data.

type MPSCNNConvolutionGradientNode ¶

type MPSCNNConvolutionGradientNode struct {
	MPSNNGradientFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnconvolutiongradientnode

func MPSCNNConvolutionGradientNodeFromID ¶

func MPSCNNConvolutionGradientNodeFromID(id objc.ID) *MPSCNNConvolutionGradientNode

func MPSCNNConvolutionGradientNodeNodeWithSourceGradientSourceImageConvolutionGradientStateWeights ¶

func MPSCNNConvolutionGradientNodeNodeWithSourceGradientSourceImageConvolutionGradientStateWeights(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSCNNConvolutionGradientStateNode, weights MPSCNNConvolutionDataSource) *MPSCNNConvolutionGradientNode

@abstract A node to represent the gradient calculation for convolution training. @param sourceGradient The input gradient from the 'downstream' gradient filter. Often that is a neuron gradient filter node. @param sourceImage The input image from the forward convolution node @param gradientState The gradient state from the forward convolution @param weights The data source from the forward convolution. It may not contain an integrated neuron. Similary, any normalization should be broken out into a separate node. Pass nil to use the weights from the forward convolution pass. @return A MPSCNNConvolutionGradientNode

func (*MPSCNNConvolutionGradientNode) InitWithSourceGradientSourceImageConvolutionGradientStateWeights ¶

func (o *MPSCNNConvolutionGradientNode) InitWithSourceGradientSourceImageConvolutionGradientStateWeights(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSCNNConvolutionGradientStateNode, weights MPSCNNConvolutionDataSource) *MPSCNNConvolutionGradientNode

@abstract A node to represent the gradient calculation for convolution training. @param sourceGradient The input gradient from the 'downstream' gradient filter. Often that is a neuron gradient filter node. @param sourceImage The input image from the forward convolution node @param gradientState The gradient state from the forward convolution @param weights The data source from the forward convolution. It may not contain an integrated neuron. Similary, any normalization should be broken out into a separate node. Pass nil to use the weights from the forward convolution pass. @return A MPSCNNConvolutionGradientNode

type MPSCNNConvolutionGradientOption ¶

type MPSCNNConvolutionGradientOption uint64
const (
	MPSCNNConvolutionGradientOptionGradientWithData           MPSCNNConvolutionGradientOption = 1
	MPSCNNConvolutionGradientOptionGradientWithWeightsAndBias MPSCNNConvolutionGradientOption = 2
	MPSCNNConvolutionGradientOptionAll                        MPSCNNConvolutionGradientOption = 3
)

func (MPSCNNConvolutionGradientOption) String ¶

type MPSCNNConvolutionGradientState ¶

type MPSCNNConvolutionGradientState struct {
	MPSNNGradientState
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnconvolutiongradientstate

func MPSCNNConvolutionGradientStateFromID ¶

func MPSCNNConvolutionGradientStateFromID(id objc.ID) *MPSCNNConvolutionGradientState

func (*MPSCNNConvolutionGradientState) Convolution ¶

@property convolution @abstract The convolution filter that produced the state. For child MPSCNNConvolutionTrasposeGradientState object, convolution below refers to MPSCNNConvolution object that produced MPSCNNConvolutionGradientState object which was used to create MPSCNNConvolutionTransposeGradientState object. See resultStateForSourceImage:sourceStates method of MPSCNNConvolutionTranspose below.

func (*MPSCNNConvolutionGradientState) GradientForBiases ¶

func (o *MPSCNNConvolutionGradientState) GradientForBiases() metal.MTLBuffer

@property gradientForBiases @abstract A buffer that contains the loss function gradients with respect to biases.

func (*MPSCNNConvolutionGradientState) GradientForWeights ¶

func (o *MPSCNNConvolutionGradientState) GradientForWeights() metal.MTLBuffer

@property gradientForWeights @abstract A buffer that contains the loss function gradients with respect to weights. Each value in the buffer is a float. The layout of the gradients with respect to the weights is the same as the weights layout provided by data source i.e. it can be interpreted as 4D array gradientForWeights[outputFeatureChannels][kernelHeight][kernelWidth]inputFeatureChannels/groups For depthwise convolution it will be (since we only support channel multiplier of 1 currently) gradientForWeights[outputFeatureChannels][kernelHeight][kernelWidth]

func (*MPSCNNConvolutionGradientState) GradientForWeightsLayout ¶

func (o *MPSCNNConvolutionGradientState) GradientForWeightsLayout() MPSCNNConvolutionWeightsLayout

@property gradientForWeightsLayout @abstract Layout of gradient with respect to weights in gradientForWeights buffer. Currently only MPSCNNConvolutionWeightsLayoutOHWI is supported.

type MPSCNNConvolutionNode ¶

type MPSCNNConvolutionNode struct {
	MPSNNFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnconvolutionnode

func MPSCNNConvolutionNodeFromID ¶

func MPSCNNConvolutionNodeFromID(id objc.ID) *MPSCNNConvolutionNode

func MPSCNNConvolutionNodeNodeWithSourceWeights ¶

func MPSCNNConvolutionNodeNodeWithSourceWeights(sourceNode *MPSNNImageNode, weights MPSCNNConvolutionDataSource) *MPSCNNConvolutionNode

@abstract Init an autoreleased not representing a MPSCNNConvolution kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param weights A pointer to a valid object conforming to the MPSCNNConvolutionDataSource protocol. This object is provided by you to encapsulate storage for convolution weights and biases. If it is used for training, it may not have a neuron embedded in the convolution descriptor. @return A new MPSNNFilter node for a MPSCNNConvolution kernel.

func (*MPSCNNConvolutionNode) AccumulatorPrecision ¶

@abstract Set the floating-point precision used by the convolution accumulator @discussion Default: MPSNNConvolutionAccumulatorPrecisionOptionFloat

func (*MPSCNNConvolutionNode) ConvolutionGradientState ¶

func (o *MPSCNNConvolutionNode) ConvolutionGradientState() *MPSCNNConvolutionGradientStateNode

@abstract A node to represent a MPSCNNConvolutionGradientState object @discussion Use this if the convolution is mirrored by a convolution transpose node later on in the graph to make sure that the size of the image returned from the convolution transpose matches the size of the image passed in to this node.

func (*MPSCNNConvolutionNode) InitWithSourceWeights ¶

func (o *MPSCNNConvolutionNode) InitWithSourceWeights(sourceNode *MPSNNImageNode, weights MPSCNNConvolutionDataSource) *MPSCNNConvolutionNode

@abstract Init a node representing a MPSCNNConvolution kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param weights A pointer to a valid object conforming to the MPSCNNConvolutionDataSource protocol. This object is provided by you to encapsulate storage for convolution weights and biases. If it is used for training, it may not have a neuron embedded in the convolution descriptor. @return A new MPSNNFilter node for a MPSCNNConvolution kernel.

func (*MPSCNNConvolutionNode) SetAccumulatorPrecision ¶

func (o *MPSCNNConvolutionNode) SetAccumulatorPrecision(accumulatorPrecision MPSNNConvolutionAccumulatorPrecisionOption)

@abstract Set the floating-point precision used by the convolution accumulator @discussion Default: MPSNNConvolutionAccumulatorPrecisionOptionFloat

func (*MPSCNNConvolutionNode) SetTrainingStyle ¶

func (o *MPSCNNConvolutionNode) SetTrainingStyle(trainingStyle MPSNNTrainingStyle)

@abstract The training style of the forward node will be propagated to gradient nodes made from it

func (*MPSCNNConvolutionNode) TrainingStyle ¶

func (o *MPSCNNConvolutionNode) TrainingStyle() MPSNNTrainingStyle

@abstract The training style of the forward node will be propagated to gradient nodes made from it

type MPSCNNConvolutionTranspose ¶

type MPSCNNConvolutionTranspose struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnconvolutiontranspose

func MPSCNNConvolutionTransposeFromID ¶

func MPSCNNConvolutionTransposeFromID(id objc.ID) *MPSCNNConvolutionTranspose

func (*MPSCNNConvolutionTranspose) AccumulatorPrecisionOption ¶

@abstract Precision of accumulator used in convolution. @discussion See MPSNeuralNetworkTypes.h for discussion. Default is MPSNNConvolutionAccumulatorPrecisionOptionFloat.

func (*MPSCNNConvolutionTranspose) DataSource ¶

@property dataSource @abstract dataSource with which convolution transpose object was created

func (*MPSCNNConvolutionTranspose) EncodeBatchToCommandBufferSourceImagesConvolutionGradientStates ¶

func (o *MPSCNNConvolutionTranspose) EncodeBatchToCommandBufferSourceImagesConvolutionGradientStates(commandBuffer metal.MTLCommandBuffer, sourceImage unsafe.Pointer, convolutionGradientState unsafe.Pointer) unsafe.Pointer

func (*MPSCNNConvolutionTranspose) EncodeBatchToCommandBufferSourceImagesConvolutionGradientStatesDestinationImages ¶

func (o *MPSCNNConvolutionTranspose) EncodeBatchToCommandBufferSourceImagesConvolutionGradientStatesDestinationImages(commandBuffer metal.MTLCommandBuffer, sourceImage unsafe.Pointer, convolutionGradientState unsafe.Pointer, destinationImage unsafe.Pointer)

func (*MPSCNNConvolutionTranspose) EncodeBatchToCommandBufferSourceImagesConvolutionGradientStatesDestinationStatesDestinationStateIsTemporary ¶

func (o *MPSCNNConvolutionTranspose) EncodeBatchToCommandBufferSourceImagesConvolutionGradientStatesDestinationStatesDestinationStateIsTemporary(commandBuffer metal.MTLCommandBuffer, sourceImages unsafe.Pointer, convolutionGradientStates unsafe.Pointer, outStates unsafe.Pointer, isTemporary bool) unsafe.Pointer

func (*MPSCNNConvolutionTranspose) EncodeToCommandBufferSourceImageConvolutionGradientState ¶

func (o *MPSCNNConvolutionTranspose) EncodeToCommandBufferSourceImageConvolutionGradientState(commandBuffer metal.MTLCommandBuffer, sourceImage *mpscore.MPSImage, convolutionGradientState *MPSCNNConvolutionGradientState) *mpscore.MPSImage

@abstract Encode a MPSCNNKernel into a command Buffer. Create a texture to hold the result and return it. @discussion In the first iteration on this method, encodeToCommandBuffer:sourceImage:destinationImage: some work was left for the developer to do in the form of correctly setting the offset property and sizing the result buffer. With the introduction of the padding policy (see padding property) the filter can do this work itself. If you would like to have some input into what sort of MPSImage (e.g. temporary vs. regular) or what size it is or where it is allocated, you may set the destinationImageAllocator to allocate the image yourself. This method uses the MPSNNPadding padding property to figure out how to size the result image and to set the offset property. See discussion in MPSNeuralNetworkTypes.h. Note: the regular encodeToCommandBuffer:sourceImage: method may be used when no state is needed, such as when the convolution transpose operation is not balanced by a matching convolution object upstream. These encode methods are for auto encoders where each convolution in inference pass is coupled with convolution transpose. In order for convolution transpose to correctly undo the convolution downsampling, MPSCNNConvolutionGradientState produced by convolution is needed by convolution transpose to correctly size destination image. These methods are only useful for inference only network. For training, use encode methods that take MPSCNNConvolutionTransposeGradientState below. @param commandBuffer The command buffer @param sourceImage A MPSImage to use as the source images for the filter. @param convolutionGradientState A valid MPSCNNConvolutionGradientState from the MPSCNNConvoluton counterpart to this MPSCNNConvolutionTranspose. If there is no forward convolution counterpart, pass NULL here. This state affects the sizing the result. @result A MPSImage or MPSTemporaryImage allocated per the destinationImageAllocator containing the output of the graph. The offset property will be adjusted to reflect the offset used during the encode. The returned image will be automatically released when the command buffer completes. If you want to keep it around for longer, retain the image. (ARC will do this for you if you use it later.)

func (*MPSCNNConvolutionTranspose) EncodeToCommandBufferSourceImageConvolutionGradientStateDestinationImage ¶

func (o *MPSCNNConvolutionTranspose) EncodeToCommandBufferSourceImageConvolutionGradientStateDestinationImage(commandBuffer metal.MTLCommandBuffer, sourceImage *mpscore.MPSImage, convolutionGradientState *MPSCNNConvolutionGradientState, destinationImage *mpscore.MPSImage)

func (*MPSCNNConvolutionTranspose) EncodeToCommandBufferSourceImageConvolutionGradientStateDestinationStateDestinationStateIsTemporary ¶

func (o *MPSCNNConvolutionTranspose) EncodeToCommandBufferSourceImageConvolutionGradientStateDestinationStateDestinationStateIsTemporary(commandBuffer metal.MTLCommandBuffer, sourceImage *mpscore.MPSImage, convolutionGradientState *MPSCNNConvolutionGradientState, outState *MPSCNNConvolutionTransposeGradientState, isTemporary bool) *mpscore.MPSImage

@abstract These low level encode functions should be used during training. The first two encode functions, which return destination image on left hand side, takes in MPSCNNConvolutionGradientState that was produced by corresponding MPSCNNConvolution when there is one e.g. auto encoders. This state is used to correctly size destination being returned. These encode methods return MPSCNNConvoltionTransposeGradientState object on auto release pool to be consumed by MPSCNNConvolutionTransposeGradient.

func (*MPSCNNConvolutionTranspose) ExportWeightsAndBiasesWithCommandBufferResultStateCanBeTemporary ¶

func (o *MPSCNNConvolutionTranspose) ExportWeightsAndBiasesWithCommandBufferResultStateCanBeTemporary(commandBuffer metal.MTLCommandBuffer, resultStateCanBeTemporary bool) *MPSCNNConvolutionWeightsAndBiasesState

@abstract GPU side export. Enqueue a kernel to export current weights and biases stored in MPSCNNConvoltionTranspose's internal buffers into weights and biases MTLBuffer returned in MPSCNNConvolutionWeightsAndBiasesState. @param commandBuffer Metal command buffer on which export kernel is enqueued. @param resultStateCanBeTemporary If FALSE, state returned will be non-temporary. If TRUE, returned state may or may not be temporary. @return MPSCNNConvolutionWeightsAndBiasesState containing weights and biases buffer to which weights got exported. This state and be temporary or non-temporary depending on the flag resultStateCanBeTemporary

func (*MPSCNNConvolutionTranspose) Groups ¶

func (o *MPSCNNConvolutionTranspose) Groups() uint

@property groups @abstract Number of groups input and output channels are divided into.

func (*MPSCNNConvolutionTranspose) InitWithCoderDevice ¶

func (o *MPSCNNConvolutionTranspose) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNConvolutionTranspose

@abstract <NSSecureCoding> support

func (*MPSCNNConvolutionTranspose) InitWithDeviceWeights ¶

@abstract Initializes a convolution transpose kernel @param device The MTLDevice on which this MPSCNNConvolutionTranspose filter will be used @param weights A pointer to a object that conforms to the MPSCNNConvolutionDataSource protocol. The MPSCNNConvolutionDataSource protocol declares the methods that an instance of MPSCNNConvolutionTranspose uses to obtain the weights and bias terms for the CNN convolutionTranspose filter. Currently we support only Float32 weights. @return A valid MPSCNNConvolutionTranspose object.

func (*MPSCNNConvolutionTranspose) InputFeatureChannels ¶

func (o *MPSCNNConvolutionTranspose) InputFeatureChannels() uint

@property inputFeatureChannels @abstract The number of feature channels per pixel in the input image.

func (*MPSCNNConvolutionTranspose) KernelOffsetX ¶

func (o *MPSCNNConvolutionTranspose) KernelOffsetX() int

@property kernelOffsetX @abstract Offset in X from which the kernel starts sliding

func (*MPSCNNConvolutionTranspose) KernelOffsetY ¶

func (o *MPSCNNConvolutionTranspose) KernelOffsetY() int

@property kernelOffsetY @abstract Offset in Y from which the kernel starts sliding

func (*MPSCNNConvolutionTranspose) OutputFeatureChannels ¶

func (o *MPSCNNConvolutionTranspose) OutputFeatureChannels() uint

@property outputFeatureChannels @abstract The number of feature channels per pixel in the output image.

func (*MPSCNNConvolutionTranspose) ReloadWeightsAndBiasesFromDataSource ¶

func (o *MPSCNNConvolutionTranspose) ReloadWeightsAndBiasesFromDataSource()

@abstract CPU side reload. Reload the updated weights and biases from data provider into internal weights and bias buffers. Weights and biases gradients needed for update are obtained from MPSCNNConvolutionTransposeGradientState object. Data provider passed in init call is used for this purpose.

func (*MPSCNNConvolutionTranspose) ReloadWeightsAndBiasesWithCommandBufferState ¶

func (o *MPSCNNConvolutionTranspose) ReloadWeightsAndBiasesWithCommandBufferState(commandBuffer metal.MTLCommandBuffer, state *MPSCNNConvolutionWeightsAndBiasesState)

@abstract GPU side reload. Reload the updated weights and biases from update buffer produced by application enqueued metal kernel into internal weights and biases buffer. Weights and biases gradients needed for update are obtained from MPSCNNConvolutionTransposeGradientState object's gradientForWeights and gradientForBiases metal buffer. @param commandBuffer Metal command buffer on which application update kernel was enqueued consuming MPSCNNConvolutionGradientState's gradientForWeights and gradientForBiases buffers and producing updateBuffer metal buffer. @param state MPSCNNConvolutionWeightsAndBiasesState containing weights and biases buffers which have updated weights produced by application's update kernel. The state readcount will be decremented.

func (*MPSCNNConvolutionTranspose) SetAccumulatorPrecisionOption ¶

func (o *MPSCNNConvolutionTranspose) SetAccumulatorPrecisionOption(accumulatorPrecisionOption MPSNNConvolutionAccumulatorPrecisionOption)

@abstract Precision of accumulator used in convolution. @discussion See MPSNeuralNetworkTypes.h for discussion. Default is MPSNNConvolutionAccumulatorPrecisionOptionFloat.

func (*MPSCNNConvolutionTranspose) SetKernelOffsetX ¶

func (o *MPSCNNConvolutionTranspose) SetKernelOffsetX(kernelOffsetX int)

func (*MPSCNNConvolutionTranspose) SetKernelOffsetY ¶

func (o *MPSCNNConvolutionTranspose) SetKernelOffsetY(kernelOffsetY int)

type MPSCNNConvolutionTransposeGradient ¶

type MPSCNNConvolutionTransposeGradient struct {
	MPSCNNGradientKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnconvolutiontransposegradient

func MPSCNNConvolutionTransposeGradientFromID ¶

func MPSCNNConvolutionTransposeGradientFromID(id objc.ID) *MPSCNNConvolutionTransposeGradient

func (*MPSCNNConvolutionTransposeGradient) DataSource ¶

@property dataSource @abstract dataSource with which gradient object was created

func (*MPSCNNConvolutionTransposeGradient) GradientOption ¶

@property gradientOption @abstract Option to control which gradient to compute. Default is MPSCNNConvolutionGradientOptionAll which means both gradient with respect to data and gradient with respect to weight and bias are computed.

func (*MPSCNNConvolutionTransposeGradient) Groups ¶

@property groups @abstract Number of groups input and output channels are divided into.

func (*MPSCNNConvolutionTransposeGradient) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNConvolutionTransposeGradient) InitWithDeviceWeights ¶

@abstract Initializes a convolution transpose gradient (with respect to weights and bias) object. @param device The MTLDevice on which this MPSCNNConvolutionGradient filter will be used @param weights A pointer to a object that conforms to the MPSCNNConvolutionDataSource protocol. Note that same data source as provided to forward convolution should be used. @return A valid MPSCNNConvolutionTransposeGradient object or nil, if failure.

func (*MPSCNNConvolutionTransposeGradient) ReloadWeightsAndBiasesFromDataSource ¶

func (o *MPSCNNConvolutionTransposeGradient) ReloadWeightsAndBiasesFromDataSource()

@abstract CPU side reload. Reload the updated weights and biases from data provider into internal weights and bias buffers. Weights and biases gradients needed for update are obtained from MPSCNNConvolutionGradientState object. Data provider passed in init call is used for this purpose.

func (*MPSCNNConvolutionTransposeGradient) ReloadWeightsAndBiasesWithCommandBufferState ¶

func (o *MPSCNNConvolutionTransposeGradient) ReloadWeightsAndBiasesWithCommandBufferState(commandBuffer metal.MTLCommandBuffer, state *MPSCNNConvolutionWeightsAndBiasesState)

@abstract GPU side reload. Reload the updated weights and biases from update buffer produced by application enqueued metal kernel into internal weights and biases buffer. Weights and biases gradients needed for update are obtained from MPSCNNConvolutionGradientState object's gradientForWeights and gradientForBiases metal buffer. @param commandBuffer Metal command buffer on which application update kernel was enqueued consuming MPSCNNConvolutionGradientState's gradientForWeights and gradientForBiases buffer and producing updateBuffer metal buffer. @param state MPSCNNConvolutionWeightsAndBiasesState containing weights and biases buffers which have updated weights produced by application's update kernel.

func (*MPSCNNConvolutionTransposeGradient) SetGradientOption ¶

func (o *MPSCNNConvolutionTransposeGradient) SetGradientOption(gradientOption MPSCNNConvolutionGradientOption)

func (*MPSCNNConvolutionTransposeGradient) SourceGradientFeatureChannels ¶

func (o *MPSCNNConvolutionTransposeGradient) SourceGradientFeatureChannels() uint

@property sourceGradientFeatureChannels @abstract The number of feature channels per pixel in the gradient image (primarySource) of encode call. This is same is outputFeatureChannels or the feature channels of destination image in forward convolution i.e. dataSource.descriptor.outputFeatureChannels

func (*MPSCNNConvolutionTransposeGradient) SourceImageFeatureChannels ¶

func (o *MPSCNNConvolutionTransposeGradient) SourceImageFeatureChannels() uint

@property sourceImageFeatureChannels @abstract The number of feature channels per pixel in the input image to forward convolution which is used here as secondarySource. This is same as dataSource.descriptor.inputFeatureChannels. This is also the number of feature channels in destinatin image here i.e. gradient with respect to data.

type MPSCNNConvolutionTransposeGradientNode ¶

type MPSCNNConvolutionTransposeGradientNode struct {
	MPSCNNConvolutionGradientNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnconvolutiontransposegradientnode

func MPSCNNConvolutionTransposeGradientNodeFromID ¶

func MPSCNNConvolutionTransposeGradientNodeFromID(id objc.ID) *MPSCNNConvolutionTransposeGradientNode

func MPSCNNConvolutionTransposeGradientNodeNodeWithSourceGradientSourceImageConvolutionTransposeGradientStateWeights ¶

func MPSCNNConvolutionTransposeGradientNodeNodeWithSourceGradientSourceImageConvolutionTransposeGradientStateWeights(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSCNNConvolutionTransposeGradientStateNode, weights MPSCNNConvolutionDataSource) *MPSCNNConvolutionTransposeGradientNode

@abstract A node to represent the gradient calculation for convolution transpose training. @param sourceGradient The input gradient from the 'downstream' gradient filter. Often that is a neuron gradient filter node. @param sourceImage The input image from the forward convolution transpose node @param gradientState The gradient state from the forward convolution transpose @param weights The data source from the forward convolution transpose. It may not contain an integrated neuron. Similary, any normalization should be broken out into a separate node. Pass nil to use the weights from the forward convolution transpose pass. @return A MPSCNNConvolutionTransposeGradientNode

func (*MPSCNNConvolutionTransposeGradientNode) InitWithSourceGradientSourceImageConvolutionTransposeGradientStateWeights ¶

func (o *MPSCNNConvolutionTransposeGradientNode) InitWithSourceGradientSourceImageConvolutionTransposeGradientStateWeights(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSCNNConvolutionTransposeGradientStateNode, weights MPSCNNConvolutionDataSource) *MPSCNNConvolutionTransposeGradientNode

@abstract A node to represent the gradient calculation for convolution transpose training. @param sourceGradient The input gradient from the 'downstream' gradient filter. Often that is a neuron gradient filter node. @param sourceImage The input image from the forward convolution transpose node @param gradientState The gradient state from the forward convolution transpose @param weights The data source from the forward convolution transpose. It may not contain an integrated neuron. Similary, any normalization should be broken out into a separate node. Pass nil to use the weights from the forward convolution transpose pass. @return A MPSCNNConvolutionTransposeGradientNode

type MPSCNNConvolutionTransposeGradientState ¶

type MPSCNNConvolutionTransposeGradientState struct {
	MPSCNNConvolutionGradientState
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnconvolutiontransposegradientstate

func MPSCNNConvolutionTransposeGradientStateFromID ¶

func MPSCNNConvolutionTransposeGradientStateFromID(id objc.ID) *MPSCNNConvolutionTransposeGradientState

func (*MPSCNNConvolutionTransposeGradientState) ConvolutionTranspose ¶

@property convolutionTranspose @abstract The convolutionTranspose filter that produced the state.

type MPSCNNConvolutionTransposeNode ¶

type MPSCNNConvolutionTransposeNode struct {
	MPSCNNConvolutionNode
}

@abstract A MPSNNFilterNode representing a MPSCNNConvolutionTranspose kernel

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnconvolutiontransposenode

func MPSCNNConvolutionTransposeNodeFromID ¶

func MPSCNNConvolutionTransposeNodeFromID(id objc.ID) *MPSCNNConvolutionTransposeNode

func MPSCNNConvolutionTransposeNodeNodeWithSourceConvolutionGradientStateWeights ¶

func MPSCNNConvolutionTransposeNodeNodeWithSourceConvolutionGradientStateWeights(sourceNode *MPSNNImageNode, convolutionGradientState *MPSCNNConvolutionGradientStateNode, weights MPSCNNConvolutionDataSource) *MPSCNNConvolutionTransposeNode

@abstract Init an autoreleased not representing a MPSCNNConvolutionTransposeNode kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param convolutionGradientState When the convolution transpose is used to 'undo' an earlier convolution in the graph, it is generally desired that the output image be the same size as the input image to the earlier convolution. You may optionally specify this size identity by passing in the MPSNNConvolutionGradientStateNode created by the convolution node here. @param weights A pointer to a valid object conforming to the MPSCNNConvolutionDataSource protocol. This object is provided by you to encapsulate storage for convolution weights and biases. @return A new MPSNNFilter node for a MPSCNNConvolutionTransposeNode kernel.

func (*MPSCNNConvolutionTransposeNode) InitWithSourceConvolutionGradientStateWeights ¶

func (o *MPSCNNConvolutionTransposeNode) InitWithSourceConvolutionGradientStateWeights(sourceNode *MPSNNImageNode, convolutionGradientState *MPSCNNConvolutionGradientStateNode, weights MPSCNNConvolutionDataSource) *MPSCNNConvolutionTransposeNode

@abstract Init a node representing a MPSCNNConvolutionTransposeNode kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param convolutionGradientState When the convolution transpose is used to 'undo' an earlier convolution in the graph, it is generally desired that the output image be the same size as the input image to the earlier convolution. You may optionally specify this size identity by passing in the MPSCNNConvolutionGradientState node here. @param weights A pointer to a valid object conforming to the MPSCNNConvolutionDataSource protocol. This object is provided by you to encapsulate storage for convolution weights and biases. @return A new MPSNNFilter node for a MPSCNNConvolutionTransposeNode kernel.

type MPSCNNConvolutionWeightsAndBiasesState ¶

type MPSCNNConvolutionWeightsAndBiasesState struct {
	mpscore.MPSState
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnconvolutionweightsandbiasesstate

func MPSCNNConvolutionWeightsAndBiasesStateFromID ¶

func MPSCNNConvolutionWeightsAndBiasesStateFromID(id objc.ID) *MPSCNNConvolutionWeightsAndBiasesState

func MPSCNNConvolutionWeightsAndBiasesStateTemporaryCNNConvolutionWeightsAndBiasesStateWithCommandBufferCnnConvolutionDescriptor ¶

func MPSCNNConvolutionWeightsAndBiasesStateTemporaryCNNConvolutionWeightsAndBiasesStateWithCommandBufferCnnConvolutionDescriptor(commandBuffer metal.MTLCommandBuffer, descriptor *MPSCNNConvolutionDescriptor) *MPSCNNConvolutionWeightsAndBiasesState

func (*MPSCNNConvolutionWeightsAndBiasesState) Biases ¶

@property biases @abstract A buffer that contains the biases. Each value is float and there are ouputFeatureChannels values.

func (*MPSCNNConvolutionWeightsAndBiasesState) BiasesOffset ¶

func (o *MPSCNNConvolutionWeightsAndBiasesState) BiasesOffset() uint

@property biasesOffset @discussion Offset at which weights start in biases buffer Default value is 0.

func (*MPSCNNConvolutionWeightsAndBiasesState) InitWithDeviceCnnConvolutionDescriptor ¶

@abstract Create and initialize MPSCNNConvolutionWeightsAndBiasesState with application provided convolution descriptor @discussion Create weights and biases buffers of appropriate size

func (*MPSCNNConvolutionWeightsAndBiasesState) InitWithWeightsBiases ¶

@abstract Create and initialize MPSCNNConvolutionWeightsAndBiasesState with application provided weights and biases buffers. @discussion This is the convinience API when buffers of exact size i.e. [weights length] = inputFeatureChannels*kernelWidth*kernelHeight*channelMultiplier*sizeof(float) // for depthwise convolution outputFeatureChannels*kernelWidth*kernelHeight*(inputChannels/groups)*sizeof(float) // for regular otherwise and [biases length] = outputFeatureChannels*sizeof(float)

func (*MPSCNNConvolutionWeightsAndBiasesState) InitWithWeightsWeightsOffsetBiasesBiasesOffsetCnnConvolutionDescriptor ¶

func (o *MPSCNNConvolutionWeightsAndBiasesState) InitWithWeightsWeightsOffsetBiasesBiasesOffsetCnnConvolutionDescriptor(weights metal.MTLBuffer, weightsOffset uint, biases metal.MTLBuffer, biasesOffset uint, descriptor *MPSCNNConvolutionDescriptor) *MPSCNNConvolutionWeightsAndBiasesState

@abstract Create and initialize MPSCNNConvolutionWeightsAndBiasesState with application provided weights and biases buffers. @discussion It gives finer allocation control to application e.g. application can pass same buffer for weights and biases with appropriate offsets. Or offset into some larger buffer from application managed heap etc. Number of weights and biases or the length of weights and biases buffer this object owns (will read or write to), starting at offset is determined by MPSCNNConvolutionDescriptor passed in. weightsLength = inputFeatureChannels*kernelWidth*kernelHeight*channelMultiplier*sizeof(float) // for depthwise convolution outputFeatureChannels*kernelWidth*kernelHeight*(inputChannels/groups)*sizeof(float) // for regular otherwise biasesLength = outputFeatureChannels*sizeof(float) Thus filters operating on this object will read or write to NSRange(weightsOffset, weightsLength) of weights buffer and NSRange(biasesOffset, biasesLength) of biases buffer. Thus sizes of buffers provided must be such that weightsOffset + weightsLength <= [weights length] and biasesOffset + biasesLength <= [biases length] Offsets must of sizeof(float) aligned i.e. multiple of 4.

func (*MPSCNNConvolutionWeightsAndBiasesState) Weights ¶

@property weights @abstract A buffer that contains the weights. Each value in the buffer is a float. The layout of the weights with respect to the weights is the same as the weights layout provided by data source i.e. it can be interpreted as 4D array weights[outputFeatureChannels][kernelHeight][kernelWidth]inputFeatureChannels/groups for regular convolution. For depthwise convolution weights[outputFeatureChannels][kernelHeight][kernelWidth] as we currently only support channel multiplier of 1.

func (*MPSCNNConvolutionWeightsAndBiasesState) WeightsOffset ¶

func (o *MPSCNNConvolutionWeightsAndBiasesState) WeightsOffset() uint

@property weightsOffset @discussion Offset at which weights start in weights buffer Default value is 0.

type MPSCNNConvolutionWeightsLayout ¶

type MPSCNNConvolutionWeightsLayout int64
const (
	MPSCNNConvolutionWeightsLayoutOHWI MPSCNNConvolutionWeightsLayout = 0
)

func (MPSCNNConvolutionWeightsLayout) String ¶

type MPSCNNCrossChannelNormalization ¶

type MPSCNNCrossChannelNormalization struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnncrosschannelnormalization

func MPSCNNCrossChannelNormalizationFromID ¶

func MPSCNNCrossChannelNormalizationFromID(id objc.ID) *MPSCNNCrossChannelNormalization

func (*MPSCNNCrossChannelNormalization) Alpha ¶

@property alpha @abstract The value of alpha. Default is 1.0. Must be non-negative.

func (*MPSCNNCrossChannelNormalization) Beta ¶

@property beta @abstract The value of beta. Default is 5.0

func (*MPSCNNCrossChannelNormalization) Delta ¶

@property delta @abstract The value of delta. Default is 1.0

func (*MPSCNNCrossChannelNormalization) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNCrossChannelNormalization) InitWithDeviceKernelSize ¶

func (o *MPSCNNCrossChannelNormalization) InitWithDeviceKernelSize(device metal.MTLDevice, kernelSize uint) *MPSCNNCrossChannelNormalization

@abstract Initialize a local response normalization filter in a channel @param device The device the filter will run on @param kernelSize The kernel filter size in each dimension. @return A valid MPSCNNCrossChannelNormalization object or nil, if failure.

func (*MPSCNNCrossChannelNormalization) KernelSize ¶

func (o *MPSCNNCrossChannelNormalization) KernelSize() uint

@property kernelSize @abstract The size of the square filter window. Default is 5

func (*MPSCNNCrossChannelNormalization) SetAlpha ¶

func (o *MPSCNNCrossChannelNormalization) SetAlpha(alpha float32)

func (*MPSCNNCrossChannelNormalization) SetBeta ¶

func (o *MPSCNNCrossChannelNormalization) SetBeta(beta float32)

func (*MPSCNNCrossChannelNormalization) SetDelta ¶

func (o *MPSCNNCrossChannelNormalization) SetDelta(delta float32)

type MPSCNNCrossChannelNormalizationGradient ¶

type MPSCNNCrossChannelNormalizationGradient struct {
	MPSCNNGradientKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnncrosschannelnormalizationgradient

func MPSCNNCrossChannelNormalizationGradientFromID ¶

func MPSCNNCrossChannelNormalizationGradientFromID(id objc.ID) *MPSCNNCrossChannelNormalizationGradient

func (*MPSCNNCrossChannelNormalizationGradient) Alpha ¶

@property alpha @abstract The value of alpha. Default is 1.0. Must be non-negative.

func (*MPSCNNCrossChannelNormalizationGradient) Beta ¶

@property beta @abstract The value of beta. Default is 5.0

func (*MPSCNNCrossChannelNormalizationGradient) Delta ¶

@property delta @abstract The value of delta. Default is 1.0

func (*MPSCNNCrossChannelNormalizationGradient) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNCrossChannelNormalizationGradient) InitWithDeviceKernelSize ¶

@abstract Initialize a cross channel normalization gradient filter @param device The device the filter will run on @param kernelSize The kernel filter size in each dimension. @return A valid MPSCNNCrossChannelNormalization object or nil, if failure.

func (*MPSCNNCrossChannelNormalizationGradient) KernelSize ¶

@property kernelSize @abstract The size of the square filter window. Default is 5

func (*MPSCNNCrossChannelNormalizationGradient) SetAlpha ¶

func (*MPSCNNCrossChannelNormalizationGradient) SetBeta ¶

func (*MPSCNNCrossChannelNormalizationGradient) SetDelta ¶

type MPSCNNCrossChannelNormalizationGradientNode ¶

type MPSCNNCrossChannelNormalizationGradientNode struct {
	MPSNNGradientFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnncrosschannelnormalizationgradientnode

func MPSCNNCrossChannelNormalizationGradientNodeFromID ¶

func MPSCNNCrossChannelNormalizationGradientNodeFromID(id objc.ID) *MPSCNNCrossChannelNormalizationGradientNode

func MPSCNNCrossChannelNormalizationGradientNodeNodeWithSourceGradientSourceImageGradientStateKernelSize ¶

func MPSCNNCrossChannelNormalizationGradientNodeNodeWithSourceGradientSourceImageGradientStateKernelSize(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, kernelSize uint) *MPSCNNCrossChannelNormalizationGradientNode

func (*MPSCNNCrossChannelNormalizationGradientNode) InitWithSourceGradientSourceImageGradientStateKernelSize ¶

func (o *MPSCNNCrossChannelNormalizationGradientNode) InitWithSourceGradientSourceImageGradientStateKernelSize(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, kernelSize uint) *MPSCNNCrossChannelNormalizationGradientNode

func (*MPSCNNCrossChannelNormalizationGradientNode) KernelSize ¶

type MPSCNNCrossChannelNormalizationNode ¶

type MPSCNNCrossChannelNormalizationNode struct {
	MPSCNNNormalizationNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnncrosschannelnormalizationnode

func MPSCNNCrossChannelNormalizationNodeFromID ¶

func MPSCNNCrossChannelNormalizationNodeFromID(id objc.ID) *MPSCNNCrossChannelNormalizationNode

func MPSCNNCrossChannelNormalizationNodeNodeWithSourceKernelSize ¶

func MPSCNNCrossChannelNormalizationNodeNodeWithSourceKernelSize(sourceNode *MPSNNImageNode, kernelSize uint) *MPSCNNCrossChannelNormalizationNode

func (*MPSCNNCrossChannelNormalizationNode) InitWithSource ¶

func (*MPSCNNCrossChannelNormalizationNode) InitWithSourceKernelSize ¶

func (o *MPSCNNCrossChannelNormalizationNode) InitWithSourceKernelSize(sourceNode *MPSNNImageNode, kernelSize uint) *MPSCNNCrossChannelNormalizationNode

func (*MPSCNNCrossChannelNormalizationNode) KernelSizeInFeatureChannels ¶

func (o *MPSCNNCrossChannelNormalizationNode) KernelSizeInFeatureChannels() uint

func (*MPSCNNCrossChannelNormalizationNode) SetKernelSizeInFeatureChannels ¶

func (o *MPSCNNCrossChannelNormalizationNode) SetKernelSizeInFeatureChannels(kernelSizeInFeatureChannels uint)

type MPSCNNDepthWiseConvolutionDescriptor ¶

type MPSCNNDepthWiseConvolutionDescriptor struct {
	MPSCNNConvolutionDescriptor
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnndepthwiseconvolutiondescriptor

func MPSCNNDepthWiseConvolutionDescriptorFromID ¶

func MPSCNNDepthWiseConvolutionDescriptorFromID(id objc.ID) *MPSCNNDepthWiseConvolutionDescriptor

func (*MPSCNNDepthWiseConvolutionDescriptor) ChannelMultiplier ¶

func (o *MPSCNNDepthWiseConvolutionDescriptor) ChannelMultiplier() uint

@property channelMultiplier @discussion Ratio of outputFeactureChannel to inputFeatureChannels for depthwise convolution i.e. how many output feature channels are produced by each input channel.

type MPSCNNDilatedPoolingMax ¶

type MPSCNNDilatedPoolingMax struct {
	MPSCNNPooling
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnndilatedpoolingmax

func MPSCNNDilatedPoolingMaxFromID ¶

func MPSCNNDilatedPoolingMaxFromID(id objc.ID) *MPSCNNDilatedPoolingMax

func (*MPSCNNDilatedPoolingMax) InitWithCoderDevice ¶

func (o *MPSCNNDilatedPoolingMax) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNDilatedPoolingMax

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel.h initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNDilatedPoolingMax @param device The MTLDevice on which to make the MPSCNNDilatedPoolingMax @return A new MPSCNNDilatedPoolingMax object, or nil if failure.

func (*MPSCNNDilatedPoolingMax) InitWithDeviceKernelWidthKernelHeightDilationRateXDilationRateYStrideInPixelsXStrideInPixelsY ¶

func (o *MPSCNNDilatedPoolingMax) InitWithDeviceKernelWidthKernelHeightDilationRateXDilationRateYStrideInPixelsXStrideInPixelsY(device metal.MTLDevice, kernelWidth uint, kernelHeight uint, dilationRateX uint, dilationRateY uint, strideInPixelsX uint, strideInPixelsY uint) *MPSCNNDilatedPoolingMax

@abstract Initialize a MPSCNNDilatedPoolingMax pooling filter @param device The device the filter will run on @param kernelWidth The width of the kernel. Can be an odd or even value. @param kernelHeight The height of the kernel. Can be an odd or even value. @param dilationRateX The dilation rate in the x dimension. @param dilationRateY The dilation rate in the y dimension. @param strideInPixelsX The output stride (downsampling factor) in the x dimension. @param strideInPixelsY The output stride (downsampling factor) in the y dimension. @return A valid MPSCNNDilatedPoolingMax object or nil, if failure.

type MPSCNNDilatedPoolingMaxGradient ¶

type MPSCNNDilatedPoolingMaxGradient struct {
	MPSCNNPoolingGradient
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnndilatedpoolingmaxgradient

func MPSCNNDilatedPoolingMaxGradientFromID ¶

func MPSCNNDilatedPoolingMaxGradientFromID(id objc.ID) *MPSCNNDilatedPoolingMaxGradient

func (*MPSCNNDilatedPoolingMaxGradient) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPoolingMaxGradient @param device The MTLDevice on which to make the MPSCNNPoolingMaxGradient @return A new MPSCNNPoolingMaxGradient object, or nil if failure.

func (*MPSCNNDilatedPoolingMaxGradient) InitWithDeviceKernelWidthKernelHeightDilationRateXDilationRateYStrideInPixelsXStrideInPixelsY ¶

func (o *MPSCNNDilatedPoolingMaxGradient) InitWithDeviceKernelWidthKernelHeightDilationRateXDilationRateYStrideInPixelsXStrideInPixelsY(device metal.MTLDevice, kernelWidth uint, kernelHeight uint, dilationRateX uint, dilationRateY uint, strideInPixelsX uint, strideInPixelsY uint) *MPSCNNDilatedPoolingMaxGradient

@abstract Initialize a MPSCNNDilatedPoolingMaxGradient pooling filter @param device The device the filter will run on @param kernelWidth The width of the kernel. Can be an odd or even value. @param kernelHeight The height of the kernel. Can be an odd or even value. @param dilationRateX The dilation rate in the x dimension. @param dilationRateY The dilation rate in the y dimension. @param strideInPixelsX The output stride (downsampling factor) in the x dimension. @param strideInPixelsY The output stride (downsampling factor) in the y dimension. @return A valid MPSCNNDilatedPoolingMax object or nil, if failure.

type MPSCNNDilatedPoolingMaxGradientNode ¶

type MPSCNNDilatedPoolingMaxGradientNode struct {
	MPSCNNPoolingGradientNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnndilatedpoolingmaxgradientnode

func MPSCNNDilatedPoolingMaxGradientNodeFromID ¶

func MPSCNNDilatedPoolingMaxGradientNodeFromID(id objc.ID) *MPSCNNDilatedPoolingMaxGradientNode

func MPSCNNDilatedPoolingMaxGradientNodeNodeWithSourceGradientSourceImageGradientStateKernelWidthKernelHeightStrideInPixelsXStrideInPixelsYDilationRateXDilationRateY ¶

func MPSCNNDilatedPoolingMaxGradientNodeNodeWithSourceGradientSourceImageGradientStateKernelWidthKernelHeightStrideInPixelsXStrideInPixelsYDilationRateXDilationRateY(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, kernelWidth uint, kernelHeight uint, strideInPixelsX uint, strideInPixelsY uint, dilationRateX uint, dilationRateY uint) *MPSCNNDilatedPoolingMaxGradientNode

@abstract make a pooling gradient node @discussion It would be much easier to use [inferencePoolingNode gradientNodeForSourceGradient:] instead. @param sourceGradient The gradient from the downstream gradient filter. @param sourceImage The input image to the inference pooling filter @param gradientState The gradient state produced by the inference poolin filter @param kernelWidth The kernel width of the inference filter @param kernelHeight The kernel height of the inference filter @param strideInPixelsX The X stride from the inference filter @param strideInPixelsY The Y stride from the inference filter

func (*MPSCNNDilatedPoolingMaxGradientNode) DilationRateX ¶

func (o *MPSCNNDilatedPoolingMaxGradientNode) DilationRateX() uint

func (*MPSCNNDilatedPoolingMaxGradientNode) DilationRateY ¶

func (o *MPSCNNDilatedPoolingMaxGradientNode) DilationRateY() uint

func (*MPSCNNDilatedPoolingMaxGradientNode) InitWithSourceGradientSourceImageGradientStateKernelWidthKernelHeightStrideInPixelsXStrideInPixelsYDilationRateXDilationRateY ¶

func (o *MPSCNNDilatedPoolingMaxGradientNode) InitWithSourceGradientSourceImageGradientStateKernelWidthKernelHeightStrideInPixelsXStrideInPixelsYDilationRateXDilationRateY(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, kernelWidth uint, kernelHeight uint, strideInPixelsX uint, strideInPixelsY uint, dilationRateX uint, dilationRateY uint) *MPSCNNDilatedPoolingMaxGradientNode

@abstract make a pooling gradient node @discussion It would be much easier to use [inferencePoolingNode gradientNodeForSourceGradient:] instead. @param sourceGradient The gradient from the downstream gradient filter. @param sourceImage The input image to the inference pooling filter @param gradientState The gradient state produced by the inference poolin filter @param kernelWidth The kernel width of the inference filter @param kernelHeight The kernel height of the inference filter @param strideInPixelsX The X stride from the inference filter @param strideInPixelsY The Y stride from the inference filter

type MPSCNNDilatedPoolingMaxNode ¶

type MPSCNNDilatedPoolingMaxNode struct {
	MPSNNFilterNode
}

@abstract A node for a MPSCNNDilatedPooling kernel @discussion This class corresponds to the MPSCNNDilatedPooling class.

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnndilatedpoolingmaxnode

func MPSCNNDilatedPoolingMaxNodeFromID ¶

func MPSCNNDilatedPoolingMaxNodeFromID(id objc.ID) *MPSCNNDilatedPoolingMaxNode

func MPSCNNDilatedPoolingMaxNodeNodeWithSourceFilterSize ¶

func MPSCNNDilatedPoolingMaxNodeNodeWithSourceFilterSize(sourceNode *MPSNNImageNode, size uint) *MPSCNNDilatedPoolingMaxNode

@abstract Convenience initializer for MPSCNNDilatedPooling nodes with square non-overlapping kernels @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param size kernelWidth = kernelHeight = strideInPixelsX = strideInPixelsY = dilationRateX = dilationRateY = size @return A new MPSNNFilter node for a MPSCNNDilatedPooling kernel.

func MPSCNNDilatedPoolingMaxNodeNodeWithSourceFilterSizeStrideDilationRate ¶

func MPSCNNDilatedPoolingMaxNodeNodeWithSourceFilterSizeStrideDilationRate(sourceNode *MPSNNImageNode, size uint, stride uint, dilationRate uint) *MPSCNNDilatedPoolingMaxNode

@abstract Convenience initializer for MPSCNNDilatedPooling nodes with square kernels and equal dilation factors @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param size kernelWidth = kernelHeight = size @param stride strideInPixelsX = strideInPixelsY = stride @param dilationRate dilationRateX = dilationRateY = stride @return A new MPSNNFilter node for a MPSCNNDilatedPooling kernel.

func (*MPSCNNDilatedPoolingMaxNode) DilationRateX ¶

func (o *MPSCNNDilatedPoolingMaxNode) DilationRateX() uint

func (*MPSCNNDilatedPoolingMaxNode) DilationRateY ¶

func (o *MPSCNNDilatedPoolingMaxNode) DilationRateY() uint

func (*MPSCNNDilatedPoolingMaxNode) InitWithSourceFilterSize ¶

func (o *MPSCNNDilatedPoolingMaxNode) InitWithSourceFilterSize(sourceNode *MPSNNImageNode, size uint) *MPSCNNDilatedPoolingMaxNode

@abstract Convenience initializer for MPSCNNDilatedPooling nodes with square non-overlapping kernels @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param size kernelWidth = kernelHeight = strideInPixelsX = strideInPixelsY = dilationRateX = dilationRateY = size @return A new MPSNNFilter node for a MPSCNNDilatedPooling kernel.

func (*MPSCNNDilatedPoolingMaxNode) InitWithSourceFilterSizeStrideDilationRate ¶

func (o *MPSCNNDilatedPoolingMaxNode) InitWithSourceFilterSizeStrideDilationRate(sourceNode *MPSNNImageNode, size uint, stride uint, dilationRate uint) *MPSCNNDilatedPoolingMaxNode

@abstract Convenience initializer for MPSCNNDilatedPooling nodes with square kernels and equal dilation factors @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param size kernelWidth = kernelHeight = size @param stride strideInPixelsX = strideInPixelsY = stride @param dilationRate dilationRateX = dilationRateY = stride @return A new MPSNNFilter node for a MPSCNNDilatedPooling kernel.

func (*MPSCNNDilatedPoolingMaxNode) InitWithSourceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsYDilationRateXDilationRateY ¶

func (o *MPSCNNDilatedPoolingMaxNode) InitWithSourceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsYDilationRateXDilationRateY(sourceNode *MPSNNImageNode, kernelWidth uint, kernelHeight uint, strideInPixelsX uint, strideInPixelsY uint, dilationRateX uint, dilationRateY uint) *MPSCNNDilatedPoolingMaxNode

@abstract Init a node representing a MPSCNNPooling kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param kernelWidth The width of the max filter window @param kernelHeight The height of the max filter window @param strideInPixelsX The output stride (downsampling factor) in the x dimension. @param strideInPixelsY The output stride (downsampling factor) in the y dimension. @param dilationRateX The dilation factor in the x dimension. @param dilationRateY The dilation factor in the y dimension. @return A new MPSNNFilter node for a MPSCNNPooling kernel.

type MPSCNNDivide ¶

type MPSCNNDivide struct {
	MPSCNNArithmetic
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnndivide

func MPSCNNDivideFromID ¶

func MPSCNNDivideFromID(id objc.ID) *MPSCNNDivide

func (*MPSCNNDivide) InitWithDevice ¶

func (o *MPSCNNDivide) InitWithDevice(device metal.MTLDevice) *MPSCNNDivide

@abstract Initialize the division operator @param device The device the filter will run on. @return A valid MPSCNNDivide object or nil, if failure.

type MPSCNNDropout ¶

type MPSCNNDropout struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnndropout

func MPSCNNDropoutFromID ¶

func MPSCNNDropoutFromID(id objc.ID) *MPSCNNDropout

func (*MPSCNNDropout) InitWithCoderDevice ¶

func (o *MPSCNNDropout) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNDropout

@abstract <NSSecureCoding> support

func (*MPSCNNDropout) InitWithDeviceKeepProbabilitySeedMaskStrideInPixels ¶

func (o *MPSCNNDropout) InitWithDeviceKeepProbabilitySeedMaskStrideInPixels(device metal.MTLDevice, keepProbability float32, seed uint, maskStrideInPixels metal.MTLSize) *MPSCNNDropout

@abstract Standard init with default properties per filter type. @param device The device that the filter will be used on. @param keepProbability The probability that each element in the input is kept. The valid range is (0.0f, 1.0f). @param seed The seed used to generate random numbers. @param maskStrideInPixels The mask stride in the x, y, and z dimensions, which allows for the broadcasting of mask data. The only valid values are 0 and 1 for each dimension. For no broadcasting, set the values for each dimension to 1. For broadcasting, set desired values to 0. @result A valid MPSCNNDropout object or nil, if failure.

func (*MPSCNNDropout) KeepProbability ¶

func (o *MPSCNNDropout) KeepProbability() float32

@property keepProbability @abstract The probability that each element in the input is kept. The valid range is (0.0f, 1.0f).

func (*MPSCNNDropout) MaskStrideInPixels ¶

func (o *MPSCNNDropout) MaskStrideInPixels() metal.MTLSize

@property maskStrideInPixels @abstract The mask stride in the x, y, and x dimensions, which allows for the broadcasting the mask data. @discussion The only valid values are 0 and 1 for each dimension. For no broadcasting, set the values for each dimension to 1. For broadcasting, set desired values to 0.

func (*MPSCNNDropout) Seed ¶

func (o *MPSCNNDropout) Seed() uint

@property seed @abstract The seed used to generate random numbers.

type MPSCNNDropoutGradient ¶

type MPSCNNDropoutGradient struct {
	MPSCNNGradientKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnndropoutgradient

func MPSCNNDropoutGradientFromID ¶

func MPSCNNDropoutGradientFromID(id objc.ID) *MPSCNNDropoutGradient

func (*MPSCNNDropoutGradient) InitWithCoderDevice ¶

func (o *MPSCNNDropoutGradient) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNDropoutGradient

@abstract <NSSecureCoding> support

func (*MPSCNNDropoutGradient) InitWithDeviceKeepProbabilitySeedMaskStrideInPixels ¶

func (o *MPSCNNDropoutGradient) InitWithDeviceKeepProbabilitySeedMaskStrideInPixels(device metal.MTLDevice, keepProbability float32, seed uint, maskStrideInPixels metal.MTLSize) *MPSCNNDropoutGradient

@abstract Standard init with default properties per filter type. @param device The device that the filter will be used on. @param keepProbability The probability that each element in the input is kept. The valid range is (0.0f, 1.0f). @param seed The seed used to generate random numbers. @param maskStrideInPixels The mask stride in the x, y, and z dimensions, which allows for the broadcasting of mask data. The only valid values are 0 and 1 for each dimension. For no broadcasting, set the values for each dimension to 1. For broadcasting, set desired values to 0. @result A valid MPSCNNDropoutGradient object or nil, if failure.

func (*MPSCNNDropoutGradient) KeepProbability ¶

func (o *MPSCNNDropoutGradient) KeepProbability() float32

@property keepProbability @abstract The probability that each element in the input is kept. The valid range is (0.0f, 1.0f).

func (*MPSCNNDropoutGradient) MaskStrideInPixels ¶

func (o *MPSCNNDropoutGradient) MaskStrideInPixels() metal.MTLSize

@property maskStrideInPixels @abstract The mask stride in the x, y, and x dimensions, which allows for the broadcasting the mask data. @discussion The only valid values are 0 and 1 for each dimension. For no broadcasting, set the values for each dimension to 1. For broadcasting, set desired values to 0.

func (*MPSCNNDropoutGradient) Seed ¶

func (o *MPSCNNDropoutGradient) Seed() uint

@property seed @abstract The seed used to generate random numbers.

type MPSCNNDropoutGradientNode ¶

type MPSCNNDropoutGradientNode struct {
	MPSNNGradientFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnndropoutgradientnode

func MPSCNNDropoutGradientNodeFromID ¶

func MPSCNNDropoutGradientNodeFromID(id objc.ID) *MPSCNNDropoutGradientNode

func MPSCNNDropoutGradientNodeNodeWithSourceGradientSourceImageGradientStateKeepProbabilitySeedMaskStrideInPixels ¶

func MPSCNNDropoutGradientNodeNodeWithSourceGradientSourceImageGradientStateKeepProbabilitySeedMaskStrideInPixels(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, keepProbability float32, seed uint, maskStrideInPixels metal.MTLSize) *MPSCNNDropoutGradientNode

@abstract create a new dropout gradient node @discussion See also -[MPSCNNNeuronNode gradientFilterNodeWithSources:] for an easier way to do this

func (*MPSCNNDropoutGradientNode) InitWithSourceGradientSourceImageGradientStateKeepProbabilitySeedMaskStrideInPixels ¶

func (o *MPSCNNDropoutGradientNode) InitWithSourceGradientSourceImageGradientStateKeepProbabilitySeedMaskStrideInPixels(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, keepProbability float32, seed uint, maskStrideInPixels metal.MTLSize) *MPSCNNDropoutGradientNode

@abstract create a new dropout gradient node @discussion See also -[MPSCNNNeuronNode gradientFilterNodeWithSources:] for an easier way to do this

func (*MPSCNNDropoutGradientNode) KeepProbability ¶

func (o *MPSCNNDropoutGradientNode) KeepProbability() float32

func (*MPSCNNDropoutGradientNode) MaskStrideInPixels ¶

func (o *MPSCNNDropoutGradientNode) MaskStrideInPixels() metal.MTLSize

func (*MPSCNNDropoutGradientNode) Seed ¶

func (o *MPSCNNDropoutGradientNode) Seed() uint

type MPSCNNDropoutGradientState ¶

type MPSCNNDropoutGradientState struct {
	MPSNNGradientState
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnndropoutgradientstate

func MPSCNNDropoutGradientStateFromID ¶

func MPSCNNDropoutGradientStateFromID(id objc.ID) *MPSCNNDropoutGradientState

func (*MPSCNNDropoutGradientState) MaskData ¶

@abstract Mask data accessor method. @return An autoreleased NSData object, containing the mask data. The mask data is populated in the -encode call, thus the contents are undefined until you -encode the filter. Use for debugging purposes only. In order to gaurantee that the mask data is correctly synchronized for CPU side access, it is the application's responsibility to call the [gradientState synchronizeOnCommandBuffer:] method before accessing the mask data.

type MPSCNNDropoutNode ¶

type MPSCNNDropoutNode struct {
	MPSNNFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnndropoutnode

func MPSCNNDropoutNodeFromID ¶

func MPSCNNDropoutNodeFromID(id objc.ID) *MPSCNNDropoutNode

func MPSCNNDropoutNodeNodeWithSource ¶

func MPSCNNDropoutNodeNodeWithSource(source *MPSNNImageNode) *MPSCNNDropoutNode

func MPSCNNDropoutNodeNodeWithSourceKeepProbability ¶

func MPSCNNDropoutNodeNodeWithSourceKeepProbability(source *MPSNNImageNode, keepProbability float32) *MPSCNNDropoutNode

func MPSCNNDropoutNodeNodeWithSourceKeepProbabilitySeedMaskStrideInPixels ¶

func MPSCNNDropoutNodeNodeWithSourceKeepProbabilitySeedMaskStrideInPixels(source *MPSNNImageNode, keepProbability float32, seed uint, maskStrideInPixels metal.MTLSize) *MPSCNNDropoutNode

func (*MPSCNNDropoutNode) InitWithSource ¶

func (o *MPSCNNDropoutNode) InitWithSource(source *MPSNNImageNode) *MPSCNNDropoutNode

func (*MPSCNNDropoutNode) InitWithSourceKeepProbability ¶

func (o *MPSCNNDropoutNode) InitWithSourceKeepProbability(source *MPSNNImageNode, keepProbability float32) *MPSCNNDropoutNode

func (*MPSCNNDropoutNode) InitWithSourceKeepProbabilitySeedMaskStrideInPixels ¶

func (o *MPSCNNDropoutNode) InitWithSourceKeepProbabilitySeedMaskStrideInPixels(source *MPSNNImageNode, keepProbability float32, seed uint, maskStrideInPixels metal.MTLSize) *MPSCNNDropoutNode

func (*MPSCNNDropoutNode) KeepProbability ¶

func (o *MPSCNNDropoutNode) KeepProbability() float32

func (*MPSCNNDropoutNode) MaskStrideInPixels ¶

func (o *MPSCNNDropoutNode) MaskStrideInPixels() metal.MTLSize

func (*MPSCNNDropoutNode) Seed ¶

func (o *MPSCNNDropoutNode) Seed() uint

type MPSCNNFullyConnected ¶

type MPSCNNFullyConnected struct {
	MPSCNNConvolution
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnfullyconnected

func MPSCNNFullyConnectedFromID ¶

func MPSCNNFullyConnectedFromID(id objc.ID) *MPSCNNFullyConnected

func (*MPSCNNFullyConnected) InitWithCoderDevice ¶

func (o *MPSCNNFullyConnected) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNFullyConnected

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNFullyConnected) InitWithDeviceWeights ¶

func (o *MPSCNNFullyConnected) InitWithDeviceWeights(device metal.MTLDevice, weights MPSCNNConvolutionDataSource) *MPSCNNFullyConnected

@abstract Initializes a fully connected kernel @param device The MTLDevice on which this MPSCNNFullyConnected filter will be used @param weights 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. @return A valid MPSCNNFullyConnected object or nil, if failure.

type MPSCNNFullyConnectedGradient ¶

type MPSCNNFullyConnectedGradient struct {
	MPSCNNConvolutionGradient
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnfullyconnectedgradient

func MPSCNNFullyConnectedGradientFromID ¶

func MPSCNNFullyConnectedGradientFromID(id objc.ID) *MPSCNNFullyConnectedGradient

func (*MPSCNNFullyConnectedGradient) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNFullyConnectedGradient) InitWithDeviceWeights ¶

@abstract Initializes a convolution gradient (with respect to weights and bias) object. @param device The MTLDevice on which this MPSCNNConvolutionGradient filter will be used @param weights A pointer to a object that conforms to the MPSCNNConvolutionDataSource protocol. Note that same data source as provided to forward convolution should be used. @return A valid MPSCNNConvolutionGradient object or nil, if failure.

type MPSCNNFullyConnectedGradientNode ¶

type MPSCNNFullyConnectedGradientNode struct {
	MPSCNNConvolutionGradientNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnfullyconnectedgradientnode

func MPSCNNFullyConnectedGradientNodeFromID ¶

func MPSCNNFullyConnectedGradientNodeFromID(id objc.ID) *MPSCNNFullyConnectedGradientNode

func MPSCNNFullyConnectedGradientNodeNodeWithSourceGradientSourceImageConvolutionGradientStateWeights ¶

func MPSCNNFullyConnectedGradientNodeNodeWithSourceGradientSourceImageConvolutionGradientStateWeights(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSCNNConvolutionGradientStateNode, weights MPSCNNConvolutionDataSource) *MPSCNNFullyConnectedGradientNode

@abstract A node to represent the gradient calculation for fully connected training. @param sourceGradient The input gradient from the 'downstream' gradient filter. Often that is a neuron gradient filter node. @param sourceImage The input image from the forward fully connected node @param gradientState The gradient state from the forward fully connected @param weights The data source from the forward fully connected. It may not contain an integrated neuron. Similary, any normalization should be broken out into a separate node. Pass nil to use the weights from the forward fully connected pass. @return A MPSCNNFullyConnectedGradientNode

func (*MPSCNNFullyConnectedGradientNode) InitWithSourceGradientSourceImageConvolutionGradientStateWeights ¶

func (o *MPSCNNFullyConnectedGradientNode) InitWithSourceGradientSourceImageConvolutionGradientStateWeights(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSCNNConvolutionGradientStateNode, weights MPSCNNConvolutionDataSource) *MPSCNNFullyConnectedGradientNode

@abstract A node to represent the gradient calculation for fully connectd training. @param sourceGradient The input gradient from the 'downstream' gradient filter. Often that is a neuron gradient filter node. @param sourceImage The input image from the forward fully connected node @param gradientState The gradient state from the forward fully connected @param weights The data source from the forward fully connected. It may not contain an integrated neuron. Similary, any normalization should be broken out into a separate node. Pass nil to use the weights from the forward convolution pass. @return A MPSCNNFullyConnectedGradientNode

type MPSCNNFullyConnectedNode ¶

type MPSCNNFullyConnectedNode struct {
	MPSCNNConvolutionNode
}

@abstract A MPSNNFilterNode representing a MPSCNNFullyConnected kernel

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnfullyconnectednode

func MPSCNNFullyConnectedNodeFromID ¶

func MPSCNNFullyConnectedNodeFromID(id objc.ID) *MPSCNNFullyConnectedNode

func MPSCNNFullyConnectedNodeNodeWithSourceWeights ¶

func MPSCNNFullyConnectedNodeNodeWithSourceWeights(sourceNode *MPSNNImageNode, weights MPSCNNConvolutionDataSource) *MPSCNNFullyConnectedNode

@abstract Init an autoreleased not representing a MPSCNNFullyConnected kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param weights A pointer to a valid object conforming to the MPSCNNConvolutionDataSource protocol. This object is provided by you to encapsulate storage for convolution weights and biases. @return A new MPSNNFilter node for a MPSCNNConvolution kernel.

func (*MPSCNNFullyConnectedNode) InitWithSourceWeights ¶

func (o *MPSCNNFullyConnectedNode) InitWithSourceWeights(sourceNode *MPSNNImageNode, weights MPSCNNConvolutionDataSource) *MPSCNNFullyConnectedNode

@abstract Init a node representing a MPSCNNFullyConnected kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param weights A pointer to a valid object conforming to the MPSCNNConvolutionDataSource protocol. This object is provided by you to encapsulate storage for convolution weights and biases. @return A new MPSNNFilter node for a MPSCNNFullyConnected kernel.

type MPSCNNGradientKernel ¶

type MPSCNNGradientKernel struct {
	MPSCNNBinaryKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnngradientkernel

func MPSCNNGradientKernelFromID ¶

func MPSCNNGradientKernelFromID(id objc.ID) *MPSCNNGradientKernel

func (*MPSCNNGradientKernel) EncodeBatchToCommandBufferSourceGradientsSourceImagesGradientStates ¶

func (o *MPSCNNGradientKernel) EncodeBatchToCommandBufferSourceGradientsSourceImagesGradientStates(commandBuffer metal.MTLCommandBuffer, sourceGradients unsafe.Pointer, sourceImages unsafe.Pointer, gradientStates unsafe.Pointer) unsafe.Pointer

@abstract Encode a gradient filter and return a gradient @discussion During training, gradient filters are used to calculate the gradient associated with the loss for each feature channel in the forward pass source image. For those nodes that are trainable, these are then used to refine the value used in the trainable parameter. They consume a source gradient image which contains the gradients corresponding with the forward pass destination image, and calculate the gradients corresponding to the forward pass source image. A gradient filter consumes a MPSNNGradientState object which captured various forward pass properties such as offset and edgeMode at the time the forward pass was encoded. These are transferred to the MPSCNNBinaryKernel secondary image properties automatically when this method creates its destination image. @param commandBuffer The MTLCommandBuffer on which to encode @param sourceGradients The gradient images from the "next" filter in the graph @param sourceImages The images used as source image from the forward pass @param gradientStates The MPSNNGradientState or MPSNNBinaryGradientState subclass produced by the forward pass

func (*MPSCNNGradientKernel) EncodeBatchToCommandBufferSourceGradientsSourceImagesGradientStatesDestinationGradients ¶

func (o *MPSCNNGradientKernel) EncodeBatchToCommandBufferSourceGradientsSourceImagesGradientStatesDestinationGradients(commandBuffer metal.MTLCommandBuffer, sourceGradients unsafe.Pointer, sourceImages unsafe.Pointer, gradientStates unsafe.Pointer, destinationGradients unsafe.Pointer)

@abstract Encode a gradient filter and return a gradient @discussion During training, gradient filters are used to calculate the gradient associated with the loss for each feature channel in the forward pass source image. For those nodes that are trainable, these are then used to refine the value used in the trainable parameter. They consume a source gradient image which contains the gradients corresponding with the forward pass destination image, and calculate the gradients corresponding to the forward pass source image. A gradient filter consumes a MPSNNGradientState object which captured various forward pass properties such as offset and edgeMode at the time the forward pass was encoded. These are transferred to the MPSCNNBinaryKernel secondary image properties automatically when you use -[MPSCNNGradientKernel destinationImageDescriptorForSourceImages:sourceStates:]. If you do not call this method, then you are responsible for configuring all of the primary and secondary image properties in MPSCNNBinaryKernel. Please see class description for expected ordering of operations. @param commandBuffer The MTLCommandBuffer on which to encode @param sourceGradients The gradient images from the "next" filter in the graph @param sourceImages The image used as source images from the forward pass @param gradientStates An array of the MPSNNGradientState or MPSNNBinaryGradientState subclass produced by the forward pass @param destinationGradients The MPSImages into which to write the filter result

func (*MPSCNNGradientKernel) EncodeToCommandBufferSourceGradientSourceImageGradientState ¶

func (o *MPSCNNGradientKernel) EncodeToCommandBufferSourceGradientSourceImageGradientState(commandBuffer metal.MTLCommandBuffer, sourceGradient *mpscore.MPSImage, sourceImage *mpscore.MPSImage, gradientState *mpscore.MPSState) *mpscore.MPSImage

@abstract Encode a gradient filter and return a gradient @discussion During training, gradient filters are used to calculate the gradient associated with the loss for each feature channel in the forward pass source image. For those nodes that are trainable, these are then used to refine the value used in the trainable parameter. They consume a source gradient image which contains the gradients corresponding with the forward pass destination image, and calculate the gradients corresponding to the forward pass source image. A gradient filter consumes a MPSNNGradientState object which captured various forward pass properties such as offset and edgeMode at the time the forward pass was encoded. These are transferred to the MPSCNNBinaryKernel secondary image properties automatically when this method creates its destination image. @param commandBuffer The MTLCommandBuffer on which to encode @param sourceGradient The gradient image from the "next" filter in the graph (in the inference direction) @param sourceImage The image used as source image by the forward inference pass @param gradientState The MPSNNGradientState or MPSNNBinaryGradientState subclass produced by the forward inference pass @result The result gradient from the gradient filter

func (*MPSCNNGradientKernel) EncodeToCommandBufferSourceGradientSourceImageGradientStateDestinationGradient ¶

func (o *MPSCNNGradientKernel) EncodeToCommandBufferSourceGradientSourceImageGradientStateDestinationGradient(commandBuffer metal.MTLCommandBuffer, sourceGradient *mpscore.MPSImage, sourceImage *mpscore.MPSImage, gradientState *mpscore.MPSState, destinationGradient *mpscore.MPSImage)

@abstract Encode a gradient filter and return a gradient @discussion During training, gradient filters are used to calculate the gradient associated with the loss for each feature channel in the forward pass source image. For those nodes that are trainable, these are then used to refine the value used in the trainable parameter. They consume a source gradient image which contains the gradients corresponding with the forward pass destination image, and calculate the gradients corresponding to the forward pass source image. A gradient filter consumes a MPSNNGradientState object which captured various forward pass properties such as offset and edgeMode at the time the forward pass was encoded. These are transferred to the MPSCNNBinaryKernel secondary image properties automatically when you use -[MPSCNNGradientKernel destinationImageDescriptorForSourceImages:sourceStates:]. If you do not call this method, then you are responsible for configuring all of the primary and secondary image properties in MPSCNNBinaryKernel. Please see class description for expected ordering of operations. @param commandBuffer The MTLCommandBuffer on which to encode @param sourceGradient The gradient image from the "next" filter in the graph @param sourceImage The image used as source image from the forward pass @param gradientState The MPSNNGradientState and MPSNNBinaryGradientState subclass produced by the forward pass @param destinationGradient The MPSImage into which to write the filter result

func (*MPSCNNGradientKernel) InitWithCoderDevice ¶

func (o *MPSCNNGradientKernel) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNGradientKernel

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNGradientKernel) InitWithDevice ¶

func (o *MPSCNNGradientKernel) InitWithDevice(device metal.MTLDevice) *MPSCNNGradientKernel

@abstract Standard init with default properties per filter type @param device The device that the filter will be used on. May not be NULL. @result 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.

func (*MPSCNNGradientKernel) KernelOffsetX ¶

func (o *MPSCNNGradientKernel) KernelOffsetX() int

@property kernelOffsetX @abstract Offset in the kernel reference frame to position the kernel in the X dimension @discussion In some cases, the input gradient must be upsampled with zero insertion to account for things like strides in the forward MPSCNNKernel pass. As such, the offset, which describes a X,Y offset in the source coordinate space is insufficient to fully describe the offset applied to a kernel. The kernel offset is the offset after upsampling. Both the source offset and kernel offset are additive: effective offset = source offset * stride + kernel offset. The offset is applied to the (upsampled) source gradient

func (*MPSCNNGradientKernel) KernelOffsetY ¶

func (o *MPSCNNGradientKernel) KernelOffsetY() int

@property kernelOffsetY @abstract Offset in the kernel reference frame to position the kernel in the Y dimension @discussion In some cases, the input gradient must be upsampled with zero insertion to account for things like strides in the forward MPSCNNKernel pass. As such, the offset, which describes a X,Y offset in the source coordinate space is insufficient to fully describe the offset applied to a kernel. The kernel offset is the offset after upsampling. Both the source offset and kernel offset are additive: effective offset = source offset * stride + kernel offset. The offset is applied to the (upsampled) source gradient

func (*MPSCNNGradientKernel) SetKernelOffsetX ¶

func (o *MPSCNNGradientKernel) SetKernelOffsetX(kernelOffsetX int)

func (*MPSCNNGradientKernel) SetKernelOffsetY ¶

func (o *MPSCNNGradientKernel) SetKernelOffsetY(kernelOffsetY int)

type MPSCNNGroupNormalization ¶

type MPSCNNGroupNormalization struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnngroupnormalization

func MPSCNNGroupNormalizationFromID ¶

func MPSCNNGroupNormalizationFromID(id objc.ID) *MPSCNNGroupNormalization

func (*MPSCNNGroupNormalization) DataSource ¶

@abstract The data source that the object was initialized with

func (*MPSCNNGroupNormalization) Epsilon ¶

func (o *MPSCNNGroupNormalization) Epsilon() float32

@property epsilon @abstract The epsilon value used to bias the variance when normalizing.

func (*MPSCNNGroupNormalization) InitWithCoderDevice ¶

func (o *MPSCNNGroupNormalization) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNGroupNormalization

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSCNNGroupNormalization object, or nil if failure.

func (*MPSCNNGroupNormalization) InitWithDeviceDataSource ¶

@abstract Initialize a MPSCNNGroupNormalization kernel on a device. @param dataSource An object conforming to the MPSCNNGroupNormalizationDataSource protocol which

func (*MPSCNNGroupNormalization) ReloadGammaAndBetaFromDataSource ¶

func (o *MPSCNNGroupNormalization) ReloadGammaAndBetaFromDataSource()

@abstract Reinitialize the filter using the data source provided at kernel initialization.

func (*MPSCNNGroupNormalization) ReloadGammaAndBetaWithCommandBufferGammaAndBetaState ¶

func (o *MPSCNNGroupNormalization) ReloadGammaAndBetaWithCommandBufferGammaAndBetaState(commandBuffer metal.MTLCommandBuffer, gammaAndBetaState *MPSCNNNormalizationGammaAndBetaState)

@abstract Reload data using new gamma and beta terms contained within an MPSCNNGroupNormalizationGradientState object. @param commandBuffer The command buffer on which to encode the reload. @param gammaAndBetaState The state containing the updated weights which are to be reloaded.

func (*MPSCNNGroupNormalization) SetEpsilon ¶

func (o *MPSCNNGroupNormalization) SetEpsilon(epsilon float32)

type MPSCNNGroupNormalizationDataSource ¶

type MPSCNNGroupNormalizationDataSource interface {
	foundation.NSCopying
}

MPSCNNGroupNormalizationDataSource wraps the ObjC protocol MPSCNNGroupNormalizationDataSource.

type MPSCNNGroupNormalizationGradientNode ¶

type MPSCNNGroupNormalizationGradientNode struct {
	MPSNNGradientFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnngroupnormalizationgradientnode

func MPSCNNGroupNormalizationGradientNodeFromID ¶

func MPSCNNGroupNormalizationGradientNodeFromID(id objc.ID) *MPSCNNGroupNormalizationGradientNode

func MPSCNNGroupNormalizationGradientNodeNodeWithSourceGradientSourceImageGradientState ¶

func MPSCNNGroupNormalizationGradientNodeNodeWithSourceGradientSourceImageGradientState(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSCNNGroupNormalizationGradientNode

func (*MPSCNNGroupNormalizationGradientNode) InitWithSourceGradientSourceImageGradientState ¶

func (o *MPSCNNGroupNormalizationGradientNode) InitWithSourceGradientSourceImageGradientState(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSCNNGroupNormalizationGradientNode

type MPSCNNGroupNormalizationGradientState ¶

type MPSCNNGroupNormalizationGradientState struct {
	MPSNNGradientState
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnngroupnormalizationgradientstate

func MPSCNNGroupNormalizationGradientStateFromID ¶

func MPSCNNGroupNormalizationGradientStateFromID(id objc.ID) *MPSCNNGroupNormalizationGradientState

func (*MPSCNNGroupNormalizationGradientState) Beta ¶

@abstract Return an MTLBuffer object with the state's current beta values..

func (*MPSCNNGroupNormalizationGradientState) Gamma ¶

@abstract Return an MTLBuffer object with the state's current gamma values.

func (*MPSCNNGroupNormalizationGradientState) GradientForBeta ¶

@property The MTLBuffer containing the gradient values for beta.

func (*MPSCNNGroupNormalizationGradientState) GradientForGamma ¶

@property The MTLBuffer containing the gradient values for gamma.

func (*MPSCNNGroupNormalizationGradientState) GroupNormalization ¶

@abstract The MPSCNNGroupNormalization object that created this state object.

type MPSCNNGroupNormalizationNode ¶

type MPSCNNGroupNormalizationNode struct {
	MPSNNFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnngroupnormalizationnode

func MPSCNNGroupNormalizationNodeFromID ¶

func MPSCNNGroupNormalizationNodeFromID(id objc.ID) *MPSCNNGroupNormalizationNode

func MPSCNNGroupNormalizationNodeNodeWithSourceDataSource ¶

func MPSCNNGroupNormalizationNodeNodeWithSourceDataSource(source *MPSNNImageNode, dataSource MPSCNNGroupNormalizationDataSource) *MPSCNNGroupNormalizationNode

func (*MPSCNNGroupNormalizationNode) InitWithSourceDataSource ¶

func (*MPSCNNGroupNormalizationNode) SetTrainingStyle ¶

func (o *MPSCNNGroupNormalizationNode) SetTrainingStyle(trainingStyle MPSNNTrainingStyle)

@abstract The training style of the forward node will be propagated to gradient nodes made from it

func (*MPSCNNGroupNormalizationNode) TrainingStyle ¶

@abstract The training style of the forward node will be propagated to gradient nodes made from it

type MPSCNNInstanceNormalization ¶

type MPSCNNInstanceNormalization struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnninstancenormalization

func MPSCNNInstanceNormalizationFromID ¶

func MPSCNNInstanceNormalizationFromID(id objc.ID) *MPSCNNInstanceNormalization

func (*MPSCNNInstanceNormalization) DataSource ¶

@abstract The data source that the object was initialized with

func (*MPSCNNInstanceNormalization) Epsilon ¶

func (o *MPSCNNInstanceNormalization) Epsilon() float32

@property epsilon @abstract The epsilon value used to bias the variance when normalizing.

func (*MPSCNNInstanceNormalization) InitWithCoderDevice ¶

func (o *MPSCNNInstanceNormalization) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNInstanceNormalization

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSCNNInstanceNormalization object, or nil if failure.

func (*MPSCNNInstanceNormalization) InitWithDeviceDataSource ¶

@abstract Initialize a MPSCNNInstanceNormalization kernel on a device. @param dataSource An object conforming to the MPSCNNInstanceNormalizationDataSource protocol which

func (*MPSCNNInstanceNormalization) ReloadDataSource ¶

@abstract Reload data using a data source. @param dataSource The data source which will provide the gamma and beta terms to scale and bias the normalized result respectively.

func (*MPSCNNInstanceNormalization) ReloadGammaAndBetaFromDataSource ¶

func (o *MPSCNNInstanceNormalization) ReloadGammaAndBetaFromDataSource()

@abstract Reinitialize the filter using the data source provided at kernel initialization.

func (*MPSCNNInstanceNormalization) ReloadGammaAndBetaWithCommandBufferGammaAndBetaState ¶

func (o *MPSCNNInstanceNormalization) ReloadGammaAndBetaWithCommandBufferGammaAndBetaState(commandBuffer metal.MTLCommandBuffer, gammaAndBetaState *MPSCNNNormalizationGammaAndBetaState)

@abstract Reload data using new gamma and beta terms contained within an MPSCNNInstanceNormalizationGradientState object. @param commandBuffer The command buffer on which to encode the reload. @param gammaAndBetaState The state containing the updated weights which are to be reloaded.

func (*MPSCNNInstanceNormalization) SetEpsilon ¶

func (o *MPSCNNInstanceNormalization) SetEpsilon(epsilon float32)

type MPSCNNInstanceNormalizationDataSource ¶

type MPSCNNInstanceNormalizationDataSource interface {
	foundation.NSCopying
}

MPSCNNInstanceNormalizationDataSource wraps the ObjC protocol MPSCNNInstanceNormalizationDataSource.

type MPSCNNInstanceNormalizationGradientNode ¶

type MPSCNNInstanceNormalizationGradientNode struct {
	MPSNNGradientFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnninstancenormalizationgradientnode

func MPSCNNInstanceNormalizationGradientNodeFromID ¶

func MPSCNNInstanceNormalizationGradientNodeFromID(id objc.ID) *MPSCNNInstanceNormalizationGradientNode

func MPSCNNInstanceNormalizationGradientNodeNodeWithSourceGradientSourceImageGradientState ¶

func MPSCNNInstanceNormalizationGradientNodeNodeWithSourceGradientSourceImageGradientState(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSCNNInstanceNormalizationGradientNode

func (*MPSCNNInstanceNormalizationGradientNode) InitWithSourceGradientSourceImageGradientState ¶

func (o *MPSCNNInstanceNormalizationGradientNode) InitWithSourceGradientSourceImageGradientState(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSCNNInstanceNormalizationGradientNode

type MPSCNNInstanceNormalizationGradientState ¶

type MPSCNNInstanceNormalizationGradientState struct {
	MPSNNGradientState
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnninstancenormalizationgradientstate

func MPSCNNInstanceNormalizationGradientStateFromID ¶

func MPSCNNInstanceNormalizationGradientStateFromID(id objc.ID) *MPSCNNInstanceNormalizationGradientState

func (*MPSCNNInstanceNormalizationGradientState) Beta ¶

@abstract Return an MTLBuffer object with the state's current beta values..

func (*MPSCNNInstanceNormalizationGradientState) Gamma ¶

@abstract Return an MTLBuffer object with the state's current gamma values.

func (*MPSCNNInstanceNormalizationGradientState) GradientForBeta ¶

@property The MTLBuffer containing the gradient values for beta.

func (*MPSCNNInstanceNormalizationGradientState) GradientForGamma ¶

@property The MTLBuffer containing the gradient values for gamma.

func (*MPSCNNInstanceNormalizationGradientState) InstanceNormalization ¶

@abstract The MPSCNNInstanceNormalization object that created this state object.

type MPSCNNInstanceNormalizationNode ¶

type MPSCNNInstanceNormalizationNode struct {
	MPSNNFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnninstancenormalizationnode

func MPSCNNInstanceNormalizationNodeFromID ¶

func MPSCNNInstanceNormalizationNodeFromID(id objc.ID) *MPSCNNInstanceNormalizationNode

func MPSCNNInstanceNormalizationNodeNodeWithSourceDataSource ¶

func MPSCNNInstanceNormalizationNodeNodeWithSourceDataSource(source *MPSNNImageNode, dataSource MPSCNNInstanceNormalizationDataSource) *MPSCNNInstanceNormalizationNode

func (*MPSCNNInstanceNormalizationNode) InitWithSourceDataSource ¶

func (*MPSCNNInstanceNormalizationNode) SetTrainingStyle ¶

func (o *MPSCNNInstanceNormalizationNode) SetTrainingStyle(trainingStyle MPSNNTrainingStyle)

@abstract The training style of the forward node will be propagated to gradient nodes made from it

func (*MPSCNNInstanceNormalizationNode) TrainingStyle ¶

@abstract The training style of the forward node will be propagated to gradient nodes made from it

type MPSCNNKernel ¶

type MPSCNNKernel struct {
	mpscore.MPSKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnkernel

func MPSCNNKernelFromID ¶

func MPSCNNKernelFromID(id objc.ID) *MPSCNNKernel

func (*MPSCNNKernel) AppendBatchBarrier ¶

func (o *MPSCNNKernel) AppendBatchBarrier() bool

@abstract Returns YES if the filter must be run over the entire batch before its results may be used @discussion Nearly all filters do not need to see the entire batch all at once and can operate correctly with partial batches. This allows the graph to strip-mine the problem, processing the graph top to bottom on a subset of the batch at a time, dramatically reducing memory usage. As the full nominal working set for a graph is often so large that it may not fit in memory, sub-batching may be required forward progress. Batch normalization statistics on the other hand must complete the batch before the statistics may be used to normalize the images in the batch in the ensuing normalization filter. Consequently, batch normalization statistics requests the graph insert a batch barrier following it by returning YES from -appendBatchBarrier. This tells the graph to complete the batch before any dependent filters can start. Note that the filter itself may still be subject to sub-batching in its operation. All filters must be able to function without seeing the entire batch in a single -encode call. Carry over state that is accumulated across sub-batches is commonly carried in a shared MPSState containing a MTLBuffer. See -isResultStateReusedAcrossBatch. Caution: on most supported devices, the working set may be so large that the graph may be forced to throw away and recalculate most intermediate images in cases where strip-mining can not occur because -appendBatchBarrier returns YES. A single batch barrier can commonly cause a memory size increase and/or performance reduction by many fold over the entire graph. Filters of this variety should be avoided. Default: NO

func (*MPSCNNKernel) BatchEncodingStorageSizeForSourceImageSourceStatesDestinationImage ¶

func (o *MPSCNNKernel) BatchEncodingStorageSizeForSourceImageSourceStatesDestinationImage(sourceImage unsafe.Pointer, sourceStates *foundation.NSArray[objc.ID], destinationImage unsafe.Pointer) uint

@abstract The size of extra MPS heap storage allocated while the kernel is encoding a batch @discussion This is best effort and just describes things that are likely to end up on the MPS heap. It does not describe all allocation done by the -encode call. It is intended for use with high water calculations for MTLHeap sizing. Allocations are typically for temporary storage needed for multipass algorithms. This interface should not be used to detect multipass algorithms.

func (*MPSCNNKernel) ClipRect ¶

func (o *MPSCNNKernel) ClipRect() metal.MTLRegion

@property clipRect @abstract An optional clip rectangle to use when writing data. Only the pixels in the rectangle will be overwritten. @discussion A MTLRegion that indicates which part of the destination to overwrite. If the clipRect does not lie completely within the destination image, the intersection between clip rectangle and destination bounds is used. Default: MPSRectNoClip (MPSKernel::MPSRectNoClip) indicating the entire image. clipRect.origin.z is the index of starting destination image in batch processing mode. clipRect.size.depth is the number of images to process in batch processing mode. See Also: @ref MetalPerformanceShaders.h subsubsection_clipRect

func (*MPSCNNKernel) DestinationFeatureChannelOffset ¶

func (o *MPSCNNKernel) DestinationFeatureChannelOffset() uint

@property destinationFeatureChannelOffset @abstract The number of channels in the destination MPSImage to skip before writing output. @discussion This is the starting offset into the destination image in the feature channel dimension at which destination data is written. This allows an application to pass a subset of all the channels in MPSImage as output of MPSKernel. E.g. Suppose MPSImage has 24 channels and a MPSKernel outputs 8 channels. If we want channels 8 to 15 of this MPSImage to be used as output, we can set destinationFeatureChannelOffset = 8. Note that this offset applies independently to each image when the MPSImage is a container for multiple images and the MPSCNNKernel is processing multiple images (clipRect.size.depth > 1). The default value is 0 and any value specifed shall be a multiple of 4. If MPSKernel outputs N channels, the destination image MUST have at least destinationFeatureChannelOffset + N channels. Using a destination image with insufficient number of feature channels will result in an error. E.g. if the MPSCNNConvolution outputs 32 channels, and the destination has 64 channels, then it is an error to set destinationFeatureChannelOffset > 32.

func (*MPSCNNKernel) DestinationImageAllocator ¶

func (o *MPSCNNKernel) DestinationImageAllocator() mpscore.MPSImageAllocator

@abstract Method to allocate the result image for -encodeToCommandBuffer:sourceImage: @discussion Default: MPSTemporaryImage.defaultAllocator

func (*MPSCNNKernel) DestinationImageDescriptorForSourceImagesSourceStates ¶

func (o *MPSCNNKernel) DestinationImageDescriptorForSourceImagesSourceStates(sourceImages *foundation.NSArray[*mpscore.MPSImage], sourceStates *foundation.NSArray[*mpscore.MPSState]) *mpscore.MPSImageDescriptor

@abstract Get a suggested destination image descriptor for a source image @discussion Your application is certainly free to pass in any destinationImage it likes to encodeToCommandBuffer:sourceImage:destinationImage, within reason. This is the basic design for iOS 10. This method is therefore not required. However, calculating the MPSImage size and MPSCNNKernel properties for each filter can be tedious and complicated work, so this method is made available to automate the process. The application may modify the properties of the descriptor before a MPSImage is made from it, so long as the choice is sensible for the kernel in question. Please see individual kernel descriptions for restrictions. The expected timeline for use is as follows: 1) This method is called: a) The default MPS padding calculation is applied. It uses the MPSNNPaddingMethod of the .padding property to provide a consistent addressing scheme over the graph. It creates the MPSImageDescriptor and adjusts the .offset property of the MPSNNKernel. When using a MPSNNGraph, the padding is set using the MPSNNFilterNode as a proxy. b) This method may be overridden by MPSCNNKernel subclass to achieve any customization appropriate to the object type. c) Source states are then applied in order. These may modify the descriptor and may update other object properties. See: -destinationImageDescriptorForSourceImages:sourceStates: forKernel:suggestedDescriptor: This is the typical way in which MPS may attempt to influence the operation of its kernels. d) If the .padding property has a custom padding policy method of the same name, it is called. Similarly, it may also adjust the descriptor and any MPSCNNKernel properties. This is the typical way in which your application may attempt to influence the operation of the MPS kernels. 2) A result is returned from this method and the caller may further adjust the descriptor and kernel properties directly. 3) The caller uses the descriptor to make a new MPSImage to use as the destination image for the -encode call in step 5. 4) The caller calls -resultStateForSourceImage:sourceStates:destinationImage: to make any result states needed for the kernel. If there isn't one, it will return nil. A variant is available to return a temporary state instead. 5) a -encode method is called to encode the kernel. The entire process 1-5 is more simply achieved by just calling an -encode... method that returns a MPSImage out the left hand sid of the method. Simpler still, use the MPSNNGraph to coordinate the entire process from end to end. Opportunities to influence the process are of course reduced, as (2) is no longer possible with either method. Your application may opt to use the five step method if it requires greater customization as described, or if it would like to estimate storage in advance based on the sum of MPSImageDescriptors before processing a graph. Storage estimation is done by using the MPSImageDescriptor to create a MPSImage (without passing it a texture), and then call -resourceSize. As long as the MPSImage is not used in an encode call and the .texture property is not invoked, the underlying MTLTexture is not created. No destination state or destination image is provided as an argument to this function because it is expected they will be made / configured after this is called. This method is expected to auto-configure important object properties that may be needed in the ensuing destination image and state creation steps. @param sourceImages A array of source images that will be passed into the -encode call Since MPSCNNKernel is a unary kernel, it is an array of length 1. @param sourceStates An optional array of source states that will be passed into the -encode call @return an image descriptor allocated on the autorelease pool

func (*MPSCNNKernel) DilationRateX ¶

func (o *MPSCNNKernel) DilationRateX() uint

@property dilationRateX @abstract Stride in source coordinates from one kernel tap to the next in the X dimension.

func (*MPSCNNKernel) DilationRateY ¶

func (o *MPSCNNKernel) DilationRateY() uint

@property dilationRate @abstract Stride in source coordinates from one kernel tap to the next in the Y dimension.

func (*MPSCNNKernel) EdgeMode ¶

func (o *MPSCNNKernel) EdgeMode() mpscore.MPSImageEdgeMode

@property edgeMode @abstract The MPSImageEdgeMode to use when texture reads stray off the edge of an image @discussion Most MPSKernel objects can read off the edge of the source image. This can happen because of a negative offset property, because the offset + clipRect.size is larger than the source image or because the filter looks at neighboring pixels, such as a Convolution filter. Default: MPSImageEdgeModeZero. See Also: @ref MetalPerformanceShaders.h subsubsection_edgemode Note: For @ref MPSCNNPoolingAverage specifying edge mode @ref MPSImageEdgeModeClamp is interpreted as a "shrink-to-edge" operation, which shrinks the effective filtering window to remain within the source image borders.

func (*MPSCNNKernel) EncodeBatchToCommandBufferSourceImages ¶

func (o *MPSCNNKernel) EncodeBatchToCommandBufferSourceImages(commandBuffer metal.MTLCommandBuffer, sourceImages unsafe.Pointer) unsafe.Pointer

@abstract Encode a MPSCNNKernel into a command Buffer. Create a texture to hold the result and return it. @discussion In the first iteration on this method, encodeToCommandBuffer:sourceImage:destinationImage: some work was left for the developer to do in the form of correctly setting the offset property and sizing the result buffer. With the introduction of the padding policy (see padding property) the filter can do this work itself. If you would like to have some input into what sort of MPSImage (e.g. temporary vs. regular) or what size it is or where it is allocated, you may set the destinationImageAllocator to allocate the image yourself. This method uses the MPSNNPadding padding property to figure out how to size the result image and to set the offset property. See discussion in MPSNeuralNetworkTypes.h. All images in a batch must have MPSImage.numberOfImages = 1. @param commandBuffer The command buffer @param sourceImages A MPSImages to use as the source images for the filter. @result An array of MPSImages or MPSTemporaryImages allocated per the destinationImageAllocator containing the output of the graph. The offset property will be adjusted to reflect the offset used during the encode. The returned images will be automatically released when the command buffer completes. If you want to keep them around for longer, retain the images.

func (*MPSCNNKernel) EncodeBatchToCommandBufferSourceImagesDestinationImages ¶

func (o *MPSCNNKernel) EncodeBatchToCommandBufferSourceImagesDestinationImages(commandBuffer metal.MTLCommandBuffer, sourceImages unsafe.Pointer, destinationImages unsafe.Pointer)

@abstract Encode a MPSCNNKernel into a command Buffer. The operation shall proceed out-of-place. @discussion This is the older style of encode which reads the offset, doesn't change it, and ignores the padding method. @param commandBuffer A valid MTLCommandBuffer to receive the encoded filter @param sourceImages A valid MPSImage object containing the source images. @param destinationImages A valid MPSImage to be overwritten by result images. destinationImages may not alias sourceImages, even at different indices.

func (*MPSCNNKernel) EncodeBatchToCommandBufferSourceImagesDestinationStatesDestinationImages ¶

func (o *MPSCNNKernel) EncodeBatchToCommandBufferSourceImagesDestinationStatesDestinationImages(commandBuffer metal.MTLCommandBuffer, sourceImages unsafe.Pointer, destinationStates unsafe.Pointer, destinationImages unsafe.Pointer)

@abstract Encode a MPSCNNKernel with a destination state into a command Buffer. @discussion This is typically used during training. The state is commonly a MPSNNGradientState. Please see -resultStateForSourceImages:SourceStates:destinationImage and batch+temporary variants. @param commandBuffer A valid MTLCommandBuffer to receive the encoded filter @param sourceImages A valid MPSImage object containing the source images. @param destinationStates A list of states to be overwritten by results @param destinationImages A valid MPSImage to be overwritten by result images. destinationImages may not alias sourceImages, even at different indices.

func (*MPSCNNKernel) EncodeBatchToCommandBufferSourceImagesDestinationStatesDestinationStateIsTemporary ¶

func (o *MPSCNNKernel) EncodeBatchToCommandBufferSourceImagesDestinationStatesDestinationStateIsTemporary(commandBuffer metal.MTLCommandBuffer, sourceImages unsafe.Pointer, outStates unsafe.Pointer, isTemporary bool) unsafe.Pointer

@abstract Encode a MPSCNNKernel into a command Buffer. Create a MPSImageBatch and MPSStateBatch to hold the results and return them. @discussion In the first iteration on this method, encodeToCommandBuffer:sourceImage:destinationImage: some work was left for the developer to do in the form of correctly setting the offset property and sizing the result buffer. With the introduction of the padding policy (see padding property) the filter can do this work itself. If you would like to have some input into what sort of MPSImage (e.g. temporary vs. regular) or what size it is or where it is allocated, you may set the destinationImageAllocator to allocate the image yourself. This method uses the MPSNNPadding padding property to figure out how to size the result image and to set the offset property. See discussion in MPSNeuralNetworkTypes.h. All images in a batch must have MPSImage.numberOfImages = 1. Usage: @code MPSStateBatch * outStates = nil; // autoreleased MPSImageBatch * result = [k encodeBatchToCommandBuffer: cmdBuf sourceImages: sourceImages destinationStates: &outStates ]; @endcode @param commandBuffer The command buffer @param sourceImages A MPSImages to use as the source images for the filter. @param outStates A pointer to storage to hold a MPSStateBatch* where output states are returned @result An array of MPSImages or MPSTemporaryImages allocated per the destinationImageAllocator containing the output of the graph. The offset property will be adjusted to reflect the offset used during the encode. The returned images will be automatically released when the command buffer completes. If you want to keep them around for longer, retain the images.

func (*MPSCNNKernel) EncodeToCommandBufferSourceImage ¶

func (o *MPSCNNKernel) EncodeToCommandBufferSourceImage(commandBuffer metal.MTLCommandBuffer, sourceImage *mpscore.MPSImage) *mpscore.MPSImage

@abstract Encode a MPSCNNKernel into a command Buffer. Create a texture to hold the result and return it. @discussion In the first iteration on this method, encodeToCommandBuffer:sourceImage:destinationImage: some work was left for the developer to do in the form of correctly setting the offset property and sizing the result buffer. With the introduction of the padding policy (see padding property) the filter can do this work itself. If you would like to have some input into what sort of MPSImage (e.g. temporary vs. regular) or what size it is or where it is allocated, you may set the destinationImageAllocator to allocate the image yourself. This method uses the MPSNNPadding padding property to figure out how to size the result image and to set the offset property. See discussion in MPSNeuralNetworkTypes.h. All images in a batch must have MPSImage.numberOfImages = 1. @param commandBuffer The command buffer @param sourceImage A MPSImage to use as the source images for the filter. @result A MPSImage or MPSTemporaryImage allocated per the destinationImageAllocator containing the output of the graph. The offset property will be adjusted to reflect the offset used during the encode. The returned image will be automatically released when the command buffer completes. If you want to keep it around for longer, retain the image. (ARC will do this for you if you use it later.)

func (*MPSCNNKernel) EncodeToCommandBufferSourceImageDestinationImage ¶

func (o *MPSCNNKernel) EncodeToCommandBufferSourceImageDestinationImage(commandBuffer metal.MTLCommandBuffer, sourceImage *mpscore.MPSImage, destinationImage *mpscore.MPSImage)

@abstract Encode a MPSCNNKernel into a command Buffer. The operation shall proceed out-of-place. @discussion This is the older style of encode which reads the offset, doesn't change it, and ignores the padding method. @param commandBuffer A valid MTLCommandBuffer to receive the encoded filter @param sourceImage A valid MPSImage object containing the source image. @param destinationImage A valid MPSImage to be overwritten by result image. destinationImage may not alias sourceImage.

func (*MPSCNNKernel) EncodeToCommandBufferSourceImageDestinationStateDestinationImage ¶

func (o *MPSCNNKernel) EncodeToCommandBufferSourceImageDestinationStateDestinationImage(commandBuffer metal.MTLCommandBuffer, sourceImage *mpscore.MPSImage, destinationState *mpscore.MPSState, destinationImage *mpscore.MPSImage)

@abstract Encode a MPSCNNKernel with a destination state into a command Buffer. @discussion This is typically used during training. The state is commonly a MPSNNGradientState. Please see -resultStateForSourceImages:SourceStates: and batch+temporary variants. @param commandBuffer A valid MTLCommandBuffer to receive the encoded filter @param sourceImage A valid MPSImage object containing the source image. @param destinationState A state to be overwritten by additional state information. @param destinationImage A valid MPSImage to be overwritten by result image. destinationImage may not alias sourceImage.

func (*MPSCNNKernel) EncodeToCommandBufferSourceImageDestinationStateDestinationStateIsTemporary ¶

func (o *MPSCNNKernel) EncodeToCommandBufferSourceImageDestinationStateDestinationStateIsTemporary(commandBuffer metal.MTLCommandBuffer, sourceImage *mpscore.MPSImage, outState *mpscore.MPSState, isTemporary bool) *mpscore.MPSImage

@abstract Encode a MPSCNNKernel into a command Buffer. Create a texture and state to hold the results and return them. @discussion In the first iteration on this method, encodeToCommandBuffer:sourceImage:destinationState:destinationImage: some work was left for the developer to do in the form of correctly setting the offset property and sizing the result buffer. With the introduction of the padding policy (see padding property) the filter can do this work itself. If you would like to have some input into what sort of MPSImage (e.g. temporary vs. regular) or what size it is or where it is allocated, you may set the destinationImageAllocator to allocate the image yourself. This method uses the MPSNNPadding padding property to figure out how to size the result image and to set the offset property. See discussion in MPSNeuralNetworkTypes.h. All images in a batch must have MPSImage.numberOfImages = 1. @param commandBuffer The command buffer @param sourceImage A MPSImage to use as the source images for the filter. @param outState A new state object is returned here. @result A MPSImage or MPSTemporaryImage allocated per the destinationImageAllocator containing the output of the graph. The offset property will be adjusted to reflect the offset used during the encode. The returned image will be automatically released when the command buffer completes. If you want to keep it around for longer, retain the image. (ARC will do this for you if you use it later.)

func (*MPSCNNKernel) EncodingStorageSizeForSourceImageSourceStatesDestinationImage ¶

func (o *MPSCNNKernel) EncodingStorageSizeForSourceImageSourceStatesDestinationImage(sourceImage *mpscore.MPSImage, sourceStates *foundation.NSArray[*mpscore.MPSState], destinationImage *mpscore.MPSImage) uint

@abstract The size of extra MPS heap storage allocated while the kernel is encoding @discussion This is best effort and just describes things that are likely to end up on the MPS heap. It does not describe all allocation done by the -encode call. It is intended for use with high water calculations for MTLHeap sizing. Allocations are typically for temporary storage needed for multipass algorithms. This interface should not be used to detect multipass algorithms.

func (*MPSCNNKernel) InitWithCoderDevice ¶

func (o *MPSCNNKernel) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNKernel

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNKernel) InitWithDevice ¶

func (o *MPSCNNKernel) InitWithDevice(device metal.MTLDevice) *MPSCNNKernel

@abstract Standard init with default properties per filter type @param device The device that the filter will be used on. May not be NULL. @result 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.

func (*MPSCNNKernel) IsBackwards ¶

func (o *MPSCNNKernel) IsBackwards() bool

@property isBackwards @abstract YES if the filter operates backwards. @discussion This influences how strideInPixelsX/Y should be interpreted. Most filters either have stride 1 or are reducing, meaning that the result image is smaller than the original by roughly a factor of the stride. A few "backward" filters (e.g convolution transpose) are intended to "undo" the effects of an earlier forward filter, and so enlarge the image. The stride is in the destination coordinate frame rather than the source coordinate frame.

func (*MPSCNNKernel) IsResultStateReusedAcrossBatch ¶

func (o *MPSCNNKernel) IsResultStateReusedAcrossBatch() bool

@abstract Returns YES if the same state is used for every operation in a batch @discussion If NO, then each image in a MPSImageBatch will need a corresponding (and different) state to go with it. Set to YES to avoid allocating redundant state in the case when the same state is used all the time. Default: NO

func (*MPSCNNKernel) IsStateModified ¶

func (o *MPSCNNKernel) IsStateModified() bool

@abstract Returns true if the -encode call modifies the state object it accepts.

func (*MPSCNNKernel) KernelHeight ¶

func (o *MPSCNNKernel) KernelHeight() uint

@property kernelHeight @abstract The height of the MPSCNNKernel filter window @discussion This is the vertical diameter of the region read by the filter for each result pixel. If the MPSCNNKernel does not have a filter window, then 1 will be returned. Warning: This property was lowered to this class in ios/tvos 11 The property may not be available on iOS/tvOS 10 for all subclasses of MPSCNNKernel

func (*MPSCNNKernel) KernelWidth ¶

func (o *MPSCNNKernel) KernelWidth() uint

@property kernelWidth @abstract The width of the MPSCNNKernel filter window @discussion This is the horizontal diameter of the region read by the filter for each result pixel. If the MPSCNNKernel does not have a filter window, then 1 will be returned. Warning: This property was lowered to this class in ios/tvos 11 The property may not be available on iOS/tvOS 10 for all subclasses of MPSCNNKernel

func (*MPSCNNKernel) Offset ¶

func (o *MPSCNNKernel) Offset() mpscore.MPSOffset

@property offset @abstract The position of the destination clip rectangle origin relative to the source buffer. @discussion The offset is defined to be the position of clipRect.origin in source coordinates. Default: {0,0,0}, indicating that the top left corners of the clipRect and source image align. offset.z is the index of starting source image in batch processing mode. See Also: @ref MetalPerformanceShaders.h subsubsection_mpsoffset

func (*MPSCNNKernel) Padding ¶

func (o *MPSCNNKernel) Padding() MPSNNPadding

@property padding @abstract The padding method used by the filter @discussion This influences how the destination image is sized and how the offset into the source image is set. It is used by the -encode methods that return a MPSImage from the left hand side.

func (*MPSCNNKernel) ResultStateBatchForSourceImageSourceStatesDestinationImage ¶

func (o *MPSCNNKernel) ResultStateBatchForSourceImageSourceStatesDestinationImage(sourceImage unsafe.Pointer, sourceStates *foundation.NSArray[objc.ID], destinationImage unsafe.Pointer) unsafe.Pointer

func (*MPSCNNKernel) ResultStateForSourceImageSourceStatesDestinationImage ¶

func (o *MPSCNNKernel) ResultStateForSourceImageSourceStatesDestinationImage(sourceImage *mpscore.MPSImage, sourceStates *foundation.NSArray[*mpscore.MPSState], destinationImage *mpscore.MPSImage) *mpscore.MPSState

@abstract Allocate a MPSState (subclass) to hold the results from a -encodeBatchToCommandBuffer... operation @discussion A graph may need to allocate storage up front before executing. This may be necessary to avoid using too much memory and to manage large batches. The function should allocate any MPSState objects that will be produced by an -encode call with the indicated sourceImages and sourceStates inputs. Though the states can be further adjusted in the ensuing -encode call, the states should be initialized with all important data and all MTLResource storage allocated. The data stored in the MTLResource need not be initialized, unless the ensuing -encode call expects it to be. The MTLDevice used by the result is derived from the source image. The padding policy will be applied to the filter before this is called to give it the chance to configure any properties like MPSCNNKernel.offset. CAUTION: The kernel must have all properties set to values that will ultimately be passed to the -encode call that writes to the state, before -resultStateForSourceImages:sourceStates:destinationImage: is called or behavior is undefined. Please note that -destinationImageDescriptorForSourceImages:sourceStates: will alter some of these properties automatically based on the padding policy. If you intend to call that to make the destination image, then you should call that before -resultStateForSourceImages:sourceStates:destinationImage:. This will ensure the properties used in the encode call and in the destination image creation match those used to configure the state. The following order is recommended: // Configure MPSCNNKernel properties first kernel.edgeMode = MPSImageEdgeModeZero; kernel.destinationFeatureChannelOffset = 128; // concatenation without the copy ... // ALERT: will change MPSCNNKernel properties MPSImageDescriptor * d = [kernel destinationImageDescriptorForSourceImage: source sourceStates: states]; MPSTemporaryImage * dest = [MPSTemporaryImage temporaryImageWithCommandBuffer: cmdBuf imageDescriptor: d]; // Now that all properties are configured properly, we can make the result state // and call encode. MPSState * __nullable destState = [kernel resultStateForSourceImage: source sourceStates: states destinationImage: dest]; // This form of -encode will be declared by the MPSCNNKernel subclass [kernel encodeToCommandBuffer: cmdBuf sourceImage: source destinationState: destState destinationImage: dest ]; Default: returns nil @param sourceImage The MPSImage consumed by the associated -encode call. @param sourceStates The list of MPSStates consumed by the associated -encode call, for a batch size of 1. @param destinationImage The destination image for the encode call @return The list of states produced by the -encode call for batch size of 1. When the batch size is not 1, this function will be called repeatedly unless -isResultStateReusedAcrossBatch returns YES. If -isResultStateReusedAcrossBatch returns YES, then it will be called once per batch and the MPSStateBatch array will contain MPSStateBatch.length references to the same object.

func (*MPSCNNKernel) SetClipRect ¶

func (o *MPSCNNKernel) SetClipRect(clipRect metal.MTLRegion)

func (*MPSCNNKernel) SetDestinationFeatureChannelOffset ¶

func (o *MPSCNNKernel) SetDestinationFeatureChannelOffset(destinationFeatureChannelOffset uint)

func (*MPSCNNKernel) SetDestinationImageAllocator ¶

func (o *MPSCNNKernel) SetDestinationImageAllocator(destinationImageAllocator mpscore.MPSImageAllocator)

@abstract Method to allocate the result image for -encodeToCommandBuffer:sourceImage: @discussion Default: MPSTemporaryImage.defaultAllocator

func (*MPSCNNKernel) SetEdgeMode ¶

func (o *MPSCNNKernel) SetEdgeMode(edgeMode mpscore.MPSImageEdgeMode)

func (*MPSCNNKernel) SetOffset ¶

func (o *MPSCNNKernel) SetOffset(offset mpscore.MPSOffset)

func (*MPSCNNKernel) SetPadding ¶

func (o *MPSCNNKernel) SetPadding(padding MPSNNPadding)

@property padding @abstract The padding method used by the filter @discussion This influences how the destination image is sized and how the offset into the source image is set. It is used by the -encode methods that return a MPSImage from the left hand side.

func (*MPSCNNKernel) SetSourceFeatureChannelMaxCount ¶

func (o *MPSCNNKernel) SetSourceFeatureChannelMaxCount(sourceFeatureChannelMaxCount uint)

func (*MPSCNNKernel) SetSourceFeatureChannelOffset ¶

func (o *MPSCNNKernel) SetSourceFeatureChannelOffset(sourceFeatureChannelOffset uint)

func (*MPSCNNKernel) SourceFeatureChannelMaxCount ¶

func (o *MPSCNNKernel) SourceFeatureChannelMaxCount() uint

@property sourceFeatureChannelMaxCount @abstract The maximum number of channels in the source MPSImage to use @discussion Most filters can insert a slice operation into the filter for free. Use this to limit the size of the feature channel slice taken from the input image. If the value is too large, it is truncated to be the remaining size in the image after the sourceFeatureChannelOffset is taken into account. Default: ULONG_MAX

func (*MPSCNNKernel) SourceFeatureChannelOffset ¶

func (o *MPSCNNKernel) SourceFeatureChannelOffset() uint

@property sourceFeatureChannelOffset @abstract The number of channels in the source MPSImage to skip before reading the input. @discussion This is the starting offset into the source image in the feature channel dimension at which source data is read. Unit: feature channels This allows an application to read a subset of all the channels in MPSImage as input of MPSKernel. E.g. Suppose MPSImage has 24 channels and a MPSKernel needs to read 8 channels. If we want channels 8 to 15 of this MPSImage to be used as input, we can set sourceFeatureChannelOffset = 8. Note that this offset applies independently to each image when the MPSImage is a container for multiple images and the MPSCNNKernel is processing multiple images (clipRect.size.depth > 1). The default value is 0 and any value specifed shall be a multiple of 4. If MPSKernel inputs N channels, the source image MUST have at least sourceFeatureChannelOffset + N channels. Using a source image with insufficient number of feature channels will result in an error. E.g. if the MPSCNNConvolution inputs 32 channels, and the source has 64 channels, then it is an error to set sourceFeatureChannelOffset > 32.

func (*MPSCNNKernel) StrideInPixelsX ¶

func (o *MPSCNNKernel) StrideInPixelsX() uint

@property strideInPixelsX @abstract The downsampling (or upsampling if a backwards filter) factor in the horizontal dimension @discussion If the filter does not do up or downsampling, 1 is returned. Warning: This property was lowered to this class in ios/tvos 11 The property may not be available on iOS/tvOS 10 for all subclasses of MPSCNNKernel

func (*MPSCNNKernel) StrideInPixelsY ¶

func (o *MPSCNNKernel) StrideInPixelsY() uint

@property strideInPixelsY @abstract The downsampling (or upsampling if a backwards filter) factor in the vertical dimension @discussion If the filter does not do up or downsampling, 1 is returned. Warning: This property was lowered to this class in ios/tvos 11 The property may not be available on iOS/tvOS 10 for all subclasses of MPSCNNKernel

func (*MPSCNNKernel) TemporaryResultStateBatchForCommandBufferSourceImageSourceStatesDestinationImage ¶

func (o *MPSCNNKernel) TemporaryResultStateBatchForCommandBufferSourceImageSourceStatesDestinationImage(commandBuffer metal.MTLCommandBuffer, sourceImage unsafe.Pointer, sourceStates *foundation.NSArray[objc.ID], destinationImage unsafe.Pointer) unsafe.Pointer

func (*MPSCNNKernel) TemporaryResultStateForCommandBufferSourceImageSourceStatesDestinationImage ¶

func (o *MPSCNNKernel) TemporaryResultStateForCommandBufferSourceImageSourceStatesDestinationImage(commandBuffer metal.MTLCommandBuffer, sourceImage *mpscore.MPSImage, sourceStates *foundation.NSArray[*mpscore.MPSState], destinationImage *mpscore.MPSImage) *mpscore.MPSState

@abstract Allocate a temporary MPSState (subclass) to hold the results from a -encodeBatchToCommandBuffer... operation @discussion A graph may need to allocate storage up front before executing. This may be necessary to avoid using too much memory and to manage large batches. The function should allocate any MPSState objects that will be produced by an -encode call with the indicated sourceImages and sourceStates inputs. Though the states can be further adjusted in the ensuing -encode call, the states should be initialized with all important data and all MTLResource storage allocated. The data stored in the MTLResource need not be initialized, unless the ensuing -encode call expects it to be. The MTLDevice used by the result is derived from the command buffer. The padding policy will be applied to the filter before this is called to give it the chance to configure any properties like MPSCNNKernel.offset. CAUTION: The kernel must have all properties set to values that will ultimately be passed to the -encode call that writes to the state, before -resultStateForSourceImages:sourceStates:destinationImage: is called or behavior is undefined. Please note that -destinationImageDescriptorForSourceImages:sourceStates:destinationImage: will alter some of these properties automatically based on the padding policy. If you intend to call that to make the destination image, then you should call that before -resultStateForSourceImages:sourceStates:destinationImage:. This will ensure the properties used in the encode call and in the destination image creation match those used to configure the state. The following order is recommended: // Configure MPSCNNKernel properties first kernel.edgeMode = MPSImageEdgeModeZero; kernel.destinationFeatureChannelOffset = 128; // concatenation without the copy ... // ALERT: will change MPSCNNKernel properties MPSImageDescriptor * d = [kernel destinationImageDescriptorForSourceImage: source sourceStates: states]; MPSTemporaryImage * dest = [MPSTemporaryImage temporaryImageWithCommandBuffer: cmdBuf imageDescriptor: d]; // Now that all properties are configured properly, we can make the result state // and call encode. MPSState * __nullable destState = [kernel temporaryResultStateForCommandBuffer: cmdBuf sourceImage: source sourceStates: states]; // This form of -encode will be declared by the MPSCNNKernel subclass [kernel encodeToCommandBuffer: cmdBuf sourceImage: source destinationState: destState destinationImage: dest ]; Default: returns nil @param commandBuffer The command buffer to allocate the temporary storage against The state will only be valid on this command buffer. @param sourceImage The MPSImage consumed by the associated -encode call. @param sourceStates The list of MPSStates consumed by the associated -encode call, for a batch size of 1. @param destinationImage The destination image for the encode call @return The list of states produced by the -encode call for batch size of 1. When the batch size is not 1, this function will be called repeatedly unless -isResultStateReusedAcrossBatch returns YES. If -isResultStateReusedAcrossBatch returns YES, then it will be called once per batch and the MPSStateBatch array will contain MPSStateBatch.length references to the same object.

type MPSCNNLocalContrastNormalization ¶

type MPSCNNLocalContrastNormalization struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnlocalcontrastnormalization

func MPSCNNLocalContrastNormalizationFromID ¶

func MPSCNNLocalContrastNormalizationFromID(id objc.ID) *MPSCNNLocalContrastNormalization

func (*MPSCNNLocalContrastNormalization) Alpha ¶

@property alpha @abstract The value of alpha. Default is 0.0 @discussion The default value 0.0 is not recommended and is preserved for backwards compatibility. With alpha 0, it performs a local mean subtraction. The MPSCNNLocalContrastNormalizationNode used with the MPSNNGraph uses 1.0 as a default.

func (*MPSCNNLocalContrastNormalization) Beta ¶

@property beta @abstract The value of beta. Default is 0.5

func (*MPSCNNLocalContrastNormalization) Delta ¶

@property delta @abstract The value of delta. Default is 1/1024

func (*MPSCNNLocalContrastNormalization) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNLocalContrastNormalization) InitWithDeviceKernelWidthKernelHeight ¶

func (o *MPSCNNLocalContrastNormalization) InitWithDeviceKernelWidthKernelHeight(device metal.MTLDevice, kernelWidth uint, kernelHeight uint) *MPSCNNLocalContrastNormalization

@abstract Initialize a local contrast normalization filter @param device The device the filter will run on @param kernelWidth The width of the kernel @param kernelHeight The height of the kernel @return A valid MPSCNNLocalContrastNormalization object or nil, if failure. NOTE: For now, kernelWidth must be equal to kernelHeight

func (*MPSCNNLocalContrastNormalization) P0 ¶

@property p0 @abstract The value of p0. Default is 1.0

func (*MPSCNNLocalContrastNormalization) Pm ¶

@property pm @abstract The value of pm. Default is 0.0

func (*MPSCNNLocalContrastNormalization) Ps ¶

@property ps @abstract The value of ps. Default is 1.0

func (*MPSCNNLocalContrastNormalization) SetAlpha ¶

func (o *MPSCNNLocalContrastNormalization) SetAlpha(alpha float32)

func (*MPSCNNLocalContrastNormalization) SetBeta ¶

func (o *MPSCNNLocalContrastNormalization) SetBeta(beta float32)

func (*MPSCNNLocalContrastNormalization) SetDelta ¶

func (o *MPSCNNLocalContrastNormalization) SetDelta(delta float32)

func (*MPSCNNLocalContrastNormalization) SetP0 ¶

func (*MPSCNNLocalContrastNormalization) SetPm ¶

func (*MPSCNNLocalContrastNormalization) SetPs ¶

type MPSCNNLocalContrastNormalizationGradient ¶

type MPSCNNLocalContrastNormalizationGradient struct {
	MPSCNNGradientKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnlocalcontrastnormalizationgradient

func MPSCNNLocalContrastNormalizationGradientFromID ¶

func MPSCNNLocalContrastNormalizationGradientFromID(id objc.ID) *MPSCNNLocalContrastNormalizationGradient

func (*MPSCNNLocalContrastNormalizationGradient) Alpha ¶

@property alpha @abstract The value of alpha. Default is 0.0 @discussion The default value 0.0 is not recommended and is preserved for backwards compatibility. With alpha 0, it performs a local mean subtraction. The MPSCNNLocalContrastNormalizationNode used with the MPSNNGraph uses 1.0 as a default.

func (*MPSCNNLocalContrastNormalizationGradient) Beta ¶

@property beta @abstract The value of beta. Default is 0.5

func (*MPSCNNLocalContrastNormalizationGradient) Delta ¶

@property delta @abstract The value of delta. Default is 1/1024

func (*MPSCNNLocalContrastNormalizationGradient) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNLocalContrastNormalizationGradient) InitWithDeviceKernelWidthKernelHeight ¶

func (o *MPSCNNLocalContrastNormalizationGradient) InitWithDeviceKernelWidthKernelHeight(device metal.MTLDevice, kernelWidth uint, kernelHeight uint) *MPSCNNLocalContrastNormalizationGradient

@abstract Initialize a local contrast normalization filter @param device The device the filter will run on @param kernelWidth The width of the kernel @param kernelHeight The height of the kernel @return A valid MPSCNNLocalContrastNormalization object or nil, if failure. NOTE: For now, kernelWidth must be equal to kernelHeight

func (*MPSCNNLocalContrastNormalizationGradient) P0 ¶

@property p0 @abstract The value of p0. Default is 1.0

func (*MPSCNNLocalContrastNormalizationGradient) Pm ¶

@property pm @abstract The value of pm. Default is 0.0

func (*MPSCNNLocalContrastNormalizationGradient) Ps ¶

@property ps @abstract The value of ps. Default is 1.0

func (*MPSCNNLocalContrastNormalizationGradient) SetAlpha ¶

func (*MPSCNNLocalContrastNormalizationGradient) SetBeta ¶

func (*MPSCNNLocalContrastNormalizationGradient) SetDelta ¶

func (*MPSCNNLocalContrastNormalizationGradient) SetP0 ¶

func (*MPSCNNLocalContrastNormalizationGradient) SetPm ¶

func (*MPSCNNLocalContrastNormalizationGradient) SetPs ¶

type MPSCNNLocalContrastNormalizationGradientNode ¶

type MPSCNNLocalContrastNormalizationGradientNode struct {
	MPSNNGradientFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnlocalcontrastnormalizationgradientnode

func MPSCNNLocalContrastNormalizationGradientNodeFromID ¶

func MPSCNNLocalContrastNormalizationGradientNodeFromID(id objc.ID) *MPSCNNLocalContrastNormalizationGradientNode

func MPSCNNLocalContrastNormalizationGradientNodeNodeWithSourceGradientSourceImageGradientStateKernelWidthKernelHeight ¶

func MPSCNNLocalContrastNormalizationGradientNodeNodeWithSourceGradientSourceImageGradientStateKernelWidthKernelHeight(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, kernelWidth uint, kernelHeight uint) *MPSCNNLocalContrastNormalizationGradientNode

func (*MPSCNNLocalContrastNormalizationGradientNode) Alpha ¶

@property alpha @abstract The value of alpha. Default is 0.0 @discussion The default value 0.0 is not recommended and is preserved for backwards compatibility. With alpha 0, it performs a local mean subtraction. The MPSCNNLocalContrastNormalizationNode used with the MPSNNGraph uses 1.0 as a default.

func (*MPSCNNLocalContrastNormalizationGradientNode) Beta ¶

@property beta @abstract The value of beta. Default is 0.5

func (*MPSCNNLocalContrastNormalizationGradientNode) Delta ¶

@property delta @abstract The value of delta. Default is 1/1024

func (*MPSCNNLocalContrastNormalizationGradientNode) InitWithSourceGradientSourceImageGradientStateKernelWidthKernelHeight ¶

func (o *MPSCNNLocalContrastNormalizationGradientNode) InitWithSourceGradientSourceImageGradientStateKernelWidthKernelHeight(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, kernelWidth uint, kernelHeight uint) *MPSCNNLocalContrastNormalizationGradientNode

func (*MPSCNNLocalContrastNormalizationGradientNode) KernelHeight ¶

func (*MPSCNNLocalContrastNormalizationGradientNode) KernelWidth ¶

func (*MPSCNNLocalContrastNormalizationGradientNode) P0 ¶

@property p0 @abstract The value of p0. Default is 1.0

func (*MPSCNNLocalContrastNormalizationGradientNode) Pm ¶

@property pm @abstract The value of pm. Default is 0.0

func (*MPSCNNLocalContrastNormalizationGradientNode) Ps ¶

@property ps @abstract The value of ps. Default is 1.0

func (*MPSCNNLocalContrastNormalizationGradientNode) SetAlpha ¶

func (*MPSCNNLocalContrastNormalizationGradientNode) SetBeta ¶

func (*MPSCNNLocalContrastNormalizationGradientNode) SetDelta ¶

func (*MPSCNNLocalContrastNormalizationGradientNode) SetP0 ¶

func (*MPSCNNLocalContrastNormalizationGradientNode) SetPm ¶

func (*MPSCNNLocalContrastNormalizationGradientNode) SetPs ¶

type MPSCNNLocalContrastNormalizationNode ¶

type MPSCNNLocalContrastNormalizationNode struct {
	MPSCNNNormalizationNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnlocalcontrastnormalizationnode

func MPSCNNLocalContrastNormalizationNodeFromID ¶

func MPSCNNLocalContrastNormalizationNodeFromID(id objc.ID) *MPSCNNLocalContrastNormalizationNode

func MPSCNNLocalContrastNormalizationNodeNodeWithSourceKernelSize ¶

func MPSCNNLocalContrastNormalizationNodeNodeWithSourceKernelSize(sourceNode *MPSNNImageNode, kernelSize uint) *MPSCNNLocalContrastNormalizationNode

func (*MPSCNNLocalContrastNormalizationNode) InitWithSource ¶

func (*MPSCNNLocalContrastNormalizationNode) InitWithSourceKernelSize ¶

func (o *MPSCNNLocalContrastNormalizationNode) InitWithSourceKernelSize(sourceNode *MPSNNImageNode, kernelSize uint) *MPSCNNLocalContrastNormalizationNode

func (*MPSCNNLocalContrastNormalizationNode) KernelHeight ¶

func (o *MPSCNNLocalContrastNormalizationNode) KernelHeight() uint

func (*MPSCNNLocalContrastNormalizationNode) KernelWidth ¶

func (o *MPSCNNLocalContrastNormalizationNode) KernelWidth() uint

func (*MPSCNNLocalContrastNormalizationNode) P0 ¶

func (*MPSCNNLocalContrastNormalizationNode) Pm ¶

func (*MPSCNNLocalContrastNormalizationNode) Ps ¶

func (*MPSCNNLocalContrastNormalizationNode) SetKernelHeight ¶

func (o *MPSCNNLocalContrastNormalizationNode) SetKernelHeight(kernelHeight uint)

func (*MPSCNNLocalContrastNormalizationNode) SetKernelWidth ¶

func (o *MPSCNNLocalContrastNormalizationNode) SetKernelWidth(kernelWidth uint)

func (*MPSCNNLocalContrastNormalizationNode) SetP0 ¶

func (*MPSCNNLocalContrastNormalizationNode) SetPm ¶

func (*MPSCNNLocalContrastNormalizationNode) SetPs ¶

type MPSCNNLogSoftMax ¶

type MPSCNNLogSoftMax struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnlogsoftmax

func MPSCNNLogSoftMaxFromID ¶

func MPSCNNLogSoftMaxFromID(id objc.ID) *MPSCNNLogSoftMax

type MPSCNNLogSoftMaxGradient ¶

type MPSCNNLogSoftMaxGradient struct {
	MPSCNNGradientKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnlogsoftmaxgradient

func MPSCNNLogSoftMaxGradientFromID ¶

func MPSCNNLogSoftMaxGradientFromID(id objc.ID) *MPSCNNLogSoftMaxGradient

func (*MPSCNNLogSoftMaxGradient) InitWithCoderDevice ¶

func (o *MPSCNNLogSoftMaxGradient) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNLogSoftMaxGradient

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNLogSoftMaxGradient) InitWithDevice ¶

@abstract Initializes a MPSCNNLogSoftMaxGradient function @param device The MTLDevice on which this MPSCNNLogSoftMaxGradient filter will be used @return A valid MPSCNNLogSoftMaxGradient object or nil, if failure.

type MPSCNNLogSoftMaxGradientNode ¶

type MPSCNNLogSoftMaxGradientNode struct {
	MPSNNGradientFilterNode
}

Node representing a MPSCNNLogSoftMaxGradient kernel

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnlogsoftmaxgradientnode

func MPSCNNLogSoftMaxGradientNodeFromID ¶

func MPSCNNLogSoftMaxGradientNodeFromID(id objc.ID) *MPSCNNLogSoftMaxGradientNode

func MPSCNNLogSoftMaxGradientNodeNodeWithSourceGradientSourceImageGradientState ¶

func MPSCNNLogSoftMaxGradientNodeNodeWithSourceGradientSourceImageGradientState(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSCNNLogSoftMaxGradientNode

func (*MPSCNNLogSoftMaxGradientNode) InitWithSourceGradientSourceImageGradientState ¶

func (o *MPSCNNLogSoftMaxGradientNode) InitWithSourceGradientSourceImageGradientState(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSCNNLogSoftMaxGradientNode

type MPSCNNLogSoftMaxNode ¶

type MPSCNNLogSoftMaxNode struct {
	MPSNNFilterNode
}

Node representing a MPSCNNLogSoftMax kernel

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnlogsoftmaxnode

func MPSCNNLogSoftMaxNodeFromID ¶

func MPSCNNLogSoftMaxNodeFromID(id objc.ID) *MPSCNNLogSoftMaxNode

func MPSCNNLogSoftMaxNodeNodeWithSource ¶

func MPSCNNLogSoftMaxNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSCNNLogSoftMaxNode

@abstract Init a node representing a autoreleased MPSCNNLogSoftMax kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @return A new MPSNNFilter node for a MPSCNNLogSoftMax kernel.

func (*MPSCNNLogSoftMaxNode) InitWithSource ¶

func (o *MPSCNNLogSoftMaxNode) InitWithSource(sourceNode *MPSNNImageNode) *MPSCNNLogSoftMaxNode

@abstract Init a node representing a MPSCNNLogSoftMax kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @return A new MPSNNFilter node for a MPSCNNLogSoftMax kernel.

type MPSCNNLoss ¶

type MPSCNNLoss struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnloss

func MPSCNNLossFromID ¶

func MPSCNNLossFromID(id objc.ID) *MPSCNNLoss

func (*MPSCNNLoss) Delta ¶

func (o *MPSCNNLoss) Delta() float32

func (*MPSCNNLoss) EncodeBatchToCommandBufferSourceImagesLabels ¶

func (o *MPSCNNLoss) EncodeBatchToCommandBufferSourceImagesLabels(commandBuffer metal.MTLCommandBuffer, sourceImage unsafe.Pointer, labels unsafe.Pointer) unsafe.Pointer

func (*MPSCNNLoss) EncodeBatchToCommandBufferSourceImagesLabelsDestinationImages ¶

func (o *MPSCNNLoss) EncodeBatchToCommandBufferSourceImagesLabelsDestinationImages(commandBuffer metal.MTLCommandBuffer, sourceImage unsafe.Pointer, labels unsafe.Pointer, destinationImage unsafe.Pointer)

func (*MPSCNNLoss) EncodeToCommandBufferSourceImageLabels ¶

func (o *MPSCNNLoss) EncodeToCommandBufferSourceImageLabels(commandBuffer metal.MTLCommandBuffer, sourceImage *mpscore.MPSImage, labels *MPSCNNLossLabels) *mpscore.MPSImage

@abstract Encode a MPSCNNLoss filter and return a gradient. @discussion This -encode call is similar to the encodeToCommandBuffer:sourceImage:labels:destinationImage: above, except that it creates and returns the MPSImage with the loss gradient result. @param commandBuffer The MTLCommandBuffer on which to encode. @param sourceImage The source image from the previous filter in the graph (in the inference direction). @param labels The object containing the target data (labels) and optionally, weights for the labels. @return The MPSImage containing the gradient result.

func (*MPSCNNLoss) EncodeToCommandBufferSourceImageLabelsDestinationImage ¶

func (o *MPSCNNLoss) EncodeToCommandBufferSourceImageLabelsDestinationImage(commandBuffer metal.MTLCommandBuffer, sourceImage *mpscore.MPSImage, labels *MPSCNNLossLabels, destinationImage *mpscore.MPSImage)

@abstract Encode a MPSCNNLoss filter and return a gradient in the destinationImage. @discussion This filter consumes the output of a previous layer, for example, the SoftMax layer containing predictions, and the MPSCNNLossLabels object containing the target data (labels) and optionally, weights for the labels. The destinationImage contains the computed gradient for the loss layer. It serves as a source gradient input image to the first gradient layer (in the backward direction), in our example, the SoftMax gradient layer. @param commandBuffer The MTLCommandBuffer on which to encode. @param sourceImage The source image from the previous filter in the graph (in the inference direction). @param labels The object containing the target data (labels) and optionally, weights for the labels. @param destinationImage The MPSImage into which to write the gradient result.

func (*MPSCNNLoss) Epsilon ¶

func (o *MPSCNNLoss) Epsilon() float32

func (*MPSCNNLoss) InitWithCoderDevice ¶

func (o *MPSCNNLoss) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNLoss

@abstract <NSSecureCoding> support

func (*MPSCNNLoss) InitWithDeviceLossDescriptor ¶

func (o *MPSCNNLoss) InitWithDeviceLossDescriptor(device metal.MTLDevice, lossDescriptor *MPSCNNLossDescriptor) *MPSCNNLoss

@abstract Initialize the loss filter with a loss descriptor. @param device The device the filter will run on. @param lossDescriptor The loss descriptor. @return A valid MPSCNNLoss object or nil, if failure.

func (*MPSCNNLoss) LabelSmoothing ¶

func (o *MPSCNNLoss) LabelSmoothing() float32

func (*MPSCNNLoss) LossType ¶

func (o *MPSCNNLoss) LossType() MPSCNNLossType

See MPSCNNLossDescriptor for information about the following properties.

func (*MPSCNNLoss) NumberOfClasses ¶

func (o *MPSCNNLoss) NumberOfClasses() uint

func (*MPSCNNLoss) ReduceAcrossBatch ¶

func (o *MPSCNNLoss) ReduceAcrossBatch() bool

func (*MPSCNNLoss) ReductionType ¶

func (o *MPSCNNLoss) ReductionType() MPSCNNReductionType

func (*MPSCNNLoss) Weight ¶

func (o *MPSCNNLoss) Weight() float32

type MPSCNNLossDataDescriptor ¶

type MPSCNNLossDataDescriptor struct {
	foundation.NSObject
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnlossdatadescriptor

func MPSCNNLossDataDescriptorCnnLossDataDescriptorWithDataLayoutSize ¶

func MPSCNNLossDataDescriptorCnnLossDataDescriptorWithDataLayoutSize(data *foundation.NSData, layout mpscore.MPSDataLayout, size metal.MTLSize) *MPSCNNLossDataDescriptor

@abstract Make a descriptor loss data. The bytesPerRow and bytesPerImage are automatically calculated assuming a dense array. If it is not a dense array, adjust bytesPerRow and bytesPerImage to the right value by changing properties. @param data The per-element loss data. The data must be in floating point format. @param layout The data layout of loss data. @param size The size of loss data. @return A valid MPSCNNLossDataDescriptor object or nil, if failure.

func MPSCNNLossDataDescriptorFromID ¶

func MPSCNNLossDataDescriptorFromID(id objc.ID) *MPSCNNLossDataDescriptor

func (*MPSCNNLossDataDescriptor) BytesPerImage ¶

func (o *MPSCNNLossDataDescriptor) BytesPerImage() uint

@property bytesPerImage @abstract Slice bytes of loss data. @discussion This parameter specifies the slice bytes of loss data.

func (*MPSCNNLossDataDescriptor) BytesPerRow ¶

func (o *MPSCNNLossDataDescriptor) BytesPerRow() uint

@property bytesPerRow @abstract Row bytes of loss data. @discussion This parameter specifies the row bytes of loss data.

func (*MPSCNNLossDataDescriptor) Layout ¶

@property layout @abstract Data layout of loss data. See MPSImage.h for more information. @discussion This parameter specifies the layout of loss data.

func (*MPSCNNLossDataDescriptor) SetBytesPerImage ¶

func (o *MPSCNNLossDataDescriptor) SetBytesPerImage(bytesPerImage uint)

func (*MPSCNNLossDataDescriptor) SetBytesPerRow ¶

func (o *MPSCNNLossDataDescriptor) SetBytesPerRow(bytesPerRow uint)

func (*MPSCNNLossDataDescriptor) Size ¶

@property size @abstract Size of loss data: (width, height, feature channels}. @discussion This parameter specifies the size of loss data.

type MPSCNNLossDescriptor ¶

type MPSCNNLossDescriptor struct {
	foundation.NSObject
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnlossdescriptor

func MPSCNNLossDescriptorCnnLossDescriptorWithTypeReductionType ¶

func MPSCNNLossDescriptorCnnLossDescriptorWithTypeReductionType(lossType MPSCNNLossType, reductionType MPSCNNReductionType) *MPSCNNLossDescriptor

@abstract Make a descriptor for a MPSCNNLoss or MPSNNLossGradient object. @param lossType The type of a loss filter. @param reductionType The type of a reduction operation to apply. This argument is ignored in the MPSNNLossGradient filter. @return A valid MPSCNNLossDescriptor object or nil, if failure.

func MPSCNNLossDescriptorFromID ¶

func MPSCNNLossDescriptorFromID(id objc.ID) *MPSCNNLossDescriptor

func (*MPSCNNLossDescriptor) Delta ¶

func (o *MPSCNNLossDescriptor) Delta() float32

@property delta @abstract The delta parameter. The default value is 1.0f. @discussion This parameter is valid only for the loss functions of the following type(s): MPSCNNLossTypeHuber. Given predictions and labels (ground truth), it is applied in the following way: if (|predictions - labels| <= delta, loss = 0.5f * predictions^2 if (|predictions - labels| > delta, loss = 0.5 * delta^2 + delta * (|predictions - labels| - delta)

func (*MPSCNNLossDescriptor) Epsilon ¶

func (o *MPSCNNLossDescriptor) Epsilon() float32

@property epsilon @abstract The epsilon parameter. The default value is 1e-7. @discussion This parameter is valid only for the loss functions of the following type(s): MPSCNNLossTypeLog. Given predictions and labels (ground truth), it is applied in the following way: -(labels * log(predictions + epsilon)) - ((1 - labels) * log(1 - predictions + epsilon))

func (*MPSCNNLossDescriptor) LabelSmoothing ¶

func (o *MPSCNNLossDescriptor) LabelSmoothing() float32

@property labelSmoothing @abstract The label smoothing parameter. The default value is 0.0f. @discussion This parameter is valid only for the loss functions of the following type(s): MPSCNNLossFunctionTypeSoftmaxCrossEntropy, MPSCNNLossFunctionTypeSigmoidCrossEntropy. MPSCNNLossFunctionTypeSoftmaxCrossEntropy: given labels (ground truth), it is applied in the following way: labels = labelSmoothing > 0 ? labels * (1 - labelSmoothing) + labelSmoothing / numberOfClasses : labels MPSCNNLossFunctionTypeSigmoidCrossEntropy: given labels (ground truth), it is applied in the following way: labels = labelSmoothing > 0 ? labels * (1 - labelSmoothing) + 0.5 * labelSmoothing : labels

func (*MPSCNNLossDescriptor) LossType ¶

func (o *MPSCNNLossDescriptor) LossType() MPSCNNLossType

@property lossType @abstract The type of a loss filter. @discussion This parameter specifies the type of a loss filter.

func (*MPSCNNLossDescriptor) NumberOfClasses ¶

func (o *MPSCNNLossDescriptor) NumberOfClasses() uint

@property numberOfClasses @abstract The number of classes parameter. The default value is 1. @discussion This parameter is valid only for the loss functions of the following type(s): MPSCNNLossFunctionTypeSoftmaxCrossEntropy. Given labels (ground truth), it is applied in the following way: labels = labelSmoothing > 0 ? labels * (1 - labelSmoothing) + labelSmoothing / numberOfClasses : labels

func (*MPSCNNLossDescriptor) ReduceAcrossBatch ¶

func (o *MPSCNNLossDescriptor) ReduceAcrossBatch() bool

@property reduceAcrossBatch @abstract If set to YES then the reduction operation is applied also across the batch-index dimension, ie. the loss value is summed over images in the batch and the result of the reduction is written on the first loss image in the batch while the other loss images will be set to zero. If set to NO, then no reductions are performed across the batch dimension and each image in the batch will contain the loss value associated with that one particular image. NOTE: If reductionType == MPSCNNReductionTypeNone, then this flag has no effect on results, that is no reductions are done in this case. NOTE: If reduceAcrossBatch is set to YES and reductionType == MPSCNNReductionTypeMean then the final forward loss value is computed by first summing over the components and then by dividing the result with: number of feature channels * width * height * number of images in the batch. The default value is NO.

func (*MPSCNNLossDescriptor) ReductionType ¶

func (o *MPSCNNLossDescriptor) ReductionType() MPSCNNReductionType

@property reductionType @abstract The type of a reduction operation performed in the loss filter. @discussion This parameter specifies the type of a reduction operation performed in the loss filter.

func (*MPSCNNLossDescriptor) SetDelta ¶

func (o *MPSCNNLossDescriptor) SetDelta(delta float32)

func (*MPSCNNLossDescriptor) SetEpsilon ¶

func (o *MPSCNNLossDescriptor) SetEpsilon(epsilon float32)

func (*MPSCNNLossDescriptor) SetLabelSmoothing ¶

func (o *MPSCNNLossDescriptor) SetLabelSmoothing(labelSmoothing float32)

func (*MPSCNNLossDescriptor) SetLossType ¶

func (o *MPSCNNLossDescriptor) SetLossType(lossType MPSCNNLossType)

func (*MPSCNNLossDescriptor) SetNumberOfClasses ¶

func (o *MPSCNNLossDescriptor) SetNumberOfClasses(numberOfClasses uint)

func (*MPSCNNLossDescriptor) SetReduceAcrossBatch ¶

func (o *MPSCNNLossDescriptor) SetReduceAcrossBatch(reduceAcrossBatch bool)

func (*MPSCNNLossDescriptor) SetReductionType ¶

func (o *MPSCNNLossDescriptor) SetReductionType(reductionType MPSCNNReductionType)

func (*MPSCNNLossDescriptor) SetWeight ¶

func (o *MPSCNNLossDescriptor) SetWeight(weight float32)

func (*MPSCNNLossDescriptor) Weight ¶

func (o *MPSCNNLossDescriptor) Weight() float32

@property weight @abstract The scale factor to apply to each element of a result. @discussion Each element of a result is multiplied by the weight value. The default value is 1.0f.

type MPSCNNLossLabels ¶

type MPSCNNLossLabels struct {
	mpscore.MPSState
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnlosslabels

func MPSCNNLossLabelsFromID ¶

func MPSCNNLossLabelsFromID(id objc.ID) *MPSCNNLossLabels

func (*MPSCNNLossLabels) InitWithDeviceLabelsDescriptor ¶

func (o *MPSCNNLossLabels) InitWithDeviceLabelsDescriptor(device metal.MTLDevice, labelsDescriptor *MPSCNNLossDataDescriptor) *MPSCNNLossLabels

@abstract Set labels (aka targets, ground truth) for the MPSCNNLossLabels object. @discussion The labels and weights data are copied into internal storage. The computed loss can either be a scalar value (in batch mode, a single value per image in a batch) or it can be one value per feature channel. Thus, the size of the loss image must either match the size of the input source image or be {1, 1, 1}, which results in a scalar value. In this convinience initializer, the assumed size of the loss image is {1, 1, 1}. @param device Device the state resources will be created on. @param labelsDescriptor Describes the labels data. This includes: - The per-element labels data. The data must be in floating point format. - Data layout of labels data. See MPSImage.h for more information. - Size of labels data: (width, height, feature channels}. - Optionally, row bytes of labels data. - Optionally, slice bytes of labels data.

func (*MPSCNNLossLabels) InitWithDeviceLossImageSizeLabelsDescriptorWeightsDescriptor ¶

func (o *MPSCNNLossLabels) InitWithDeviceLossImageSizeLabelsDescriptorWeightsDescriptor(device metal.MTLDevice, lossImageSize metal.MTLSize, labelsDescriptor *MPSCNNLossDataDescriptor, weightsDescriptor *MPSCNNLossDataDescriptor) *MPSCNNLossLabels

@abstract Set labels (aka targets, ground truth) and weights for the MPSCNNLossLabels object. Weights are optional. @discussion The labels and weights data are copied into internal storage. @param device Device the state resources will be created on. @param lossImageSize The size of the resulting loss image: { width, height, featureChannels }. The computed loss can either be a scalar value (in batch mode, a single value per image in a batch) or it can be one value per feature channel. Thus, the size of the loss image must either match the size of the input source image or be {1, 1, 1}, which results in a scalar value. @param labelsDescriptor Describes the labels data. This includes: - The per-element labels data. The data must be in floating point format. - Data layout of labels data. See MPSImage.h for more information. - Size of labels data: (width, height, feature channels}. - Optionally, row bytes of labels data. - Optionally, slice bytes of labels data. @param weightsDescriptor Describes the weights data. This includes: - The per-element weights data. The data must be in floating point format. - Data layout of weights data. See MPSImage.h for more information. - Size of weights data: (width, height, feature channels}. - Optionally, row bytes of weights data. - Optionally, slice bytes of weights data. This parameter is optional. If you are using a single weight, please use the weight property of the MPSCNNLossDescriptor object.

func (*MPSCNNLossLabels) InitWithDeviceLossImageSizeLabelsImageWeightsImage ¶

func (o *MPSCNNLossLabels) InitWithDeviceLossImageSizeLabelsImageWeightsImage(device metal.MTLDevice, lossImageSize metal.MTLSize, labelsImage *mpscore.MPSImage, weightsImage *mpscore.MPSImage) *MPSCNNLossLabels

@abstract Set labels (aka targets, ground truth) and weights for the MPSCNNLossLabels object. Weights are optional. @discussion The labels and weights images are retained - it is the users responsibility to make sure that they contain the right data when the loss filter is run on the device. @param device Device the state resources will be created on. @param lossImageSize The size of the resulting loss image: { width, height, featureChannels }. The computed loss can either be a scalar value (in batch mode, a single value per image in a batch) or it can be one value per feature channel. Thus, the size of the loss image must either match the size of the input source image or be {1, 1, 1}, which results in a scalar value. @param labelsImage Describes the labels data. @param weightsImage Describes the weights data. This parameter is optional. If you are using a single weight, please use the weight property of the MPSCNNLossDescriptor object.

func (*MPSCNNLossLabels) LabelsImage ¶

func (o *MPSCNNLossLabels) LabelsImage() *mpscore.MPSImage

@abstract Labels image accessor method. @return An autoreleased MPSImage object, containing the labels data. The labels data is populated in the -initWithDevice call. In order to guarantee that the image is correctly synchronized for CPU side access, it is the application's responsibility to call the [gradientState synchronizeOnCommandBuffer:] method before accessing the data in the image.

func (*MPSCNNLossLabels) LossImage ¶

func (o *MPSCNNLossLabels) LossImage() *mpscore.MPSImage

@abstract Loss image accessor method. @return An autoreleased MPSImage object, containing the loss data. The loss data is populated in the -encode call, thus the contents are undefined until you -encode the filter. In order to guarantee that the image is correctly synchronized for CPU side access, it is the application's responsibility to call the [gradientState synchronizeOnCommandBuffer:] method before accessing the data in the image.

func (*MPSCNNLossLabels) WeightsImage ¶

func (o *MPSCNNLossLabels) WeightsImage() *mpscore.MPSImage

@abstract Weights image accessor method. @return An autoreleased MPSImage object, containing the weights data. The weights data is populated in the -initWithDevice call. In order to guarantee that the image is correctly synchronized for CPU side access, it is the application's responsibility to call the [gradientState synchronizeOnCommandBuffer:] method before accessing the data in the image.

type MPSCNNLossNode ¶

type MPSCNNLossNode struct {
	MPSNNFilterNode
}

@class MPSCNNLossNode @discussion This node calculates loss information during training typically immediately after the inference portion of network evaluation is performed. The result image of the loss operations is typically the first gradient image to be comsumed by the gradient passes that work their way back up the graph. In addition, the node will update the loss image in the MPSNNLabels with the desired estimate of correctness.

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnlossnode

func MPSCNNLossNodeFromID ¶

func MPSCNNLossNodeFromID(id objc.ID) *MPSCNNLossNode

func MPSCNNLossNodeNodeWithSourceLossDescriptor ¶

func MPSCNNLossNodeNodeWithSourceLossDescriptor(source *MPSNNImageNode, descriptor *MPSCNNLossDescriptor) *MPSCNNLossNode

func (*MPSCNNLossNode) InitWithSourceLossDescriptor ¶

func (o *MPSCNNLossNode) InitWithSourceLossDescriptor(source *MPSNNImageNode, descriptor *MPSCNNLossDescriptor) *MPSCNNLossNode

func (*MPSCNNLossNode) InputLabels ¶

func (o *MPSCNNLossNode) InputLabels() *MPSNNLabelsNode

@abstract Get the input node for labes and weights, for example to set the handle

type MPSCNNLossType ¶

type MPSCNNLossType int64
const (
	MPSCNNLossTypeMeanAbsoluteError         MPSCNNLossType = 0
	MPSCNNLossTypeMeanSquaredError          MPSCNNLossType = 1
	MPSCNNLossTypeSoftMaxCrossEntropy       MPSCNNLossType = 2
	MPSCNNLossTypeSigmoidCrossEntropy       MPSCNNLossType = 3
	MPSCNNLossTypeCategoricalCrossEntropy   MPSCNNLossType = 4
	MPSCNNLossTypeHinge                     MPSCNNLossType = 5
	MPSCNNLossTypeHuber                     MPSCNNLossType = 6
	MPSCNNLossTypeCosineDistance            MPSCNNLossType = 7
	MPSCNNLossTypeLog                       MPSCNNLossType = 8
	MPSCNNLossTypeKullbackLeiblerDivergence MPSCNNLossType = 9
	MPSCNNLossTypeCount                     MPSCNNLossType = 10
)

func (MPSCNNLossType) String ¶

func (e MPSCNNLossType) String() string

type MPSCNNMultiaryKernel ¶

type MPSCNNMultiaryKernel struct {
	mpscore.MPSKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnmultiarykernel

func MPSCNNMultiaryKernelFromID ¶

func MPSCNNMultiaryKernelFromID(id objc.ID) *MPSCNNMultiaryKernel

func (*MPSCNNMultiaryKernel) AppendBatchBarrier ¶

func (o *MPSCNNMultiaryKernel) AppendBatchBarrier() bool

@abstract Returns YES if the filter must be run over the entire batch before its results may be used @discussion Nearly all filters do not need to see the entire batch all at once and can operate correctly with partial batches. This allows the graph to strip-mine the problem, processing the graph top to bottom on a subset of the batch at a time, dramatically reducing memory usage. As the full nominal working set for a graph is often so large that it may not fit in memory, sub-batching may be required forward progress. Batch normalization statistics on the other hand must complete the batch before the statistics may be used to normalize the images in the batch in the ensuing normalization filter. Consequently, batch normalization statistics requests the graph insert a batch barrier following it by returning YES from -appendBatchBarrier. This tells the graph to complete the batch before any dependent filters can start. Note that the filter itself may still be subject to sub-batching in its operation. All filters must be able to function without seeing the entire batch in a single -encode call. Carry over state that is accumulated across sub-batches is commonly carried in a shared MPSState containing a MTLBuffer. See -isResultStateReusedAcrossBatch. Caution: on most supported devices, the working set may be so large that the graph may be forced to throw away and recalculate most intermediate images in cases where strip-mining can not occur because -appendBatchBarrier returns YES. A single batch barrier can commonly cause a memory size increase and/or performance reduction by many fold over the entire graph. Filters of this variety should be avoided. Default: NO

func (*MPSCNNMultiaryKernel) ClipRect ¶

func (o *MPSCNNMultiaryKernel) ClipRect() metal.MTLRegion

@property clipRect @abstract An optional clip rectangle to use when writing data. Only the pixels in the rectangle will be overwritten. @discussion A MTLRegion that indicates which part of the destination to overwrite. If the clipRect does not lie completely within the destination image, the intersection between clip rectangle and destination bounds is used. Default: MPSRectNoClip (MPSKernel::MPSRectNoClip) indicating the entire image. clipRect.origin.z is the index of starting destination image in batch processing mode. clipRect.size.depth is the number of images to process in batch processing mode. See Also: @ref subsubsection_clipRect

func (*MPSCNNMultiaryKernel) DestinationFeatureChannelOffset ¶

func (o *MPSCNNMultiaryKernel) DestinationFeatureChannelOffset() uint

@property destinationFeatureChannelOffset @abstract The number of channels in the destination MPSImage to skip before writing output. @discussion This is the starting offset into the destination image in the feature channel dimension at which destination data is written. This allows an application to pass a subset of all the channels in MPSImage as output of MPSKernel. E.g. Suppose MPSImage has 24 channels and a MPSKernel outputs 8 channels. If we want channels 8 to 15 of this MPSImage to be used as output, we can set destinationFeatureChannelOffset = 8. Note that this offset applies independently to each image when the MPSImage is a container for multiple images and the MPSCNNKernel is processing multiple images (clipRect.size.depth > 1). The default value is 0 and any value specifed shall be a multiple of 4. If MPSKernel outputs N channels, destination image MUST have at least destinationFeatureChannelOffset + N channels. Using a destination image with insufficient number of feature channels result in an error. E.g. if the MPSCNNConvolution outputs 32 channels, and destination has 64 channels, then it is an error to set destinationFeatureChannelOffset > 32.

func (*MPSCNNMultiaryKernel) DestinationImageAllocator ¶

func (o *MPSCNNMultiaryKernel) DestinationImageAllocator() mpscore.MPSImageAllocator

@abstract Method to allocate the result image for -encodeToCommandBuffer:sourceImage: @discussion Default: MPSTemporaryImage.defaultAllocator

func (*MPSCNNMultiaryKernel) DestinationImageDescriptorForSourceImagesSourceStates ¶

func (o *MPSCNNMultiaryKernel) DestinationImageDescriptorForSourceImagesSourceStates(sourceImages *foundation.NSArray[*mpscore.MPSImage], sourceStates *foundation.NSArray[*mpscore.MPSState]) *mpscore.MPSImageDescriptor

@abstract Get a suggested destination image descriptor for a source image @discussion Your application is certainly free to pass in any destinationImage it likes to encodeToCommandBuffer:sourceImage:destinationImage, within reason. This is the basic design for iOS 10. This method is therefore not required. However, calculating the MPSImage size and MPSCNNKernel properties for each filter can be tedious and complicated work, so this method is made available to automate the process. The application may modify the properties of the descriptor before a MPSImage is made from it, so long as the choice is sensible for the kernel in question. Please see individual kernel descriptions for restrictions. The expected timeline for use is as follows: 1) This method is called: a) The default MPS padding calculation is applied. It uses the MPSNNPaddingMethod of the .padding property to provide a consistent addressing scheme over the graph. It creates the MPSImageDescriptor and adjusts the .offset property of the MPSNNKernel. When using a MPSNNGraph, the padding is set using the MPSNNFilterNode as a proxy. b) This method may be overridden by MPSCNNKernel subclass to achieve any customization appropriate to the object type. c) Source states are then applied in order. These may modify the descriptor and may update other object properties. See: -destinationImageDescriptorForSourceImages:sourceStates: forKernel:suggestedDescriptor: This is the typical way in which MPS may attempt to influence the operation of its kernels. d) If the .padding property has a custom padding policy method of the same name, it is called. Similarly, it may also adjust the descriptor and any MPSCNNKernel properties. This is the typical way in which your application may attempt to influence the operation of the MPS kernels. 2) A result is returned from this method and the caller may further adjust the descriptor and kernel properties directly. 3) The caller uses the descriptor to make a new MPSImage to use as the destination image for the -encode call in step 5. 4) The caller calls -resultStateForSourceImage:sourceStates:destinationImage: to make any result states needed for the kernel. If there isn't one, it will return nil. A variant is available to return a temporary state instead. 5) a -encode method is called to encode the kernel. The entire process 1-5 is more simply achieved by just calling an -encode... method that returns a MPSImage out the left hand sid of the method. Simpler still, use the MPSNNGraph to coordinate the entire process from end to end. Opportunities to influence the process are of course reduced, as (2) is no longer possible with either method. Your application may opt to use the five step method if it requires greater customization as described, or if it would like to estimate storage in advance based on the sum of MPSImageDescriptors before processing a graph. Storage estimation is done by using the MPSImageDescriptor to create a MPSImage (without passing it a texture), and then call -resourceSize. As long as the MPSImage is not used in an encode call and the .texture property is not invoked, the underlying MTLTexture is not created. No destination state or destination image is provided as an argument to this function because it is expected they will be made / configured after this is called. This method is expected to auto-configure important object properties that may be needed in the ensuing destination image and state creation steps. @param sourceImages A array of source images that will be passed into the -encode call Since MPSCNNKernel is a unary kernel, it is an array of length 1. @param sourceStates An optional array of source states that will be passed into the -encode call @return an image descriptor allocated on the autorelease pool

func (*MPSCNNMultiaryKernel) DilationRateXatIndex ¶

func (o *MPSCNNMultiaryKernel) DilationRateXatIndex(index uint) uint

@abstract Stride in source coordinates from one kernel tap to the next in the X dimension. @param index The index of the source image to which the dilation rate applies @return The dilation rate

func (*MPSCNNMultiaryKernel) DilationRateYatIndex ¶

func (o *MPSCNNMultiaryKernel) DilationRateYatIndex(index uint) uint

@abstract Stride in source coordinates from one kernel tap to the next in the Y dimension. @param index The index of the source image to which the dilation rate applies @return The dilation rate

func (*MPSCNNMultiaryKernel) EdgeModeAtIndex ¶

func (o *MPSCNNMultiaryKernel) EdgeModeAtIndex(index uint) mpscore.MPSImageEdgeMode

@abstract The MPSImageEdgeMode to use when texture reads stray off the edge of the primary source image @discussion Most MPSKernel objects can read off the edge of the source image. This can happen because of a negative offset property, because the offset + clipRect.size is larger than the source image or because the filter looks at neighboring pixels, such as a Convolution filter. Default: MPSImageEdgeModeZero. See Also: @ref subsubsection_edgemode @param index The index of the source image to which the edge mode refers @return The edge mode for that source image

func (*MPSCNNMultiaryKernel) EncodeBatchToCommandBufferSourceImages ¶

func (o *MPSCNNMultiaryKernel) EncodeBatchToCommandBufferSourceImages(commandBuffer metal.MTLCommandBuffer, sourceImageBatches *foundation.NSArray[objc.ID]) unsafe.Pointer

@abstract Encode a MPSCNNKernel into a command Buffer. Create textures to hold the results and return them. @discussion In the first iteration on this method, encodeBatchToCommandBuffer:sourceImage:destinationImage: some work was left for the developer to do in the form of correctly setting the offset property and sizing the result buffer. With the introduction of the padding policy (see padding property) the filter can do this work itself. If you would like to have some input into what sort of MPSImage (e.g. temporary vs. regular) or what size it is or where it is allocated, you may set the destinationImageAllocator to allocate the image yourself. This method uses the MPSNNPadding padding property to figure out how to size the result image and to set the offset property. See discussion in MPSNeuralNetworkTypes.h. All images in a batch must have MPSImage.numberOfImages = 1. @param commandBuffer The command buffer @param sourceImageBatches An array of image batches to use as the source images for the filter. @result A MPSImage or MPSTemporaryImage allocated per the destinationImageAllocator containing the output of the graph. The returned image will be automatically released when the command buffer completes. If you want to keep it around for longer, retain the image. (ARC will do this for you if you use it later.)

func (*MPSCNNMultiaryKernel) EncodeBatchToCommandBufferSourceImagesDestinationImages ¶

func (o *MPSCNNMultiaryKernel) EncodeBatchToCommandBufferSourceImagesDestinationImages(commandBuffer metal.MTLCommandBuffer, sourceImages *foundation.NSArray[objc.ID], destinationImages unsafe.Pointer)

@abstract Encode a MPSCNNKernel into a command Buffer. The operation shall proceed out-of-place. @discussion This is the older style of encode which reads the offset, doesn't change it, and ignores the padding method. Multiple images are processed concurrently. All images must have MPSImage.numberOfImages = 1. @param commandBuffer A valid MTLCommandBuffer to receive the encoded filter @param sourceImages An array of image batches containing the source images. @param destinationImages An array of MPSImage objects to contain the result images. destinationImages may not alias primarySourceImages or secondarySourceImages in any manner.

func (*MPSCNNMultiaryKernel) EncodeBatchToCommandBufferSourceImagesDestinationStatesDestinationStateIsTemporary ¶

func (o *MPSCNNMultiaryKernel) EncodeBatchToCommandBufferSourceImagesDestinationStatesDestinationStateIsTemporary(commandBuffer metal.MTLCommandBuffer, sourceImageBatches *foundation.NSArray[objc.ID], outState unsafe.Pointer, isTemporary bool) unsafe.Pointer

@abstract Encode a MPSCNNKernel into a command Buffer. Create a texture and state to hold the results and return them. @discussion In the first iteration on this method, encodeToCommandBuffer:sourceImage:destinationState:destinationImage: some work was left for the developer to do in the form of correctly setting the offset property and sizing the result buffer. With the introduction of the padding policy (see padding property) the filter can do this work itself. If you would like to have some input into what sort of MPSImage (e.g. temporary vs. regular) or what size it is or where it is allocated, you may set the destinationImageAllocator to allocate the image yourself. This method uses the MPSNNPadding padding property to figure out how to size the result image and to set the offset property. See discussion in MPSNeuralNetworkTypes.h. All images in a batch must have MPSImage.numberOfImages = 1. @param commandBuffer The command buffer @param sourceImageBatches An array of batches to use as the source images for the filter. @param outState A new state object is returned here. @param isTemporary YES if the outState should be a temporary object @result A MPSImage or MPSTemporaryImage allocated per the destinationImageAllocator containing the output of the graph. The offset property will be adjusted to reflect the offset used during the encode. The returned image will be automatically released when the command buffer completes. If you want to keep it around for longer, retain the image. (ARC will do this for you if you use it later.)

func (*MPSCNNMultiaryKernel) EncodeToCommandBufferSourceImages ¶

func (o *MPSCNNMultiaryKernel) EncodeToCommandBufferSourceImages(commandBuffer metal.MTLCommandBuffer, sourceImages *foundation.NSArray[*mpscore.MPSImage]) *mpscore.MPSImage

@abstract Encode a MPSCNNKernel into a command Buffer. Create a texture to hold the result and return it. @discussion In the first iteration on this method, encodeToCommandBuffer:sourceImage:destinationImage: some work was left for the developer to do in the form of correctly setting the offset property and sizing the result buffer. With the introduction of the padding policy (see padding property) the filter can do this work itself. If you would like to have some input into what sort of MPSImage (e.g. temporary vs. regular) or what size it is or where it is allocated, you may set the destinationImageAllocator to allocate the image yourself. This method uses the MPSNNPadding padding property to figure out how to size the result image and to set the offset property. See discussion in MPSNeuralNetworkTypes.h. @param commandBuffer The command buffer @param sourceImages An array of MPSImages to use as the source images for the filter. @result A MPSImage or MPSTemporaryImage allocated per the destinationImageAllocator containing the output of the graph. The returned image will be automatically released when the command buffer completes. If you want to keep it around for longer, retain the image. (ARC will do this for you if you use it later.)

func (*MPSCNNMultiaryKernel) EncodeToCommandBufferSourceImagesDestinationImage ¶

func (o *MPSCNNMultiaryKernel) EncodeToCommandBufferSourceImagesDestinationImage(commandBuffer metal.MTLCommandBuffer, sourceImages *foundation.NSArray[*mpscore.MPSImage], destinationImage *mpscore.MPSImage)

@abstract Encode a MPSCNNKernel into a command Buffer. The operation shall proceed out-of-place. @discussion This is the older style of encode which reads the offset, doesn't change it, and ignores the padding method. @param commandBuffer A valid MTLCommandBuffer to receive the encoded filter @param sourceImages An array containing the source images @param destinationImage A valid MPSImage to be overwritten by result image. destinationImage may not alias primarySourceImage or secondarySourceImage.

func (*MPSCNNMultiaryKernel) EncodeToCommandBufferSourceImagesDestinationStateDestinationStateIsTemporary ¶

func (o *MPSCNNMultiaryKernel) EncodeToCommandBufferSourceImagesDestinationStateDestinationStateIsTemporary(commandBuffer metal.MTLCommandBuffer, sourceImages *foundation.NSArray[*mpscore.MPSImage], outState *mpscore.MPSState, isTemporary bool) *mpscore.MPSImage

@abstract Encode a MPSCNNKernel into a command Buffer. Create a texture and state to hold the results and return them. @discussion In the first iteration on this method, encodeToCommandBuffer:sourceImage:destinationState:destinationImage: some work was left for the developer to do in the form of correctly setting the offset property and sizing the result buffer. With the introduction of the padding policy (see padding property) the filter can do this work itself. If you would like to have some input into what sort of MPSImage (e.g. temporary vs. regular) or what size it is or where it is allocated, you may set the destinationImageAllocator to allocate the image yourself. This method uses the MPSNNPadding padding property to figure out how to size the result image and to set the offset property. See discussion in MPSNeuralNetworkTypes.h. All images in a batch must have MPSImage.numberOfImages = 1. @param commandBuffer The command buffer @param sourceImages An array of MPSImages to use as the source images for the filter. @param outState The address of location to write the pointer to the result state of the operation @param isTemporary YES if the outState should be a temporary object @result A MPSImage or MPSTemporaryImage allocated per the destinationImageAllocator containing the output of the graph. The offset property will be adjusted to reflect the offset used during the encode. The returned image will be automatically released when the command buffer completes. If you want to keep it around for longer, retain the image. (ARC will do this for you if you use it later.)

func (*MPSCNNMultiaryKernel) InitWithCoderDevice ¶

func (o *MPSCNNMultiaryKernel) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNMultiaryKernel

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNMultiaryKernel) InitWithDeviceSourceCount ¶

func (o *MPSCNNMultiaryKernel) InitWithDeviceSourceCount(device metal.MTLDevice, sourceCount uint) *MPSCNNMultiaryKernel

@abstract Standard init with default properties per filter type @param device The device that the filter will be used on. May not be NULL. @param sourceCount The number of source images or MPSImageBatches @result 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.

func (*MPSCNNMultiaryKernel) IsBackwards ¶

func (o *MPSCNNMultiaryKernel) IsBackwards() bool

@property isBackwards @abstract YES if the filter operates backwards. @discussion This influences how strideInPixelsX/Y should be interpreted.

func (*MPSCNNMultiaryKernel) IsResultStateReusedAcrossBatch ¶

func (o *MPSCNNMultiaryKernel) IsResultStateReusedAcrossBatch() bool

@abstract Returns YES if the same state is used for every operation in a batch @discussion If NO, then each image in a MPSImageBatch will need a corresponding (and different) state to go with it. Set to YES to avoid allocating redundant state in the case when the same state is used all the time. Default: NO

func (*MPSCNNMultiaryKernel) IsStateModified ¶

func (o *MPSCNNMultiaryKernel) IsStateModified() bool

@abstract Returns true if the -encode call modifies the state object it accepts.

func (*MPSCNNMultiaryKernel) KernelHeightAtIndex ¶

func (o *MPSCNNMultiaryKernel) KernelHeightAtIndex(index uint) uint

@abstract The height of the kernel filter window @discussion This is the horizontal diameter of the region read by the filter for each result pixel. If the MPSCNNKernel does not have a filter window, then 1 will be returned. @param index The index of the source image to which the kernel width refers

func (*MPSCNNMultiaryKernel) KernelWidthAtIndex ¶

func (o *MPSCNNMultiaryKernel) KernelWidthAtIndex(index uint) uint

@abstract The width of the kernel filter window @discussion This is the horizontal diameter of the region read by the filter for each result pixel. If the MPSCNNKernel does not have a filter window, then 1 will be returned. @param index The index of the source image to which the kernel width refers

func (*MPSCNNMultiaryKernel) OffsetAtIndex ¶

func (o *MPSCNNMultiaryKernel) OffsetAtIndex(index uint) mpscore.MPSOffset

@abstract The positon of the destination clip rectangle origin relative to each source buffer @discussion The offset is defined to be the position of clipRect.origin in source coordinates. Default: {0,0,0}, indicating that the top left corners of the clipRect and source image align. offset.z is the index of starting source image in batch processing mode. @param index The index of the source image described by the offset @return A MPSOffset for that image

func (*MPSCNNMultiaryKernel) Padding ¶

func (o *MPSCNNMultiaryKernel) Padding() MPSNNPadding

@property padding @abstract The padding method used by the filter @discussion This influences how strideInPixelsX/Y should be interpreted. Default: MPSNNPaddingMethodAlignCentered | MPSNNPaddingMethodAddRemainderToTopLeft | MPSNNPaddingMethodSizeSame Some object types (e.g. MPSCNNFullyConnected) may override this default with something appropriate to its operation.

func (*MPSCNNMultiaryKernel) ResultStateBatchForSourceImagesSourceStatesDestinationImage ¶

func (o *MPSCNNMultiaryKernel) ResultStateBatchForSourceImagesSourceStatesDestinationImage(sourceImages *foundation.NSArray[objc.ID], sourceStates *foundation.NSArray[objc.ID], destinationImage unsafe.Pointer) unsafe.Pointer

func (*MPSCNNMultiaryKernel) ResultStateForSourceImagesSourceStatesDestinationImage ¶

func (o *MPSCNNMultiaryKernel) ResultStateForSourceImagesSourceStatesDestinationImage(sourceImages *foundation.NSArray[*mpscore.MPSImage], sourceStates *foundation.NSArray[*mpscore.MPSState], destinationImage *mpscore.MPSImage) *mpscore.MPSState

@abstract Allocate a MPSState (subclass) to hold the results from a -encodeBatchToCommandBuffer... operation @discussion A graph may need to allocate storage up front before executing. This may be necessary to avoid using too much memory and to manage large batches. The function should allocate any MPSState objects that will be produced by an -encode call with the indicated sourceImages and sourceStates inputs. Though the states can be further adjusted in the ensuing -encode call, the states should be initialized with all important data and all MTLResource storage allocated. The data stored in the MTLResource need not be initialized, unless the ensuing -encode call expects it to be. The MTLDevice used by the result is derived from the source image. The padding policy will be applied to the filter before this is called to give it the chance to configure any properties like MPSCNNKernel.offset. CAUTION: The kernel must have all properties set to values that will ultimately be passed to the -encode call that writes to the state, before -resultStateForSourceImages:sourceStates:destinationImage: is called or behavior is undefined. Please note that -destinationImageDescriptorForSourceImages:sourceStates: will alter some of these properties automatically based on the padding policy. If you intend to call that to make the destination image, then you should call that before -resultStateForSourceImages:sourceStates:destinationImage:. This will ensure the properties used in the encode call and in the destination image creation match those used to configure the state. The following order is recommended: // Configure MPSCNNKernel properties first kernel.edgeMode = MPSImageEdgeModeZero; kernel.destinationFeatureChannelOffset = 128; // concatenation without the copy ... // ALERT: will change MPSCNNKernel properties MPSImageDescriptor * d = [kernel destinationImageDescriptorForSourceImage: source sourceStates: states]; MPSTemporaryImage * dest = [MPSTemporaryImage temporaryImageWithCommandBuffer: cmdBuf imageDescriptor: d]; // Now that all properties are configured properly, we can make the result state // and call encode. MPSState * __nullable destState = [kernel resultStateForSourceImage: source sourceStates: states destinationImage: dest]; // This form of -encode will be declared by the MPSCNNKernel subclass [kernel encodeToCommandBuffer: cmdBuf sourceImage: source destinationState: destState destinationImage: dest ]; Default: returns nil @param sourceImages The MPSImage consumed by the associated -encode call. @param sourceStates The list of MPSStates consumed by the associated -encode call, for a batch size of 1. @param destinationImage The destination image for the encode call @return The list of states produced by the -encode call for batch size of 1. When the batch size is not 1, this function will be called repeatedly unless -isResultStateReusedAcrossBatch returns YES. If -isResultStateReusedAcrossBatch returns YES, then it will be called once per batch and the MPSStateBatch array will contain MPSStateBatch.length references to the same object.

func (*MPSCNNMultiaryKernel) SetClipRect ¶

func (o *MPSCNNMultiaryKernel) SetClipRect(clipRect metal.MTLRegion)

func (*MPSCNNMultiaryKernel) SetDestinationFeatureChannelOffset ¶

func (o *MPSCNNMultiaryKernel) SetDestinationFeatureChannelOffset(destinationFeatureChannelOffset uint)

func (*MPSCNNMultiaryKernel) SetDestinationImageAllocator ¶

func (o *MPSCNNMultiaryKernel) SetDestinationImageAllocator(destinationImageAllocator mpscore.MPSImageAllocator)

func (*MPSCNNMultiaryKernel) SetDilationRateXAtIndex ¶

func (o *MPSCNNMultiaryKernel) SetDilationRateXAtIndex(dilationRate uint, index uint)

@abstract Set the stride in source coordinates from one kernel tap to the next in the X dimension. @param index The index of the source image to which the dilation rate applies @param dilationRate The dilation rate

func (*MPSCNNMultiaryKernel) SetDilationRateYAtIndex ¶

func (o *MPSCNNMultiaryKernel) SetDilationRateYAtIndex(dilationRate uint, index uint)

@abstract Set the stride in source coordinates from one kernel tap to the next in the Y dimension. @param index The index of the source image to which the dilation rate applies @param dilationRate The dilation rate

func (*MPSCNNMultiaryKernel) SetEdgeModeAtIndex ¶

func (o *MPSCNNMultiaryKernel) SetEdgeModeAtIndex(edgeMode mpscore.MPSImageEdgeMode, index uint)

@abstract Set the MPSImageEdgeMode to use when texture reads stray off the edge of the primary source image @discussion Most MPSKernel objects can read off the edge of the source image. This can happen because of a negative offset property, because the offset + clipRect.size is larger than the source image or because the filter looks at neighboring pixels, such as a Convolution filter. Default: MPSImageEdgeModeZero. See Also: @ref subsubsection_edgemode @param edgeMode The new edge mode to use @param index The index of the source image to which the edge mode refers

func (*MPSCNNMultiaryKernel) SetKernelHeightAtIndex ¶

func (o *MPSCNNMultiaryKernel) SetKernelHeightAtIndex(height uint, index uint)

@abstract Set the height of the kernel filter window @discussion This is the horizontal diameter of the region read by the filter for each result pixel. If the MPSCNNKernel does not have a filter window, then 1 will be returned. @param height The new width @param index The index of the source image to which the kernel width refers

func (*MPSCNNMultiaryKernel) SetKernelWidthAtIndex ¶

func (o *MPSCNNMultiaryKernel) SetKernelWidthAtIndex(width uint, index uint)

@abstract Set the width of the kernel filter window @discussion This is the horizontal diameter of the region read by the filter for each result pixel. If the MPSCNNKernel does not have a filter window, then 1 will be returned. @param width The new width @param index The index of the source image to which the kernel width refers

func (*MPSCNNMultiaryKernel) SetOffsetAtIndex ¶

func (o *MPSCNNMultiaryKernel) SetOffsetAtIndex(offset mpscore.MPSOffset, index uint)

@abstract Set the positon of the destination clip rectangle origin relative to each source buffer @discussion The offset is defined to be the position of clipRect.origin in source coordinates. Default: {0,0,0}, indicating that the top left corners of the clipRect and source image align. offset.z is the index of starting source image in batch processing mode. @param offset The new offset @param index The index of the source image described by the offset

func (*MPSCNNMultiaryKernel) SetPadding ¶

func (o *MPSCNNMultiaryKernel) SetPadding(padding MPSNNPadding)

func (*MPSCNNMultiaryKernel) SetSourceFeatureChannelMaxCountAtIndex ¶

func (o *MPSCNNMultiaryKernel) SetSourceFeatureChannelMaxCountAtIndex(count uint, index uint)

@abstract Set the maximum number of channels in the source MPSImage to use @discussion Most filters can insert a slice operation into the filter for free. Use this to limit the size of the feature channel slice taken from the input image. If the value is too large, it is truncated to be the remaining size in the image after the sourceFeatureChannelOffset is taken into account. Default: ULONG_MAX @param count The new source feature channel max count @param index The index of the source image to which the max count refers

func (*MPSCNNMultiaryKernel) SetSourceFeatureChannelOffsetAtIndex ¶

func (o *MPSCNNMultiaryKernel) SetSourceFeatureChannelOffsetAtIndex(offset uint, index uint)

@abstract Set the number of channels in the source MPSImage to skip before reading the input. @discussion This is the starting offset into the source image in the feature channel dimension at which source data is read. Unit: feature channels This allows an application to read a subset of all the channels in MPSImage as input of MPSKernel. E.g. Suppose MPSImage has 24 channels and a MPSKernel needs to read 8 channels. If we want channels 8 to 15 of this MPSImage to be used as input, we can set sourceFeatureChannelOffset[0] = 8. Note that this offset applies independently to each image when the MPSImage is a container for multiple images and the MPSCNNKernel is processing multiple images (clipRect.size.depth > 1). The default value is 0 and any value specifed shall be a multiple of 4. If MPSKernel inputs N channels, the source image MUST have at least primarySourceFeatureChannelOffset + N channels. Using a source image with insufficient number of feature channels will result in an error. E.g. if the MPSCNNConvolution inputs 32 channels, and the source has 64 channels, then it is an error to set primarySourceFeatureChannelOffset > 32. @param index The index of the source image that the feature channel offset describes @param offset The source feature channel offset

func (*MPSCNNMultiaryKernel) SetStrideInPixelsXAtIndex ¶

func (o *MPSCNNMultiaryKernel) SetStrideInPixelsXAtIndex(stride uint, index uint)

@abstract The downsampling factor in the horizontal dimension for the source image @discussion If the filter does not do up or downsampling, 1 is returned. Default: 1 @param index The index of the source Image @param stride The stride for the source image

func (*MPSCNNMultiaryKernel) SetStrideInPixelsYAtIndex ¶

func (o *MPSCNNMultiaryKernel) SetStrideInPixelsYAtIndex(stride uint, index uint)

@abstract The downsampling factor in the vertical dimension for the source image @discussion If the filter does not do up or downsampling, 1 is returned. Default: 1 @param index The index of the source Image @param stride The stride for the source image

func (*MPSCNNMultiaryKernel) SourceCount ¶

func (o *MPSCNNMultiaryKernel) SourceCount() uint

@abstract The number of source images accepted by the kernel

func (*MPSCNNMultiaryKernel) SourceFeatureChannelMaxCountAtIndex ¶

func (o *MPSCNNMultiaryKernel) SourceFeatureChannelMaxCountAtIndex(index uint) uint

@abstract The maximum number of channels in the source MPSImage to use @discussion Most filters can insert a slice operation into the filter for free. Use this to limit the size of the feature channel slice taken from the input image. If the value is too large, it is truncated to be the remaining size in the image after the sourceFeatureChannelOffset is taken into account. Default: ULONG_MAX @param index The index of the source image to which the max count refers @return The source feature channel max count

func (*MPSCNNMultiaryKernel) SourceFeatureChannelOffsetAtIndex ¶

func (o *MPSCNNMultiaryKernel) SourceFeatureChannelOffsetAtIndex(index uint) uint

@abstract The number of channels in the source MPSImage to skip before reading the input. @discussion This is the starting offset into the source image in the feature channel dimension at which source data is read. Unit: feature channels This allows an application to read a subset of all the channels in MPSImage as input of MPSKernel. E.g. Suppose MPSImage has 24 channels and a MPSKernel needs to read 8 channels. If we want channels 8 to 15 of this MPSImage to be used as input, we can set sourceFeatureChannelOffset[0] = 8. Note that this offset applies independently to each image when the MPSImage is a container for multiple images and the MPSCNNKernel is processing multiple images (clipRect.size.depth > 1). The default value is 0 and any value specifed shall be a multiple of 4. If MPSKernel inputs N channels, the source image MUST have at least primarySourceFeatureChannelOffset + N channels. Using a source image with insufficient number of feature channels will result in an error. E.g. if the MPSCNNConvolution inputs 32 channels, and the source has 64 channels, then it is an error to set primarySourceFeatureChannelOffset > 32. @param index The index of the source image that the feature channel offset describes @return The source feature channel offset

func (*MPSCNNMultiaryKernel) StrideInPixelsXatIndex ¶

func (o *MPSCNNMultiaryKernel) StrideInPixelsXatIndex(index uint) uint

@abstract The downsampling factor in the horizontal dimension for the source image @param index The index of the source Image @discussion If the filter does not do up or downsampling, 1 is returned. @return The stride

func (*MPSCNNMultiaryKernel) StrideInPixelsYatIndex ¶

func (o *MPSCNNMultiaryKernel) StrideInPixelsYatIndex(index uint) uint

@abstract The downsampling factor in the vertical dimension for the source image @param index The index of the source Image @discussion If the filter does not do up or downsampling, 1 is returned. @return The stride

func (*MPSCNNMultiaryKernel) TemporaryResultStateBatchForCommandBufferSourceImagesSourceStatesDestinationImage ¶

func (o *MPSCNNMultiaryKernel) TemporaryResultStateBatchForCommandBufferSourceImagesSourceStatesDestinationImage(commandBuffer metal.MTLCommandBuffer, sourceImage *foundation.NSArray[objc.ID], sourceStates *foundation.NSArray[objc.ID], destinationImage unsafe.Pointer) unsafe.Pointer

func (*MPSCNNMultiaryKernel) TemporaryResultStateForCommandBufferSourceImagesSourceStatesDestinationImage ¶

func (o *MPSCNNMultiaryKernel) TemporaryResultStateForCommandBufferSourceImagesSourceStatesDestinationImage(commandBuffer metal.MTLCommandBuffer, sourceImage *foundation.NSArray[*mpscore.MPSImage], sourceStates *foundation.NSArray[*mpscore.MPSState], destinationImage *mpscore.MPSImage) *mpscore.MPSState

@abstract Allocate a temporary MPSState (subclass) to hold the results from a -encodeBatchToCommandBuffer... operation @discussion A graph may need to allocate storage up front before executing. This may be necessary to avoid using too much memory and to manage large batches. The function should allocate any MPSState objects that will be produced by an -encode call with the indicated sourceImages and sourceStates inputs. Though the states can be further adjusted in the ensuing -encode call, the states should be initialized with all important data and all MTLResource storage allocated. The data stored in the MTLResource need not be initialized, unless the ensuing -encode call expects it to be. The MTLDevice used by the result is derived from the command buffer. The padding policy will be applied to the filter before this is called to give it the chance to configure any properties like MPSCNNKernel.offset. CAUTION: The kernel must have all properties set to values that will ultimately be passed to the -encode call that writes to the state, before -resultStateForSourceImages:sourceStates:destinationImage: is called or behavior is undefined. Please note that -destinationImageDescriptorForSourceImages:sourceStates:destinationImage: will alter some of these properties automatically based on the padding policy. If you intend to call that to make the destination image, then you should call that before -resultStateForSourceImages:sourceStates:destinationImage:. This will ensure the properties used in the encode call and in the destination image creation match those used to configure the state. The following order is recommended: // Configure MPSCNNKernel properties first kernel.edgeMode = MPSImageEdgeModeZero; kernel.destinationFeatureChannelOffset = 128; // concatenation without the copy ... // ALERT: will change MPSCNNKernel properties MPSImageDescriptor * d = [kernel destinationImageDescriptorForSourceImage: source sourceStates: states]; MPSTemporaryImage * dest = [MPSTemporaryImage temporaryImageWithCommandBuffer: cmdBuf imageDescriptor: d]; // Now that all properties are configured properly, we can make the result state // and call encode. MPSState * __nullable destState = [kernel temporaryResultStateForCommandBuffer: cmdBuf sourceImage: source sourceStates: states]; // This form of -encode will be declared by the MPSCNNKernel subclass [kernel encodeToCommandBuffer: cmdBuf sourceImage: source destinationState: destState destinationImage: dest ]; Default: returns nil @param commandBuffer The command buffer to allocate the temporary storage against The state will only be valid on this command buffer. @param sourceImage The MPSImage consumed by the associated -encode call. @param sourceStates The list of MPSStates consumed by the associated -encode call, for a batch size of 1. @param destinationImage The destination image for the encode call @return The list of states produced by the -encode call for batch size of 1. When the batch size is not 1, this function will be called repeatedly unless -isResultStateReusedAcrossBatch returns YES. If -isResultStateReusedAcrossBatch returns YES, then it will be called once per batch and the MPSStateBatch array will contain MPSStateBatch.length references to the same object.

type MPSCNNMultiply ¶

type MPSCNNMultiply struct {
	MPSCNNArithmetic
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnmultiply

func MPSCNNMultiplyFromID ¶

func MPSCNNMultiplyFromID(id objc.ID) *MPSCNNMultiply

func (*MPSCNNMultiply) InitWithDevice ¶

func (o *MPSCNNMultiply) InitWithDevice(device metal.MTLDevice) *MPSCNNMultiply

@abstract Initialize the multiplication operator @param device The device the filter will run on. @return A valid MPSCNNMultiply object or nil, if failure.

type MPSCNNMultiplyGradient ¶

type MPSCNNMultiplyGradient struct {
	MPSCNNArithmeticGradient
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnmultiplygradient

func MPSCNNMultiplyGradientFromID ¶

func MPSCNNMultiplyGradientFromID(id objc.ID) *MPSCNNMultiplyGradient

func (*MPSCNNMultiplyGradient) InitWithDeviceIsSecondarySourceFilter ¶

func (o *MPSCNNMultiplyGradient) InitWithDeviceIsSecondarySourceFilter(device metal.MTLDevice, isSecondarySourceFilter bool) *MPSCNNMultiplyGradient

@abstract Initialize the multiplication gradient operator. @param device The device the filter will run on. @param isSecondarySourceFilter A boolean indicating whether the arithmetic gradient filter is operating on the primary or secondary source image from the forward pass. @return A valid MPSCNNMultiplyGradient object or nil, if failure.

type MPSCNNNeuron ¶

type MPSCNNNeuron struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuron

func MPSCNNNeuronFromID ¶

func MPSCNNNeuronFromID(id objc.ID) *MPSCNNNeuron

func (*MPSCNNNeuron) A ¶

func (o *MPSCNNNeuron) A() float32

func (*MPSCNNNeuron) B ¶

func (o *MPSCNNNeuron) B() float32

func (*MPSCNNNeuron) C ¶

func (o *MPSCNNNeuron) C() float32

func (*MPSCNNNeuron) Data ¶

func (o *MPSCNNNeuron) Data() *foundation.NSData

func (*MPSCNNNeuron) InitWithCoderDevice ¶

func (o *MPSCNNNeuron) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNNeuron

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNNeuron) InitWithDeviceNeuronDescriptor ¶

func (o *MPSCNNNeuron) InitWithDeviceNeuronDescriptor(device metal.MTLDevice, neuronDescriptor *MPSNNNeuronDescriptor) *MPSCNNNeuron

@abstract Initialize the neuron filter with a neuron descriptor. @param device The device the filter will run on. @param neuronDescriptor The neuron descriptor. For the neuron of type MPSCNNNeuronTypePReLU, the neuron descriptor references an NSData object containing a float array with the per feature channel value of PReLu parameter and, in this case, the MPSCNNNeuron retains the NSData object. @return A valid MPSCNNNeuron object or nil, if failure.

func (*MPSCNNNeuron) NeuronType ¶

func (o *MPSCNNNeuron) NeuronType() MPSCNNNeuronType

type MPSCNNNeuronAbsolute ¶

type MPSCNNNeuronAbsolute struct {
	MPSCNNNeuron
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronabsolute

func MPSCNNNeuronAbsoluteFromID ¶

func MPSCNNNeuronAbsoluteFromID(id objc.ID) *MPSCNNNeuronAbsolute

func (*MPSCNNNeuronAbsolute) InitWithDevice ¶

func (o *MPSCNNNeuronAbsolute) InitWithDevice(device metal.MTLDevice) *MPSCNNNeuronAbsolute

@abstract Initialize a neuron filter @param device The device the filter will run on @return A valid MPSCNNNeuronAbsolute object or nil, if failure.

type MPSCNNNeuronAbsoluteNode ¶

type MPSCNNNeuronAbsoluteNode struct {
	MPSCNNNeuronNode
}

@abstract A node representing a MPSCNNNeuronAbsolute kernel @discussion For each pixel, applies the following function: @code f(x) = fabs(x) @endcode

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronabsolutenode

func MPSCNNNeuronAbsoluteNodeFromID ¶

func MPSCNNNeuronAbsoluteNodeFromID(id objc.ID) *MPSCNNNeuronAbsoluteNode

func MPSCNNNeuronAbsoluteNodeNodeWithSource ¶

func MPSCNNNeuronAbsoluteNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronAbsoluteNode

@abstract Create an autoreleased node with default values for parameters a & b

func (*MPSCNNNeuronAbsoluteNode) InitWithSource ¶

func (o *MPSCNNNeuronAbsoluteNode) InitWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronAbsoluteNode

@abstract Init a node with default values for parameters a & b

type MPSCNNNeuronELU ¶

type MPSCNNNeuronELU struct {
	MPSCNNNeuron
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronelu

func MPSCNNNeuronELUFromID ¶

func MPSCNNNeuronELUFromID(id objc.ID) *MPSCNNNeuronELU

func (*MPSCNNNeuronELU) InitWithDeviceA ¶

func (o *MPSCNNNeuronELU) InitWithDeviceA(device metal.MTLDevice, a float32) *MPSCNNNeuronELU

@abstract Initialize a parametric ELU neuron filter @param device The device the filter will run on @param a Filter property "a". See class discussion. @return A valid MPSCNNNeuronELU object or nil, if failure.

type MPSCNNNeuronELUNode ¶

type MPSCNNNeuronELUNode struct {
	MPSCNNNeuronNode
}

@abstract A node representing a MPSCNNNeuronELU kernel @discussion For each pixel, applies the following function: @code f(x) = a * exp(x) - 1, x < 0 x , x >= 0 @endcode

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronelunode

func MPSCNNNeuronELUNodeFromID ¶

func MPSCNNNeuronELUNodeFromID(id objc.ID) *MPSCNNNeuronELUNode

func MPSCNNNeuronELUNodeNodeWithSource ¶

func MPSCNNNeuronELUNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronELUNode

@abstract Create an autoreleased node with default values for parameters a & b

func MPSCNNNeuronELUNodeNodeWithSourceA ¶

func MPSCNNNeuronELUNodeNodeWithSourceA(sourceNode *MPSNNImageNode, a float32) *MPSCNNNeuronELUNode

func (*MPSCNNNeuronELUNode) InitWithSource ¶

func (o *MPSCNNNeuronELUNode) InitWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronELUNode

@abstract Init a node with default values for parameters a & b

func (*MPSCNNNeuronELUNode) InitWithSourceA ¶

func (o *MPSCNNNeuronELUNode) InitWithSourceA(sourceNode *MPSNNImageNode, a float32) *MPSCNNNeuronELUNode

type MPSCNNNeuronExponential ¶

type MPSCNNNeuronExponential struct {
	MPSCNNNeuron
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronexponential

func MPSCNNNeuronExponentialFromID ¶

func MPSCNNNeuronExponentialFromID(id objc.ID) *MPSCNNNeuronExponential

func (*MPSCNNNeuronExponential) InitWithDeviceABC ¶

func (o *MPSCNNNeuronExponential) InitWithDeviceABC(device metal.MTLDevice, a float32, b float32, c float32) *MPSCNNNeuronExponential

@abstract Initialize a Exponential neuron filter. @param device The device the filter will run on. @param a Filter property "a". See class discussion. @param b Filter property "b". See class discussion. @param c Filter property "c". See class discussion. @return A valid MPSCNNNeuronExponential object or nil, if failure.

type MPSCNNNeuronExponentialNode ¶

type MPSCNNNeuronExponentialNode struct {
	MPSCNNNeuronNode
}

@abstract A node representing a MPSCNNNeuronExponential kernel @discussion For each pixel, applies the following function: @code f(x) = c ^ (a * x + b) @endcode

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronexponentialnode

func MPSCNNNeuronExponentialNodeFromID ¶

func MPSCNNNeuronExponentialNodeFromID(id objc.ID) *MPSCNNNeuronExponentialNode

func MPSCNNNeuronExponentialNodeNodeWithSource ¶

func MPSCNNNeuronExponentialNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronExponentialNode

@abstract Create an autoreleased node with default values for parameters a, b, and c

func MPSCNNNeuronExponentialNodeNodeWithSourceABC ¶

func MPSCNNNeuronExponentialNodeNodeWithSourceABC(sourceNode *MPSNNImageNode, a float32, b float32, c float32) *MPSCNNNeuronExponentialNode

func (*MPSCNNNeuronExponentialNode) InitWithSource ¶

@abstract Init a node with default values for parameters a, b, and c

func (*MPSCNNNeuronExponentialNode) InitWithSourceABC ¶

@abstract Init a node representing a MPSCNNNeuronExponential kernel @discussion For each pixel, applies the following function: @code f(x) = c ^ (a * x + b) @endcode @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param a See discussion above. @param b See discussion above. @param c See discussion above. @return A new MPSNNFilter node for a MPSCNNNeuronExponential kernel.

type MPSCNNNeuronGeLUNode ¶

type MPSCNNNeuronGeLUNode struct {
	MPSCNNNeuronNode
}

@abstract A node representing a MPSCNNNeuronGeLU kernel @discussion For each pixel, applies the following function:

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneurongelunode

func MPSCNNNeuronGeLUNodeFromID ¶

func MPSCNNNeuronGeLUNodeFromID(id objc.ID) *MPSCNNNeuronGeLUNode

func MPSCNNNeuronGeLUNodeNodeWithSource ¶

func MPSCNNNeuronGeLUNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronGeLUNode

@abstract Create an autoreleased node

func (*MPSCNNNeuronGeLUNode) InitWithSource ¶

func (o *MPSCNNNeuronGeLUNode) InitWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronGeLUNode

@abstract Init a node representing a MPSCNNNeuronGeLU kernel @discussion For each pixel, applies the following function: @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @return A new MPSNNFilter node for a MPSCNNNeuronLogarithm kernel.

type MPSCNNNeuronGradient ¶

type MPSCNNNeuronGradient struct {
	MPSCNNGradientKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneurongradient

func MPSCNNNeuronGradientFromID ¶

func MPSCNNNeuronGradientFromID(id objc.ID) *MPSCNNNeuronGradient

func (*MPSCNNNeuronGradient) A ¶

func (*MPSCNNNeuronGradient) B ¶

func (*MPSCNNNeuronGradient) C ¶

func (*MPSCNNNeuronGradient) Data ¶

func (*MPSCNNNeuronGradient) InitWithCoderDevice ¶

func (o *MPSCNNNeuronGradient) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNNeuronGradient

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNNeuronGradient) InitWithDeviceNeuronDescriptor ¶

func (o *MPSCNNNeuronGradient) InitWithDeviceNeuronDescriptor(device metal.MTLDevice, neuronDescriptor *MPSNNNeuronDescriptor) *MPSCNNNeuronGradient

@abstract Initialize the neuron gradient filter with a neuron descriptor. @param device The device the filter will run on. @param neuronDescriptor The neuron descriptor. For the neuron of type MPSCNNNeuronTypePReLU, the neuron descriptor references an NSData object containing a float array with the per feature channel value of PReLu parameter and, in this case, the MPSCNNNeuronGradient retains the NSData object. @return A valid MPSCNNNeuronGradient object or nil, if failure.

func (*MPSCNNNeuronGradient) NeuronType ¶

func (o *MPSCNNNeuronGradient) NeuronType() MPSCNNNeuronType

type MPSCNNNeuronGradientNode ¶

type MPSCNNNeuronGradientNode struct {
	MPSNNGradientFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneurongradientnode

func MPSCNNNeuronGradientNodeFromID ¶

func MPSCNNNeuronGradientNodeFromID(id objc.ID) *MPSCNNNeuronGradientNode

func MPSCNNNeuronGradientNodeNodeWithSourceGradientSourceImageGradientStateDescriptor ¶

func MPSCNNNeuronGradientNodeNodeWithSourceGradientSourceImageGradientStateDescriptor(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, descriptor *MPSNNNeuronDescriptor) *MPSCNNNeuronGradientNode

@abstract create a new neuron gradient node @discussion See also -[MPSCNNNeuronNode gradientFilterNodeWithSources:] for an easier way to do this

func (*MPSCNNNeuronGradientNode) Descriptor ¶

@abstract The neuron descriptor

func (*MPSCNNNeuronGradientNode) InitWithSourceGradientSourceImageGradientStateDescriptor ¶

func (o *MPSCNNNeuronGradientNode) InitWithSourceGradientSourceImageGradientStateDescriptor(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, descriptor *MPSNNNeuronDescriptor) *MPSCNNNeuronGradientNode

@abstract create a new neuron gradient node @discussion See also -[MPSCNNNeuronNode gradientFilterNodeWithSources:] for an easier way to do this

type MPSCNNNeuronHardSigmoid ¶

type MPSCNNNeuronHardSigmoid struct {
	MPSCNNNeuron
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronhardsigmoid

func MPSCNNNeuronHardSigmoidFromID ¶

func MPSCNNNeuronHardSigmoidFromID(id objc.ID) *MPSCNNNeuronHardSigmoid

func (*MPSCNNNeuronHardSigmoid) InitWithDeviceAB ¶

@abstract Initialize a neuron filter @param device The device the filter will run on @param a Filter property "a". See class discussion. @param b Filter property "b". See class discussion. @return A valid MPSCNNNeuronHardSigmoid object or nil, if failure.

type MPSCNNNeuronHardSigmoidNode ¶

type MPSCNNNeuronHardSigmoidNode struct {
	MPSCNNNeuronNode
}

@abstract A node representing a MPSCNNNeuronHardSigmoid kernel @discussion For each pixel, applies the following function: @code f(x) = clamp((a * x) + b, 0, 1) @endcode

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronhardsigmoidnode

func MPSCNNNeuronHardSigmoidNodeFromID ¶

func MPSCNNNeuronHardSigmoidNodeFromID(id objc.ID) *MPSCNNNeuronHardSigmoidNode

func MPSCNNNeuronHardSigmoidNodeNodeWithSource ¶

func MPSCNNNeuronHardSigmoidNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronHardSigmoidNode

@abstract Create an autoreleased node with default values for parameters a & b

func MPSCNNNeuronHardSigmoidNodeNodeWithSourceAB ¶

func MPSCNNNeuronHardSigmoidNodeNodeWithSourceAB(sourceNode *MPSNNImageNode, a float32, b float32) *MPSCNNNeuronHardSigmoidNode

func (*MPSCNNNeuronHardSigmoidNode) InitWithSource ¶

@abstract Init a node with default values for parameters a & b

func (*MPSCNNNeuronHardSigmoidNode) InitWithSourceAB ¶

@abstract Init a node representing a MPSCNNNeuronHardSigmoid kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param a See discussion above. @param b See discussion above. @return A new MPSNNFilter node for a MPSCNNNeuronHardSigmoid kernel.

type MPSCNNNeuronLinear ¶

type MPSCNNNeuronLinear struct {
	MPSCNNNeuron
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronlinear

func MPSCNNNeuronLinearFromID ¶

func MPSCNNNeuronLinearFromID(id objc.ID) *MPSCNNNeuronLinear

func (*MPSCNNNeuronLinear) InitWithDeviceAB ¶

func (o *MPSCNNNeuronLinear) InitWithDeviceAB(device metal.MTLDevice, a float32, b float32) *MPSCNNNeuronLinear

@abstract Initialize the linear neuron filter @param device The device the filter will run on @param a Filter property "a". See class discussion. @param b Filter property "b". See class discussion. @return A valid MPSCNNNeuronLinear object or nil, if failure.

type MPSCNNNeuronLinearNode ¶

type MPSCNNNeuronLinearNode struct {
	MPSCNNNeuronNode
}

@abstract A node representing a MPSCNNNeuronLinear kernel @discussion For each pixel, applies the following function: @code f(x) = a * x + b @endcode

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronlinearnode

func MPSCNNNeuronLinearNodeFromID ¶

func MPSCNNNeuronLinearNodeFromID(id objc.ID) *MPSCNNNeuronLinearNode

func MPSCNNNeuronLinearNodeNodeWithSource ¶

func MPSCNNNeuronLinearNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronLinearNode

@abstract Create an autoreleased node with default values for parameters a & b

func MPSCNNNeuronLinearNodeNodeWithSourceAB ¶

func MPSCNNNeuronLinearNodeNodeWithSourceAB(sourceNode *MPSNNImageNode, a float32, b float32) *MPSCNNNeuronLinearNode

func (*MPSCNNNeuronLinearNode) InitWithSource ¶

func (o *MPSCNNNeuronLinearNode) InitWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronLinearNode

@abstract Init a node with default values for parameters a & b

func (*MPSCNNNeuronLinearNode) InitWithSourceAB ¶

func (o *MPSCNNNeuronLinearNode) InitWithSourceAB(sourceNode *MPSNNImageNode, a float32, b float32) *MPSCNNNeuronLinearNode

@abstract Init a node representing a MPSCNNNeuronLinear kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param a See discussion above. @param b See discussion above. @return A new MPSNNFilter node for a MPSCNNNeuronLinear kernel.

type MPSCNNNeuronLogarithm ¶

type MPSCNNNeuronLogarithm struct {
	MPSCNNNeuron
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronlogarithm

func MPSCNNNeuronLogarithmFromID ¶

func MPSCNNNeuronLogarithmFromID(id objc.ID) *MPSCNNNeuronLogarithm

func (*MPSCNNNeuronLogarithm) InitWithDeviceABC ¶

func (o *MPSCNNNeuronLogarithm) InitWithDeviceABC(device metal.MTLDevice, a float32, b float32, c float32) *MPSCNNNeuronLogarithm

@abstract Initialize a Logarithm neuron filter. @param device The device the filter will run on. @param a Filter property "a". See class discussion. @param b Filter property "b". See class discussion. @param c Filter property "c". See class discussion. @return A valid MPSCNNNeuronLogarithm object or nil, if failure.

type MPSCNNNeuronLogarithmNode ¶

type MPSCNNNeuronLogarithmNode struct {
	MPSCNNNeuronNode
}

@abstract A node representing a MPSCNNNeuronLogarithm kernel @discussion For each pixel, applies the following function: @code f(x) = log_c(a * x + b) @endcode

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronlogarithmnode

func MPSCNNNeuronLogarithmNodeFromID ¶

func MPSCNNNeuronLogarithmNodeFromID(id objc.ID) *MPSCNNNeuronLogarithmNode

func MPSCNNNeuronLogarithmNodeNodeWithSource ¶

func MPSCNNNeuronLogarithmNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronLogarithmNode

@abstract Create an autoreleased node with default values for parameters a, b, and c

func MPSCNNNeuronLogarithmNodeNodeWithSourceABC ¶

func MPSCNNNeuronLogarithmNodeNodeWithSourceABC(sourceNode *MPSNNImageNode, a float32, b float32, c float32) *MPSCNNNeuronLogarithmNode

func (*MPSCNNNeuronLogarithmNode) InitWithSource ¶

func (o *MPSCNNNeuronLogarithmNode) InitWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronLogarithmNode

@abstract Init a node with default values for parameters a, b, and c

func (*MPSCNNNeuronLogarithmNode) InitWithSourceABC ¶

func (o *MPSCNNNeuronLogarithmNode) InitWithSourceABC(sourceNode *MPSNNImageNode, a float32, b float32, c float32) *MPSCNNNeuronLogarithmNode

@abstract Init a node representing a MPSCNNNeuronLogarithm kernel @discussion For each pixel, applies the following function: @code f(x) = log_c(a * x + b) @endcode @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param a See discussion above. @param b See discussion above. @param c See discussion above. @return A new MPSNNFilter node for a MPSCNNNeuronLogarithm kernel.

type MPSCNNNeuronNode ¶

type MPSCNNNeuronNode struct {
	MPSNNFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronnode

func MPSCNNNeuronNodeFromID ¶

func MPSCNNNeuronNodeFromID(id objc.ID) *MPSCNNNeuronNode

func MPSCNNNeuronNodeNodeWithSourceDescriptor ¶

func MPSCNNNeuronNodeNodeWithSourceDescriptor(sourceNode *MPSNNImageNode, descriptor *MPSNNNeuronDescriptor) *MPSCNNNeuronNode

@abstract Create a neuron node of the appropriate type with a MPSNNNeuronDescriptor

func (*MPSCNNNeuronNode) A ¶

func (o *MPSCNNNeuronNode) A() float32

@abstract filter parameter a

func (*MPSCNNNeuronNode) B ¶

func (o *MPSCNNNeuronNode) B() float32

@abstract filter parameter b

func (*MPSCNNNeuronNode) C ¶

func (o *MPSCNNNeuronNode) C() float32

@abstract filter parameter c

type MPSCNNNeuronPReLU ¶

type MPSCNNNeuronPReLU struct {
	MPSCNNNeuron
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronprelu

func MPSCNNNeuronPReLUFromID ¶

func MPSCNNNeuronPReLUFromID(id objc.ID) *MPSCNNNeuronPReLU

func (*MPSCNNNeuronPReLU) InitWithDeviceACount ¶

func (o *MPSCNNNeuronPReLU) InitWithDeviceACount(device metal.MTLDevice, a *float32, count uint) *MPSCNNNeuronPReLU

@abstract Initialize the PReLU neuron filter @param device The device the filter will run on @param a Array of floats containing per channel value of PReLu parameter @param count Number of float values in array a. This usually corresponds to number of output channels in convolution layer @return A valid MPSCNNNeuronPReLU object or nil, if failure.

type MPSCNNNeuronPReLUNode ¶

type MPSCNNNeuronPReLUNode struct {
	MPSCNNNeuronNode
}

@abstract A ReLU node with parameter a provided independently for each feature channel @discussion For each pixel, applies the following function: @code f(x) = x if x >= 0 = aData[i] * x if x < 0, i is the index of the feature channel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param aData An array of single precision floating-point alpha values to use @endcode

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronprelunode

func MPSCNNNeuronPReLUNodeFromID ¶

func MPSCNNNeuronPReLUNodeFromID(id objc.ID) *MPSCNNNeuronPReLUNode

func MPSCNNNeuronPReLUNodeNodeWithSourceAData ¶

func MPSCNNNeuronPReLUNodeNodeWithSourceAData(sourceNode *MPSNNImageNode, aData *foundation.NSData) *MPSCNNNeuronPReLUNode

func (*MPSCNNNeuronPReLUNode) InitWithSourceAData ¶

func (o *MPSCNNNeuronPReLUNode) InitWithSourceAData(sourceNode *MPSNNImageNode, aData *foundation.NSData) *MPSCNNNeuronPReLUNode

@abstract Init a node representing a MPSCNNNeuronTanH kernel @discussion For each pixel, applies the following function: @code f(x) = x if x >= 0 = aData[i] * x if x < 0, i is the index of the feature channel @endcode @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param aData An array of single precision floating-point alpha values to use @return A new MPSNNFilter node for a MPSCNNNeuronTanH kernel.

type MPSCNNNeuronPower ¶

type MPSCNNNeuronPower struct {
	MPSCNNNeuron
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronpower

func MPSCNNNeuronPowerFromID ¶

func MPSCNNNeuronPowerFromID(id objc.ID) *MPSCNNNeuronPower

func (*MPSCNNNeuronPower) InitWithDeviceABC ¶

func (o *MPSCNNNeuronPower) InitWithDeviceABC(device metal.MTLDevice, a float32, b float32, c float32) *MPSCNNNeuronPower

@abstract Initialize a Power neuron filter. @param device The device the filter will run on. @param a Filter property "a". See class discussion. @param b Filter property "b". See class discussion. @param c Filter property "c". See class discussion. @return A valid MPSCNNNeuronPower object or nil, if failure.

type MPSCNNNeuronPowerNode ¶

type MPSCNNNeuronPowerNode struct {
	MPSCNNNeuronNode
}

@abstract A node representing a MPSCNNNeuronPower kernel @discussion For each pixel, applies the following function: @code f(x) = (a * x + b) ^ c @endcode

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronpowernode

func MPSCNNNeuronPowerNodeFromID ¶

func MPSCNNNeuronPowerNodeFromID(id objc.ID) *MPSCNNNeuronPowerNode

func MPSCNNNeuronPowerNodeNodeWithSource ¶

func MPSCNNNeuronPowerNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronPowerNode

@abstract Create an autoreleased node with default values for parameters a, b, and c

func MPSCNNNeuronPowerNodeNodeWithSourceABC ¶

func MPSCNNNeuronPowerNodeNodeWithSourceABC(sourceNode *MPSNNImageNode, a float32, b float32, c float32) *MPSCNNNeuronPowerNode

func (*MPSCNNNeuronPowerNode) InitWithSource ¶

func (o *MPSCNNNeuronPowerNode) InitWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronPowerNode

@abstract Init a node with default values for parameters a, b, and c

func (*MPSCNNNeuronPowerNode) InitWithSourceABC ¶

func (o *MPSCNNNeuronPowerNode) InitWithSourceABC(sourceNode *MPSNNImageNode, a float32, b float32, c float32) *MPSCNNNeuronPowerNode

@abstract Init a node representing a MPSCNNNeuronPower kernel @discussion For each pixel, applies the following function: @code f(x) = (a * x + b) ^ c @endcode @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param a See discussion above. @param b See discussion above. @param c See discussion above. @return A new MPSNNFilter node for a MPSCNNNeuronPower kernel.

type MPSCNNNeuronReLU ¶

type MPSCNNNeuronReLU struct {
	MPSCNNNeuron
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronrelu

func MPSCNNNeuronReLUFromID ¶

func MPSCNNNeuronReLUFromID(id objc.ID) *MPSCNNNeuronReLU

func (*MPSCNNNeuronReLU) InitWithDeviceA ¶

func (o *MPSCNNNeuronReLU) InitWithDeviceA(device metal.MTLDevice, a float32) *MPSCNNNeuronReLU

@abstract Initialize the ReLU neuron filter @param device The device the filter will run on @param a Filter property "a". See class discussion. @return A valid MPSCNNNeuronReLU object or nil, if failure.

type MPSCNNNeuronReLUN ¶

type MPSCNNNeuronReLUN struct {
	MPSCNNNeuron
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronrelun

func MPSCNNNeuronReLUNFromID ¶

func MPSCNNNeuronReLUNFromID(id objc.ID) *MPSCNNNeuronReLUN

func (*MPSCNNNeuronReLUN) InitWithDeviceAB ¶

func (o *MPSCNNNeuronReLUN) InitWithDeviceAB(device metal.MTLDevice, a float32, b float32) *MPSCNNNeuronReLUN

@abstract Initialize a ReLUN neuron filter @param device The device the filter will run on @param a Filter property "a". See class discussion. @param b Filter property "b". See class discussion. @return A valid MPSCNNNeuronReLUN object or nil, if failure.

type MPSCNNNeuronReLUNNode ¶

type MPSCNNNeuronReLUNNode struct {
	MPSCNNNeuronNode
}

@abstract A node representing a MPSCNNNeuronReLUN kernel @discussion For each pixel, applies the following function: @code f(x) = min((x >= 0 ? x : a * x), b) @endcode

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronrelunnode

func MPSCNNNeuronReLUNNodeFromID ¶

func MPSCNNNeuronReLUNNodeFromID(id objc.ID) *MPSCNNNeuronReLUNNode

func MPSCNNNeuronReLUNNodeNodeWithSource ¶

func MPSCNNNeuronReLUNNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronReLUNNode

@abstract Create an autoreleased node with default values for parameters a & b

func MPSCNNNeuronReLUNNodeNodeWithSourceAB ¶

func MPSCNNNeuronReLUNNodeNodeWithSourceAB(sourceNode *MPSNNImageNode, a float32, b float32) *MPSCNNNeuronReLUNNode

func (*MPSCNNNeuronReLUNNode) InitWithSource ¶

func (o *MPSCNNNeuronReLUNNode) InitWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronReLUNNode

@abstract Create an autoreleased node with default values for parameters a & b

func (*MPSCNNNeuronReLUNNode) InitWithSourceAB ¶

func (o *MPSCNNNeuronReLUNNode) InitWithSourceAB(sourceNode *MPSNNImageNode, a float32, b float32) *MPSCNNNeuronReLUNNode

type MPSCNNNeuronReLUNode ¶

type MPSCNNNeuronReLUNode struct {
	MPSCNNNeuronNode
}

@abstract A node representing a MPSCNNNeuronReLU kernel @discussion For each pixel, applies the following function: @code f(x) = x if x >= 0 = a * x if x < 0 @endcode

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronrelunode

func MPSCNNNeuronReLUNodeFromID ¶

func MPSCNNNeuronReLUNodeFromID(id objc.ID) *MPSCNNNeuronReLUNode

func MPSCNNNeuronReLUNodeNodeWithSource ¶

func MPSCNNNeuronReLUNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronReLUNode

@abstract Create an autoreleased node with default values for parameters a & b

func MPSCNNNeuronReLUNodeNodeWithSourceA ¶

func MPSCNNNeuronReLUNodeNodeWithSourceA(sourceNode *MPSNNImageNode, a float32) *MPSCNNNeuronReLUNode

func (*MPSCNNNeuronReLUNode) InitWithSource ¶

func (o *MPSCNNNeuronReLUNode) InitWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronReLUNode

@abstract Init a node with default values for parameters a & b

func (*MPSCNNNeuronReLUNode) InitWithSourceA ¶

func (o *MPSCNNNeuronReLUNode) InitWithSourceA(sourceNode *MPSNNImageNode, a float32) *MPSCNNNeuronReLUNode

@abstract Init a node with default values for parameters a & b

type MPSCNNNeuronSigmoid ¶

type MPSCNNNeuronSigmoid struct {
	MPSCNNNeuron
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronsigmoid

func MPSCNNNeuronSigmoidFromID ¶

func MPSCNNNeuronSigmoidFromID(id objc.ID) *MPSCNNNeuronSigmoid

func (*MPSCNNNeuronSigmoid) InitWithDevice ¶

func (o *MPSCNNNeuronSigmoid) InitWithDevice(device metal.MTLDevice) *MPSCNNNeuronSigmoid

@abstract Initialize a neuron filter @param device The device the filter will run on @return A valid MPSCNNNeuronSigmoid object or nil, if failure.

type MPSCNNNeuronSigmoidNode ¶

type MPSCNNNeuronSigmoidNode struct {
	MPSCNNNeuronNode
}

@abstract A node representing a MPSCNNNeuronSigmoid kernel @discussion For each pixel, applies the following function: @code f(x) = 1 / (1 + e^-x) @endcode

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronsigmoidnode

func MPSCNNNeuronSigmoidNodeFromID ¶

func MPSCNNNeuronSigmoidNodeFromID(id objc.ID) *MPSCNNNeuronSigmoidNode

func MPSCNNNeuronSigmoidNodeNodeWithSource ¶

func MPSCNNNeuronSigmoidNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronSigmoidNode

@abstract Create an autoreleased node with default values for parameters a & b

func (*MPSCNNNeuronSigmoidNode) InitWithSource ¶

func (o *MPSCNNNeuronSigmoidNode) InitWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronSigmoidNode

@abstract Init a node with default values for parameters a & b

type MPSCNNNeuronSoftPlus ¶

type MPSCNNNeuronSoftPlus struct {
	MPSCNNNeuron
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronsoftplus

func MPSCNNNeuronSoftPlusFromID ¶

func MPSCNNNeuronSoftPlusFromID(id objc.ID) *MPSCNNNeuronSoftPlus

func (*MPSCNNNeuronSoftPlus) InitWithDeviceAB ¶

func (o *MPSCNNNeuronSoftPlus) InitWithDeviceAB(device metal.MTLDevice, a float32, b float32) *MPSCNNNeuronSoftPlus

@abstract Initialize a parametric softplus neuron filter @param device The device the filter will run on @param a Filter property "a". See class discussion. @param b Filter property "b". See class discussion. @return A valid MPSCNNNeuronSoftPlus object or nil, if failure.

type MPSCNNNeuronSoftPlusNode ¶

type MPSCNNNeuronSoftPlusNode struct {
	MPSCNNNeuronNode
}

@abstract A node representing a MPSCNNNeuronSoftPlus kernel @discussion For each pixel, applies the following function: @code f(x) = a * log(1 + e^(b * x)) @endcode

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronsoftplusnode

func MPSCNNNeuronSoftPlusNodeFromID ¶

func MPSCNNNeuronSoftPlusNodeFromID(id objc.ID) *MPSCNNNeuronSoftPlusNode

func MPSCNNNeuronSoftPlusNodeNodeWithSource ¶

func MPSCNNNeuronSoftPlusNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronSoftPlusNode

@abstract Create an autoreleased node with default values for parameters a & b

func MPSCNNNeuronSoftPlusNodeNodeWithSourceAB ¶

func MPSCNNNeuronSoftPlusNodeNodeWithSourceAB(sourceNode *MPSNNImageNode, a float32, b float32) *MPSCNNNeuronSoftPlusNode

func (*MPSCNNNeuronSoftPlusNode) InitWithSource ¶

func (o *MPSCNNNeuronSoftPlusNode) InitWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronSoftPlusNode

@abstract Init a node with default values for parameters a & b

func (*MPSCNNNeuronSoftPlusNode) InitWithSourceAB ¶

func (o *MPSCNNNeuronSoftPlusNode) InitWithSourceAB(sourceNode *MPSNNImageNode, a float32, b float32) *MPSCNNNeuronSoftPlusNode

@abstract Init a node representing a MPSCNNNeuronSoftPlus kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param a See discussion above. @param b See discussion above. @return A new MPSNNFilter node for a MPSCNNNeuronSoftPlus kernel.

type MPSCNNNeuronSoftSign ¶

type MPSCNNNeuronSoftSign struct {
	MPSCNNNeuron
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronsoftsign

func MPSCNNNeuronSoftSignFromID ¶

func MPSCNNNeuronSoftSignFromID(id objc.ID) *MPSCNNNeuronSoftSign

func (*MPSCNNNeuronSoftSign) InitWithDevice ¶

func (o *MPSCNNNeuronSoftSign) InitWithDevice(device metal.MTLDevice) *MPSCNNNeuronSoftSign

@abstract Initialize a softsign neuron filter @param device The device the filter will run on @return A valid MPSCNNNeuronSoftSign object or nil, if failure.

type MPSCNNNeuronSoftSignNode ¶

type MPSCNNNeuronSoftSignNode struct {
	MPSCNNNeuronNode
}

@abstract A node representing a MPSCNNNeuronSoftSign kernel @discussion For each pixel, applies the following function: @code f(x) = x / (1 + abs(x)) @endcode

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneuronsoftsignnode

func MPSCNNNeuronSoftSignNodeFromID ¶

func MPSCNNNeuronSoftSignNodeFromID(id objc.ID) *MPSCNNNeuronSoftSignNode

func MPSCNNNeuronSoftSignNodeNodeWithSource ¶

func MPSCNNNeuronSoftSignNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronSoftSignNode

@abstract Create an autoreleased node with default values for parameters a & b

func (*MPSCNNNeuronSoftSignNode) InitWithSource ¶

func (o *MPSCNNNeuronSoftSignNode) InitWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronSoftSignNode

@abstract Init a node with default values for parameters a & b

type MPSCNNNeuronTanH ¶

type MPSCNNNeuronTanH struct {
	MPSCNNNeuron
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneurontanh

func MPSCNNNeuronTanHFromID ¶

func MPSCNNNeuronTanHFromID(id objc.ID) *MPSCNNNeuronTanH

func (*MPSCNNNeuronTanH) InitWithDeviceAB ¶

func (o *MPSCNNNeuronTanH) InitWithDeviceAB(device metal.MTLDevice, a float32, b float32) *MPSCNNNeuronTanH

@abstract Initialize the hyperbolic tangent neuron filter @param device The device the filter will run on @param a Filter property "a". See class discussion. @param b Filter property "b". See class discussion. @return A valid MPSCNNNeuronTanH object or nil, if failure.

type MPSCNNNeuronTanHNode ¶

type MPSCNNNeuronTanHNode struct {
	MPSCNNNeuronNode
}

@abstract A node representing a MPSCNNNeuronTanH kernel @discussion For each pixel, applies the following function: @code f(x) = a * tanh(b * x) @endcode

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnneurontanhnode

func MPSCNNNeuronTanHNodeFromID ¶

func MPSCNNNeuronTanHNodeFromID(id objc.ID) *MPSCNNNeuronTanHNode

func MPSCNNNeuronTanHNodeNodeWithSource ¶

func MPSCNNNeuronTanHNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronTanHNode

@abstract Create an autoreleased node with default values for parameters a & b

func MPSCNNNeuronTanHNodeNodeWithSourceAB ¶

func MPSCNNNeuronTanHNodeNodeWithSourceAB(sourceNode *MPSNNImageNode, a float32, b float32) *MPSCNNNeuronTanHNode

func (*MPSCNNNeuronTanHNode) InitWithSource ¶

func (o *MPSCNNNeuronTanHNode) InitWithSource(sourceNode *MPSNNImageNode) *MPSCNNNeuronTanHNode

@abstract Init a node with default values for parameters a & b

func (*MPSCNNNeuronTanHNode) InitWithSourceAB ¶

func (o *MPSCNNNeuronTanHNode) InitWithSourceAB(sourceNode *MPSNNImageNode, a float32, b float32) *MPSCNNNeuronTanHNode

@abstract Init a node representing a MPSCNNNeuronTanH kernel @discussion For each pixel, applies the following function: @code f(x) = a * tanh(b * x) @endcode @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param a See discussion above. @param b See discussion above. @return A new MPSNNFilter node for a MPSCNNNeuronTanH kernel.

type MPSCNNNeuronType ¶

type MPSCNNNeuronType int64
const (
	MPSCNNNeuronTypeNone        MPSCNNNeuronType = 0
	MPSCNNNeuronTypeReLU        MPSCNNNeuronType = 1
	MPSCNNNeuronTypeLinear      MPSCNNNeuronType = 2
	MPSCNNNeuronTypeSigmoid     MPSCNNNeuronType = 3
	MPSCNNNeuronTypeHardSigmoid MPSCNNNeuronType = 4
	MPSCNNNeuronTypeTanH        MPSCNNNeuronType = 5
	MPSCNNNeuronTypeAbsolute    MPSCNNNeuronType = 6
	MPSCNNNeuronTypeSoftPlus    MPSCNNNeuronType = 7
	MPSCNNNeuronTypeSoftSign    MPSCNNNeuronType = 8
	MPSCNNNeuronTypeELU         MPSCNNNeuronType = 9
	MPSCNNNeuronTypePReLU       MPSCNNNeuronType = 10
	MPSCNNNeuronTypeReLUN       MPSCNNNeuronType = 11
	MPSCNNNeuronTypePower       MPSCNNNeuronType = 12
	MPSCNNNeuronTypeExponential MPSCNNNeuronType = 13
	MPSCNNNeuronTypeLogarithm   MPSCNNNeuronType = 14
	MPSCNNNeuronTypeGeLU        MPSCNNNeuronType = 15
	MPSCNNNeuronTypeCount       MPSCNNNeuronType = 16
)

func (MPSCNNNeuronType) String ¶

func (e MPSCNNNeuronType) String() string

type MPSCNNNormalizationGammaAndBetaState ¶

type MPSCNNNormalizationGammaAndBetaState struct {
	mpscore.MPSState
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnnormalizationgammaandbetastate

func MPSCNNNormalizationGammaAndBetaStateFromID ¶

func MPSCNNNormalizationGammaAndBetaStateFromID(id objc.ID) *MPSCNNNormalizationGammaAndBetaState

func MPSCNNNormalizationGammaAndBetaStateTemporaryStateWithCommandBufferNumberOfFeatureChannels ¶

func MPSCNNNormalizationGammaAndBetaStateTemporaryStateWithCommandBufferNumberOfFeatureChannels(commandBuffer metal.MTLCommandBuffer, numberOfFeatureChannels uint) *MPSCNNNormalizationGammaAndBetaState

@abstract Create a temporary MPSCNNNormalizationGammaAndBetaState suitable for a normalization operation on images containing no more than the specified number of feature channels. @param commandBuffer The command buffer on which the temporary state will be used. @param numberOfFeatureChannels The number of feature channels used to size the state.

func (*MPSCNNNormalizationGammaAndBetaState) Beta ¶

@property beta @abstract A MTLBuffer containing the beta terms.

func (*MPSCNNNormalizationGammaAndBetaState) Gamma ¶

@property gamma @abstract A MTLBuffer containing the gamma terms.

func (*MPSCNNNormalizationGammaAndBetaState) InitWithGammaBeta ¶

@abstract Initialize a MPSCNNNormalizationGammaAndBetaState object using values contained in MTLBuffers. @param gamma The MTLBuffer containing gamma terms. @param beta The MTLBuffer containing beta terms.

type MPSCNNNormalizationMeanAndVarianceState ¶

type MPSCNNNormalizationMeanAndVarianceState struct {
	mpscore.MPSState
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnnormalizationmeanandvariancestate

func MPSCNNNormalizationMeanAndVarianceStateFromID ¶

func MPSCNNNormalizationMeanAndVarianceStateFromID(id objc.ID) *MPSCNNNormalizationMeanAndVarianceState

func MPSCNNNormalizationMeanAndVarianceStateTemporaryStateWithCommandBufferNumberOfFeatureChannels ¶

func MPSCNNNormalizationMeanAndVarianceStateTemporaryStateWithCommandBufferNumberOfFeatureChannels(commandBuffer metal.MTLCommandBuffer, numberOfFeatureChannels uint) *MPSCNNNormalizationMeanAndVarianceState

@abstract Create a temporary MPSCNNNormalizationMeanAndVarianceState suitable for a normalization operation on images containing no more than the specified number of feature channels. @param commandBuffer The command buffer on which the temporary state will be used. @param numberOfFeatureChannels The number of feature channels used to size the state.

func (*MPSCNNNormalizationMeanAndVarianceState) InitWithMeanVariance ¶

@abstract Initialize a MPSCNNNormalizationMeanAndVarianceState object using values contained in MTLBuffers. @param mean The MTLBuffer containing mean terms. @param variance The MTLBuffer containing variance terms.

func (*MPSCNNNormalizationMeanAndVarianceState) Mean ¶

@property mean @abstract A MTLBuffer containing the mean terms.

func (*MPSCNNNormalizationMeanAndVarianceState) Variance ¶

@property variance @abstract A MTLBuffer containing the variance terms.

type MPSCNNNormalizationNode ¶

type MPSCNNNormalizationNode struct {
	MPSNNFilterNode
}

@abstract virtual base class for CNN normalization nodes

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnnormalizationnode

func MPSCNNNormalizationNodeFromID ¶

func MPSCNNNormalizationNodeFromID(id objc.ID) *MPSCNNNormalizationNode

func MPSCNNNormalizationNodeNodeWithSource ¶

func MPSCNNNormalizationNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSCNNNormalizationNode

func (*MPSCNNNormalizationNode) Alpha ¶

func (o *MPSCNNNormalizationNode) Alpha() float32

@property alpha @abstract The value of alpha. Default is 1.0. Must be non-negative.

func (*MPSCNNNormalizationNode) Beta ¶

func (o *MPSCNNNormalizationNode) Beta() float32

@property beta @abstract The value of beta. Default is 5.0

func (*MPSCNNNormalizationNode) Delta ¶

func (o *MPSCNNNormalizationNode) Delta() float32

@property delta @abstract The value of delta. Default is 1.0

func (*MPSCNNNormalizationNode) InitWithSource ¶

func (o *MPSCNNNormalizationNode) InitWithSource(sourceNode *MPSNNImageNode) *MPSCNNNormalizationNode

func (*MPSCNNNormalizationNode) SetAlpha ¶

func (o *MPSCNNNormalizationNode) SetAlpha(alpha float32)

func (*MPSCNNNormalizationNode) SetBeta ¶

func (o *MPSCNNNormalizationNode) SetBeta(beta float32)

func (*MPSCNNNormalizationNode) SetDelta ¶

func (o *MPSCNNNormalizationNode) SetDelta(delta float32)

type MPSCNNPooling ¶

type MPSCNNPooling struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnpooling

func MPSCNNPoolingFromID ¶

func MPSCNNPoolingFromID(id objc.ID) *MPSCNNPooling

func (*MPSCNNPooling) InitWithCoderDevice ¶

func (o *MPSCNNPooling) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNPooling

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSCNNPooling object, or nil if failure.

func (*MPSCNNPooling) InitWithDeviceKernelWidthKernelHeight ¶

func (o *MPSCNNPooling) InitWithDeviceKernelWidthKernelHeight(device metal.MTLDevice, kernelWidth uint, kernelHeight uint) *MPSCNNPooling

@abstract Initialize a pooling filter @param device The device the filter will run on @param kernelWidth The width of the kernel. Can be an odd or even value. @param kernelHeight The height of the kernel. Can be an odd or even value. @return A valid MPSCNNPooling object or nil, if failure.

func (*MPSCNNPooling) InitWithDeviceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsY ¶

func (o *MPSCNNPooling) InitWithDeviceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsY(device metal.MTLDevice, kernelWidth uint, kernelHeight uint, strideInPixelsX uint, strideInPixelsY uint) *MPSCNNPooling

@abstract Initialize a pooling filter @param device The device the filter will run on @param kernelWidth The width of the kernel. Can be an odd or even value. @param kernelHeight The height of the kernel. Can be an odd or even value. @param strideInPixelsX The output stride (downsampling factor) in the x dimension. @param strideInPixelsY The output stride (downsampling factor) in the y dimension. @return A valid MPSCNNPooling object or nil, if failure.

type MPSCNNPoolingAverage ¶

type MPSCNNPoolingAverage struct {
	MPSCNNPooling
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnpoolingaverage

func MPSCNNPoolingAverageFromID ¶

func MPSCNNPoolingAverageFromID(id objc.ID) *MPSCNNPoolingAverage

func (*MPSCNNPoolingAverage) InitWithCoderDevice ¶

func (o *MPSCNNPoolingAverage) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNPoolingAverage

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSCNNPooling object, or nil if failure.

func (*MPSCNNPoolingAverage) InitWithDeviceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsY ¶

func (o *MPSCNNPoolingAverage) InitWithDeviceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsY(device metal.MTLDevice, kernelWidth uint, kernelHeight uint, strideInPixelsX uint, strideInPixelsY uint) *MPSCNNPoolingAverage

@abstract Initialize a MPSCNNPoolingAverage pooling filter @param device The device the filter will run on @param kernelWidth The width of the kernel. Can be an odd or even value. @param kernelHeight The height of the kernel. Can be an odd or even value. @param strideInPixelsX The output stride (downsampling factor) in the x dimension. @param strideInPixelsY The output stride (downsampling factor) in the y dimension. @return A valid MPSCNNPooling object or nil, if failure.

func (*MPSCNNPoolingAverage) SetZeroPadSizeX ¶

func (o *MPSCNNPoolingAverage) SetZeroPadSizeX(zeroPadSizeX uint)

func (*MPSCNNPoolingAverage) SetZeroPadSizeY ¶

func (o *MPSCNNPoolingAverage) SetZeroPadSizeY(zeroPadSizeY uint)

func (*MPSCNNPoolingAverage) ZeroPadSizeX ¶

func (o *MPSCNNPoolingAverage) ZeroPadSizeX() uint

@property zeroPadSizeX @abstract How much zero padding to apply to both left and right borders of the input image for average pooling, when using @see edgeMode MPSImageEdgeModeClamp. For @see edgeMode MPSImageEdgeModeZero this property is ignored and the area outside the image is interpreted to contain zeros. The zero padding size is used to shrink the pooling window to fit inside the area bound by the source image and its padding region, but the effect is that the normalization factor of the average computation is computed also for the zeros in the padding region.

func (*MPSCNNPoolingAverage) ZeroPadSizeY ¶

func (o *MPSCNNPoolingAverage) ZeroPadSizeY() uint

@property zeroPadSizeY @abstract How much zero padding to apply to both top and bottom borders of the input image for average pooling, when using @see edgeMode MPSImageEdgeModeClamp. For @see edgeMode MPSImageEdgeModeZero this property is ignored and the area outside the image is interpreted to contain zeros. The zero padding size is used to shrink the pooling window to fit inside the area bound by the source image and its padding region, but the effect is that the normalization factor of the average computation is computed also for the zeros in the padding region.

type MPSCNNPoolingAverageGradient ¶

type MPSCNNPoolingAverageGradient struct {
	MPSCNNPoolingGradient
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnpoolingaveragegradient

func MPSCNNPoolingAverageGradientFromID ¶

func MPSCNNPoolingAverageGradientFromID(id objc.ID) *MPSCNNPoolingAverageGradient

func (*MPSCNNPoolingAverageGradient) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPoolingAverageGradient @param device The MTLDevice on which to make the MPSCNNPoolingAverageGradient @return A new MPSCNNPoolingAverageGradient object, or nil if failure.

func (*MPSCNNPoolingAverageGradient) InitWithDeviceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsY ¶

func (o *MPSCNNPoolingAverageGradient) InitWithDeviceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsY(device metal.MTLDevice, kernelWidth uint, kernelHeight uint, strideInPixelsX uint, strideInPixelsY uint) *MPSCNNPoolingAverageGradient

@abstract Initialize a gradient average pooling filter @param device The device the filter will run on @param kernelWidth The width of the kernel. Can be an odd or even value. @param kernelHeight The height of the kernel. Can be an odd or even value. @param strideInPixelsX The input stride (upsampling factor) in the x dimension. @param strideInPixelsY The input stride (upsampling factor) in the y dimension. @return A valid MPSCNNPoolingGradient object or nil, if failure.

func (*MPSCNNPoolingAverageGradient) SetZeroPadSizeX ¶

func (o *MPSCNNPoolingAverageGradient) SetZeroPadSizeX(zeroPadSizeX uint)

func (*MPSCNNPoolingAverageGradient) SetZeroPadSizeY ¶

func (o *MPSCNNPoolingAverageGradient) SetZeroPadSizeY(zeroPadSizeY uint)

func (*MPSCNNPoolingAverageGradient) ZeroPadSizeX ¶

func (o *MPSCNNPoolingAverageGradient) ZeroPadSizeX() uint

@property zeroPadSizeX @abstract How much zero padding to apply to both left and right borders of the input image for average pooling, when using @see edgeMode MPSImageEdgeModeClamp. For @see edgeMode MPSImageEdgeModeZero this property is ignored and the area outside the image is interpreted to contain zeros. The zero padding size is used to shrink the pooling window to fit inside the area bound by the source image and its padding region, but the effect is that the normalization factor of the average computation is computed also for the zeros in the padding region.

func (*MPSCNNPoolingAverageGradient) ZeroPadSizeY ¶

func (o *MPSCNNPoolingAverageGradient) ZeroPadSizeY() uint

@property zeroPadSizeY @abstract How much zero padding to apply to both top and bottom borders of the input image for average pooling, when using @see edgeMode MPSImageEdgeModeClamp. For @see edgeMode MPSImageEdgeModeZero this property is ignored and the area outside the image is interpreted to contain zeros. The zero padding size is used to shrink the pooling window to fit inside the area bound by the source image and its padding region, but the effect is that the normalization factor of the average computation is computed also for the zeros in the padding region.

type MPSCNNPoolingAverageNode ¶

type MPSCNNPoolingAverageNode struct {
	MPSCNNPoolingNode
}

@abstract A node representing a MPSCNNPoolingAverage kernel @discussion The default edge mode is MPSImageEdgeModeClamp

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnpoolingaveragenode

func MPSCNNPoolingAverageNodeFromID ¶

func MPSCNNPoolingAverageNodeFromID(id objc.ID) *MPSCNNPoolingAverageNode

type MPSCNNPoolingGradient ¶

type MPSCNNPoolingGradient struct {
	MPSCNNGradientKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnpoolinggradient

func MPSCNNPoolingGradientFromID ¶

func MPSCNNPoolingGradientFromID(id objc.ID) *MPSCNNPoolingGradient

func (*MPSCNNPoolingGradient) InitWithCoderDevice ¶

func (o *MPSCNNPoolingGradient) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNPoolingGradient

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPoolingGradient @param device The MTLDevice on which to make the MPSCNNPoolingGradient @return A new MPSCNNPooling object, or nil if failure.

func (*MPSCNNPoolingGradient) InitWithDeviceKernelWidthKernelHeight ¶

func (o *MPSCNNPoolingGradient) InitWithDeviceKernelWidthKernelHeight(device metal.MTLDevice, kernelWidth uint, kernelHeight uint) *MPSCNNPoolingGradient

@abstract Initialize a gradient pooling filter @param device The device the filter will run on @param kernelWidth The width of the kernel. Can be an odd or even value. @param kernelHeight The height of the kernel. Can be an odd or even value. @return A valid MPSCNNPoolingGradient object or nil, if failure.

func (*MPSCNNPoolingGradient) InitWithDeviceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsY ¶

func (o *MPSCNNPoolingGradient) InitWithDeviceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsY(device metal.MTLDevice, kernelWidth uint, kernelHeight uint, strideInPixelsX uint, strideInPixelsY uint) *MPSCNNPoolingGradient

@abstract Initialize a gradient pooling filter @param device The device the filter will run on @param kernelWidth The width of the kernel. Can be an odd or even value. @param kernelHeight The height of the kernel. Can be an odd or even value. @param strideInPixelsX The input stride (upsampling factor) in the x dimension. @param strideInPixelsY The input stride (upsampling factor) in the y dimension. @return A valid MPSCNNPoolingGradient object or nil, if failure.

func (*MPSCNNPoolingGradient) SetSourceSize ¶

func (o *MPSCNNPoolingGradient) SetSourceSize(sourceSize metal.MTLSize)

func (*MPSCNNPoolingGradient) SourceSize ¶

func (o *MPSCNNPoolingGradient) SourceSize() metal.MTLSize

@property sourceSize @abstract An optional source size which defines together with primaryOffset, the set of input gradient pixels to take into account in the gradient computations. @discussion A MTLSize that together with primaryOffset indicates which part of the source gradient to consider. If the area does not lie completely within the primary source image, the intersection between source area rectangle and primary source bounds is used. Default: A size where every component is NSUIntegerMax indicating the entire rest of the image, starting from an offset (see primaryOffset).

type MPSCNNPoolingGradientNode ¶

type MPSCNNPoolingGradientNode struct {
	MPSNNGradientFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnpoolinggradientnode

func MPSCNNPoolingGradientNodeFromID ¶

func MPSCNNPoolingGradientNodeFromID(id objc.ID) *MPSCNNPoolingGradientNode

func MPSCNNPoolingGradientNodeNodeWithSourceGradientSourceImageGradientStateKernelWidthKernelHeightStrideInPixelsXStrideInPixelsYPaddingPolicy ¶

func MPSCNNPoolingGradientNodeNodeWithSourceGradientSourceImageGradientStateKernelWidthKernelHeightStrideInPixelsXStrideInPixelsYPaddingPolicy(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, kernelWidth uint, kernelHeight uint, strideInPixelsX uint, strideInPixelsY uint, paddingPolicy MPSNNPadding) *MPSCNNPoolingGradientNode

@abstract make a pooling gradient node @discussion It would be much easier to use [inferencePoolingNode gradientNodeForSourceGradient:] instead. @param sourceGradient The gradient from the downstream gradient filter. @param sourceImage The input image to the inference pooling filter @param gradientState The gradient state produced by the inference poolin filter @param kernelWidth The kernel width of the inference filter @param kernelHeight The kernel height of the inference filter @param strideInPixelsX The X stride from the inference filter @param strideInPixelsY The Y stride from the inference filter

func (*MPSCNNPoolingGradientNode) InitWithSourceGradientSourceImageGradientStateKernelWidthKernelHeightStrideInPixelsXStrideInPixelsYPaddingPolicy ¶

func (o *MPSCNNPoolingGradientNode) InitWithSourceGradientSourceImageGradientStateKernelWidthKernelHeightStrideInPixelsXStrideInPixelsYPaddingPolicy(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, kernelWidth uint, kernelHeight uint, strideInPixelsX uint, strideInPixelsY uint, paddingPolicy MPSNNPadding) *MPSCNNPoolingGradientNode

@abstract make a pooling gradient node @discussion It would be much easier to use [inferencePoolingNode gradientNodeForSourceGradient:] instead. @param sourceGradient The gradient from the downstream gradient filter. @param sourceImage The input image to the inference pooling filter @param gradientState The gradient state produced by the inference poolin filter @param kernelWidth The kernel width of the inference filter @param kernelHeight The kernel height of the inference filter @param strideInPixelsX The X stride from the inference filter @param strideInPixelsY The Y stride from the inference filter

func (*MPSCNNPoolingGradientNode) KernelHeight ¶

func (o *MPSCNNPoolingGradientNode) KernelHeight() uint

func (*MPSCNNPoolingGradientNode) KernelWidth ¶

func (o *MPSCNNPoolingGradientNode) KernelWidth() uint

func (*MPSCNNPoolingGradientNode) StrideInPixelsX ¶

func (o *MPSCNNPoolingGradientNode) StrideInPixelsX() uint

func (*MPSCNNPoolingGradientNode) StrideInPixelsY ¶

func (o *MPSCNNPoolingGradientNode) StrideInPixelsY() uint

type MPSCNNPoolingL2Norm ¶

type MPSCNNPoolingL2Norm struct {
	MPSCNNPooling
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnpoolingl2norm

func MPSCNNPoolingL2NormFromID ¶

func MPSCNNPoolingL2NormFromID(id objc.ID) *MPSCNNPoolingL2Norm

func (*MPSCNNPoolingL2Norm) InitWithCoderDevice ¶

func (o *MPSCNNPoolingL2Norm) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNPoolingL2Norm

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSCNNPooling object, or nil if failure.

func (*MPSCNNPoolingL2Norm) InitWithDeviceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsY ¶

func (o *MPSCNNPoolingL2Norm) InitWithDeviceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsY(device metal.MTLDevice, kernelWidth uint, kernelHeight uint, strideInPixelsX uint, strideInPixelsY uint) *MPSCNNPoolingL2Norm

@abstract Initialize a MPSCNNPoolingL2Norm pooling filter @param device The device the filter will run on @param kernelWidth The width of the kernel. Can be an odd or even value. @param kernelHeight The height of the kernel. Can be an odd or even value. @param strideInPixelsX The output stride (downsampling factor) in the x dimension. @param strideInPixelsY The output stride (downsampling factor) in the y dimension. @return A valid MPSCNNPooling object or nil, if failure.

type MPSCNNPoolingL2NormGradient ¶

type MPSCNNPoolingL2NormGradient struct {
	MPSCNNPoolingGradient
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnpoolingl2normgradient

func MPSCNNPoolingL2NormGradientFromID ¶

func MPSCNNPoolingL2NormGradientFromID(id objc.ID) *MPSCNNPoolingL2NormGradient

func (*MPSCNNPoolingL2NormGradient) InitWithCoderDevice ¶

func (o *MPSCNNPoolingL2NormGradient) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNPoolingL2NormGradient

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPoolingL2NormGradient @param device The MTLDevice on which to make the MPSCNNPoolingL2NormGradient @return A new MPSCNNPoolingL2NormGradient object, or nil if failure.

func (*MPSCNNPoolingL2NormGradient) InitWithDeviceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsY ¶

func (o *MPSCNNPoolingL2NormGradient) InitWithDeviceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsY(device metal.MTLDevice, kernelWidth uint, kernelHeight uint, strideInPixelsX uint, strideInPixelsY uint) *MPSCNNPoolingL2NormGradient

@abstract Initialize a gradient L2-norm pooling filter @param device The device the filter will run on @param kernelWidth The width of the kernel. Can be an odd or even value. @param kernelHeight The height of the kernel. Can be an odd or even value. @param strideInPixelsX The input stride (upsampling factor) in the x dimension. @param strideInPixelsY The input stride (upsampling factor) in the y dimension. @return A valid MPSCNNPoolingL2NormGradient object or nil, if failure.

type MPSCNNPoolingL2NormNode ¶

type MPSCNNPoolingL2NormNode struct {
	MPSCNNPoolingNode
}

@abstract A node representing a MPSCNNPoolingL2Norm kernel @discussion The default edge mode is MPSImageEdgeModeClamp

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnpoolingl2normnode

func MPSCNNPoolingL2NormNodeFromID ¶

func MPSCNNPoolingL2NormNodeFromID(id objc.ID) *MPSCNNPoolingL2NormNode

type MPSCNNPoolingMax ¶

type MPSCNNPoolingMax struct {
	MPSCNNPooling
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnpoolingmax

func MPSCNNPoolingMaxFromID ¶

func MPSCNNPoolingMaxFromID(id objc.ID) *MPSCNNPoolingMax

func (*MPSCNNPoolingMax) InitWithCoderDevice ¶

func (o *MPSCNNPoolingMax) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNPoolingMax

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSCNNPooling object, or nil if failure.

func (*MPSCNNPoolingMax) InitWithDeviceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsY ¶

func (o *MPSCNNPoolingMax) InitWithDeviceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsY(device metal.MTLDevice, kernelWidth uint, kernelHeight uint, strideInPixelsX uint, strideInPixelsY uint) *MPSCNNPoolingMax

@abstract Initialize a MPSCNNPoolingMax pooling filter @param device The device the filter will run on @param kernelWidth The width of the kernel. Can be an odd or even value. @param kernelHeight The height of the kernel. Can be an odd or even value. @param strideInPixelsX The output stride (downsampling factor) in the x dimension. @param strideInPixelsY The output stride (downsampling factor) in the y dimension. @return A valid MPSCNNPooling object or nil, if failure.

type MPSCNNPoolingMaxGradient ¶

type MPSCNNPoolingMaxGradient struct {
	MPSCNNPoolingGradient
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnpoolingmaxgradient

func MPSCNNPoolingMaxGradientFromID ¶

func MPSCNNPoolingMaxGradientFromID(id objc.ID) *MPSCNNPoolingMaxGradient

func (*MPSCNNPoolingMaxGradient) InitWithCoderDevice ¶

func (o *MPSCNNPoolingMaxGradient) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNPoolingMaxGradient

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPoolingMaxGradient @param device The MTLDevice on which to make the MPSCNNPoolingMaxGradient @return A new MPSCNNPoolingMaxGradient object, or nil if failure.

func (*MPSCNNPoolingMaxGradient) InitWithDeviceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsY ¶

func (o *MPSCNNPoolingMaxGradient) InitWithDeviceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsY(device metal.MTLDevice, kernelWidth uint, kernelHeight uint, strideInPixelsX uint, strideInPixelsY uint) *MPSCNNPoolingMaxGradient

@abstract Initialize a gradient max pooling filter @param device The device the filter will run on @param kernelWidth The width of the kernel. Can be an odd or even value. @param kernelHeight The height of the kernel. Can be an odd or even value. @param strideInPixelsX The input stride (upsampling factor) in the x dimension. @param strideInPixelsY The input stride (upsampling factor) in the y dimension. @return A valid MPSCNNPoolingGradient object or nil, if failure.

type MPSCNNPoolingMaxNode ¶

type MPSCNNPoolingMaxNode struct {
	MPSCNNPoolingNode
}

@abstract A node representing a MPSCNNPoolingMax kernel @discussion The default edge mode is MPSImageEdgeModeClamp

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnpoolingmaxnode

func MPSCNNPoolingMaxNodeFromID ¶

func MPSCNNPoolingMaxNodeFromID(id objc.ID) *MPSCNNPoolingMaxNode

type MPSCNNPoolingNode ¶

type MPSCNNPoolingNode struct {
	MPSNNFilterNode
}

@abstract A node for a MPSCNNPooling kernel @discussion This is an abstract base class that does not correspond with any particular MPSCNNKernel. Please make one of the MPSCNNPooling subclasses instead.

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnpoolingnode

func MPSCNNPoolingNodeFromID ¶

func MPSCNNPoolingNodeFromID(id objc.ID) *MPSCNNPoolingNode

func MPSCNNPoolingNodeNodeWithSourceFilterSize ¶

func MPSCNNPoolingNodeNodeWithSourceFilterSize(sourceNode *MPSNNImageNode, size uint) *MPSCNNPoolingNode

@abstract Convenience initializer for MPSCNNPooling nodes with square non-overlapping kernels @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param size kernelWidth = kernelHeight = strideInPixelsX = strideInPixelsY = size @return A new MPSNNFilter node for a MPSCNNPooling kernel.

func MPSCNNPoolingNodeNodeWithSourceFilterSizeStride ¶

func MPSCNNPoolingNodeNodeWithSourceFilterSizeStride(sourceNode *MPSNNImageNode, size uint, stride uint) *MPSCNNPoolingNode

@abstract Convenience initializer for MPSCNNPooling nodes with square non-overlapping kernels and a different stride @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param size kernelWidth = kernelHeight = size @param stride strideInPixelsX = strideInPixelsY = stride @return A new MPSNNFilter node for a MPSCNNPooling kernel.

func (*MPSCNNPoolingNode) InitWithSourceFilterSize ¶

func (o *MPSCNNPoolingNode) InitWithSourceFilterSize(sourceNode *MPSNNImageNode, size uint) *MPSCNNPoolingNode

@abstract Convenience initializer for MPSCNNPooling nodes with square non-overlapping kernels @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param size kernelWidth = kernelHeight = strideInPixelsX = strideInPixelsY = size @return A new MPSNNFilter node for a MPSCNNPooling kernel.

func (*MPSCNNPoolingNode) InitWithSourceFilterSizeStride ¶

func (o *MPSCNNPoolingNode) InitWithSourceFilterSizeStride(sourceNode *MPSNNImageNode, size uint, stride uint) *MPSCNNPoolingNode

@abstract Convenience initializer for MPSCNNPooling nodes with square kernels @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param size kernelWidth = kernelHeight = size @param stride strideInPixelsX = strideInPixelsY = stride @return A new MPSNNFilter node for a MPSCNNPooling kernel.

func (*MPSCNNPoolingNode) InitWithSourceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsY ¶

func (o *MPSCNNPoolingNode) InitWithSourceKernelWidthKernelHeightStrideInPixelsXStrideInPixelsY(sourceNode *MPSNNImageNode, kernelWidth uint, kernelHeight uint, strideInPixelsX uint, strideInPixelsY uint) *MPSCNNPoolingNode

@abstract Init a node representing a MPSCNNPooling kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param kernelWidth The width of the max filter window @param kernelHeight The height of the max filter window @param strideInPixelsX The output stride (downsampling factor) in the x dimension. @param strideInPixelsY The output stride (downsampling factor) in the y dimension. @return A new MPSNNFilter node for a MPSCNNPooling kernel.

func (*MPSCNNPoolingNode) KernelHeight ¶

func (o *MPSCNNPoolingNode) KernelHeight() uint

func (*MPSCNNPoolingNode) KernelWidth ¶

func (o *MPSCNNPoolingNode) KernelWidth() uint

func (*MPSCNNPoolingNode) StrideInPixelsX ¶

func (o *MPSCNNPoolingNode) StrideInPixelsX() uint

func (*MPSCNNPoolingNode) StrideInPixelsY ¶

func (o *MPSCNNPoolingNode) StrideInPixelsY() uint

type MPSCNNReductionType ¶

type MPSCNNReductionType int64
const (
	MPSCNNReductionTypeNone                MPSCNNReductionType = 0
	MPSCNNReductionTypeSum                 MPSCNNReductionType = 1
	MPSCNNReductionTypeMean                MPSCNNReductionType = 2
	MPSCNNReductionTypeSumByNonZeroWeights MPSCNNReductionType = 3
	MPSCNNReductionTypeCount               MPSCNNReductionType = 4
)

func (MPSCNNReductionType) String ¶

func (e MPSCNNReductionType) String() string

type MPSCNNSoftMax ¶

type MPSCNNSoftMax struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnsoftmax

func MPSCNNSoftMaxFromID ¶

func MPSCNNSoftMaxFromID(id objc.ID) *MPSCNNSoftMax

type MPSCNNSoftMaxGradient ¶

type MPSCNNSoftMaxGradient struct {
	MPSCNNGradientKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnsoftmaxgradient

func MPSCNNSoftMaxGradientFromID ¶

func MPSCNNSoftMaxGradientFromID(id objc.ID) *MPSCNNSoftMaxGradient

func (*MPSCNNSoftMaxGradient) InitWithCoderDevice ¶

func (o *MPSCNNSoftMaxGradient) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNSoftMaxGradient

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNSoftMaxGradient) InitWithDevice ¶

func (o *MPSCNNSoftMaxGradient) InitWithDevice(device metal.MTLDevice) *MPSCNNSoftMaxGradient

@abstract Initializes a MPSCNNSoftMaxGradient function @param device The MTLDevice on which this MPSCNNSoftMaxGradient filter will be used @return A valid MPSCNNSoftMaxGradient object or nil, if failure.

type MPSCNNSoftMaxGradientNode ¶

type MPSCNNSoftMaxGradientNode struct {
	MPSNNGradientFilterNode
}

Node representing a MPSCNNSoftMaxGradient kernel

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnsoftmaxgradientnode

func MPSCNNSoftMaxGradientNodeFromID ¶

func MPSCNNSoftMaxGradientNodeFromID(id objc.ID) *MPSCNNSoftMaxGradientNode

func MPSCNNSoftMaxGradientNodeNodeWithSourceGradientSourceImageGradientState ¶

func MPSCNNSoftMaxGradientNodeNodeWithSourceGradientSourceImageGradientState(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSCNNSoftMaxGradientNode

func (*MPSCNNSoftMaxGradientNode) InitWithSourceGradientSourceImageGradientState ¶

func (o *MPSCNNSoftMaxGradientNode) InitWithSourceGradientSourceImageGradientState(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSCNNSoftMaxGradientNode

type MPSCNNSoftMaxNode ¶

type MPSCNNSoftMaxNode struct {
	MPSNNFilterNode
}

Node representing a MPSCNNSoftMax kernel

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnsoftmaxnode

func MPSCNNSoftMaxNodeFromID ¶

func MPSCNNSoftMaxNodeFromID(id objc.ID) *MPSCNNSoftMaxNode

func MPSCNNSoftMaxNodeNodeWithSource ¶

func MPSCNNSoftMaxNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSCNNSoftMaxNode

@abstract Init a node representing a autoreleased MPSCNNSoftMax kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @return A new MPSNNFilter node for a MPSCNNSoftMax kernel.

func (*MPSCNNSoftMaxNode) InitWithSource ¶

func (o *MPSCNNSoftMaxNode) InitWithSource(sourceNode *MPSNNImageNode) *MPSCNNSoftMaxNode

@abstract Init a node representing a MPSCNNSoftMax kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @return A new MPSNNFilter node for a MPSCNNSoftMax kernel.

type MPSCNNSpatialNormalization ¶

type MPSCNNSpatialNormalization struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnspatialnormalization

func MPSCNNSpatialNormalizationFromID ¶

func MPSCNNSpatialNormalizationFromID(id objc.ID) *MPSCNNSpatialNormalization

func (*MPSCNNSpatialNormalization) Alpha ¶

@property alpha @abstract The value of alpha. Default is 1.0. Must be non-negative.

func (*MPSCNNSpatialNormalization) Beta ¶

@property beta @abstract The value of beta. Default is 5.0

func (*MPSCNNSpatialNormalization) Delta ¶

@property delta @abstract The value of delta. Default is 1.0

func (*MPSCNNSpatialNormalization) InitWithCoderDevice ¶

func (o *MPSCNNSpatialNormalization) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNSpatialNormalization

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNSpatialNormalization) InitWithDeviceKernelWidthKernelHeight ¶

func (o *MPSCNNSpatialNormalization) InitWithDeviceKernelWidthKernelHeight(device metal.MTLDevice, kernelWidth uint, kernelHeight uint) *MPSCNNSpatialNormalization

@abstract Initialize a spatial normalization filter @param device The device the filter will run on @param kernelWidth The width of the kernel @param kernelHeight The height of the kernel @return A valid MPSCNNSpatialNormalization object or nil, if failure. NOTE: For now, kernelWidth must be equal to kernelHeight

func (*MPSCNNSpatialNormalization) SetAlpha ¶

func (o *MPSCNNSpatialNormalization) SetAlpha(alpha float32)

func (*MPSCNNSpatialNormalization) SetBeta ¶

func (o *MPSCNNSpatialNormalization) SetBeta(beta float32)

func (*MPSCNNSpatialNormalization) SetDelta ¶

func (o *MPSCNNSpatialNormalization) SetDelta(delta float32)

type MPSCNNSpatialNormalizationGradient ¶

type MPSCNNSpatialNormalizationGradient struct {
	MPSCNNGradientKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnspatialnormalizationgradient

func MPSCNNSpatialNormalizationGradientFromID ¶

func MPSCNNSpatialNormalizationGradientFromID(id objc.ID) *MPSCNNSpatialNormalizationGradient

func (*MPSCNNSpatialNormalizationGradient) Alpha ¶

@property alpha @abstract The value of alpha. Default is 1.0. Must be non-negative.

func (*MPSCNNSpatialNormalizationGradient) Beta ¶

@property beta @abstract The value of beta. Default is 5.0

func (*MPSCNNSpatialNormalizationGradient) Delta ¶

@property delta @abstract The value of delta. Default is 1.0

func (*MPSCNNSpatialNormalizationGradient) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSCNNSpatialNormalizationGradient) InitWithDeviceKernelWidthKernelHeight ¶

func (o *MPSCNNSpatialNormalizationGradient) InitWithDeviceKernelWidthKernelHeight(device metal.MTLDevice, kernelWidth uint, kernelHeight uint) *MPSCNNSpatialNormalizationGradient

@abstract Initialize a spatial normalization filter @param device The device the filter will run on @param kernelWidth The width of the kernel @param kernelHeight The height of the kernel @return A valid MPSCNNSpatialNormalization object or nil, if failure. NOTE: For now, kernelWidth must be equal to kernelHeight

func (*MPSCNNSpatialNormalizationGradient) SetAlpha ¶

func (o *MPSCNNSpatialNormalizationGradient) SetAlpha(alpha float32)

func (*MPSCNNSpatialNormalizationGradient) SetBeta ¶

func (*MPSCNNSpatialNormalizationGradient) SetDelta ¶

func (o *MPSCNNSpatialNormalizationGradient) SetDelta(delta float32)

type MPSCNNSpatialNormalizationGradientNode ¶

type MPSCNNSpatialNormalizationGradientNode struct {
	MPSNNGradientFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnspatialnormalizationgradientnode

func MPSCNNSpatialNormalizationGradientNodeFromID ¶

func MPSCNNSpatialNormalizationGradientNodeFromID(id objc.ID) *MPSCNNSpatialNormalizationGradientNode

func MPSCNNSpatialNormalizationGradientNodeNodeWithSourceGradientSourceImageGradientStateKernelSize ¶

func MPSCNNSpatialNormalizationGradientNodeNodeWithSourceGradientSourceImageGradientStateKernelSize(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, kernelSize uint) *MPSCNNSpatialNormalizationGradientNode

func (*MPSCNNSpatialNormalizationGradientNode) Alpha ¶

@property alpha @abstract The value of alpha. Default is 1.0. Must be non-negative.

func (*MPSCNNSpatialNormalizationGradientNode) Beta ¶

@property beta @abstract The value of beta. Default is 5.0

func (*MPSCNNSpatialNormalizationGradientNode) Delta ¶

@property delta @abstract The value of delta. Default is 1.0

func (*MPSCNNSpatialNormalizationGradientNode) InitWithSourceGradientSourceImageGradientStateKernelSize ¶

func (o *MPSCNNSpatialNormalizationGradientNode) InitWithSourceGradientSourceImageGradientStateKernelSize(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, kernelSize uint) *MPSCNNSpatialNormalizationGradientNode

func (*MPSCNNSpatialNormalizationGradientNode) KernelHeight ¶

func (o *MPSCNNSpatialNormalizationGradientNode) KernelHeight() uint

func (*MPSCNNSpatialNormalizationGradientNode) KernelWidth ¶

func (*MPSCNNSpatialNormalizationGradientNode) SetAlpha ¶

func (*MPSCNNSpatialNormalizationGradientNode) SetBeta ¶

func (*MPSCNNSpatialNormalizationGradientNode) SetDelta ¶

func (*MPSCNNSpatialNormalizationGradientNode) SetKernelHeight ¶

func (o *MPSCNNSpatialNormalizationGradientNode) SetKernelHeight(kernelHeight uint)

func (*MPSCNNSpatialNormalizationGradientNode) SetKernelWidth ¶

func (o *MPSCNNSpatialNormalizationGradientNode) SetKernelWidth(kernelWidth uint)

type MPSCNNSpatialNormalizationNode ¶

type MPSCNNSpatialNormalizationNode struct {
	MPSCNNNormalizationNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnspatialnormalizationnode

func MPSCNNSpatialNormalizationNodeFromID ¶

func MPSCNNSpatialNormalizationNodeFromID(id objc.ID) *MPSCNNSpatialNormalizationNode

func MPSCNNSpatialNormalizationNodeNodeWithSourceKernelSize ¶

func MPSCNNSpatialNormalizationNodeNodeWithSourceKernelSize(sourceNode *MPSNNImageNode, kernelSize uint) *MPSCNNSpatialNormalizationNode

func (*MPSCNNSpatialNormalizationNode) InitWithSource ¶

func (*MPSCNNSpatialNormalizationNode) InitWithSourceKernelSize ¶

func (o *MPSCNNSpatialNormalizationNode) InitWithSourceKernelSize(sourceNode *MPSNNImageNode, kernelSize uint) *MPSCNNSpatialNormalizationNode

func (*MPSCNNSpatialNormalizationNode) KernelHeight ¶

func (o *MPSCNNSpatialNormalizationNode) KernelHeight() uint

func (*MPSCNNSpatialNormalizationNode) KernelWidth ¶

func (o *MPSCNNSpatialNormalizationNode) KernelWidth() uint

func (*MPSCNNSpatialNormalizationNode) SetKernelHeight ¶

func (o *MPSCNNSpatialNormalizationNode) SetKernelHeight(kernelHeight uint)

func (*MPSCNNSpatialNormalizationNode) SetKernelWidth ¶

func (o *MPSCNNSpatialNormalizationNode) SetKernelWidth(kernelWidth uint)

type MPSCNNSubPixelConvolutionDescriptor ¶

type MPSCNNSubPixelConvolutionDescriptor struct {
	MPSCNNConvolutionDescriptor
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnsubpixelconvolutiondescriptor

func MPSCNNSubPixelConvolutionDescriptorFromID ¶

func MPSCNNSubPixelConvolutionDescriptorFromID(id objc.ID) *MPSCNNSubPixelConvolutionDescriptor

func (*MPSCNNSubPixelConvolutionDescriptor) SetSubPixelScaleFactor ¶

func (o *MPSCNNSubPixelConvolutionDescriptor) SetSubPixelScaleFactor(subPixelScaleFactor uint)

func (*MPSCNNSubPixelConvolutionDescriptor) SubPixelScaleFactor ¶

func (o *MPSCNNSubPixelConvolutionDescriptor) SubPixelScaleFactor() uint

@property subPixelScaleFactor @discussion Upsampling scale factor. Each pixel in input is upsampled into a subPixelScaleFactor x subPixelScaleFactor pixel block by rearranging the outputFeatureChannels as described above. Default value is 1.

type MPSCNNSubtract ¶

type MPSCNNSubtract struct {
	MPSCNNArithmetic
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnsubtract

func MPSCNNSubtractFromID ¶

func MPSCNNSubtractFromID(id objc.ID) *MPSCNNSubtract

func (*MPSCNNSubtract) InitWithDevice ¶

func (o *MPSCNNSubtract) InitWithDevice(device metal.MTLDevice) *MPSCNNSubtract

@abstract Initialize the subtraction operator @param device The device the filter will run on. @return A valid MPSCNNSubtract object or nil, if failure.

type MPSCNNSubtractGradient ¶

type MPSCNNSubtractGradient struct {
	MPSCNNArithmeticGradient
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnsubtractgradient

func MPSCNNSubtractGradientFromID ¶

func MPSCNNSubtractGradientFromID(id objc.ID) *MPSCNNSubtractGradient

func (*MPSCNNSubtractGradient) InitWithDeviceIsSecondarySourceFilter ¶

func (o *MPSCNNSubtractGradient) InitWithDeviceIsSecondarySourceFilter(device metal.MTLDevice, isSecondarySourceFilter bool) *MPSCNNSubtractGradient

@abstract Initialize the subtraction gradient operator. @param device The device the filter will run on. @param isSecondarySourceFilter A boolean indicating whether the arithmetic gradient filter is operating on the primary or secondary source image from the forward pass. @return A valid MPSCNNSubtractGradient object or nil, if failure.

type MPSCNNUpsampling ¶

type MPSCNNUpsampling struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnupsampling

func MPSCNNUpsamplingFromID ¶

func MPSCNNUpsamplingFromID(id objc.ID) *MPSCNNUpsampling

func (*MPSCNNUpsampling) AlignCorners ¶

func (o *MPSCNNUpsampling) AlignCorners() bool

@property alignCorners @abstract If YES, the centers of the 4 corner pixels of the input and output regions are aligned, preserving the values at the corner pixels. The default is NO.

func (*MPSCNNUpsampling) ScaleFactorX ¶

func (o *MPSCNNUpsampling) ScaleFactorX() float64

@property scaleFactorX @abstract The upsampling scale factor for the x dimension. The default value is 1.

func (*MPSCNNUpsampling) ScaleFactorY ¶

func (o *MPSCNNUpsampling) ScaleFactorY() float64

@property scaleFactorY @abstract The upsampling scale factor for the y dimension. The default value is 1.

type MPSCNNUpsamplingBilinear ¶

type MPSCNNUpsamplingBilinear struct {
	MPSCNNUpsampling
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnupsamplingbilinear

func MPSCNNUpsamplingBilinearFromID ¶

func MPSCNNUpsamplingBilinearFromID(id objc.ID) *MPSCNNUpsamplingBilinear

func (*MPSCNNUpsamplingBilinear) InitWithDeviceIntegerScaleFactorXIntegerScaleFactorY ¶

func (o *MPSCNNUpsamplingBilinear) InitWithDeviceIntegerScaleFactorXIntegerScaleFactorY(device metal.MTLDevice, integerScaleFactorX uint, integerScaleFactorY uint) *MPSCNNUpsamplingBilinear

@abstract Initialize the bilinear spatial upsampling filter. @param device The device the filter will run on. @param integerScaleFactorX The upsampling factor for the x dimension. @param integerScaleFactorY The upsampling factor for the y dimension. @return A valid MPSCNNUpsamplingBilinear object or nil, if failure.

func (*MPSCNNUpsamplingBilinear) InitWithDeviceIntegerScaleFactorXIntegerScaleFactorYAlignCorners ¶

func (o *MPSCNNUpsamplingBilinear) InitWithDeviceIntegerScaleFactorXIntegerScaleFactorYAlignCorners(device metal.MTLDevice, integerScaleFactorX uint, integerScaleFactorY uint, alignCorners bool) *MPSCNNUpsamplingBilinear

@abstract Initialize the bilinear spatial upsampling filter. @param device The device the filter will run on. @param integerScaleFactorX The upsampling factor for the x dimension. @param integerScaleFactorY The upsampling factor for the y dimension. @param alignCorners Specifier whether the centers of the 4 corner pixels of the input and output regions are aligned, preserving the values at the corner pixels. @return A valid MPSCNNUpsamplingBilinear object or nil, if failure.

type MPSCNNUpsamplingBilinearGradient ¶

type MPSCNNUpsamplingBilinearGradient struct {
	MPSCNNUpsamplingGradient
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnupsamplingbilineargradient

func MPSCNNUpsamplingBilinearGradientFromID ¶

func MPSCNNUpsamplingBilinearGradientFromID(id objc.ID) *MPSCNNUpsamplingBilinearGradient

func (*MPSCNNUpsamplingBilinearGradient) InitWithDeviceIntegerScaleFactorXIntegerScaleFactorY ¶

func (o *MPSCNNUpsamplingBilinearGradient) InitWithDeviceIntegerScaleFactorXIntegerScaleFactorY(device metal.MTLDevice, integerScaleFactorX uint, integerScaleFactorY uint) *MPSCNNUpsamplingBilinearGradient

@abstract Initialize the bilinear spatial downsampling filter. @param device The device the filter will run on. @param integerScaleFactorX The downsampling factor for the x dimension. @param integerScaleFactorY The downsampling factor for the y dimension. @return A valid MPSCNNUpsamplingBilinearGradient object or nil, if failure.

type MPSCNNUpsamplingBilinearGradientNode ¶

type MPSCNNUpsamplingBilinearGradientNode struct {
	MPSNNGradientFilterNode
}

Node representing a MPSCNNUpsamplingBilinear kernel

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnupsamplingbilineargradientnode

func MPSCNNUpsamplingBilinearGradientNodeFromID ¶

func MPSCNNUpsamplingBilinearGradientNodeFromID(id objc.ID) *MPSCNNUpsamplingBilinearGradientNode

func MPSCNNUpsamplingBilinearGradientNodeNodeWithSourceGradientSourceImageGradientStateScaleFactorXScaleFactorY ¶

func MPSCNNUpsamplingBilinearGradientNodeNodeWithSourceGradientSourceImageGradientStateScaleFactorXScaleFactorY(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, scaleFactorX float64, scaleFactorY float64) *MPSCNNUpsamplingBilinearGradientNode

@abstract A node to represent the gradient calculation for nearest upsampling training. @discussion [forwardFilter gradientFilterWithSources:] is a more convient way to do this. @param sourceGradient The input gradient from the 'downstream' gradient filter. @param sourceImage The input image from the forward filter node @param gradientState The gradient state from the forward filter @param scaleFactorX The X scale factor from the forward pass @param scaleFactorY The Y scale factor from the forward pass @return A MPSCNNUpsamplingBilinearGradientNode

func (*MPSCNNUpsamplingBilinearGradientNode) InitWithSourceGradientSourceImageGradientStateScaleFactorXScaleFactorY ¶

func (o *MPSCNNUpsamplingBilinearGradientNode) InitWithSourceGradientSourceImageGradientStateScaleFactorXScaleFactorY(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, scaleFactorX float64, scaleFactorY float64) *MPSCNNUpsamplingBilinearGradientNode

@abstract A node to represent the gradient calculation for nearest upsampling training. @discussion [forwardFilter gradientFilterWithSources:] is a more convient way to do this. @param sourceGradient The input gradient from the 'downstream' gradient filter. @param sourceImage The input image from the forward filter node @param gradientState The gradient state from the forward filter @param scaleFactorX The X scale factor from the forward pass @param scaleFactorY The Y scale factor from the forward pass @return A MPSCNNUpsamplingBilinearGradientNode

func (*MPSCNNUpsamplingBilinearGradientNode) ScaleFactorX ¶

func (*MPSCNNUpsamplingBilinearGradientNode) ScaleFactorY ¶

type MPSCNNUpsamplingBilinearNode ¶

type MPSCNNUpsamplingBilinearNode struct {
	MPSNNFilterNode
}

Node representing a MPSCNNUpsamplingBilinear kernel

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnupsamplingbilinearnode

func MPSCNNUpsamplingBilinearNodeFromID ¶

func MPSCNNUpsamplingBilinearNodeFromID(id objc.ID) *MPSCNNUpsamplingBilinearNode

func MPSCNNUpsamplingBilinearNodeNodeWithSourceIntegerScaleFactorXIntegerScaleFactorY ¶

func MPSCNNUpsamplingBilinearNodeNodeWithSourceIntegerScaleFactorXIntegerScaleFactorY(sourceNode *MPSNNImageNode, integerScaleFactorX uint, integerScaleFactorY uint) *MPSCNNUpsamplingBilinearNode

@abstract Init a autoreleased node representing a MPSCNNUpsamplingBilinear kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param integerScaleFactorX The upsampling factor for the x dimension. @param integerScaleFactorY The upsampling factor for the y dimension. @return A new MPSNNFilter node for a MPSCNNUpsamplingBilinear kernel.

func MPSCNNUpsamplingBilinearNodeNodeWithSourceIntegerScaleFactorXIntegerScaleFactorYAlignCorners ¶

func MPSCNNUpsamplingBilinearNodeNodeWithSourceIntegerScaleFactorXIntegerScaleFactorYAlignCorners(sourceNode *MPSNNImageNode, integerScaleFactorX uint, integerScaleFactorY uint, alignCorners bool) *MPSCNNUpsamplingBilinearNode

@abstract Init a autoreleased node representing a MPSCNNUpsamplingBilinear kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param integerScaleFactorX The upsampling factor for the x dimension. @param integerScaleFactorY The upsampling factor for the y dimension. @param alignCorners Specifier whether the centers of the 4 corner pixels of the input and output regions are aligned, @return A new MPSNNFilter node for a MPSCNNUpsamplingBilinear kernel.

func (*MPSCNNUpsamplingBilinearNode) AlignCorners ¶

func (o *MPSCNNUpsamplingBilinearNode) AlignCorners() bool

func (*MPSCNNUpsamplingBilinearNode) InitWithSourceIntegerScaleFactorXIntegerScaleFactorY ¶

func (o *MPSCNNUpsamplingBilinearNode) InitWithSourceIntegerScaleFactorXIntegerScaleFactorY(sourceNode *MPSNNImageNode, integerScaleFactorX uint, integerScaleFactorY uint) *MPSCNNUpsamplingBilinearNode

@abstract Init a node representing a MPSCNNUpsamplingBilinear kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param integerScaleFactorX The upsampling factor for the x dimension. @param integerScaleFactorY The upsampling factor for the y dimension. @return A new MPSNNFilter node for a MPSCNNUpsamplingBilinear kernel.

func (*MPSCNNUpsamplingBilinearNode) InitWithSourceIntegerScaleFactorXIntegerScaleFactorYAlignCorners ¶

func (o *MPSCNNUpsamplingBilinearNode) InitWithSourceIntegerScaleFactorXIntegerScaleFactorYAlignCorners(sourceNode *MPSNNImageNode, integerScaleFactorX uint, integerScaleFactorY uint, alignCorners bool) *MPSCNNUpsamplingBilinearNode

@abstract Init a node representing a MPSCNNUpsamplingBilinear kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param integerScaleFactorX The upsampling factor for the x dimension. @param integerScaleFactorY The upsampling factor for the y dimension. @param alignCorners Specifier whether the centers of the 4 corner pixels of the input and output regions are aligned, @return A new MPSNNFilter node for a MPSCNNUpsamplingBilinear kernel.

func (*MPSCNNUpsamplingBilinearNode) ScaleFactorX ¶

func (o *MPSCNNUpsamplingBilinearNode) ScaleFactorX() float64

func (*MPSCNNUpsamplingBilinearNode) ScaleFactorY ¶

func (o *MPSCNNUpsamplingBilinearNode) ScaleFactorY() float64

type MPSCNNUpsamplingGradient ¶

type MPSCNNUpsamplingGradient struct {
	MPSCNNGradientKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnupsamplinggradient

func MPSCNNUpsamplingGradientFromID ¶

func MPSCNNUpsamplingGradientFromID(id objc.ID) *MPSCNNUpsamplingGradient

func (*MPSCNNUpsamplingGradient) ScaleFactorX ¶

func (o *MPSCNNUpsamplingGradient) ScaleFactorX() float64

@property scaleFactorX @abstract The downsampling scale factor for the x dimension. The default value is 1.

func (*MPSCNNUpsamplingGradient) ScaleFactorY ¶

func (o *MPSCNNUpsamplingGradient) ScaleFactorY() float64

@property scaleFactorY @abstract The downsampling scale factor for the y dimension. The default value is 1.

type MPSCNNUpsamplingNearest ¶

type MPSCNNUpsamplingNearest struct {
	MPSCNNUpsampling
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnupsamplingnearest

func MPSCNNUpsamplingNearestFromID ¶

func MPSCNNUpsamplingNearestFromID(id objc.ID) *MPSCNNUpsamplingNearest

func (*MPSCNNUpsamplingNearest) InitWithDeviceIntegerScaleFactorXIntegerScaleFactorY ¶

func (o *MPSCNNUpsamplingNearest) InitWithDeviceIntegerScaleFactorXIntegerScaleFactorY(device metal.MTLDevice, integerScaleFactorX uint, integerScaleFactorY uint) *MPSCNNUpsamplingNearest

@abstract Initialize the nearest spatial upsampling filter. @param device The device the filter will run on. @param integerScaleFactorX The upsampling factor for the x dimension. @param integerScaleFactorY The upsampling factor for the y dimension. @return A valid MPSCNNUpsamplingNearest object or nil, if failure.

type MPSCNNUpsamplingNearestGradient ¶

type MPSCNNUpsamplingNearestGradient struct {
	MPSCNNUpsamplingGradient
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnupsamplingnearestgradient

func MPSCNNUpsamplingNearestGradientFromID ¶

func MPSCNNUpsamplingNearestGradientFromID(id objc.ID) *MPSCNNUpsamplingNearestGradient

func (*MPSCNNUpsamplingNearestGradient) InitWithDeviceIntegerScaleFactorXIntegerScaleFactorY ¶

func (o *MPSCNNUpsamplingNearestGradient) InitWithDeviceIntegerScaleFactorXIntegerScaleFactorY(device metal.MTLDevice, integerScaleFactorX uint, integerScaleFactorY uint) *MPSCNNUpsamplingNearestGradient

@abstract Initialize the nearest spatial upsampling filter. @param device The device the filter will run on. @param integerScaleFactorX The downsampling factor for the x dimension. @param integerScaleFactorY The downsampling factor for the y dimension. @return A valid MPSCNNUpsamplingNearestGradient object or nil, if failure.

type MPSCNNUpsamplingNearestGradientNode ¶

type MPSCNNUpsamplingNearestGradientNode struct {
	MPSNNGradientFilterNode
}

Node representing a MPSCNNUpsamplingNearest kernel

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnupsamplingnearestgradientnode

func MPSCNNUpsamplingNearestGradientNodeFromID ¶

func MPSCNNUpsamplingNearestGradientNodeFromID(id objc.ID) *MPSCNNUpsamplingNearestGradientNode

func MPSCNNUpsamplingNearestGradientNodeNodeWithSourceGradientSourceImageGradientStateScaleFactorXScaleFactorY ¶

func MPSCNNUpsamplingNearestGradientNodeNodeWithSourceGradientSourceImageGradientStateScaleFactorXScaleFactorY(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, scaleFactorX float64, scaleFactorY float64) *MPSCNNUpsamplingNearestGradientNode

@abstract A node to represent the gradient calculation for nearest upsampling training. @discussion [forwardFilter gradientFilterWithSources:] is a more convient way to do this. @param sourceGradient The input gradient from the 'downstream' gradient filter. @param sourceImage The input image from the forward filter node @param gradientState The gradient state from the forward filter @param scaleFactorX The X scale factor from the forward pass @param scaleFactorY The Y scale factor from the forward pass @return A MPSCNNUpsamplingNearestGradientNode

func (*MPSCNNUpsamplingNearestGradientNode) InitWithSourceGradientSourceImageGradientStateScaleFactorXScaleFactorY ¶

func (o *MPSCNNUpsamplingNearestGradientNode) InitWithSourceGradientSourceImageGradientStateScaleFactorXScaleFactorY(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, scaleFactorX float64, scaleFactorY float64) *MPSCNNUpsamplingNearestGradientNode

@abstract A node to represent the gradient calculation for nearest upsampling training. @discussion [forwardFilter gradientFilterWithSources:] is a more convient way to do this. @param sourceGradient The input gradient from the 'downstream' gradient filter. @param sourceImage The input image from the forward filter node @param gradientState The gradient state from the forward filter @param scaleFactorX The X scale factor from the forward pass @param scaleFactorY The Y scale factor from the forward pass @return A MPSCNNUpsamplingNearestGradientNode

func (*MPSCNNUpsamplingNearestGradientNode) ScaleFactorX ¶

func (o *MPSCNNUpsamplingNearestGradientNode) ScaleFactorX() float64

func (*MPSCNNUpsamplingNearestGradientNode) ScaleFactorY ¶

func (o *MPSCNNUpsamplingNearestGradientNode) ScaleFactorY() float64

type MPSCNNUpsamplingNearestNode ¶

type MPSCNNUpsamplingNearestNode struct {
	MPSNNFilterNode
}

Node representing a MPSCNNUpsamplingNearest kernel

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnupsamplingnearestnode

func MPSCNNUpsamplingNearestNodeFromID ¶

func MPSCNNUpsamplingNearestNodeFromID(id objc.ID) *MPSCNNUpsamplingNearestNode

func MPSCNNUpsamplingNearestNodeNodeWithSourceIntegerScaleFactorXIntegerScaleFactorY ¶

func MPSCNNUpsamplingNearestNodeNodeWithSourceIntegerScaleFactorXIntegerScaleFactorY(sourceNode *MPSNNImageNode, integerScaleFactorX uint, integerScaleFactorY uint) *MPSCNNUpsamplingNearestNode

@abstract Convenience initializer for an autoreleased MPSCNNUpsamplingNearest nodes @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param integerScaleFactorX The upsampling factor for the x dimension. @param integerScaleFactorY The upsampling factor for the y dimension. @return A new MPSNNFilter node for a MPSCNNUpsamplingNearest kernel.

func (*MPSCNNUpsamplingNearestNode) InitWithSourceIntegerScaleFactorXIntegerScaleFactorY ¶

func (o *MPSCNNUpsamplingNearestNode) InitWithSourceIntegerScaleFactorXIntegerScaleFactorY(sourceNode *MPSNNImageNode, integerScaleFactorX uint, integerScaleFactorY uint) *MPSCNNUpsamplingNearestNode

@abstract Init a node representing a MPSCNNUpsamplingNearest kernel @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @param integerScaleFactorX The upsampling factor for the x dimension. @param integerScaleFactorY The upsampling factor for the y dimension. @return A new MPSNNFilter node for a MPSCNNUpsamplingNearest kernel.

func (*MPSCNNUpsamplingNearestNode) ScaleFactorX ¶

func (o *MPSCNNUpsamplingNearestNode) ScaleFactorX() float64

func (*MPSCNNUpsamplingNearestNode) ScaleFactorY ¶

func (o *MPSCNNUpsamplingNearestNode) ScaleFactorY() float64

type MPSCNNWeightsQuantizationType ¶

type MPSCNNWeightsQuantizationType int64
const (
	MPSCNNWeightsQuantizationTypeNone        MPSCNNWeightsQuantizationType = 0
	MPSCNNWeightsQuantizationTypeLinear      MPSCNNWeightsQuantizationType = 1
	MPSCNNWeightsQuantizationTypeLookupTable MPSCNNWeightsQuantizationType = 2
)

func (MPSCNNWeightsQuantizationType) String ¶

type MPSCNNYOLOLoss ¶

type MPSCNNYOLOLoss struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnyololoss

func MPSCNNYOLOLossFromID ¶

func MPSCNNYOLOLossFromID(id objc.ID) *MPSCNNYOLOLoss

func (*MPSCNNYOLOLoss) AnchorBoxes ¶

func (o *MPSCNNYOLOLoss) AnchorBoxes() *foundation.NSData

func (*MPSCNNYOLOLoss) EncodeBatchToCommandBufferSourceImagesLabels ¶

func (o *MPSCNNYOLOLoss) EncodeBatchToCommandBufferSourceImagesLabels(commandBuffer metal.MTLCommandBuffer, sourceImage unsafe.Pointer, labels unsafe.Pointer) unsafe.Pointer

func (*MPSCNNYOLOLoss) EncodeBatchToCommandBufferSourceImagesLabelsDestinationImages ¶

func (o *MPSCNNYOLOLoss) EncodeBatchToCommandBufferSourceImagesLabelsDestinationImages(commandBuffer metal.MTLCommandBuffer, sourceImage unsafe.Pointer, labels unsafe.Pointer, destinationImage unsafe.Pointer)

func (*MPSCNNYOLOLoss) EncodeToCommandBufferSourceImageLabels ¶

func (o *MPSCNNYOLOLoss) EncodeToCommandBufferSourceImageLabels(commandBuffer metal.MTLCommandBuffer, sourceImage *mpscore.MPSImage, labels *MPSCNNLossLabels) *mpscore.MPSImage

@abstract Encode a MPSCNNLoss filter and return a gradient. @discussion This -encode call is similar to the encodeToCommandBuffer:sourceImage:labels:destinationImage: above, except that it creates and returns the MPSImage with the loss gradient result. @param commandBuffer The MTLCommandBuffer on which to encode. @param sourceImage The source image from the previous filter in the graph (in the inference direction). @param labels The object containing the target data (labels) and optionally, weights for the labels. @return The MPSImage containing the gradient result.

func (*MPSCNNYOLOLoss) EncodeToCommandBufferSourceImageLabelsDestinationImage ¶

func (o *MPSCNNYOLOLoss) EncodeToCommandBufferSourceImageLabelsDestinationImage(commandBuffer metal.MTLCommandBuffer, sourceImage *mpscore.MPSImage, labels *MPSCNNLossLabels, destinationImage *mpscore.MPSImage)

@abstract Encode a MPSCNNYOLOLoss filter and return a gradient in the destinationImage. @discussion This filter consumes the output of a previous layer and the MPSCNNLossLabels object containing the target data (labels) and optionally, weights for the labels. The destinationImage contains the computed gradient for the loss layer. It serves as a source gradient input image to the first gradient layer (in the backward direction). For information on the data-layout see @ref MPSCNNYOLOLossDescriptor. @param commandBuffer The MTLCommandBuffer on which to encode. @param sourceImage The source image from the previous filter in the graph (in the inference direction). @param labels The object containing the target data (labels) and optionally, weights for the labels. @param destinationImage The MPSImage into which to write the gradient result.

func (*MPSCNNYOLOLoss) InitWithCoderDevice ¶

func (o *MPSCNNYOLOLoss) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSCNNYOLOLoss

@abstract <NSSecureCoding> support

func (*MPSCNNYOLOLoss) InitWithDeviceLossDescriptor ¶

func (o *MPSCNNYOLOLoss) InitWithDeviceLossDescriptor(device metal.MTLDevice, lossDescriptor *MPSCNNYOLOLossDescriptor) *MPSCNNYOLOLoss

@abstract Initialize the loss filter with a loss descriptor. @param device The device the filter will run on. @param lossDescriptor The loss descriptor. @return A valid MPSCNNLoss object or nil, if failure.

func (*MPSCNNYOLOLoss) LossClasses ¶

func (o *MPSCNNYOLOLoss) LossClasses() *MPSCNNLoss

@property lossClasses @abstract loss filter for prediction of bounding box predicted class of the detected object

func (*MPSCNNYOLOLoss) LossConfidence ¶

func (o *MPSCNNYOLOLoss) LossConfidence() *MPSCNNLoss

@property lossConfidence @abstract loss filter for prediction of bounding box probability of presence of object

func (*MPSCNNYOLOLoss) LossWH ¶

func (o *MPSCNNYOLOLoss) LossWH() *MPSCNNLoss

@property lossWH @abstract loss filter for prediction of bounding box size

func (*MPSCNNYOLOLoss) LossXY ¶

func (o *MPSCNNYOLOLoss) LossXY() *MPSCNNLoss

@property lossXY @abstract loss filter for prediction of bounding box position

func (*MPSCNNYOLOLoss) MaxIOUForObjectAbsence ¶

func (o *MPSCNNYOLOLoss) MaxIOUForObjectAbsence() float32

func (*MPSCNNYOLOLoss) MinIOUForObjectPresence ¶

func (o *MPSCNNYOLOLoss) MinIOUForObjectPresence() float32

func (*MPSCNNYOLOLoss) NumberOfAnchorBoxes ¶

func (o *MPSCNNYOLOLoss) NumberOfAnchorBoxes() uint

func (*MPSCNNYOLOLoss) ReduceAcrossBatch ¶

func (o *MPSCNNYOLOLoss) ReduceAcrossBatch() bool

func (*MPSCNNYOLOLoss) ReductionType ¶

func (o *MPSCNNYOLOLoss) ReductionType() MPSCNNReductionType

func (*MPSCNNYOLOLoss) ScaleClass ¶

func (o *MPSCNNYOLOLoss) ScaleClass() float32

func (*MPSCNNYOLOLoss) ScaleNoObject ¶

func (o *MPSCNNYOLOLoss) ScaleNoObject() float32

func (*MPSCNNYOLOLoss) ScaleObject ¶

func (o *MPSCNNYOLOLoss) ScaleObject() float32

func (*MPSCNNYOLOLoss) ScaleWH ¶

func (o *MPSCNNYOLOLoss) ScaleWH() float32

func (*MPSCNNYOLOLoss) ScaleXY ¶

func (o *MPSCNNYOLOLoss) ScaleXY() float32

See MPSCNNYOLOLossDescriptor for information about the following properties.

type MPSCNNYOLOLossDescriptor ¶

type MPSCNNYOLOLossDescriptor struct {
	foundation.NSObject
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnyololossdescriptor

func MPSCNNYOLOLossDescriptorCnnLossDescriptorWithXYLossTypeWHLossTypeConfidenceLossTypeClassesLossTypeReductionTypeAnchorBoxesNumberOfAnchorBoxes ¶

func MPSCNNYOLOLossDescriptorCnnLossDescriptorWithXYLossTypeWHLossTypeConfidenceLossTypeClassesLossTypeReductionTypeAnchorBoxesNumberOfAnchorBoxes(xYLossType MPSCNNLossType, wHLossType MPSCNNLossType, confidenceLossType MPSCNNLossType, classesLossType MPSCNNLossType, reductionType MPSCNNReductionType, anchorBoxes *foundation.NSData, numberOfAnchorBoxes uint) *MPSCNNYOLOLossDescriptor

@abstract Make a descriptor for a MPSCNNYOLOLoss object. @param XYLossType The type of spatial position loss filter. @param WHLossType The type of spatial size loss filter. @param confidenceLossType The type of confidence filter. @param classesLossType The type of classes filter. @param reductionType The type of a reduction operation to apply. @param anchorBoxes This is an NSData which has an array of anchorBoxes defined as a struct{ float width; float height; }; @return A valid MPSCNNYOLOLossDescriptor object or nil, if failure.

func MPSCNNYOLOLossDescriptorFromID ¶

func MPSCNNYOLOLossDescriptorFromID(id objc.ID) *MPSCNNYOLOLossDescriptor

func (*MPSCNNYOLOLossDescriptor) AnchorBoxes ¶

func (o *MPSCNNYOLOLossDescriptor) AnchorBoxes() *foundation.NSData

@property anchorBoxes @abstract NSData containing the width and height for numberOfAnchorBoxes anchor boxes This NSData should have 2 float values per anchor box which represent the width and height of the anchor box. @code typedef struct anchorBox{ float width; float height; }anchorBox; anchorBox_t gAnchorBoxes[MAX_NUM_ANCHOR_BOXES] = { {.width = 1.f, .height = 2.f}, {.width = 1.f, .height = 1.f}, {.width = 2.f, .height = 1.f}, }; NSData* labelsInputData = [NSData dataWithBytes: gAnchorBoxes length: MAX_NUM_ANCHOR_BOXES * sizeof(anchorBox)]; @endcode

func (*MPSCNNYOLOLossDescriptor) ClassesLossDescriptor ¶

func (o *MPSCNNYOLOLossDescriptor) ClassesLossDescriptor() *MPSCNNLossDescriptor

@property classesLossDescriptor @abstract The type of a loss filter. @discussion This parameter specifies the type of a loss filter.

func (*MPSCNNYOLOLossDescriptor) ConfidenceLossDescriptor ¶

func (o *MPSCNNYOLOLossDescriptor) ConfidenceLossDescriptor() *MPSCNNLossDescriptor

@property confidenceLossDescriptor @abstract The type of a loss filter. @discussion This parameter specifies the type of a loss filter.

func (*MPSCNNYOLOLossDescriptor) MaxIOUForObjectAbsence ¶

func (o *MPSCNNYOLOLossDescriptor) MaxIOUForObjectAbsence() float32

@property neg_iou @abstract If the prediction IOU with groundTruth is lower than this value we consider it a confident object absence, default is 0.3

func (*MPSCNNYOLOLossDescriptor) MinIOUForObjectPresence ¶

func (o *MPSCNNYOLOLossDescriptor) MinIOUForObjectPresence() float32

@property pos_iou @abstract If the prediction IOU with groundTruth is higher than this value we consider it a confident object presence, default is 0.7

func (*MPSCNNYOLOLossDescriptor) NumberOfAnchorBoxes ¶

func (o *MPSCNNYOLOLossDescriptor) NumberOfAnchorBoxes() uint

@property numberOfAnchorBoxes @abstract number of anchor boxes used to detect object per grid cell

func (*MPSCNNYOLOLossDescriptor) ReduceAcrossBatch ¶

func (o *MPSCNNYOLOLossDescriptor) ReduceAcrossBatch() bool

@property reduceAcrossBatch @abstract If set to YES then the reduction operation is applied also across the batch-index dimension, ie. the loss value is summed over images in the batch and the result of the reduction is written on the first loss image in the batch while the other loss images will be set to zero. If set to NO, then no reductions are performed across the batch dimension and each image in the batch will contain the loss value associated with that one particular image. NOTE: If reductionType == MPSCNNReductionTypeNone, then this flag has no effect on results, that is no reductions are done in this case. NOTE: If reduceAcrossBatch is set to YES and reductionType == MPSCNNReductionTypeMean then the final forward loss value is computed by first summing over the components and then by dividing the result with: number of feature channels * width * height * number of images in the batch. The default value is NO.

func (*MPSCNNYOLOLossDescriptor) ReductionType ¶

func (o *MPSCNNYOLOLossDescriptor) ReductionType() MPSCNNReductionType

@property reductionType @abstract ReductionType shared accross all losses (so they may generate same sized output)

func (*MPSCNNYOLOLossDescriptor) Rescore ¶

func (o *MPSCNNYOLOLossDescriptor) Rescore() bool

@property rescore @abstract Rescore pertains to multiplying the confidence groundTruth with IOU (intersection over union) of predicted bounding box and the groundTruth boundingBox. Default is YES

func (*MPSCNNYOLOLossDescriptor) ScaleClass ¶

func (o *MPSCNNYOLOLossDescriptor) ScaleClass() float32

@property scaleClass @abstract scale factor for no object classes loss and loss gradient default is 2.0

func (*MPSCNNYOLOLossDescriptor) ScaleNoObject ¶

func (o *MPSCNNYOLOLossDescriptor) ScaleNoObject() float32

@property scaleNoObject @abstract scale factor for no object confidence loss and loss gradient default is 5.0

func (*MPSCNNYOLOLossDescriptor) ScaleObject ¶

func (o *MPSCNNYOLOLossDescriptor) ScaleObject() float32

@property scaleObject @abstract scale factor for no object confidence loss and loss gradient default is 100.0

func (*MPSCNNYOLOLossDescriptor) ScaleWH ¶

func (o *MPSCNNYOLOLossDescriptor) ScaleWH() float32

@property scaleWH @abstract scale factor for WH loss and loss gradient default is 10.0

func (*MPSCNNYOLOLossDescriptor) ScaleXY ¶

func (o *MPSCNNYOLOLossDescriptor) ScaleXY() float32

@property scaleXY @abstract scale factor for XY loss and loss gradient default is 10.0

func (*MPSCNNYOLOLossDescriptor) SetAnchorBoxes ¶

func (o *MPSCNNYOLOLossDescriptor) SetAnchorBoxes(anchorBoxes *foundation.NSData)

func (*MPSCNNYOLOLossDescriptor) SetClassesLossDescriptor ¶

func (o *MPSCNNYOLOLossDescriptor) SetClassesLossDescriptor(classesLossDescriptor *MPSCNNLossDescriptor)

func (*MPSCNNYOLOLossDescriptor) SetConfidenceLossDescriptor ¶

func (o *MPSCNNYOLOLossDescriptor) SetConfidenceLossDescriptor(confidenceLossDescriptor *MPSCNNLossDescriptor)

func (*MPSCNNYOLOLossDescriptor) SetMaxIOUForObjectAbsence ¶

func (o *MPSCNNYOLOLossDescriptor) SetMaxIOUForObjectAbsence(maxIOUForObjectAbsence float32)

func (*MPSCNNYOLOLossDescriptor) SetMinIOUForObjectPresence ¶

func (o *MPSCNNYOLOLossDescriptor) SetMinIOUForObjectPresence(minIOUForObjectPresence float32)

func (*MPSCNNYOLOLossDescriptor) SetNumberOfAnchorBoxes ¶

func (o *MPSCNNYOLOLossDescriptor) SetNumberOfAnchorBoxes(numberOfAnchorBoxes uint)

func (*MPSCNNYOLOLossDescriptor) SetReduceAcrossBatch ¶

func (o *MPSCNNYOLOLossDescriptor) SetReduceAcrossBatch(reduceAcrossBatch bool)

func (*MPSCNNYOLOLossDescriptor) SetReductionType ¶

func (o *MPSCNNYOLOLossDescriptor) SetReductionType(reductionType MPSCNNReductionType)

func (*MPSCNNYOLOLossDescriptor) SetRescore ¶

func (o *MPSCNNYOLOLossDescriptor) SetRescore(rescore bool)

func (*MPSCNNYOLOLossDescriptor) SetScaleClass ¶

func (o *MPSCNNYOLOLossDescriptor) SetScaleClass(scaleClass float32)

func (*MPSCNNYOLOLossDescriptor) SetScaleNoObject ¶

func (o *MPSCNNYOLOLossDescriptor) SetScaleNoObject(scaleNoObject float32)

func (*MPSCNNYOLOLossDescriptor) SetScaleObject ¶

func (o *MPSCNNYOLOLossDescriptor) SetScaleObject(scaleObject float32)

func (*MPSCNNYOLOLossDescriptor) SetScaleWH ¶

func (o *MPSCNNYOLOLossDescriptor) SetScaleWH(scaleWH float32)

func (*MPSCNNYOLOLossDescriptor) SetScaleXY ¶

func (o *MPSCNNYOLOLossDescriptor) SetScaleXY(scaleXY float32)

func (*MPSCNNYOLOLossDescriptor) SetWHLossDescriptor ¶

func (o *MPSCNNYOLOLossDescriptor) SetWHLossDescriptor(wHLossDescriptor *MPSCNNLossDescriptor)

func (*MPSCNNYOLOLossDescriptor) SetXYLossDescriptor ¶

func (o *MPSCNNYOLOLossDescriptor) SetXYLossDescriptor(xYLossDescriptor *MPSCNNLossDescriptor)

func (*MPSCNNYOLOLossDescriptor) WHLossDescriptor ¶

func (o *MPSCNNYOLOLossDescriptor) WHLossDescriptor() *MPSCNNLossDescriptor

@property WHLossDescriptor @abstract The type of a loss filter. @discussion This parameter specifies the type of a loss filter.

func (*MPSCNNYOLOLossDescriptor) XYLossDescriptor ¶

func (o *MPSCNNYOLOLossDescriptor) XYLossDescriptor() *MPSCNNLossDescriptor

@property XYLossDescriptor @abstract The type of a loss filter. @discussion This parameter specifies the type of a loss filter.

type MPSCNNYOLOLossNode ¶

type MPSCNNYOLOLossNode struct {
	MPSNNFilterNode
}

@class MPSCNNYOLOLossNode @discussion This node calculates loss information during training typically immediately after the inference portion of network evaluation is performed. The result image of the loss operations is typically the first gradient image to be comsumed by the gradient passes that work their way back up the graph. In addition, the node will update the loss image in the MPSNNLabels with the desired estimate of correctness.

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpscnnyololossnode

func MPSCNNYOLOLossNodeFromID ¶

func MPSCNNYOLOLossNodeFromID(id objc.ID) *MPSCNNYOLOLossNode

func MPSCNNYOLOLossNodeNodeWithSourceLossDescriptor ¶

func MPSCNNYOLOLossNodeNodeWithSourceLossDescriptor(source *MPSNNImageNode, descriptor *MPSCNNYOLOLossDescriptor) *MPSCNNYOLOLossNode

func (*MPSCNNYOLOLossNode) InitWithSourceLossDescriptor ¶

func (o *MPSCNNYOLOLossNode) InitWithSourceLossDescriptor(source *MPSNNImageNode, descriptor *MPSCNNYOLOLossDescriptor) *MPSCNNYOLOLossNode

func (*MPSCNNYOLOLossNode) InputLabels ¶

func (o *MPSCNNYOLOLossNode) InputLabels() *MPSNNLabelsNode

@abstract Get the input node for labes and weights, for example to set the handle

type MPSCustomKernelIndex ¶

type MPSCustomKernelIndex int64
const (
	MPSCustomKernelIndexDestIndex     MPSCustomKernelIndex = 0
	MPSCustomKernelIndexSrc0Index     MPSCustomKernelIndex = 0
	MPSCustomKernelIndexSrc1Index     MPSCustomKernelIndex = 1
	MPSCustomKernelIndexSrc2Index     MPSCustomKernelIndex = 2
	MPSCustomKernelIndexSrc3Index     MPSCustomKernelIndex = 3
	MPSCustomKernelIndexSrc4Index     MPSCustomKernelIndex = 4
	MPSCustomKernelIndexUserDataIndex MPSCustomKernelIndex = 30
)

func (MPSCustomKernelIndex) String ¶

func (e MPSCustomKernelIndex) String() string

type MPSDeviceCapsValues ¶

type MPSDeviceCapsValues int64
const (
	MPSDeviceCapsNull                        MPSDeviceCapsValues = 0
	MPSDeviceSupportsReadableArrayOfTextures MPSDeviceCapsValues = 1
	MPSDeviceSupportsWritableArrayOfTextures MPSDeviceCapsValues = 2
	MPSDeviceSupportsReadWriteTextures       MPSDeviceCapsValues = 4
	MPSDeviceSupportsSimdgroupBarrier        MPSDeviceCapsValues = 8
	MPSDeviceSupportsQuadShuffle             MPSDeviceCapsValues = 16
	MPSDeviceSupportsSimdShuffle             MPSDeviceCapsValues = 32
	MPSDeviceSupportsSimdReduction           MPSDeviceCapsValues = 64
	MPSDeviceSupportsFloat32Filtering        MPSDeviceCapsValues = 128
	MPSDeviceSupportsNorm16BicubicFiltering  MPSDeviceCapsValues = 256
	MPSDeviceSupportsFloat16BicubicFiltering MPSDeviceCapsValues = 512
	MPSDeviceIsAppleDevice                   MPSDeviceCapsValues = 1024
	MPSDeviceSupportsSimdShuffleAndFill      MPSDeviceCapsValues = 2048
	MPSDeviceSupportsBFloat16Arithmetic      MPSDeviceCapsValues = 4096
	MPSDeviceCapsLast                        MPSDeviceCapsValues = 8192
)

func (MPSDeviceCapsValues) String ¶

func (e MPSDeviceCapsValues) String() string

type MPSGRUDescriptor ¶

type MPSGRUDescriptor struct {
	MPSRNNDescriptor
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsgrudescriptor

func MPSGRUDescriptorCreateGRUDescriptorWithInputFeatureChannelsOutputFeatureChannels ¶

func MPSGRUDescriptorCreateGRUDescriptorWithInputFeatureChannelsOutputFeatureChannels(inputFeatureChannels uint, outputFeatureChannels uint) *MPSGRUDescriptor

@abstract Creates a GRU descriptor. @param inputFeatureChannels The number of feature channels in the input image/matrix. Must be >= 1. @param outputFeatureChannels The number of feature channels in the output image/matrix. Must be >= 1. @return A valid MPSGRUDescriptor object or nil, if failure.

func MPSGRUDescriptorFromID ¶

func MPSGRUDescriptorFromID(id objc.ID) *MPSGRUDescriptor

func (*MPSGRUDescriptor) FlipOutputGates ¶

func (o *MPSGRUDescriptor) FlipOutputGates() bool

@property flipOutputGates @abstract If YES then the GRU-block output formula is changed to: h1_i = ( 1 - z_i ^ p)^(1/p) h0_i + z_i h_i. Defaults to NO.

func (*MPSGRUDescriptor) GatePnormValue ¶

func (o *MPSGRUDescriptor) GatePnormValue() float32

@property gatePnormValue @abstract The p-norm gating norm value as specified by the GRU formulae. Defaults to 1.0f.

func (*MPSGRUDescriptor) InputGateInputWeights ¶

func (o *MPSGRUDescriptor) InputGateInputWeights() MPSCNNConvolutionDataSource

@property inputGateInputWeights @abstract Contains weights 'Wz_ij', bias 'bz_i' and neuron 'gz' from the GRU formula. If nil then assumed zero weights, bias and no neuron (identity mapping). Defaults to nil.

func (*MPSGRUDescriptor) InputGateRecurrentWeights ¶

func (o *MPSGRUDescriptor) InputGateRecurrentWeights() MPSCNNConvolutionDataSource

@property inputGateRecurrentWeights @abstract Contains weights 'Uz_ij' from the GRU formula. If nil then assumed zero weights. Defaults to nil.

func (*MPSGRUDescriptor) OutputGateInputGateWeights ¶

func (o *MPSGRUDescriptor) OutputGateInputGateWeights() MPSCNNConvolutionDataSource

@property outputGateInputGateWeights @abstract Contains weights 'Vh_ij' - can be used to implement the "Minimally Gated Unit". If nil then assumed zero weights. Defaults to nil.

func (*MPSGRUDescriptor) OutputGateInputWeights ¶

func (o *MPSGRUDescriptor) OutputGateInputWeights() MPSCNNConvolutionDataSource

@property outputGateInputWeights @abstract Contains weights 'Wh_ij', bias 'bh_i' and neuron 'gh' from the GRU formula. If nil then assumed zero weights, bias and no neuron (identity mapping).Defaults to nil.

func (*MPSGRUDescriptor) OutputGateRecurrentWeights ¶

func (o *MPSGRUDescriptor) OutputGateRecurrentWeights() MPSCNNConvolutionDataSource

@property outputGateRecurrentWeights @abstract Contains weights 'Uh_ij' from the GRU formula. If nil then assumed zero weights. Defaults to nil.

func (*MPSGRUDescriptor) RecurrentGateInputWeights ¶

func (o *MPSGRUDescriptor) RecurrentGateInputWeights() MPSCNNConvolutionDataSource

@property recurrentGateInputWeights @abstract Contains weights 'Wr_ij', bias 'br_i' and neuron 'gr' from the GRU formula. If nil then assumed zero weights, bias and no neuron (identity mapping).Defaults to nil.

func (*MPSGRUDescriptor) RecurrentGateRecurrentWeights ¶

func (o *MPSGRUDescriptor) RecurrentGateRecurrentWeights() MPSCNNConvolutionDataSource

@property recurrentGateRecurrentWeights @abstract Contains weights 'Ur_ij' from the GRU formula. If nil then assumed zero weights.Defaults to nil.

func (*MPSGRUDescriptor) SetFlipOutputGates ¶

func (o *MPSGRUDescriptor) SetFlipOutputGates(flipOutputGates bool)

func (*MPSGRUDescriptor) SetGatePnormValue ¶

func (o *MPSGRUDescriptor) SetGatePnormValue(gatePnormValue float32)

func (*MPSGRUDescriptor) SetInputGateInputWeights ¶

func (o *MPSGRUDescriptor) SetInputGateInputWeights(inputGateInputWeights MPSCNNConvolutionDataSource)

func (*MPSGRUDescriptor) SetInputGateRecurrentWeights ¶

func (o *MPSGRUDescriptor) SetInputGateRecurrentWeights(inputGateRecurrentWeights MPSCNNConvolutionDataSource)

func (*MPSGRUDescriptor) SetOutputGateInputGateWeights ¶

func (o *MPSGRUDescriptor) SetOutputGateInputGateWeights(outputGateInputGateWeights MPSCNNConvolutionDataSource)

func (*MPSGRUDescriptor) SetOutputGateInputWeights ¶

func (o *MPSGRUDescriptor) SetOutputGateInputWeights(outputGateInputWeights MPSCNNConvolutionDataSource)

func (*MPSGRUDescriptor) SetOutputGateRecurrentWeights ¶

func (o *MPSGRUDescriptor) SetOutputGateRecurrentWeights(outputGateRecurrentWeights MPSCNNConvolutionDataSource)

func (*MPSGRUDescriptor) SetRecurrentGateInputWeights ¶

func (o *MPSGRUDescriptor) SetRecurrentGateInputWeights(recurrentGateInputWeights MPSCNNConvolutionDataSource)

func (*MPSGRUDescriptor) SetRecurrentGateRecurrentWeights ¶

func (o *MPSGRUDescriptor) SetRecurrentGateRecurrentWeights(recurrentGateRecurrentWeights MPSCNNConvolutionDataSource)

type MPSHandle ¶

type MPSHandle interface {
	foundation.NSSecureCoding
	Label() *foundation.NSString
}

MPSHandle wraps the ObjC protocol MPSHandle.

type MPSImageSizeEncodingState ¶

type MPSImageSizeEncodingState interface {
	SourceWidth() uint
	SourceHeight() uint
}

MPSImageSizeEncodingState wraps the ObjC protocol MPSImageSizeEncodingState.

type MPSImageTransformProvider ¶

type MPSImageTransformProvider interface {
	foundation.NSSecureCoding
	TransformForSourceImageHandle(image *mpscore.MPSImage, handle MPSHandle) mpscore.MPSScaleTransform
}

MPSImageTransformProvider wraps the ObjC protocol MPSImageTransformProvider.

type MPSImageType ¶

type MPSImageType int64
const (
	MPSImageType2d                    MPSImageType = 0
	MPSImageType2d_array              MPSImageType = 1
	MPSImageTypeArray2d               MPSImageType = 2
	MPSImageTypeArray2d_array         MPSImageType = 3
	MPSImageType_ArrayMask            MPSImageType = 1
	MPSImageType_BatchMask            MPSImageType = 2
	MPSImageType_typeMask             MPSImageType = 3
	MPSImageType_noAlpha              MPSImageType = 4
	MPSImageType_texelFormatMask      MPSImageType = 56
	MPSImageType_texelFormatShift     MPSImageType = 3
	MPSImageType_texelFormatStandard  MPSImageType = 0
	MPSImageType_texelFormatUnorm8    MPSImageType = 8
	MPSImageType_texelFormatFloat16   MPSImageType = 16
	MPSImageType_texelFormatBFloat16  MPSImageType = 24
	MPSImageType_bitCount             MPSImageType = 6
	MPSImageType_mask                 MPSImageType = 63
	MPSImageType2d_noAlpha            MPSImageType = 4
	MPSImageType2d_array_noAlpha      MPSImageType = 5
	MPSImageTypeArray2d_noAlpha       MPSImageType = 6
	MPSImageTypeArray2d_array_noAlpha MPSImageType = 7
)

func (MPSImageType) String ¶

func (e MPSImageType) String() string

type MPSLSTMDescriptor ¶

type MPSLSTMDescriptor struct {
	MPSRNNDescriptor
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpslstmdescriptor

func MPSLSTMDescriptorCreateLSTMDescriptorWithInputFeatureChannelsOutputFeatureChannels ¶

func MPSLSTMDescriptorCreateLSTMDescriptorWithInputFeatureChannelsOutputFeatureChannels(inputFeatureChannels uint, outputFeatureChannels uint) *MPSLSTMDescriptor

@abstract Creates a LSTM descriptor. @param inputFeatureChannels The number of feature channels in the input image/matrix. Must be >= 1. @param outputFeatureChannels The number of feature channels in the output image/matrix. Must be >= 1. @return A valid MPSNNLSTMDescriptor object or nil, if failure.

func MPSLSTMDescriptorFromID ¶

func MPSLSTMDescriptorFromID(id objc.ID) *MPSLSTMDescriptor

func (*MPSLSTMDescriptor) CellGateInputWeights ¶

func (o *MPSLSTMDescriptor) CellGateInputWeights() MPSCNNConvolutionDataSource

@property cellGateInputWeights @abstract Contains weights 'Wc_ij', bias 'bc_i' and neuron 'gc' from the LSTM formula. If nil then assumed zero weights, bias and no neuron (identity mapping). Defaults to nil.

func (*MPSLSTMDescriptor) CellGateMemoryWeights ¶

func (o *MPSLSTMDescriptor) CellGateMemoryWeights() MPSCNNConvolutionDataSource

@property cellGateMemoryWeights @abstract Contains weights 'Vc_ij' - the 'peephole' weights - from the LSTM formula. if YES == memoryWeightsAreDiagonal, then the number of weights used is the number of features in the memory cell image/matrix. If nil then assumed zero weights. Defaults to nil.

func (*MPSLSTMDescriptor) CellGateRecurrentWeights ¶

func (o *MPSLSTMDescriptor) CellGateRecurrentWeights() MPSCNNConvolutionDataSource

@property cellGateRecurrentWeights @abstract Contains weights 'Uc_ij' from the LSTM formula. If nil then assumed zero weights. Defaults to nil.

func (*MPSLSTMDescriptor) CellToOutputNeuronParamA ¶

func (o *MPSLSTMDescriptor) CellToOutputNeuronParamA() float32

@property cellToOutputNeuronParamA @abstract Neuron parameter A for 'gh'. Defaults to 1.0f.

func (*MPSLSTMDescriptor) CellToOutputNeuronParamB ¶

func (o *MPSLSTMDescriptor) CellToOutputNeuronParamB() float32

@property cellToOutputNeuronParamB @abstract Neuron parameter B for 'gh'. Defaults to 1.0f.

func (*MPSLSTMDescriptor) CellToOutputNeuronParamC ¶

func (o *MPSLSTMDescriptor) CellToOutputNeuronParamC() float32

@property cellToOutputNeuronParamC @abstract Neuron parameter C for 'gh'. Defaults to 1.0f.

func (*MPSLSTMDescriptor) CellToOutputNeuronType ¶

func (o *MPSLSTMDescriptor) CellToOutputNeuronType() MPSCNNNeuronType

@property cellToOutputNeuronType @abstract Neuron type definition for 'gh', see @ref MPSCNNNeuronType. Defaults to MPSCNNNeuronTypeTanH.

func (*MPSLSTMDescriptor) ForgetGateInputWeights ¶

func (o *MPSLSTMDescriptor) ForgetGateInputWeights() MPSCNNConvolutionDataSource

@property forgetGateInputWeights @abstract Contains weights 'Wf_ij', bias 'bf_i' and neuron 'gf' from the LSTM formula. If nil then assumed zero weights, bias and no neuron (identity mapping).Defaults to nil.

func (*MPSLSTMDescriptor) ForgetGateMemoryWeights ¶

func (o *MPSLSTMDescriptor) ForgetGateMemoryWeights() MPSCNNConvolutionDataSource

@property forgetGateMemoryWeights @abstract Contains weights 'Vf_ij' - the 'peephole' weights - from the LSTM formula. if YES == memoryWeightsAreDiagonal, then the number of weights used is the number of features in the memory cell image/matrix. If nil then assumed zero weights. Defaults to nil.

func (*MPSLSTMDescriptor) ForgetGateRecurrentWeights ¶

func (o *MPSLSTMDescriptor) ForgetGateRecurrentWeights() MPSCNNConvolutionDataSource

@property forgetGateRecurrentWeights @abstract Contains weights 'Uf_ij' from the LSTM formula. If nil then assumed zero weights. Defaults to nil.

func (*MPSLSTMDescriptor) InputGateInputWeights ¶

func (o *MPSLSTMDescriptor) InputGateInputWeights() MPSCNNConvolutionDataSource

@property inputGateInputWeights @abstract Contains weights 'Wi_ij', bias 'bi_i' and neuron 'gi' from the LSTM formula. If nil then assumed zero weights, bias and no neuron (identity mapping). Defaults to nil.

func (*MPSLSTMDescriptor) InputGateMemoryWeights ¶

func (o *MPSLSTMDescriptor) InputGateMemoryWeights() MPSCNNConvolutionDataSource

@property inputGateMemoryWeights @abstract Contains weights 'Vi_ij' - the 'peephole' weights - from the LSTM formula. if YES == memoryWeightsAreDiagonal, then the number of weights used is the number of features in the memory cell image/matrix. If nil then assumed zero weights. Defaults to nil.

func (*MPSLSTMDescriptor) InputGateRecurrentWeights ¶

func (o *MPSLSTMDescriptor) InputGateRecurrentWeights() MPSCNNConvolutionDataSource

@property inputGateRecurrentWeights @abstract Contains weights 'Ui_ij' from the LSTM formula. If nil then assumed zero weights. Defaults to nil.

func (*MPSLSTMDescriptor) MemoryWeightsAreDiagonal ¶

func (o *MPSLSTMDescriptor) MemoryWeightsAreDiagonal() bool

@property memoryWeightsAreDiagonal @abstract If YES, then the 'peephole' weight matrices will be diagonal matrices represented as vectors of length the number of features in memory cells, that will be multiplied pointwise with the peephole matrix or image in order to achieve the diagonal (nonmixing) update. Defaults to NO.

func (*MPSLSTMDescriptor) OutputGateInputWeights ¶

func (o *MPSLSTMDescriptor) OutputGateInputWeights() MPSCNNConvolutionDataSource

@property outputGateInputWeights @abstract Contains weights 'Wo_ij', bias 'bo_i' and neuron 'go' from the LSTM formula. If nil then assumed zero weights, bias and no neuron (identity mapping). Defaults to nil.

func (*MPSLSTMDescriptor) OutputGateMemoryWeights ¶

func (o *MPSLSTMDescriptor) OutputGateMemoryWeights() MPSCNNConvolutionDataSource

@property outputGateMemoryWeights @abstract Contains weights 'Vo_ij' - the 'peephole' weights - from the LSTM. if YES == memoryWeightsAreDiagonal, then the number of weights used is the number of features in the memory cell image/matrix. If nil then assumed zero weights. Defaults to nil.

func (*MPSLSTMDescriptor) OutputGateRecurrentWeights ¶

func (o *MPSLSTMDescriptor) OutputGateRecurrentWeights() MPSCNNConvolutionDataSource

@property outputGateRecurrentWeights @abstract Contains weights 'Uo_ij' from the LSTM formula. If nil then assumed zero weights. Defaults to nil.

func (*MPSLSTMDescriptor) SetCellGateInputWeights ¶

func (o *MPSLSTMDescriptor) SetCellGateInputWeights(cellGateInputWeights MPSCNNConvolutionDataSource)

func (*MPSLSTMDescriptor) SetCellGateMemoryWeights ¶

func (o *MPSLSTMDescriptor) SetCellGateMemoryWeights(cellGateMemoryWeights MPSCNNConvolutionDataSource)

func (*MPSLSTMDescriptor) SetCellGateRecurrentWeights ¶

func (o *MPSLSTMDescriptor) SetCellGateRecurrentWeights(cellGateRecurrentWeights MPSCNNConvolutionDataSource)

func (*MPSLSTMDescriptor) SetCellToOutputNeuronParamA ¶

func (o *MPSLSTMDescriptor) SetCellToOutputNeuronParamA(cellToOutputNeuronParamA float32)

func (*MPSLSTMDescriptor) SetCellToOutputNeuronParamB ¶

func (o *MPSLSTMDescriptor) SetCellToOutputNeuronParamB(cellToOutputNeuronParamB float32)

func (*MPSLSTMDescriptor) SetCellToOutputNeuronParamC ¶

func (o *MPSLSTMDescriptor) SetCellToOutputNeuronParamC(cellToOutputNeuronParamC float32)

func (*MPSLSTMDescriptor) SetCellToOutputNeuronType ¶

func (o *MPSLSTMDescriptor) SetCellToOutputNeuronType(cellToOutputNeuronType MPSCNNNeuronType)

func (*MPSLSTMDescriptor) SetForgetGateInputWeights ¶

func (o *MPSLSTMDescriptor) SetForgetGateInputWeights(forgetGateInputWeights MPSCNNConvolutionDataSource)

func (*MPSLSTMDescriptor) SetForgetGateMemoryWeights ¶

func (o *MPSLSTMDescriptor) SetForgetGateMemoryWeights(forgetGateMemoryWeights MPSCNNConvolutionDataSource)

func (*MPSLSTMDescriptor) SetForgetGateRecurrentWeights ¶

func (o *MPSLSTMDescriptor) SetForgetGateRecurrentWeights(forgetGateRecurrentWeights MPSCNNConvolutionDataSource)

func (*MPSLSTMDescriptor) SetInputGateInputWeights ¶

func (o *MPSLSTMDescriptor) SetInputGateInputWeights(inputGateInputWeights MPSCNNConvolutionDataSource)

func (*MPSLSTMDescriptor) SetInputGateMemoryWeights ¶

func (o *MPSLSTMDescriptor) SetInputGateMemoryWeights(inputGateMemoryWeights MPSCNNConvolutionDataSource)

func (*MPSLSTMDescriptor) SetInputGateRecurrentWeights ¶

func (o *MPSLSTMDescriptor) SetInputGateRecurrentWeights(inputGateRecurrentWeights MPSCNNConvolutionDataSource)

func (*MPSLSTMDescriptor) SetMemoryWeightsAreDiagonal ¶

func (o *MPSLSTMDescriptor) SetMemoryWeightsAreDiagonal(memoryWeightsAreDiagonal bool)

func (*MPSLSTMDescriptor) SetOutputGateInputWeights ¶

func (o *MPSLSTMDescriptor) SetOutputGateInputWeights(outputGateInputWeights MPSCNNConvolutionDataSource)

func (*MPSLSTMDescriptor) SetOutputGateMemoryWeights ¶

func (o *MPSLSTMDescriptor) SetOutputGateMemoryWeights(outputGateMemoryWeights MPSCNNConvolutionDataSource)

func (*MPSLSTMDescriptor) SetOutputGateRecurrentWeights ¶

func (o *MPSLSTMDescriptor) SetOutputGateRecurrentWeights(outputGateRecurrentWeights MPSCNNConvolutionDataSource)

type MPSMatrixBatchNormalization ¶

type MPSMatrixBatchNormalization struct {
	mpsmatrix.MPSMatrixUnaryKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsmatrixbatchnormalization

func MPSMatrixBatchNormalizationFromID ¶

func MPSMatrixBatchNormalizationFromID(id objc.ID) *MPSMatrixBatchNormalization

func (*MPSMatrixBatchNormalization) ComputeStatistics ¶

func (o *MPSMatrixBatchNormalization) ComputeStatistics() bool

@property computeStatistics @discussion If YES the batch statistics will be computed prior to performing the normalization. Otherwise the provided statistics will be used. Defaults to NO at initialization time.

func (*MPSMatrixBatchNormalization) EncodeToCommandBufferInputMatrixMeanVectorVarianceVectorGammaVectorBetaVectorResultMatrix ¶

func (o *MPSMatrixBatchNormalization) EncodeToCommandBufferInputMatrixMeanVectorVarianceVectorGammaVectorBetaVectorResultMatrix(commandBuffer metal.MTLCommandBuffer, inputMatrix *mpscore.MPSMatrix, meanVector *mpscore.MPSVector, varianceVector *mpscore.MPSVector, gammaVector *mpscore.MPSVector, betaVector *mpscore.MPSVector, resultMatrix *mpscore.MPSMatrix)

@abstract Encode a MPSMatrixBatchNormalization object to a command buffer. @param commandBuffer A valid MTLCommandBuffer to receive the encoded kernel. @param inputMatrix A valid MPSMatrix object which specifies the input array. @param meanVector A valid MPSVector object containing batch mean values to be used to normalize the inputs if computeStatistics is NO. If computeStatistics is YES the resulting batch mean values will be returned in this array. @param varianceVector A valid MPSVector object containing batch variance values to be used to normalize the inputs if computeStatistics is NO. If computeStatistics is YES the resulting batch variance values will be returned in this array. @param gammaVector A valid MPSVector object which specifies the gamma terms, or a null object to indicate that no scaling is to be applied. @param betaVector A valid MPSVector object which specifies the beta terms, or a null object to indicate that no values are to be added. @param resultMatrix A valid MPSMatrix object which specifies the output array. @discussion Encodes the operation to the specified command buffer. resultMatrix must be large enough to hold a MIN(sourceNumberOfFeatureVectors, inputMatrix.rows - sourceMatrixOrigin.x) x MIN(inputMatrix.columns - sourceMatrixOrigin.y, sourceInputFeatureChannels) array. Let numChannels = MIN(inputMatrix.columns - sourceMatrixOrigin.y, sourceInputFeatureChannels) The gamma, beta, mean, and variance vectors must contain at least numChannels elements.

func (*MPSMatrixBatchNormalization) Epsilon ¶

func (o *MPSMatrixBatchNormalization) Epsilon() float32

@property epsilon @discussion A small value to add to the variance when normalizing the inputs. Defaults to FLT_MIN upon initialization.

func (*MPSMatrixBatchNormalization) InitWithCoderDevice ¶

func (o *MPSMatrixBatchNormalization) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSMatrixBatchNormalization

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSMatrixBatchNormalization object. @param device The MTLDevice on which to make the MPSMatrixBatchNormalization object. @return A new MPSMatrixBatchNormalization object, or nil if failure.

func (*MPSMatrixBatchNormalization) InitWithDevice ¶

func (*MPSMatrixBatchNormalization) NeuronParameterA ¶

func (o *MPSMatrixBatchNormalization) NeuronParameterA() float32

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixBatchNormalization) NeuronParameterB ¶

func (o *MPSMatrixBatchNormalization) NeuronParameterB() float32

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixBatchNormalization) NeuronParameterC ¶

func (o *MPSMatrixBatchNormalization) NeuronParameterC() float32

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixBatchNormalization) NeuronType ¶

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixBatchNormalization) SetComputeStatistics ¶

func (o *MPSMatrixBatchNormalization) SetComputeStatistics(computeStatistics bool)

func (*MPSMatrixBatchNormalization) SetEpsilon ¶

func (o *MPSMatrixBatchNormalization) SetEpsilon(epsilon float32)

func (*MPSMatrixBatchNormalization) SetNeuronTypeParameterAParameterBParameterC ¶

func (o *MPSMatrixBatchNormalization) SetNeuronTypeParameterAParameterBParameterC(neuronType MPSCNNNeuronType, parameterA float32, parameterB float32, parameterC float32)

@abstract Specifies a neuron activation function to be used. @discussion This method can be used to add a neuron activation funtion of given type with associated scalar parameters A, 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 MPSMatrixNeuron kernel is initialized with a default neuron function of MPSCNNNeuronTypeNone. @param neuronType Type of neuron activation function. For full list see MPSCNNNeuronType.h @param parameterA parameterA of neuron activation that is shared across all output values. @param parameterB parameterB of neuron activation that is shared across all output values. @param parameterC parameterC of neuron activation that is shared across all output values.

func (*MPSMatrixBatchNormalization) SetSourceInputFeatureChannels ¶

func (o *MPSMatrixBatchNormalization) SetSourceInputFeatureChannels(sourceInputFeatureChannels uint)

func (*MPSMatrixBatchNormalization) SetSourceNumberOfFeatureVectors ¶

func (o *MPSMatrixBatchNormalization) SetSourceNumberOfFeatureVectors(sourceNumberOfFeatureVectors uint)

func (*MPSMatrixBatchNormalization) SourceInputFeatureChannels ¶

func (o *MPSMatrixBatchNormalization) SourceInputFeatureChannels() uint

@property sourceInputFeatureChannels @discussion The input size to to use in the operation. This is equivalent to the number of columns in the primary (input array) source matrix to consider and the number of channels to produce for the output matrix. This property is modifiable and defaults to NSUIntegerMax. At encode time the larger of this property or the available input size is used. The value of NSUIntegerMax thus indicates that all available columns in the input array (beginning at sourceMatrixOrigin.y) should be considered. Defines also the number of output feature channels. Note: The value used in the operation will be MIN(inputMatrix.columns - sourceMatrixOrigin.y, sourceInputFeatureChannels)

func (*MPSMatrixBatchNormalization) SourceNumberOfFeatureVectors ¶

func (o *MPSMatrixBatchNormalization) SourceNumberOfFeatureVectors() uint

@property sourceNumberOfFeatureVectors @discussion The number of input vectors which make up the input array. This is equivalent to the number of rows to consider from the primary source matrix. This property is modifiable and defaults to NSUIntegerMax. At encode time the larger of this property or the available number of inputs is used. The value of NSUIntegerMax thus indicates that all available input rows (beginning at sourceMatrixOrigin.x) should be considered.

type MPSMatrixBatchNormalizationGradient ¶

type MPSMatrixBatchNormalizationGradient struct {
	mpsmatrix.MPSMatrixBinaryKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsmatrixbatchnormalizationgradient

func MPSMatrixBatchNormalizationGradientFromID ¶

func MPSMatrixBatchNormalizationGradientFromID(id objc.ID) *MPSMatrixBatchNormalizationGradient

func (*MPSMatrixBatchNormalizationGradient) EncodeToCommandBufferGradientMatrixInputMatrixMeanVectorVarianceVectorGammaVectorBetaVectorResultGradientForDataMatrixResultGradientForGammaVectorResultGradientForBetaVector ¶

func (o *MPSMatrixBatchNormalizationGradient) EncodeToCommandBufferGradientMatrixInputMatrixMeanVectorVarianceVectorGammaVectorBetaVectorResultGradientForDataMatrixResultGradientForGammaVectorResultGradientForBetaVector(commandBuffer metal.MTLCommandBuffer, gradientMatrix *mpscore.MPSMatrix, inputMatrix *mpscore.MPSMatrix, meanVector *mpscore.MPSVector, varianceVector *mpscore.MPSVector, gammaVector *mpscore.MPSVector, betaVector *mpscore.MPSVector, resultGradientForDataMatrix *mpscore.MPSMatrix, resultGradientForGammaVector *mpscore.MPSVector, resultGradientForBetaVector *mpscore.MPSVector)

@abstract Encode a MPSMatrixBatchNormalizationGradient object to a command buffer and compute its gradient with respect to its input data. @param commandBuffer The commandBuffer on which to encode the operation. @param gradientMatrix A matrix whose values represent the gradient of a loss function with respect to the results of a forward MPSMatrixBatchNormalization operation. @param inputMatrix A matrix containing the inputs to a forward MPSMatrixBatchNormalization operation for which the gradient values are to be computed. @param meanVector A vector containing the batch mean values. Should contain either the specified values used to compute the forward result, or the computed values resulting from the forward kernel execution. @param varianceVector A vector containing the batch variance values. Should contain either the specified values used to compute the forward result, or the computed values resulting from the forward kernel execution. @param gammaVector A vector containing the gamma terms. Should be the same values as used when computing the forward result. @param betaVector A vector containing the beta terms. Should be the same values as used when computing the forward result. @param resultGradientForDataMatrix The matrix containing the resulting gradient values. @param resultGradientForGammaVector If non-NULL the vector containing gradients for the gamma terms. @param resultGradientForBetaVector If non-NULL the vector containing gradients for the beta terms.

func (*MPSMatrixBatchNormalizationGradient) Epsilon ¶

@property epsilon @discussion A small term added to the variance when normalizing the input.

func (*MPSMatrixBatchNormalizationGradient) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSMatrixBatchNormalizationGradient @param device The MTLDevice on which to make the MPSMatrixBatchNormalizationGradient object. @return A new MPSMatrixBatchNormalizationGradient object, or nil if failure.

func (*MPSMatrixBatchNormalizationGradient) InitWithDevice ¶

func (*MPSMatrixBatchNormalizationGradient) NeuronParameterA ¶

func (o *MPSMatrixBatchNormalizationGradient) NeuronParameterA() float32

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixBatchNormalizationGradient) NeuronParameterB ¶

func (o *MPSMatrixBatchNormalizationGradient) NeuronParameterB() float32

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixBatchNormalizationGradient) NeuronParameterC ¶

func (o *MPSMatrixBatchNormalizationGradient) NeuronParameterC() float32

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixBatchNormalizationGradient) NeuronType ¶

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixBatchNormalizationGradient) SetEpsilon ¶

func (o *MPSMatrixBatchNormalizationGradient) SetEpsilon(epsilon float32)

func (*MPSMatrixBatchNormalizationGradient) SetNeuronTypeParameterAParameterBParameterC ¶

func (o *MPSMatrixBatchNormalizationGradient) SetNeuronTypeParameterAParameterBParameterC(neuronType MPSCNNNeuronType, parameterA float32, parameterB float32, parameterC float32)

@abstract Specifies a neuron activation function to be used. @discussion This method can be used to add a neuron activation funtion of given type with associated scalar parameters A, 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 MPSMatrixBatchNormalizationGradient kernel is initialized with a default neuron function of MPSCNNNeuronTypeNone. @param neuronType Type of neuron activation function. For full list see MPSCNNNeuronType.h @param parameterA parameterA of neuron activation that is shared across all output values. @param parameterB parameterB of neuron activation that is shared across all output values. @param parameterC parameterC of neuron activation that is shared across all output values.

func (*MPSMatrixBatchNormalizationGradient) SetSourceInputFeatureChannels ¶

func (o *MPSMatrixBatchNormalizationGradient) SetSourceInputFeatureChannels(sourceInputFeatureChannels uint)

func (*MPSMatrixBatchNormalizationGradient) SetSourceNumberOfFeatureVectors ¶

func (o *MPSMatrixBatchNormalizationGradient) SetSourceNumberOfFeatureVectors(sourceNumberOfFeatureVectors uint)

func (*MPSMatrixBatchNormalizationGradient) SourceInputFeatureChannels ¶

func (o *MPSMatrixBatchNormalizationGradient) SourceInputFeatureChannels() uint

@property sourceInputFeatureChannels @discussion The number of feature channels in the input vectors.

func (*MPSMatrixBatchNormalizationGradient) SourceNumberOfFeatureVectors ¶

func (o *MPSMatrixBatchNormalizationGradient) SourceNumberOfFeatureVectors() uint

@property sourceNumberOfFeatureVectors @discussion The number of input vectors which make up the input array.

type MPSMatrixFullyConnected ¶

type MPSMatrixFullyConnected struct {
	mpsmatrix.MPSMatrixBinaryKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsmatrixfullyconnected

func MPSMatrixFullyConnectedFromID ¶

func MPSMatrixFullyConnectedFromID(id objc.ID) *MPSMatrixFullyConnected

func (*MPSMatrixFullyConnected) Alpha ¶

func (o *MPSMatrixFullyConnected) Alpha() float64

@property alpha @discussion The scale factor to apply to the product. Specified in double precision. Will be converted to the appropriate precision in the implementation subject to rounding and/or clamping as necessary. Defaults to 1.0 at initialization time.

func (*MPSMatrixFullyConnected) EncodeToCommandBufferInputMatrixWeightMatrixBiasVectorResultMatrix ¶

func (o *MPSMatrixFullyConnected) EncodeToCommandBufferInputMatrixWeightMatrixBiasVectorResultMatrix(commandBuffer metal.MTLCommandBuffer, inputMatrix *mpscore.MPSMatrix, weightMatrix *mpscore.MPSMatrix, biasVector *mpscore.MPSVector, resultMatrix *mpscore.MPSMatrix)

@abstract Encode a MPSMatrixFullyConnected object to a command buffer. @param commandBuffer A valid MTLCommandBuffer to receive the encoded kernel. @param inputMatrix A valid MPSMatrix object which specifies the input array. @param weightMatrix A valid MPSMatrix object which specifies the weight array. @param biasVector A valid MPSVector object which specifies the bias values, or a null object to indicate that no bias is to be applied. @param resultMatrix A valid MPSMatrix object which specifies the output array. @discussion Encodes the operation to the specified command buffer. resultMatrix must be large enough to hold a MIN(sourceNumberOfInputs, inputMatrix.rows - primarySourceMatrixOrigin.x) x MIN(sourceOutputFeatureChannels, weightMatrix.columns - secondarySourceMatrixOrigin.y) array. The bias vector must contain at least MIN(sourceOutputFeatureChannels, weightMatrix.columns - secondarySourceMatrixOrigin.y) elements.

func (*MPSMatrixFullyConnected) InitWithCoderDevice ¶

func (o *MPSMatrixFullyConnected) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSMatrixFullyConnected

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSMatrixFullyConnected @param device The MTLDevice on which to make the MPSMatrixFullyConnected object. @return A new MPSMatrixFullyConnected object, or nil if failure.

func (*MPSMatrixFullyConnected) InitWithDevice ¶

func (*MPSMatrixFullyConnected) NeuronParameterA ¶

func (o *MPSMatrixFullyConnected) NeuronParameterA() float32

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixFullyConnected) NeuronParameterB ¶

func (o *MPSMatrixFullyConnected) NeuronParameterB() float32

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixFullyConnected) NeuronParameterC ¶

func (o *MPSMatrixFullyConnected) NeuronParameterC() float32

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixFullyConnected) NeuronType ¶

func (o *MPSMatrixFullyConnected) NeuronType() MPSCNNNeuronType

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixFullyConnected) SetAlpha ¶

func (o *MPSMatrixFullyConnected) SetAlpha(alpha float64)

func (*MPSMatrixFullyConnected) SetNeuronTypeParameterAParameterBParameterC ¶

func (o *MPSMatrixFullyConnected) SetNeuronTypeParameterAParameterBParameterC(neuronType MPSCNNNeuronType, parameterA float32, parameterB float32, parameterC float32)

@abstract Specifies a neuron activation function to be used. @discussion This method can be used to add a neuron activation funtion of given type with associated scalar parameters A, 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. For those kind of neuron activation functions, use appropriate setter functions. An MPSMatrixFullyConnected kernel is initialized with a default neuron function of MPSCNNNeuronTypeNone. @param neuronType Type of neuron activation function. For full list see MPSCNNNeuronType.h @param parameterA parameterA of neuron activation that is shared across all output values. @param parameterB parameterB of neuron activation that is shared across all output values. @param parameterC parameterC of neuron activation that is shared across all output values.

func (*MPSMatrixFullyConnected) SetSourceInputFeatureChannels ¶

func (o *MPSMatrixFullyConnected) SetSourceInputFeatureChannels(sourceInputFeatureChannels uint)

func (*MPSMatrixFullyConnected) SetSourceNumberOfFeatureVectors ¶

func (o *MPSMatrixFullyConnected) SetSourceNumberOfFeatureVectors(sourceNumberOfFeatureVectors uint)

func (*MPSMatrixFullyConnected) SetSourceOutputFeatureChannels ¶

func (o *MPSMatrixFullyConnected) SetSourceOutputFeatureChannels(sourceOutputFeatureChannels uint)

func (*MPSMatrixFullyConnected) SourceInputFeatureChannels ¶

func (o *MPSMatrixFullyConnected) SourceInputFeatureChannels() uint

@property sourceInputFeatureChannels @discussion The input size to to use in the operation. This is equivalent to the number of columns and the number of rows in the primary (input array) and secondary (weight array) source matrices respectively. This property is modifiable and defaults to NSUIntegerMax. At encode time the larger of this property or the available input size is used. The value of NSUIntegerMax thus indicates that all available columns in the input array (beginning at primarySourceMatrixOrigin.y) and all available rows in the weight array (beginning at secondarySourceMatrixOrigin.x) should be considered. Note: The value used in the operation will be MIN(MIN(inputMatrix.columns - primarySourceMatrixOrigin.y, weightMatrix.rows - secondarySourceMatrixOrigin.x), sourceInputFeatureChannels)

func (*MPSMatrixFullyConnected) SourceNumberOfFeatureVectors ¶

func (o *MPSMatrixFullyConnected) SourceNumberOfFeatureVectors() uint

@property sourceNumberOfFeatureVectors @discussion The number of input vectors which make up the input array. This is equivalent to the number of rows to consider from the primary source matrix. This property is modifiable and defaults to NSUIntegerMax. At encode time the larger of this property or the available number of inputs is used. The value of NSUIntegerMax thus indicates that all available input rows (beginning at primarySourceMatrixOrigin.x) should be considered.

func (*MPSMatrixFullyConnected) SourceOutputFeatureChannels ¶

func (o *MPSMatrixFullyConnected) SourceOutputFeatureChannels() uint

@property sourceOutputFeatureChannels @discussion The output size to to use in the operation. This is equivalent to the number of columns to consider in the weight array, or the secondary source matrix. This property is modifiable and defaults to NSUIntegerMax. At encode time the larger of this property or the available output size is used. The value of NSUIntegerMax thus indicates that all available columns in the weight array (beginning at secondarySourceMatrixOrigin.y) should be considered.

type MPSMatrixFullyConnectedGradient ¶

type MPSMatrixFullyConnectedGradient struct {
	mpsmatrix.MPSMatrixBinaryKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsmatrixfullyconnectedgradient

func MPSMatrixFullyConnectedGradientFromID ¶

func MPSMatrixFullyConnectedGradientFromID(id objc.ID) *MPSMatrixFullyConnectedGradient

func (*MPSMatrixFullyConnectedGradient) Alpha ¶

@property alpha @discussion Scale factor to apply to the product. This value should be equal to the corresponding value in the forward fully connected kernel.

func (*MPSMatrixFullyConnectedGradient) EncodeGradientForDataToCommandBufferGradientMatrixWeightMatrixResultGradientForDataMatrix ¶

func (o *MPSMatrixFullyConnectedGradient) EncodeGradientForDataToCommandBufferGradientMatrixWeightMatrixResultGradientForDataMatrix(commandBuffer metal.MTLCommandBuffer, gradientMatrix *mpscore.MPSMatrix, weightMatrix *mpscore.MPSMatrix, resultGradientForDataMatrix *mpscore.MPSMatrix)

@abstract Encode a MPSMatrixFullyConnectedGradient object to a command buffer and produce the gradient of the loss function with respect to the input data. @param commandBuffer A valid MTLCommandBuffer to receive the encoded kernel. @param gradientMatrix A valid MPSMatrix object which specifies the input gradient. @param weightMatrix A valid MPSMatrix object which specifies the weight array. @param resultGradientForDataMatrix A valid MPSMatrix object which specifies the result gradient. @discussion This operation computes the resulting gradient of the loss function with respect to the forward kernel's input data. weightMatrix should contain the same values used to compute the result of the forward kernel.

func (*MPSMatrixFullyConnectedGradient) EncodeGradientForWeightsAndBiasToCommandBufferGradientMatrixInputMatrixResultGradientForWeightMatrixResultGradientForBiasVector ¶

func (o *MPSMatrixFullyConnectedGradient) EncodeGradientForWeightsAndBiasToCommandBufferGradientMatrixInputMatrixResultGradientForWeightMatrixResultGradientForBiasVector(commandBuffer metal.MTLCommandBuffer, gradientMatrix *mpscore.MPSMatrix, inputMatrix *mpscore.MPSMatrix, resultGradientForWeightMatrix *mpscore.MPSMatrix, resultGradientForBiasVector *mpscore.MPSVector)

@abstract Encode a MPSMatrixFullyConnectedGradient object to a command buffer and produce the gradient of the loss function with respect to the weight matrix and bias vector. @param commandBuffer A valid MTLCommandBuffer to receive the encoded kernel. @param gradientMatrix A valid MPSMatrix object which specifies the input gradient. @param inputMatrix A valid MPSMatrix object which specifies the input array. @param resultGradientForWeightMatrix A valid MPSMatrix object which specifies the resulting gradients with respect to the weights. @param resultGradientForBiasVector A valid MPSVector object which specifies the resulting gradients with respect to the bias terms. If NULL these values will not be returned. @discussion This operation computes the resulting gradient of the loss function with respect to the forward kernel's weight data. inputMatrix should contain the same values used to compute the result of the forward kernel.

func (*MPSMatrixFullyConnectedGradient) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSMatrixFullyConnectedGradient @param device The MTLDevice on which to make the MPSMatrixFullyConnectedGradient object. @return A new MPSMatrixFullyConnected object, or nil if failure.

func (*MPSMatrixFullyConnectedGradient) InitWithDevice ¶

func (*MPSMatrixFullyConnectedGradient) SetAlpha ¶

func (o *MPSMatrixFullyConnectedGradient) SetAlpha(alpha float64)

func (*MPSMatrixFullyConnectedGradient) SetSourceInputFeatureChannels ¶

func (o *MPSMatrixFullyConnectedGradient) SetSourceInputFeatureChannels(sourceInputFeatureChannels uint)

func (*MPSMatrixFullyConnectedGradient) SetSourceNumberOfFeatureVectors ¶

func (o *MPSMatrixFullyConnectedGradient) SetSourceNumberOfFeatureVectors(sourceNumberOfFeatureVectors uint)

func (*MPSMatrixFullyConnectedGradient) SetSourceOutputFeatureChannels ¶

func (o *MPSMatrixFullyConnectedGradient) SetSourceOutputFeatureChannels(sourceOutputFeatureChannels uint)

func (*MPSMatrixFullyConnectedGradient) SourceInputFeatureChannels ¶

func (o *MPSMatrixFullyConnectedGradient) SourceInputFeatureChannels() uint

@property sourceInputFeatureChannels @discussion The number of feature channels in the input to the forward fully connected layer. This is equivalent to the number of columns in the input matrix. This value should be equal to the corresponding value in the forward fully connected kernel.

func (*MPSMatrixFullyConnectedGradient) SourceNumberOfFeatureVectors ¶

func (o *MPSMatrixFullyConnectedGradient) SourceNumberOfFeatureVectors() uint

@property sourceNumberOfFeatureVectors @discussion The number of input vectors which make up the input array. This is equivalent to the number of rows in both the input matrix and the source gradient matrix. This value should be equal to the corresponding value in the forward fully connected kernel.

func (*MPSMatrixFullyConnectedGradient) SourceOutputFeatureChannels ¶

func (o *MPSMatrixFullyConnectedGradient) SourceOutputFeatureChannels() uint

@property sourceOutputFeatureChannels @discussion The number of feature channels in the output of the forward fully connected layer. This is equivalent to the number of columns in both the weight matrix and the source gradient matrix. This value should be equal to the corresponding value in the forward fully connected kernel.

type MPSMatrixNeuron ¶

type MPSMatrixNeuron struct {
	mpsmatrix.MPSMatrixUnaryKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsmatrixneuron

func MPSMatrixNeuronFromID ¶

func MPSMatrixNeuronFromID(id objc.ID) *MPSMatrixNeuron

func (*MPSMatrixNeuron) Alpha ¶

func (o *MPSMatrixNeuron) Alpha() float64

@property alpha @discussion The scale factor to apply to the input. Specified in double precision. Will be converted to the appropriate precision in the implementation subject to rounding and/or clamping as necessary. Defaults to 1.0 at initialization time.

func (*MPSMatrixNeuron) EncodeToCommandBufferInputMatrixBiasVectorResultMatrix ¶

func (o *MPSMatrixNeuron) EncodeToCommandBufferInputMatrixBiasVectorResultMatrix(commandBuffer metal.MTLCommandBuffer, inputMatrix *mpscore.MPSMatrix, biasVector *mpscore.MPSVector, resultMatrix *mpscore.MPSMatrix)

@abstract Encode a MPSMatrixNeuron object to a command buffer. @param commandBuffer A valid MTLCommandBuffer to receive the encoded kernel. @param inputMatrix A valid MPSMatrix object which specifies the input array. @param biasVector A valid MPSVector object which specifies the bias values, or a null object to indicate that no bias is to be applied. @param resultMatrix A valid MPSMatrix object which specifies the output array. @discussion Encodes the operation to the specified command buffer. resultMatrix must be large enough to hold a MIN(sourceNumberOfFeatureVectors, inputMatrix.rows - sourceMatrixOrigin.x) x MIN(inputMatrix.columns - sourceMatrixOrigin.y, sourceInputFeatureChannels) array. The bias vector must contain at least MIN(inputMatrix.columns - sourceMatrixOrigin.y, sourceInputFeatureChannels) elements.

func (*MPSMatrixNeuron) InitWithCoderDevice ¶

func (o *MPSMatrixNeuron) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSMatrixNeuron

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSMatrixNeuron @param device The MTLDevice on which to make the MPSMatrixNeuron object. @return A new MPSMatrixNeuron object, or nil if failure.

func (*MPSMatrixNeuron) InitWithDevice ¶

func (o *MPSMatrixNeuron) InitWithDevice(device metal.MTLDevice) *MPSMatrixNeuron

func (*MPSMatrixNeuron) NeuronParameterA ¶

func (o *MPSMatrixNeuron) NeuronParameterA() float32

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixNeuron) NeuronParameterB ¶

func (o *MPSMatrixNeuron) NeuronParameterB() float32

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixNeuron) NeuronParameterC ¶

func (o *MPSMatrixNeuron) NeuronParameterC() float32

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixNeuron) NeuronType ¶

func (o *MPSMatrixNeuron) NeuronType() MPSCNNNeuronType

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixNeuron) SetAlpha ¶

func (o *MPSMatrixNeuron) SetAlpha(alpha float64)

func (*MPSMatrixNeuron) SetNeuronToPReLUWithParametersA ¶

func (o *MPSMatrixNeuron) SetNeuronToPReLUWithParametersA(a *foundation.NSData)

@abstract Add per output value neuron parameters A for PReLu neuron activation functions. @discussion This method sets the neuron to PReLU, zeros parameters A and B and sets the per output value neuron parameters A to an array containing a unique value of A for each output value. If the neuron function is f(v,a,b), it will apply resultMatrix(i, j) = f( input(i, j), A[j], B[j] ) where j in [0, sourceInputFeatureChannels] See https://arxiv.org/pdf/1502.01852.pdf for details. All other neuron types, where parameter A and parameter B are shared across output values must be set using -setNeuronType:parameterA:parameterB: @param A An array containing float values for neuron parameter A. Number of entries must be equal to MIN(inputMatrix.columns - sourceMatrixOrigin.y, sourceInputFeatureChannels)

func (*MPSMatrixNeuron) SetNeuronTypeParameterAParameterBParameterC ¶

func (o *MPSMatrixNeuron) SetNeuronTypeParameterAParameterBParameterC(neuronType MPSCNNNeuronType, parameterA float32, parameterB float32, parameterC float32)

@abstract Specifies a neuron activation function to be used. @discussion This method can be used to add a neuron activation funtion of given type with associated scalar parameters A, 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. For those kind of neuron activation functions, use appropriate setter functions. An MPSMatrixNeuron kernel is initialized with a default neuron function of MPSCNNNeuronTypeNone. @param neuronType Type of neuron activation function. For full list see MPSCNNNeuronType.h @param parameterA parameterA of neuron activation that is shared across all output values. @param parameterB parameterB of neuron activation that is shared across all output values. @param parameterC parameterC of neuron activation that is shared across all output values.

func (*MPSMatrixNeuron) SetSourceInputFeatureChannels ¶

func (o *MPSMatrixNeuron) SetSourceInputFeatureChannels(sourceInputFeatureChannels uint)

func (*MPSMatrixNeuron) SetSourceNumberOfFeatureVectors ¶

func (o *MPSMatrixNeuron) SetSourceNumberOfFeatureVectors(sourceNumberOfFeatureVectors uint)

func (*MPSMatrixNeuron) SourceInputFeatureChannels ¶

func (o *MPSMatrixNeuron) SourceInputFeatureChannels() uint

@property sourceInputFeatureChannels @discussion The input size to to use in the operation. This is equivalent to the number of columns in the primary (input array) source matrix to consider and the number of channels to produce for the output matrix. This property is modifiable and defaults to NSUIntegerMax. At encode time the larger of this property or the available input size is used. The value of NSUIntegerMax thus indicates that all available columns in the input array (beginning at sourceMatrixOrigin.y) should be considered. Defines also the number of output feature channels. Note: The value used in the operation will be MIN(inputMatrix.columns - sourceMatrixOrigin.y, sourceInputFeatureChannels)

func (*MPSMatrixNeuron) SourceNumberOfFeatureVectors ¶

func (o *MPSMatrixNeuron) SourceNumberOfFeatureVectors() uint

@property sourceNumberOfFeatureVectors @discussion The number of input vectors which make up the input array. This is equivalent to the number of rows to consider from the primary source matrix. This property is modifiable and defaults to NSUIntegerMax. At encode time the larger of this property or the available number of inputs is used. The value of NSUIntegerMax thus indicates that all available input rows (beginning at sourceMatrixOrigin.x) should be considered.

type MPSMatrixNeuronGradient ¶

type MPSMatrixNeuronGradient struct {
	mpsmatrix.MPSMatrixBinaryKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsmatrixneurongradient

func MPSMatrixNeuronGradientFromID ¶

func MPSMatrixNeuronGradientFromID(id objc.ID) *MPSMatrixNeuronGradient

func (*MPSMatrixNeuronGradient) Alpha ¶

func (o *MPSMatrixNeuronGradient) Alpha() float64

@property alpha @discussion The scale factor to apply to the input.

func (*MPSMatrixNeuronGradient) EncodeToCommandBufferGradientMatrixInputMatrixBiasVectorResultGradientForDataMatrixResultGradientForBiasVector ¶

func (o *MPSMatrixNeuronGradient) EncodeToCommandBufferGradientMatrixInputMatrixBiasVectorResultGradientForDataMatrixResultGradientForBiasVector(commandBuffer metal.MTLCommandBuffer, gradientMatrix *mpscore.MPSMatrix, inputMatrix *mpscore.MPSMatrix, biasVector *mpscore.MPSVector, resultGradientForDataMatrix *mpscore.MPSMatrix, resultGradientForBiasVector *mpscore.MPSVector)

@abstract Encode a MPSMatrixNeuronGradient object to a command buffer and compute its gradient with respect to its input data. @param commandBuffer The commandBuffer on which to encode the operation. @param gradientMatrix A matrix whose values represent the gradient of a loss function with respect to the results of a forward MPSMatrixNeuron operation. @param inputMatrix A matrix containing the inputs to a forward MPSMatrixNeuron operation for which the gradient values are to be computed. @param biasVector A vector containing the bias terms. @param resultGradientForDataMatrix The matrix containing the resulting gradient values. @param resultGradientForBiasVector If non-NULL the vector containing gradients for the bias terms.

func (*MPSMatrixNeuronGradient) InitWithCoderDevice ¶

func (o *MPSMatrixNeuronGradient) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSMatrixNeuronGradient

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSMatrixNeuronGradient @param device The MTLDevice on which to make the MPSMatrixNeuronGradient object. @return A new MPSMatrixNeuronGradient object, or nil if failure.

func (*MPSMatrixNeuronGradient) InitWithDevice ¶

func (*MPSMatrixNeuronGradient) NeuronParameterA ¶

func (o *MPSMatrixNeuronGradient) NeuronParameterA() float32

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixNeuronGradient) NeuronParameterB ¶

func (o *MPSMatrixNeuronGradient) NeuronParameterB() float32

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixNeuronGradient) NeuronParameterC ¶

func (o *MPSMatrixNeuronGradient) NeuronParameterC() float32

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixNeuronGradient) NeuronType ¶

func (o *MPSMatrixNeuronGradient) NeuronType() MPSCNNNeuronType

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixNeuronGradient) SetAlpha ¶

func (o *MPSMatrixNeuronGradient) SetAlpha(alpha float64)

func (*MPSMatrixNeuronGradient) SetNeuronToPReLUWithParametersA ¶

func (o *MPSMatrixNeuronGradient) SetNeuronToPReLUWithParametersA(a *foundation.NSData)

@abstract Add per output value neuron parameters A for PReLu neuron activation functions. @discussion This method sets the neuron to PReLU, zeros parameters A and B and sets the per output value neuron parameters A to an array containing a unique value of A for each output value. If the neuron function is f(v,a,b), it will apply resultMatrix(i, j) = f( input(i, j), A[j], B[j] ) where j in [0, sourceInputFeatureChannels] See https://arxiv.org/pdf/1502.01852.pdf for details. All other neuron types, where parameter A and parameter B are shared across output values must be set using -setNeuronType:parameterA:parameterB: @param A An array containing float values for neuron parameter A. Number of entries must be equal to MIN(inputMatrix.columns - sourceMatrixOrigin.y, sourceInputFeatureChannels)

func (*MPSMatrixNeuronGradient) SetNeuronTypeParameterAParameterBParameterC ¶

func (o *MPSMatrixNeuronGradient) SetNeuronTypeParameterAParameterBParameterC(neuronType MPSCNNNeuronType, parameterA float32, parameterB float32, parameterC float32)

@abstract Specifies a neuron activation function to be used. @discussion This method can be used to add a neuron activation funtion of given type with associated scalar parameters A, 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. For those kind of neuron activation functions, use appropriate setter functions. An MPSMatrixNeuron kernel is initialized with a default neuron function of MPSCNNNeuronTypeNone. @param neuronType Type of neuron activation function. For full list see MPSCNNNeuronType.h @param parameterA parameterA of neuron activation that is shared across all output values. @param parameterB parameterB of neuron activation that is shared across all output values. @param parameterC parameterC of neuron activation that is shared across all output values.

func (*MPSMatrixNeuronGradient) SetSourceInputFeatureChannels ¶

func (o *MPSMatrixNeuronGradient) SetSourceInputFeatureChannels(sourceInputFeatureChannels uint)

func (*MPSMatrixNeuronGradient) SetSourceNumberOfFeatureVectors ¶

func (o *MPSMatrixNeuronGradient) SetSourceNumberOfFeatureVectors(sourceNumberOfFeatureVectors uint)

func (*MPSMatrixNeuronGradient) SourceInputFeatureChannels ¶

func (o *MPSMatrixNeuronGradient) SourceInputFeatureChannels() uint

@property sourceInputFeatureChannels @discussion The number of feature channels in the input vectors.

func (*MPSMatrixNeuronGradient) SourceNumberOfFeatureVectors ¶

func (o *MPSMatrixNeuronGradient) SourceNumberOfFeatureVectors() uint

@property sourceNumberOfFeatureVectors @discussion The number of input vectors which make up the input array.

type MPSMatrixSum ¶

type MPSMatrixSum struct {
	mpscore.MPSKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsmatrixsum

func MPSMatrixSumFromID ¶

func MPSMatrixSumFromID(id objc.ID) *MPSMatrixSum

func (*MPSMatrixSum) Columns ¶

func (o *MPSMatrixSum) Columns() uint

@abstract The number of columns to sum.

func (*MPSMatrixSum) Count ¶

func (o *MPSMatrixSum) Count() uint

@abstract The number of matrices to sum.

func (*MPSMatrixSum) EncodeToCommandBufferSourceMatricesResultMatrixScaleVectorOffsetVectorBiasVectorStartIndex ¶

func (o *MPSMatrixSum) EncodeToCommandBufferSourceMatricesResultMatrixScaleVectorOffsetVectorBiasVectorStartIndex(buffer metal.MTLCommandBuffer, sourceMatrices *foundation.NSArray[*mpscore.MPSMatrix], resultMatrix *mpscore.MPSMatrix, scaleVector *mpscore.MPSVector, offsetVector *mpscore.MPSVector, biasVector *mpscore.MPSVector, startIndex uint)

@abstract Encode the operations to the command buffer @param buffer The command buffer in which to encode the operation. @param sourceMatrices A list of matrices from which the matrix data is read. @param resultMatrix The result matrix. @param scaleVector A MPSVector of type MPSDataTypeFloat32 containing the list of scale factors, specified in single precision. @param offsetVector A MPSVector of type MPSDataTypeUInt32 containing the list of offsets, stored as a packed array of MPSMatrixOffset values. @param biasVector A MPSVector containing the bias terms to add to the result prior to applying the neuron function, if any. May be nil. @param startIndex The starting index into the scale and offset vectors.

func (*MPSMatrixSum) InitWithCoderDevice ¶

func (o *MPSMatrixSum) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSMatrixSum

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSMatrixSum kernel. @param device The MTLDevice on which to make the MPSMatrixSum object. @return A new MPSMatrixSum object, or nil if failure.

func (*MPSMatrixSum) InitWithDeviceCountRowsColumnsTranspose ¶

func (o *MPSMatrixSum) InitWithDeviceCountRowsColumnsTranspose(device metal.MTLDevice, count uint, rows uint, columns uint, transpose bool) *MPSMatrixSum

@abstract Initialize a MPSMatrixSum kernel. @param device The device on which to initialize the kernel. @param count The number of matrices to be summed. @param rows The number of rows to use in the input matrices. @param columns The number of columns to use in the input matrices. @param transpose If YES the result of the summation is to be transposed prior to applying the bias and activation.

func (*MPSMatrixSum) NeuronParameterA ¶

func (o *MPSMatrixSum) NeuronParameterA() float32

@abstract Neuron parameter A.

func (*MPSMatrixSum) NeuronParameterB ¶

func (o *MPSMatrixSum) NeuronParameterB() float32

@abstract Neuron parameter B.

func (*MPSMatrixSum) NeuronParameterC ¶

func (o *MPSMatrixSum) NeuronParameterC() float32

@abstract Neuron parameter C.

func (*MPSMatrixSum) NeuronType ¶

func (o *MPSMatrixSum) NeuronType() MPSCNNNeuronType

@abstract Getter funtion for neuronType set using setNeuronType:parameterA:parameterB:parameterC method

func (*MPSMatrixSum) ResultMatrixOrigin ¶

func (o *MPSMatrixSum) ResultMatrixOrigin() metal.MTLOrigin

@property resultMatrixOrigin @discussion The origin, relative to [0, 0] in the result matrix, at which to start writing results. This property is modifiable and defaults to [0, 0] at initialization time. If a different origin is desired then this should be modified prior to encoding the kernel.

func (*MPSMatrixSum) Rows ¶

func (o *MPSMatrixSum) Rows() uint

@abstract The number of rows to sum.

func (*MPSMatrixSum) SetNeuronTypeParameterAParameterBParameterC ¶

func (o *MPSMatrixSum) SetNeuronTypeParameterAParameterBParameterC(neuronType MPSCNNNeuronType, parameterA float32, parameterB float32, parameterC float32)

@abstract Specifies a neuron activation function to be used. @discussion This method can be used to add a neuron activation funtion of given type with associated scalar parameters A, 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 MPSMatrixSum kernel is initialized with a default neuron function of MPSCNNNeuronTypeNone. @param neuronType Type of neuron activation function. For full list see MPSCNNNeuronType.h @param parameterA parameterA of neuron activation that is shared across all output values. @param parameterB parameterB of neuron activation that is shared across all output values. @param parameterC parameterC of neuron activation that is shared across all output values.

func (*MPSMatrixSum) SetResultMatrixOrigin ¶

func (o *MPSMatrixSum) SetResultMatrixOrigin(resultMatrixOrigin metal.MTLOrigin)

func (*MPSMatrixSum) Transpose ¶

func (o *MPSMatrixSum) Transpose() bool

@abstract The transposition used to initialize the kernel.

type MPSNNAdditionGradientNode ¶

type MPSNNAdditionGradientNode struct {
	MPSNNArithmeticGradientNode
}

@abstract returns gradient for either primary or secondary source image from the inference pass. Use the isSecondarySourceFilter property to indicate whether this filter is computing the gradient for the primary or secondary source image from the inference pass.

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnadditiongradientnode

func MPSNNAdditionGradientNodeFromID ¶

func MPSNNAdditionGradientNodeFromID(id objc.ID) *MPSNNAdditionGradientNode

type MPSNNAdditionNode ¶

type MPSNNAdditionNode struct {
	MPSNNBinaryArithmeticNode
}

@abstract returns elementwise sum of left + right

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnadditionnode

func MPSNNAdditionNodeFromID ¶

func MPSNNAdditionNodeFromID(id objc.ID) *MPSNNAdditionNode

type MPSNNArithmeticGradientNode ¶

type MPSNNArithmeticGradientNode struct {
	MPSNNGradientFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnarithmeticgradientnode

func MPSNNArithmeticGradientNodeFromID ¶

func MPSNNArithmeticGradientNodeFromID(id objc.ID) *MPSNNArithmeticGradientNode

func MPSNNArithmeticGradientNodeNodeWithSourceGradientSourceImageGradientStateIsSecondarySourceFilter ¶

func MPSNNArithmeticGradientNodeNodeWithSourceGradientSourceImageGradientStateIsSecondarySourceFilter(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNBinaryGradientStateNode, isSecondarySourceFilter bool) *MPSNNArithmeticGradientNode

@abstract create a new arithmetic gradient node @discussion See also -[MPSCNNNeuronNode gradientFilterNodesWithSources:] for an easier way to do this. @param sourceGradient The input gradient from the 'downstream' gradient filter. @param sourceImage The source input image from the forward pass (primary or secondary). @param gradientState The gradient state produced by the concatenation filter, consumed by this filter.

func (*MPSNNArithmeticGradientNode) Bias ¶

func (*MPSNNArithmeticGradientNode) InitWithGradientImagesForwardFilterIsSecondarySourceFilter ¶

func (o *MPSNNArithmeticGradientNode) InitWithGradientImagesForwardFilterIsSecondarySourceFilter(gradientImages *foundation.NSArray[*MPSNNImageNode], filter *MPSNNFilterNode, isSecondarySourceFilter bool) *MPSNNArithmeticGradientNode

@abstract create a new arithmetic gradient node @discussion See also -[MPSCNNNeuronNode gradientFilterNodesWithSources:] for an easier way to do this. @param gradientImages The input gradient from the 'downstream' gradient filter and the source input image from the forward pass (primary or secondary). @param filter The matching filter node from the forward pass. @param isSecondarySourceFilter The isSecondarySourceFilter property is used to indicate whether the arithmetic gradient filter is operating on the primary or secondary source image from the forward pass.

func (*MPSNNArithmeticGradientNode) InitWithSourceGradientSourceImageGradientStateIsSecondarySourceFilter ¶

func (o *MPSNNArithmeticGradientNode) InitWithSourceGradientSourceImageGradientStateIsSecondarySourceFilter(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNBinaryGradientStateNode, isSecondarySourceFilter bool) *MPSNNArithmeticGradientNode

@abstract create a new arithmetic gradient node @discussion See also -[MPSCNNNeuronNode gradientFilterNodesWithSources:] for an easier way to do this. @param sourceGradient The input gradient from the 'downstream' gradient filter. @param sourceImage The source input image from the forward pass (primary or secondary). @param gradientState The gradient state produced by the concatenation filter, consumed by this filter.

func (*MPSNNArithmeticGradientNode) IsSecondarySourceFilter ¶

func (o *MPSNNArithmeticGradientNode) IsSecondarySourceFilter() bool

func (*MPSNNArithmeticGradientNode) MaximumValue ¶

func (o *MPSNNArithmeticGradientNode) MaximumValue() float32

func (*MPSNNArithmeticGradientNode) MinimumValue ¶

func (o *MPSNNArithmeticGradientNode) MinimumValue() float32

func (*MPSNNArithmeticGradientNode) PrimaryScale ¶

func (o *MPSNNArithmeticGradientNode) PrimaryScale() float32

func (*MPSNNArithmeticGradientNode) SecondaryScale ¶

func (o *MPSNNArithmeticGradientNode) SecondaryScale() float32

func (*MPSNNArithmeticGradientNode) SecondaryStrideInFeatureChannels ¶

func (o *MPSNNArithmeticGradientNode) SecondaryStrideInFeatureChannels() uint

func (*MPSNNArithmeticGradientNode) SecondaryStrideInPixelsX ¶

func (o *MPSNNArithmeticGradientNode) SecondaryStrideInPixelsX() uint

func (*MPSNNArithmeticGradientNode) SecondaryStrideInPixelsY ¶

func (o *MPSNNArithmeticGradientNode) SecondaryStrideInPixelsY() uint

func (*MPSNNArithmeticGradientNode) SetBias ¶

func (o *MPSNNArithmeticGradientNode) SetBias(bias float32)

func (*MPSNNArithmeticGradientNode) SetMaximumValue ¶

func (o *MPSNNArithmeticGradientNode) SetMaximumValue(maximumValue float32)

func (*MPSNNArithmeticGradientNode) SetMinimumValue ¶

func (o *MPSNNArithmeticGradientNode) SetMinimumValue(minimumValue float32)

func (*MPSNNArithmeticGradientNode) SetPrimaryScale ¶

func (o *MPSNNArithmeticGradientNode) SetPrimaryScale(primaryScale float32)

func (*MPSNNArithmeticGradientNode) SetSecondaryScale ¶

func (o *MPSNNArithmeticGradientNode) SetSecondaryScale(secondaryScale float32)

func (*MPSNNArithmeticGradientNode) SetSecondaryStrideInFeatureChannels ¶

func (o *MPSNNArithmeticGradientNode) SetSecondaryStrideInFeatureChannels(secondaryStrideInFeatureChannels uint)

func (*MPSNNArithmeticGradientNode) SetSecondaryStrideInPixelsX ¶

func (o *MPSNNArithmeticGradientNode) SetSecondaryStrideInPixelsX(secondaryStrideInPixelsX uint)

func (*MPSNNArithmeticGradientNode) SetSecondaryStrideInPixelsY ¶

func (o *MPSNNArithmeticGradientNode) SetSecondaryStrideInPixelsY(secondaryStrideInPixelsY uint)

type MPSNNBinaryArithmeticNode ¶

type MPSNNBinaryArithmeticNode struct {
	MPSNNFilterNode
}

@abstract virtual base class for basic arithmetic nodes

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnbinaryarithmeticnode

func MPSNNBinaryArithmeticNodeFromID ¶

func MPSNNBinaryArithmeticNodeFromID(id objc.ID) *MPSNNBinaryArithmeticNode

func MPSNNBinaryArithmeticNodeNodeWithLeftSourceRightSource ¶

func MPSNNBinaryArithmeticNodeNodeWithLeftSourceRightSource(left *MPSNNImageNode, right *MPSNNImageNode) *MPSNNBinaryArithmeticNode

@abstract create an autoreleased arithemtic node with two sources @param left the left operand @param right the right operand

func MPSNNBinaryArithmeticNodeNodeWithSources ¶

func MPSNNBinaryArithmeticNodeNodeWithSources(sourceNodes *foundation.NSArray[*MPSNNImageNode]) *MPSNNBinaryArithmeticNode

@abstract create an autoreleased arithemtic node with an array of sources @param sourceNodes A valid NSArray containing two sources

func (*MPSNNBinaryArithmeticNode) Bias ¶

func (*MPSNNBinaryArithmeticNode) GradientClass ¶

func (o *MPSNNBinaryArithmeticNode) GradientClass() objc.Class

func (*MPSNNBinaryArithmeticNode) InitWithLeftSourceRightSource ¶

func (o *MPSNNBinaryArithmeticNode) InitWithLeftSourceRightSource(left *MPSNNImageNode, right *MPSNNImageNode) *MPSNNBinaryArithmeticNode

@abstract init an arithemtic node with two sources @param left the left operand @param right the right operand

func (*MPSNNBinaryArithmeticNode) InitWithSources ¶

@abstract init an arithemtic node with an array of sources @param sourceNodes A valid NSArray containing two sources

func (*MPSNNBinaryArithmeticNode) MaximumValue ¶

func (o *MPSNNBinaryArithmeticNode) MaximumValue() float32

func (*MPSNNBinaryArithmeticNode) MinimumValue ¶

func (o *MPSNNBinaryArithmeticNode) MinimumValue() float32

func (*MPSNNBinaryArithmeticNode) PrimaryScale ¶

func (o *MPSNNBinaryArithmeticNode) PrimaryScale() float32

func (*MPSNNBinaryArithmeticNode) PrimaryStrideInFeatureChannels ¶

func (o *MPSNNBinaryArithmeticNode) PrimaryStrideInFeatureChannels() uint

func (*MPSNNBinaryArithmeticNode) PrimaryStrideInPixelsX ¶

func (o *MPSNNBinaryArithmeticNode) PrimaryStrideInPixelsX() uint

func (*MPSNNBinaryArithmeticNode) PrimaryStrideInPixelsY ¶

func (o *MPSNNBinaryArithmeticNode) PrimaryStrideInPixelsY() uint

func (*MPSNNBinaryArithmeticNode) SecondaryScale ¶

func (o *MPSNNBinaryArithmeticNode) SecondaryScale() float32

func (*MPSNNBinaryArithmeticNode) SecondaryStrideInFeatureChannels ¶

func (o *MPSNNBinaryArithmeticNode) SecondaryStrideInFeatureChannels() uint

func (*MPSNNBinaryArithmeticNode) SecondaryStrideInPixelsX ¶

func (o *MPSNNBinaryArithmeticNode) SecondaryStrideInPixelsX() uint

func (*MPSNNBinaryArithmeticNode) SecondaryStrideInPixelsY ¶

func (o *MPSNNBinaryArithmeticNode) SecondaryStrideInPixelsY() uint

func (*MPSNNBinaryArithmeticNode) SetBias ¶

func (o *MPSNNBinaryArithmeticNode) SetBias(bias float32)

func (*MPSNNBinaryArithmeticNode) SetMaximumValue ¶

func (o *MPSNNBinaryArithmeticNode) SetMaximumValue(maximumValue float32)

func (*MPSNNBinaryArithmeticNode) SetMinimumValue ¶

func (o *MPSNNBinaryArithmeticNode) SetMinimumValue(minimumValue float32)

func (*MPSNNBinaryArithmeticNode) SetPrimaryScale ¶

func (o *MPSNNBinaryArithmeticNode) SetPrimaryScale(primaryScale float32)

func (*MPSNNBinaryArithmeticNode) SetPrimaryStrideInFeatureChannels ¶

func (o *MPSNNBinaryArithmeticNode) SetPrimaryStrideInFeatureChannels(primaryStrideInFeatureChannels uint)

func (*MPSNNBinaryArithmeticNode) SetPrimaryStrideInPixelsX ¶

func (o *MPSNNBinaryArithmeticNode) SetPrimaryStrideInPixelsX(primaryStrideInPixelsX uint)

func (*MPSNNBinaryArithmeticNode) SetPrimaryStrideInPixelsY ¶

func (o *MPSNNBinaryArithmeticNode) SetPrimaryStrideInPixelsY(primaryStrideInPixelsY uint)

func (*MPSNNBinaryArithmeticNode) SetSecondaryScale ¶

func (o *MPSNNBinaryArithmeticNode) SetSecondaryScale(secondaryScale float32)

func (*MPSNNBinaryArithmeticNode) SetSecondaryStrideInFeatureChannels ¶

func (o *MPSNNBinaryArithmeticNode) SetSecondaryStrideInFeatureChannels(secondaryStrideInFeatureChannels uint)

func (*MPSNNBinaryArithmeticNode) SetSecondaryStrideInPixelsX ¶

func (o *MPSNNBinaryArithmeticNode) SetSecondaryStrideInPixelsX(secondaryStrideInPixelsX uint)

func (*MPSNNBinaryArithmeticNode) SetSecondaryStrideInPixelsY ¶

func (o *MPSNNBinaryArithmeticNode) SetSecondaryStrideInPixelsY(secondaryStrideInPixelsY uint)

type MPSNNCompare ¶

type MPSNNCompare struct {
	MPSCNNArithmetic
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnncompare

func MPSNNCompareFromID ¶

func MPSNNCompareFromID(id objc.ID) *MPSNNCompare

func (*MPSNNCompare) ComparisonType ¶

func (o *MPSNNCompare) ComparisonType() MPSNNComparisonType

@property comparisonType @abstract The comparison type to use

func (*MPSNNCompare) InitWithDevice ¶

func (o *MPSNNCompare) InitWithDevice(device metal.MTLDevice) *MPSNNCompare

@abstract Initialize the comparison operator @param device The device the filter will run on. @return A valid MPSNNCompare object or nil, if failure.

func (*MPSNNCompare) SetComparisonType ¶

func (o *MPSNNCompare) SetComparisonType(comparisonType MPSNNComparisonType)

func (*MPSNNCompare) SetThreshold ¶

func (o *MPSNNCompare) SetThreshold(threshold float32)

func (*MPSNNCompare) Threshold ¶

func (o *MPSNNCompare) Threshold() float32

@property threshold @abstract The threshold to use when comparing for equality. Two values will be considered to be equal if the absolute value of their difference is less than, or equal, to the specified threshold: result = |b - a| <= threshold

type MPSNNComparisonNode ¶

type MPSNNComparisonNode struct {
	MPSNNBinaryArithmeticNode
}

@abstract returns elementwise comparison of left and right

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnncomparisonnode

func MPSNNComparisonNodeFromID ¶

func MPSNNComparisonNodeFromID(id objc.ID) *MPSNNComparisonNode

func (*MPSNNComparisonNode) ComparisonType ¶

func (o *MPSNNComparisonNode) ComparisonType() MPSNNComparisonType

@property comparisonType @abstract The comparison type to set on the underlying kernel. Defaults to MPSNNComparisonTypeEqual.

func (*MPSNNComparisonNode) SetComparisonType ¶

func (o *MPSNNComparisonNode) SetComparisonType(comparisonType MPSNNComparisonType)

type MPSNNComparisonType ¶

type MPSNNComparisonType uint64
const (
	MPSNNComparisonTypeEqual          MPSNNComparisonType = 0
	MPSNNComparisonTypeNotEqual       MPSNNComparisonType = 1
	MPSNNComparisonTypeLess           MPSNNComparisonType = 2
	MPSNNComparisonTypeLessOrEqual    MPSNNComparisonType = 3
	MPSNNComparisonTypeGreater        MPSNNComparisonType = 4
	MPSNNComparisonTypeGreaterOrEqual MPSNNComparisonType = 5
)

func (MPSNNComparisonType) String ¶

func (e MPSNNComparisonType) String() string

type MPSNNConcatenationGradientNode ¶

type MPSNNConcatenationGradientNode struct {
	MPSNNGradientFilterNode
}

@class MPSNNConcatenationGradientNode @abstract A MPSNNSlice filter that operates as the conjugate computation for concatentation operators during training @discussion As concatenation is formally just a copy and not a computation, there isn't a lot of arithmetic for the slice operator to do, but we still need to extract out the relevant portion of the gradient of the input signal that went into the corresponding concatenation destination image.

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnconcatenationgradientnode

func MPSNNConcatenationGradientNodeFromID ¶

func MPSNNConcatenationGradientNodeFromID(id objc.ID) *MPSNNConcatenationGradientNode

func MPSNNConcatenationGradientNodeNodeWithSourceGradientSourceImageGradientState ¶

func MPSNNConcatenationGradientNodeNodeWithSourceGradientSourceImageGradientState(gradientSourceNode *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSNNConcatenationGradientNode

@abstract create a MPSNNConcatenationGradientNode @discussion Generally you should use [MPSNNConcatenationNode gradientFiltersWithSources:] instead. @param gradientSourceNode The gradient image functioning as input for the operator @param sourceImage The particular input image to the concatentation, if any, that the slice corresponds with @param gradientState The gradient state produced by the concatenation filter, consumed by this filter

func (*MPSNNConcatenationGradientNode) InitWithSourceGradientSourceImageGradientState ¶

func (o *MPSNNConcatenationGradientNode) InitWithSourceGradientSourceImageGradientState(gradientSourceNode *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSNNConcatenationGradientNode

@abstract Init a MPSNNConcatenationGradientNode @discussion Generally you should use [MPSNNConcatenationNode gradientFiltersWithSources:] instead. @param gradientSourceNode The gradient image functioning as input for the operator @param sourceImage The particular input image to the concatentation, if any, that the slice corresponds with @param gradientState The gradient state produced by the concatenation filter, consumed by this filter

type MPSNNConcatenationNode ¶

type MPSNNConcatenationNode struct {
	MPSNNFilterNode
}

Node representing a the concatenation (in the feature channel dimension) of the results from one or more kernels

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnconcatenationnode

func MPSNNConcatenationNodeFromID ¶

func MPSNNConcatenationNodeFromID(id objc.ID) *MPSNNConcatenationNode

func MPSNNConcatenationNodeNodeWithSources ¶

func MPSNNConcatenationNodeNodeWithSources(sourceNodes *foundation.NSArray[*MPSNNImageNode]) *MPSNNConcatenationNode

@abstract Init a autoreleased node that concatenates feature channels from multiple images @discussion In some neural network designs, it is necessary to append feature channels from one neural network filter to the results of another. If we have three image nodes with M, N and O feature channels in them, passed to -initWithSources: as @[imageM, imageN, imageO], then feature channels [0,M-1] will be drawn from image M, feature channels [M, M+N-1] will be drawn from image N and feature channels [M+N, M+N+O-1] will be drawn from image O. As all images are padded out to a multiple of four feature channels, M, N and O here are also multiples of four, even when the MPSImages are not. That is, if the image is 23 feature channels and one channel of padding, it takes up 24 feature channels worth of space in the concatenated result. Performance Note: Generally, concatenation is free as long as all of the sourceNodes are produced by filters in the same MPSNNGraph. Most MPSCNNKernels have the ability to write their results at a feature channel offset within a target MPSImage. However, if the MPSNNImageNode source nodes come from images external to the MPSNNGraph, then we have to do a copy operation to assemble the concatenated node. As a result, when deciding where to break a large logical graph into multiple smaller MPSNNGraphs, it is better for concatenations to appear at the ends of subgraphs when possible rather than at the start, to the extent that all the images used in the concatenation are produced by that subgraph. @param sourceNodes The MPSNNImageNode representing the source MPSImages for the filter @return A new MPSNNFilter node that concatenates its inputs.

func (*MPSNNConcatenationNode) InitWithSources ¶

@abstract Init a node that concatenates feature channels from multiple images @discussion In some neural network designs, it is necessary to append feature channels from one neural network filter to the results of another. If we have three image nodes with M, N and O feature channels in them, passed to -initWithSources: as @[imageM, imageN, imageO], then feature channels [0,M-1] will be drawn from image M, feature channels [M, M+N-1] will be drawn from image N and feature channels [M+N, M+N+O-1] will be drawn from image O. As all images are padded out to a multiple of four feature channels, M, N and O here are also multiples of four, even when the MPSImages are not. That is, if the image is 23 feature channels and one channel of padding, it takes up 24 feature channels worth of space in the concatenated result. Performance Note: Generally, concatenation is free as long as all of the sourceNodes are produced by filters in the same MPSNNGraph. Most MPSCNNKernels have the ability to write their results at a feature channel offset within a target MPSImage. However, if the MPSNNImageNode source nodes come from images external to the MPSNNGraph, then we have to do a copy operation to assemble the concatenated node. As a result, when deciding where to break a large logical graph into multiple smaller MPSNNGraphs, it is better for concatenations to appear at the ends of subgraphs when possible rather than at the start, to the extent that all the images used in the concatenation are produced by that subgraph. @param sourceNodes The MPSNNImageNode representing the source MPSImages for the filter @return A new MPSNNFilter node that concatenates its inputs.

type MPSNNConvolutionAccumulatorPrecisionOption ¶

type MPSNNConvolutionAccumulatorPrecisionOption uint64
const (
	// Set accumulator type to half precision float.
	MPSNNConvolutionAccumulatorPrecisionOptionHalf MPSNNConvolutionAccumulatorPrecisionOption = 0
	// Set accumulator type to single precision float.
	MPSNNConvolutionAccumulatorPrecisionOptionFloat MPSNNConvolutionAccumulatorPrecisionOption = 1
)

func (MPSNNConvolutionAccumulatorPrecisionOption) String ¶

type MPSNNCropAndResizeBilinear ¶

type MPSNNCropAndResizeBilinear struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnncropandresizebilinear

func MPSNNCropAndResizeBilinearFromID ¶

func MPSNNCropAndResizeBilinearFromID(id objc.ID) *MPSNNCropAndResizeBilinear

func (*MPSNNCropAndResizeBilinear) InitWithCoderDevice ¶

func (o *MPSNNCropAndResizeBilinear) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNCropAndResizeBilinear

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSNNCropAndResizeBilinear @param device The MTLDevice on which to make the MPSNNCropAndResizeBilinear @return A new MPSNNResizeBilinear object, or nil if failure.

func (*MPSNNCropAndResizeBilinear) InitWithDeviceResizeWidthResizeHeightNumberOfRegionsRegions ¶

func (o *MPSNNCropAndResizeBilinear) InitWithDeviceResizeWidthResizeHeightNumberOfRegionsRegions(device metal.MTLDevice, resizeWidth uint, resizeHeight uint, numberOfRegions uint, regions *mpscore.MPSRegion) *MPSNNCropAndResizeBilinear

@abstract Initialize the crop and resize bilinear filter. @param device The device the filter will run on. @param resizeWidth The destination resize width in pixels @param resizeHeight The destination resize height in pixels @param numberOfRegions Specifies the number of bounding box i.e. regions to resize @param regions This is a pointer to "numberOfRegions" boxes which specify the locations in the source image to use for each box/region to perform the resize operation. @return A valid MPSNNCropAndResizeBilinear object or nil, if failure.

func (*MPSNNCropAndResizeBilinear) NumberOfRegions ¶

func (o *MPSNNCropAndResizeBilinear) NumberOfRegions() uint

@property numberOfRegions @abstract the number of bounding box i.e. regions to resize.

func (*MPSNNCropAndResizeBilinear) Regions ¶

@property regions @abstract This is a pointer to "numberOfRegions" boxes which specify the locations in the source image to use for each box/region to perform the resize operation. The coordinates specified are normalized values. A normalized region outside the [0, 1] range is allowed, in which case we use extrapolation_value to extrapolate the input image values.

func (*MPSNNCropAndResizeBilinear) ResizeHeight ¶

func (o *MPSNNCropAndResizeBilinear) ResizeHeight() uint

@property resizeHeight @abstract The resize height.

func (*MPSNNCropAndResizeBilinear) ResizeWidth ¶

func (o *MPSNNCropAndResizeBilinear) ResizeWidth() uint

@property resizeWidth @abstract The resize width.

type MPSNNDefaultPadding ¶

type MPSNNDefaultPadding struct {
	foundation.NSObject
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnndefaultpadding

func MPSNNDefaultPaddingFromID ¶

func MPSNNDefaultPaddingFromID(id objc.ID) *MPSNNDefaultPadding

func MPSNNDefaultPaddingPaddingForTensorflowAveragePooling ¶

func MPSNNDefaultPaddingPaddingForTensorflowAveragePooling() *MPSNNDefaultPadding

@abstract A padding policy that attempts to reproduce TensorFlow behavior for average pooling @discussion Most TensorFlow padding is covered by the standard MPSNNPaddingMethod encodings. You can use +paddingWithMethod to get quick access to MPSNNPadding objects, when default filter behavior isn't enough. (It often is.) However, the edging for max pooling in TensorFlow is a bit unusual. This padding method attempts to reproduce TensorFlow padding for average pooling. In addition to setting MPSNNPaddingMethodSizeSame | MPSNNPaddingMethodAlignCentered | MPSNNPaddingMethodAddRemainderToBottomRight, it also configures the filter to run with MPSImageEdgeModeClamp, which (as a special case for average pooling only), normalizes the sum of contributing samples to the area of valid contributing pixels only. @code // Sample implementation for the tensorflowPoolingPaddingPolicy returned -(MPSNNPaddingMethod) paddingMethod{ return MPSNNPaddingMethodCustom | MPSNNPaddingMethodSizeSame; } -(MPSImageDescriptor * __nonnull) destinationImageDescriptorForSourceImages: (NSArray <MPSImage *> *__nonnull) sourceImages sourceStates: (NSArray <MPSState *> * __nullable) sourceStates forKernel: (MPSKernel * __nonnull) kernel suggestedDescriptor: (MPSImageDescriptor * __nonnull) inDescriptor { ((MPSCNNKernel *)kernel).edgeMode = MPSImageEdgeModeClamp; return inDescriptor; } @endcode

func MPSNNDefaultPaddingPaddingForTensorflowAveragePoolingValidOnly ¶

func MPSNNDefaultPaddingPaddingForTensorflowAveragePoolingValidOnly() *MPSNNDefaultPadding

@abstract Typical pooling padding policy for valid only mode

func MPSNNDefaultPaddingPaddingWithMethod ¶

func MPSNNDefaultPaddingPaddingWithMethod(method MPSNNPaddingMethod) *MPSNNDefaultPadding

@abstract Fetch a well known object that implements a non-custom padding method @discussion For custom padding methods, you will need to implement an object that conforms to the full MPSNNPadding protocol, including NSSecureCoding. @param method A MPSNNPaddingMethod @return An object that implements <MPSNNPadding> for use with MPSNNGraphNodes.

func (*MPSNNDefaultPadding) Label ¶

@abstract Human readable description of what the padding policy does

type MPSNNDivisionNode ¶

type MPSNNDivisionNode struct {
	MPSNNBinaryArithmeticNode
}

@abstract returns elementwise quotient of left / right

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnndivisionnode

func MPSNNDivisionNodeFromID ¶

func MPSNNDivisionNodeFromID(id objc.ID) *MPSNNDivisionNode

type MPSNNFilterNode ¶

type MPSNNFilterNode struct {
	foundation.NSObject
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnfilternode

func MPSNNFilterNodeFromID ¶

func MPSNNFilterNodeFromID(id objc.ID) *MPSNNFilterNode

func (*MPSNNFilterNode) GradientFilterWithSource ¶

func (o *MPSNNFilterNode) GradientFilterWithSource(gradientImage *MPSNNImageNode) *MPSNNGradientFilterNode

@abstract Return the gradient (backwards) version of this filter. @discussion The backwards training version of the filter will be returned. The non-gradient image and state arguments for the filter are automatically obtained from the target. @param gradientImage The gradient images corresponding with the resultImage of the target

func (*MPSNNFilterNode) GradientFilterWithSources ¶

func (o *MPSNNFilterNode) GradientFilterWithSources(gradientImages *foundation.NSArray[*MPSNNImageNode]) *MPSNNGradientFilterNode

@abstract Return the gradient (backwards) version of this filter. @discussion The backwards training version of the filter will be returned. The non-gradient image and state arguments for the filter are automatically obtained from the target. @param gradientImages The gradient images corresponding with the resultImage of the target

func (*MPSNNFilterNode) GradientFiltersWithSource ¶

func (o *MPSNNFilterNode) GradientFiltersWithSource(gradientImage *MPSNNImageNode) *foundation.NSArray[*MPSNNGradientFilterNode]

@abstract Return multiple gradient versions of the filter @discussion MPSNNFilters that consume multiple inputs generally result in multiple conjugate filters for the gradient computation at the end of training. For example, a single concatenation operation that concatenates multple images will result in an array of slice operators that carve out subsections of the input gradient image.

func (*MPSNNFilterNode) GradientFiltersWithSources ¶

func (o *MPSNNFilterNode) GradientFiltersWithSources(gradientImages *foundation.NSArray[*MPSNNImageNode]) *foundation.NSArray[*MPSNNGradientFilterNode]

@abstract Return multiple gradient versions of the filter @discussion MPSNNFilters that consume multiple inputs generally result in multiple conjugate filters for the gradient computation at the end of training. For example, a single concatenation operation that concatenates multple images will result in an array of slice operators that carve out subsections of the input gradient image.

func (*MPSNNFilterNode) Label ¶

func (o *MPSNNFilterNode) Label() *foundation.NSString

@property label @abstract A string to help identify this object.

func (*MPSNNFilterNode) PaddingPolicy ¶

func (o *MPSNNFilterNode) PaddingPolicy() MPSNNPadding

@abstract The padding method used for the filter node @discussion The padding policy configures how the filter centers the region of interest in the source image. It principally is responsible for setting the MPSCNNKernel.offset and the size of the image produced, and sometimes will also configure .sourceFeatureChannelOffset, .sourceFeatureChannelMaxCount, and .edgeMode. It is permitted to set any other filter properties as needed using a custom padding policy. The default padding policy varies per filter to conform to consensus expectation for the behavior of that filter. In some cases, pre-made padding policies are provided to match the behavior of common neural networking frameworks with particularly complex or unexpected behavior for specific nodes. See MPSNNDefaultPadding class methods in MPSNeuralNetworkTypes.h for more. BUG: MPS doesn't provide a good way to reset the MPSKernel properties in the context of a MPSNNGraph after the kernel is finished encoding. These values carry on to the next time the graph is used. Consequently, if your custom padding policy modifies the property as a function of the previous value, e.g.: kernel.someProperty += 2; then the second time the graph runs, the property may have an inconsistent value, leading to unexpected behavior. The default padding computation runs before the custom padding method to provide it with a sense of what is expected for the default configuration and will reinitialize the value in the case of the .offset. However, that computation usually doesn't reset other properties. In such cases, the custom padding policy may need to keep a record of the original value to enable consistent behavior.

func (*MPSNNFilterNode) ResultImage ¶

func (o *MPSNNFilterNode) ResultImage() *MPSNNImageNode

@abstract Get the node representing the image result of the filter @discussion Except where otherwise noted, the precision used for the result image (see format property) is copied from the precision from the first input image node.

func (*MPSNNFilterNode) ResultState ¶

func (o *MPSNNFilterNode) ResultState() *MPSNNStateNode

@abstract convenience method for resultStates[0] @discussion If resultStates is nil, returns nil

func (*MPSNNFilterNode) ResultStates ¶

func (o *MPSNNFilterNode) ResultStates() *foundation.NSArray[*MPSNNStateNode]

@abstract Get the node representing the state result of the filter @discussion If more than one, see description of subclass for ordering.

func (*MPSNNFilterNode) SetLabel ¶

func (o *MPSNNFilterNode) SetLabel(label *foundation.NSString)

func (*MPSNNFilterNode) SetPaddingPolicy ¶

func (o *MPSNNFilterNode) SetPaddingPolicy(paddingPolicy MPSNNPadding)

func (*MPSNNFilterNode) TrainingGraphWithSourceGradientNodeHandler ¶

func (o *MPSNNFilterNode) TrainingGraphWithSourceGradientNodeHandler(gradientImage *MPSNNImageNode, nodeHandler func(*MPSNNFilterNode, *MPSNNFilterNode, *MPSNNImageNode, *MPSNNImageNode)) *foundation.NSArray[*MPSNNFilterNode]

@abstract Build training graph from inference graph @discussion This method will iteratively build the training portion of a graph based on an inference graph. Self should be the last node in the inference graph. It is typically a loss layer, but can be anything. Typically, the "inference graph" used here is the desired inference graph with a dropout node and a loss layer node appended. The nodes that are created will have default properties. In certain cases, these may not be appropriate (e.g. if you want to do CPU based updates of convolution weights instead of default GPU updates.) In such cases, your application should use the nodeHandler to configure the new nodes as they are created. BUG: This method can not follow links to regions of the graph that are connected to the rest of the graph solely via MPSNNStateNodes. A gradient image input is required to construct a MPSNNGradientFilterNode from a inference filter node. @param gradientImage The input gradient image for the first gradient node in the training section of the graph. If nil, self.resultImage is used. This results in a standard monolithic training graph. If the graph is instead divided into multiple subgraphs (potentially to allow for your custom code to appear inbetween MPSNNGraph segments) a new MPSImageNode* may be substituted. @param nodeHandler An optional block to allow for customization of gradient nodes and intermediate images as the graph is constructed. It may also be used to prune braches of the developing training graph. If nil, the default handler is used. It builds the full graph, and assigns any inferenceNodeSources[i].handle to their gradient counterparts. @return The list of new MPSNNFilterNode training graph termini. These MPSNNFilterNodes are not necessarily all MPSNNGradientFilterNodes. To build a full list of nodes created, use a custom nodeHandler. If no nodes are created nil is returned.

type MPSNNForwardLoss ¶

type MPSNNForwardLoss struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnforwardloss

func MPSNNForwardLossFromID ¶

func MPSNNForwardLossFromID(id objc.ID) *MPSNNForwardLoss

func (*MPSNNForwardLoss) Delta ¶

func (o *MPSNNForwardLoss) Delta() float32

func (*MPSNNForwardLoss) EncodeBatchToCommandBufferSourceImagesLabelsWeightsDestinationStatesDestinationImages ¶

func (o *MPSNNForwardLoss) EncodeBatchToCommandBufferSourceImagesLabelsWeightsDestinationStatesDestinationImages(commandBuffer metal.MTLCommandBuffer, sourceImages unsafe.Pointer, labels unsafe.Pointer, weights unsafe.Pointer, destinationStates unsafe.Pointer, destinationImages unsafe.Pointer)

func (*MPSNNForwardLoss) EncodeBatchToCommandBufferSourceImagesLabelsWeightsDestinationStatesDestinationStateIsTemporary ¶

func (o *MPSNNForwardLoss) EncodeBatchToCommandBufferSourceImagesLabelsWeightsDestinationStatesDestinationStateIsTemporary(commandBuffer metal.MTLCommandBuffer, sourceImages unsafe.Pointer, labels unsafe.Pointer, weights unsafe.Pointer, outStates unsafe.Pointer, isTemporary bool) unsafe.Pointer

func (*MPSNNForwardLoss) Epsilon ¶

func (o *MPSNNForwardLoss) Epsilon() float32

func (*MPSNNForwardLoss) InitWithCoderDevice ¶

func (o *MPSNNForwardLoss) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNForwardLoss

@abstract <NSSecureCoding> support

func (*MPSNNForwardLoss) InitWithDeviceLossDescriptor ¶

func (o *MPSNNForwardLoss) InitWithDeviceLossDescriptor(device metal.MTLDevice, lossDescriptor *MPSCNNLossDescriptor) *MPSNNForwardLoss

@abstract Initialize the loss forward pass filter with a loss descriptor. @param device The device the filter will run on. @param lossDescriptor The loss descriptor. @return A valid MPSNNForwardLoss object or nil, if failure.

func (*MPSNNForwardLoss) LabelSmoothing ¶

func (o *MPSNNForwardLoss) LabelSmoothing() float32

func (*MPSNNForwardLoss) LossType ¶

func (o *MPSNNForwardLoss) LossType() MPSCNNLossType

See MPSCNNLossDescriptor for information about the following properties.

func (*MPSNNForwardLoss) NumberOfClasses ¶

func (o *MPSNNForwardLoss) NumberOfClasses() uint

func (*MPSNNForwardLoss) ReduceAcrossBatch ¶

func (o *MPSNNForwardLoss) ReduceAcrossBatch() bool

func (*MPSNNForwardLoss) ReductionType ¶

func (o *MPSNNForwardLoss) ReductionType() MPSCNNReductionType

func (*MPSNNForwardLoss) SetDelta ¶

func (o *MPSNNForwardLoss) SetDelta(delta float32)

func (*MPSNNForwardLoss) SetEpsilon ¶

func (o *MPSNNForwardLoss) SetEpsilon(epsilon float32)

func (*MPSNNForwardLoss) SetLabelSmoothing ¶

func (o *MPSNNForwardLoss) SetLabelSmoothing(labelSmoothing float32)

func (*MPSNNForwardLoss) SetWeight ¶

func (o *MPSNNForwardLoss) SetWeight(weight float32)

func (*MPSNNForwardLoss) Weight ¶

func (o *MPSNNForwardLoss) Weight() float32

type MPSNNForwardLossNode ¶

type MPSNNForwardLossNode struct {
	MPSNNFilterNode
}

Node representing a @ref MPSNNForwardLoss kernel

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnforwardlossnode

func MPSNNForwardLossNodeFromID ¶

func MPSNNForwardLossNodeFromID(id objc.ID) *MPSNNForwardLossNode

func MPSNNForwardLossNodeNodeWithSourceLabelsLossDescriptor ¶

func MPSNNForwardLossNodeNodeWithSourceLabelsLossDescriptor(source *MPSNNImageNode, labels *MPSNNImageNode, descriptor *MPSCNNLossDescriptor) *MPSNNForwardLossNode

func MPSNNForwardLossNodeNodeWithSourceLabelsWeightsLossDescriptor ¶

func MPSNNForwardLossNodeNodeWithSourceLabelsWeightsLossDescriptor(source *MPSNNImageNode, labels *MPSNNImageNode, weights *MPSNNImageNode, descriptor *MPSCNNLossDescriptor) *MPSNNForwardLossNode

func MPSNNForwardLossNodeNodeWithSourcesLossDescriptor ¶

func MPSNNForwardLossNodeNodeWithSourcesLossDescriptor(sourceNodes *foundation.NSArray[*MPSNNImageNode], descriptor *MPSCNNLossDescriptor) *MPSNNForwardLossNode

@abstract Init a forward loss node from multiple images @param sourceNodes The MPSNNImageNode representing the source MPSImages for the filter Node0: logits, Node1: labels, Node2: weights @return A new MPSNNFilter node.

func (*MPSNNForwardLossNode) Delta ¶

func (o *MPSNNForwardLossNode) Delta() float32

func (*MPSNNForwardLossNode) Epsilon ¶

func (o *MPSNNForwardLossNode) Epsilon() float32

func (*MPSNNForwardLossNode) InitWithSourceLabelsLossDescriptor ¶

func (o *MPSNNForwardLossNode) InitWithSourceLabelsLossDescriptor(source *MPSNNImageNode, labels *MPSNNImageNode, descriptor *MPSCNNLossDescriptor) *MPSNNForwardLossNode

func (*MPSNNForwardLossNode) InitWithSourceLabelsWeightsLossDescriptor ¶

func (o *MPSNNForwardLossNode) InitWithSourceLabelsWeightsLossDescriptor(source *MPSNNImageNode, labels *MPSNNImageNode, weights *MPSNNImageNode, descriptor *MPSCNNLossDescriptor) *MPSNNForwardLossNode

func (*MPSNNForwardLossNode) InitWithSourcesLossDescriptor ¶

func (o *MPSNNForwardLossNode) InitWithSourcesLossDescriptor(sourceNodes *foundation.NSArray[*MPSNNImageNode], descriptor *MPSCNNLossDescriptor) *MPSNNForwardLossNode

func (*MPSNNForwardLossNode) LabelSmoothing ¶

func (o *MPSNNForwardLossNode) LabelSmoothing() float32

func (*MPSNNForwardLossNode) LossType ¶

func (o *MPSNNForwardLossNode) LossType() MPSCNNLossType

func (*MPSNNForwardLossNode) NumberOfClasses ¶

func (o *MPSNNForwardLossNode) NumberOfClasses() uint

func (*MPSNNForwardLossNode) PropertyCallBack ¶

func (o *MPSNNForwardLossNode) PropertyCallBack() MPSNNLossCallback

@property propertyCallBack @abstract Optional callback option - setting this allows the scalar weight value to be changed dynamically at encode time. Default value: nil.

func (*MPSNNForwardLossNode) ReduceAcrossBatch ¶

func (o *MPSNNForwardLossNode) ReduceAcrossBatch() bool

func (*MPSNNForwardLossNode) ReductionType ¶

func (o *MPSNNForwardLossNode) ReductionType() MPSCNNReductionType

func (*MPSNNForwardLossNode) SetPropertyCallBack ¶

func (o *MPSNNForwardLossNode) SetPropertyCallBack(propertyCallBack MPSNNLossCallback)

func (*MPSNNForwardLossNode) Weight ¶

func (o *MPSNNForwardLossNode) Weight() float32

type MPSNNGradientState ¶

type MPSNNGradientState struct {
	mpscore.MPSState
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnngradientstate

func MPSNNGradientStateFromID ¶

func MPSNNGradientStateFromID(id objc.ID) *MPSNNGradientState

type MPSNNGramMatrixCalculation ¶

type MPSNNGramMatrixCalculation struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnngrammatrixcalculation

func MPSNNGramMatrixCalculationFromID ¶

func MPSNNGramMatrixCalculationFromID(id objc.ID) *MPSNNGramMatrixCalculation

func (*MPSNNGramMatrixCalculation) Alpha ¶

@property alpha @abstract Scaling factor for the output. Default: 1.0f.

func (*MPSNNGramMatrixCalculation) InitWithCoderDevice ¶

func (o *MPSNNGramMatrixCalculation) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNGramMatrixCalculation

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSNNGramMatrixCalculation) InitWithDevice ¶

@abstract Initializes a MPSNNGramMatrixCalculation kernel with scaling factor alpha = 1.0f. @param device The MTLDevice on which this MPSNNGramMatrixCalculation filter will be used. @return A valid MPSNNGramMatrixCalculation object or nil, if failure.

func (*MPSNNGramMatrixCalculation) InitWithDeviceAlpha ¶

func (o *MPSNNGramMatrixCalculation) InitWithDeviceAlpha(device metal.MTLDevice, alpha float32) *MPSNNGramMatrixCalculation

@abstract Initializes a MPSNNGramMatrixCalculation kernel. @param device The MTLDevice on which this MPSNNGramMatrixCalculation filter will be used. @param alpha Scaling factor for the output. @return A valid MPSNNGramMatrixCalculation object or nil, if failure.

func (*MPSNNGramMatrixCalculation) SetAlpha ¶

func (o *MPSNNGramMatrixCalculation) SetAlpha(alpha float32)

type MPSNNGramMatrixCalculationGradient ¶

type MPSNNGramMatrixCalculationGradient struct {
	MPSCNNGradientKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnngrammatrixcalculationgradient

func MPSNNGramMatrixCalculationGradientFromID ¶

func MPSNNGramMatrixCalculationGradientFromID(id objc.ID) *MPSNNGramMatrixCalculationGradient

func (*MPSNNGramMatrixCalculationGradient) Alpha ¶

@property alpha @abstract Scaling factor for the output. Default: 1.0f. NOTE: the value for alpha is automatically adjusted by the @ref MPSNNGradientState when it is provided in the encode call.

func (*MPSNNGramMatrixCalculationGradient) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSNNGramMatrixCalculationGradient) InitWithDevice ¶

@abstract Initializes a MPSNNGramMatrixCalculationGradient kernel with scaling factor alpha = 1.0f. @param device The MTLDevice on which this MPSNNGramMatrixCalculationGradient filter will be used. @return A valid MPSNNGramMatrixCalculationGradient object or nil, if failure.

func (*MPSNNGramMatrixCalculationGradient) InitWithDeviceAlpha ¶

@abstract Initializes a MPSNNGramMatrixCalculationGradient kernel. @param device The MTLDevice on which this MPSNNGramMatrixCalculationGradient filter will be used. @param alpha Scaling factor for the output. NOTE: the value for alpha is automatically adjusted by the @ref MPSNNGradientState when it is provided in the encode call. @return A valid MPSNNGramMatrixCalculationGradient object or nil, if failure.

func (*MPSNNGramMatrixCalculationGradient) SetAlpha ¶

func (o *MPSNNGramMatrixCalculationGradient) SetAlpha(alpha float32)

type MPSNNGramMatrixCalculationGradientNode ¶

type MPSNNGramMatrixCalculationGradientNode struct {
	MPSNNGradientFilterNode
}

Node representing a @ref MPSNNGramMatrixCalculationGradient kernel

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnngrammatrixcalculationgradientnode

func MPSNNGramMatrixCalculationGradientNodeFromID ¶

func MPSNNGramMatrixCalculationGradientNodeFromID(id objc.ID) *MPSNNGramMatrixCalculationGradientNode

func MPSNNGramMatrixCalculationGradientNodeNodeWithSourceGradientSourceImageGradientState ¶

func MPSNNGramMatrixCalculationGradientNodeNodeWithSourceGradientSourceImageGradientState(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSNNGramMatrixCalculationGradientNode

func MPSNNGramMatrixCalculationGradientNodeNodeWithSourceGradientSourceImageGradientStateAlpha ¶

func MPSNNGramMatrixCalculationGradientNodeNodeWithSourceGradientSourceImageGradientStateAlpha(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, alpha float32) *MPSNNGramMatrixCalculationGradientNode

func (*MPSNNGramMatrixCalculationGradientNode) Alpha ¶

@property alpha @abstract Scaling factor for the output. Default: 1.0f.

func (*MPSNNGramMatrixCalculationGradientNode) InitWithSourceGradientSourceImageGradientState ¶

func (o *MPSNNGramMatrixCalculationGradientNode) InitWithSourceGradientSourceImageGradientState(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSNNGramMatrixCalculationGradientNode

func (*MPSNNGramMatrixCalculationGradientNode) InitWithSourceGradientSourceImageGradientStateAlpha ¶

func (o *MPSNNGramMatrixCalculationGradientNode) InitWithSourceGradientSourceImageGradientStateAlpha(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode, alpha float32) *MPSNNGramMatrixCalculationGradientNode

type MPSNNGramMatrixCalculationNode ¶

type MPSNNGramMatrixCalculationNode struct {
	MPSNNFilterNode
}

Node representing a @ref MPSNNGramMatrixCalculation kernel

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnngrammatrixcalculationnode

func MPSNNGramMatrixCalculationNodeFromID ¶

func MPSNNGramMatrixCalculationNodeFromID(id objc.ID) *MPSNNGramMatrixCalculationNode

func MPSNNGramMatrixCalculationNodeNodeWithSource ¶

func MPSNNGramMatrixCalculationNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSNNGramMatrixCalculationNode

@abstract Init a node representing a autoreleased MPSNNGramMatrixCalculationNode kernel. @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter. @return A new MPSNNFilter node for a MPSNNGramMatrixCalculationNode kernel.

func MPSNNGramMatrixCalculationNodeNodeWithSourceAlpha ¶

func MPSNNGramMatrixCalculationNodeNodeWithSourceAlpha(sourceNode *MPSNNImageNode, alpha float32) *MPSNNGramMatrixCalculationNode

@abstract Init a node representing a autoreleased MPSNNGramMatrixCalculationNode kernel. @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter. @param alpha Scaling factor for the output. @return A new MPSNNFilter node for a MPSNNGramMatrixCalculationNode kernel.

func (*MPSNNGramMatrixCalculationNode) Alpha ¶

@property alpha @abstract Scaling factor for the output. Default: 1.0f.

func (*MPSNNGramMatrixCalculationNode) InitWithSource ¶

@abstract Init a node representing a MPSNNGramMatrixCalculationNode kernel. @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter. @return A new MPSNNFilter node for a MPSNNGramMatrixCalculationNode kernel.

func (*MPSNNGramMatrixCalculationNode) InitWithSourceAlpha ¶

func (o *MPSNNGramMatrixCalculationNode) InitWithSourceAlpha(sourceNode *MPSNNImageNode, alpha float32) *MPSNNGramMatrixCalculationNode

@abstract Init a node representing a MPSNNGramMatrixCalculationNode kernel. @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter. @param alpha Scaling factor for the output. @return A new MPSNNFilter node for a MPSNNGramMatrixCalculationNode kernel.

func (*MPSNNGramMatrixCalculationNode) PropertyCallBack ¶

@property propertyCallBack @abstract Optional callback option - setting this allows the alpha value to be changed dynamically at encode time. Default value: nil.

func (*MPSNNGramMatrixCalculationNode) SetPropertyCallBack ¶

func (o *MPSNNGramMatrixCalculationNode) SetPropertyCallBack(propertyCallBack MPSNNGramMatrixCallback)

type MPSNNGramMatrixCallback ¶

type MPSNNGramMatrixCallback interface {
	foundation.NSSecureCoding
	foundation.NSCopying
	AlphaForSourceImageDestinationImage(sourceImage *mpscore.MPSImage, destinationImage *mpscore.MPSImage) float32
}

MPSNNGramMatrixCallback wraps the ObjC protocol MPSNNGramMatrixCallback.

type MPSNNGraph ¶

type MPSNNGraph struct {
	mpscore.MPSKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnngraph

func MPSNNGraphFromID ¶

func MPSNNGraphFromID(id objc.ID) *MPSNNGraph

func MPSNNGraphGraphWithDeviceResultImage ¶

func MPSNNGraphGraphWithDeviceResultImage(device metal.MTLDevice, resultImage *MPSNNImageNode) *MPSNNGraph

func MPSNNGraphGraphWithDeviceResultImageResultImageIsNeeded ¶

func MPSNNGraphGraphWithDeviceResultImageResultImageIsNeeded(device metal.MTLDevice, resultImage *MPSNNImageNode, resultIsNeeded bool) *MPSNNGraph

func MPSNNGraphGraphWithDeviceResultImagesResultsAreNeeded ¶

func MPSNNGraphGraphWithDeviceResultImagesResultsAreNeeded(device metal.MTLDevice, resultImages *foundation.NSArray[*MPSNNImageNode], areResultsNeeded *bool) *MPSNNGraph

func (*MPSNNGraph) DestinationImageAllocator ¶

func (o *MPSNNGraph) DestinationImageAllocator() mpscore.MPSImageAllocator

@abstract Method to allocate the result image from -encodeToCommandBuffer... @discussion This property overrides the allocator for the final result image in the graph. Default: MPSImage.defaultAllocator

func (*MPSNNGraph) EncodeBatchToCommandBufferSourceImagesSourceStates ¶

func (o *MPSNNGraph) EncodeBatchToCommandBufferSourceImagesSourceStates(commandBuffer metal.MTLCommandBuffer, sourceImages *foundation.NSArray[objc.ID], sourceStates *foundation.NSArray[objc.ID]) unsafe.Pointer

@abstract Convenience method to encode a batch of images

func (*MPSNNGraph) EncodeBatchToCommandBufferSourceImagesSourceStatesIntermediateImagesDestinationStates ¶

func (o *MPSNNGraph) EncodeBatchToCommandBufferSourceImagesSourceStatesIntermediateImagesDestinationStates(commandBuffer metal.MTLCommandBuffer, sourceImages *foundation.NSArray[objc.ID], sourceStates *foundation.NSArray[objc.ID], intermediateImages *foundation.NSMutableArray[objc.ID], destinationStates *foundation.NSMutableArray[objc.ID]) unsafe.Pointer

@abstract Encode the graph to a MTLCommandBuffer @discussion This interface is like the other except that it operates on a batch of images all at once. In addition, you may specify whether the result is needed. @param commandBuffer The command buffer. If the command buffer is a MPSCommandBuffer, the work will be committed to Metal in small pieces so that the CPU-side latency is much reduced. @param sourceImages A list of MPSImages to use as the source images for the graph. These should be in the same order as the list returned from MPSNNGraph.sourceImageHandles. The images may be image arrays. Typically, this is only one or two images such as a .JPG decoded into a MPSImage*. If the sourceImages are MPSTemporaryImages, the graph will decrement the readCount by 1, even if the graph actually reads an image multiple times. @param sourceStates A list of MPSState objects to use as state for a graph. These should be in the same order as the list returned from MPSNNGraph.sourceStateHandles. May be nil, if there is no source state. If the sourceStates are temporary, the graph will decrement the readCount by 1, even if the graph actually reads the state multiple times. @param intermediateImages An optional NSMutableArray to receive any MPSImage objects exported as part of its operation. These are only the images that were tagged with MPSNNImageNode.exportFromGraph = YES. The identity of the states is given by -resultStateHandles. If temporary, each intermediateImage will have a readCount of 1. If the result was tagged exportFromGraph = YES, it will be here too, with a readCount of 2. To be able to access the images from outside the graph on the CPU, your application must also set MPSNNImageNode.synchronizeResource = YES, and MPSNNImageNode.imageAllocator = [MPSImage defaultAllocator]; The defaultAllocator creates a permanent image that can be read with readBytes. @param destinationStates An optional NSMutableArray to receive any MPSState objects created as part of its operation. The identity of the states is given by -resultStateHandles. @result A MPSImageBatch or MPSTemporaryImageBatch allocated per the destinationImageAllocator containing the output of the graph. It will be automatically released when commandBuffer completes. If resultIsNeeded == NO, then this will return nil.

func (*MPSNNGraph) EncodeToCommandBufferSourceImages ¶

func (o *MPSNNGraph) EncodeToCommandBufferSourceImages(commandBuffer metal.MTLCommandBuffer, sourceImages *foundation.NSArray[*mpscore.MPSImage]) *mpscore.MPSImage

@abstract Encode the graph to a MTLCommandBuffer @discussion IMPORTANT: Please use [MTLCommandBuffer addCompletedHandler:] to determine when this work is done. Use CPU time that would have been spent waiting for the GPU to encode the next command buffer and commit it too. That way, the work for the next command buffer is ready to go the moment the GPU is done. This will keep the GPU busy and running at top speed. Those who ignore this advice and use [MTLCommandBuffer waitUntilCompleted] instead will likely cause their code to slow down by a factor of two or more. The CPU clock spins down while it waits for the GPU. When the GPU completes, the CPU runs slowly for a while until it spins up. The GPU has to wait for the CPU to encode more work (at low clock), giving it plenty of time to spin its own clock down. In typical CNN graph usage, neither may ever reach maximum clock frequency, causing slow down far beyond what otherwise would be expected from simple failure to schedule CPU and GPU work concurrently. Regrattably, it is probable that every performance benchmark you see on the net will be based on [MTLCommandBuffer waitUntilCompleted]. @param commandBuffer The command buffer. If the command buffer is a MPSCommandBuffer, the work will be committed to Metal in small pieces so that the CPU-side latency is much reduced. @param sourceImages A list of MPSImages to use as the source images for the graph. These should be in the same order as the list returned from MPSNNGraph.sourceImageHandles. @result A MPSImage or MPSTemporaryImage allocated per the destinationImageAllocator containing the output of the graph. It will be automatically released when commandBuffer completes. It can be nil if resultImageIsNeeded == NO

func (*MPSNNGraph) EncodeToCommandBufferSourceImagesSourceStatesIntermediateImagesDestinationStates ¶

func (o *MPSNNGraph) EncodeToCommandBufferSourceImagesSourceStatesIntermediateImagesDestinationStates(commandBuffer metal.MTLCommandBuffer, sourceImages *foundation.NSArray[*mpscore.MPSImage], sourceStates *foundation.NSArray[*mpscore.MPSState], intermediateImages *foundation.NSMutableArray[*mpscore.MPSImage], destinationStates *foundation.NSMutableArray[*mpscore.MPSState]) *mpscore.MPSImage

@abstract Encode the graph to a MTLCommandBuffer @param commandBuffer The command buffer. If the command buffer is a MPSCommandBuffer, the work will be committed to Metal in small pieces so that the CPU-side latency is much reduced. @param sourceImages A list of MPSImages to use as the source images for the graph. These should be in the same order as the list returned from MPSNNGraph.sourceImageHandles. The images may be image arrays. Typically, this is only one or two images such as a .JPG decoded into a MPSImage*. If the sourceImages are MPSTemporaryImages, the graph will decrement the readCount by 1, even if the graph actually reads an image multiple times. @param sourceStates A list of MPSState objects to use as state for a graph. These should be in the same order as the list returned from MPSNNGraph.sourceStateHandles. May be nil, if there is no source state. If the sourceStates are temporary, the graph will decrement the readCount by 1, even if the graph actually reads the state multiple times. @param intermediateImages An optional NSMutableArray to receive any MPSImage objects exported as part of its operation. These are only the images that were tagged with MPSNNImageNode.exportFromGraph = YES. The identity of the states is given by -resultStateHandles. If temporary, each intermediateImage will have a readCount of 1. If the result was tagged exportFromGraph = YES, it will be here too, with a readCount of 2. To be able to access the images from outside the graph on the CPU, your application must also set MPSNNImageNode.synchronizeResource = YES, and MPSNNImageNode.imageAllocator = [MPSImage defaultAllocator]; The defaultAllocator creates a permanent image that can be read with readBytes. @param destinationStates An optional NSMutableArray to receive any MPSState objects created as part of its operation. The identity of the states is given by -resultStateHandles. @result A MPSImage or MPSTemporaryImage allocated per the destinationImageAllocator containing the output of the graph. It will be automatically released when commandBuffer completes.

func (*MPSNNGraph) ExecuteAsyncWithSourceImagesCompletionHandler ¶

func (o *MPSNNGraph) ExecuteAsyncWithSourceImagesCompletionHandler(sourceImages *foundation.NSArray[*mpscore.MPSImage], handler func(*mpscore.MPSImage, unsafe.Pointer)) *mpscore.MPSImage

@abstract Convenience method to execute a graph without having to manage many Metal details @discussion This function will synchronously encode the graph on a private command buffer, commit it to a MPS internal command queue and return. The GPU will start working. When the GPU is done, the completion handler will be called. You should use the intervening time to encode other work for execution on the GPU, so that the GPU stays busy and doesn't clock down. The work will be performed on the MTLDevice that hosts the source images. This is a convenience API. There are a few situations it does not handle optimally. These may be better handled using [encodeToCommandBuffer:sourceImages:]. Specifically: @code o If the graph needs to be run multiple times for different images, it would be better to encode the graph multiple times on the same command buffer using [encodeToCommandBuffer:sourceImages:] This will allow the multiple graphs to share memory for intermediate storage, dramatically reducing memory usage. o If preprocessing or post-processing of the MPSImage is required, such as resizing or normalization outside of a convolution, it would be better to encode those things on the same command buffer. Memory may be saved here too for intermediate storage. (MPSTemporaryImage lifetime does not span multiple command buffers.) @endcode @param sourceImages A list of MPSImages to use as the source images for the graph. These should be in the same order as the list returned from MPSNNGraph.sourceImageHandles. They should be allocated against the same MTLDevice. There must be at least one source image. Note: this array is intended to handle the case where multiple input images are required to generate a single graph result. That is, the graph itself has multiple inputs. If you need to execute the graph multiple times, then call this API multiple times, or (faster) make use of MPSImageBatches using -executeBatchToCommandBuffer:sourceImages:sourceStates:... (See discussion) @param handler A block to receive any errors generated. This block may run on any thread and may be called before this method returns. The image, if any, passed to this callback is the same image as that returned from the left hand side. @return A MPSImage to receive the result. The data in the image will not be valid until the completionHandler is called.

func (*MPSNNGraph) Format ¶

@abstract The default storage format used for graph intermediate images @discussion This doesn't affect how data is stored in buffers in states. Nor does it affect the storage format for weights such as convolution weights stored by individual filters. Default: MPSImageFeatureChannelFormatFloat16

func (*MPSNNGraph) InitWithCoderDevice ¶

func (o *MPSNNGraph) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNGraph

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSNNGraph) InitWithDeviceResultImage ¶

func (o *MPSNNGraph) InitWithDeviceResultImage(device metal.MTLDevice, resultImage *MPSNNImageNode) *MPSNNGraph

func (*MPSNNGraph) InitWithDeviceResultImageResultImageIsNeeded ¶

func (o *MPSNNGraph) InitWithDeviceResultImageResultImageIsNeeded(device metal.MTLDevice, resultImage *MPSNNImageNode, resultIsNeeded bool) *MPSNNGraph

func (*MPSNNGraph) InitWithDeviceResultImagesResultsAreNeeded ¶

func (o *MPSNNGraph) InitWithDeviceResultImagesResultsAreNeeded(device metal.MTLDevice, resultImages *foundation.NSArray[*MPSNNImageNode], areResultsNeeded *bool) *MPSNNGraph

@abstract Initialize a MPSNNGraph object on a device starting with resultImage working backward @discussion The MPSNNGraph constructor will start with the indicated result images, and look to see what MPSNNFilterNode produced them, then look to its dependencies and so forth to reveal the subsection of the graph necessary to compute the image. This variant is provided to support graphs and subgraphs with multiple image outputs. @param device The MTLDevice on which to run the graph @param resultImages The MPSNNImageNodes corresponding to the last images in the graph. The first image in the array will be returned from the -encode method LHS. The rest will be included in the list of intermediate images. @param areResultsNeeded An array of BOOL values with count equal to resultImages.count. If NO is passed for a given image, the image itself is marked unneeded and might be skipped. The graph will prune this branch back to the first requred filter. A filter is required if it generates a needed result image, or is needed to update training parameters. @result A new MPSNNGraph.

func (*MPSNNGraph) IntermediateImageHandles ¶

func (o *MPSNNGraph) IntermediateImageHandles() *foundation.NSArray[MPSHandle]

@abstract Get a list of identifiers for intermediate images objects produced by the graph

func (*MPSNNGraph) OutputStateIsTemporary ¶

func (o *MPSNNGraph) OutputStateIsTemporary() bool

@abstract Should MPSState objects produced by -encodeToCommandBuffer... be temporary objects. @discussion See MPSState description. Default: NO

func (*MPSNNGraph) ReadCountForSourceImageAtIndex ¶

func (o *MPSNNGraph) ReadCountForSourceImageAtIndex(index uint) uint

@abstract Find the number of times a image will be read by the graph * @discussion From the set of images (or image batches) passed in to the graph, find the number of times the graph will read an image. This may be needed by your application to correctly set the MPSImage.readCount property. @param index The index of the image. The index of the image matches the index of the image in the array returned by the sourceImageHandles property. @return The read count of the image(s) at the index will be reduced by the value returned when the graph is finished encoding. The readcount of the image(s) must be at least this value when it is passed into the -encode... method.

func (*MPSNNGraph) ReadCountForSourceStateAtIndex ¶

func (o *MPSNNGraph) ReadCountForSourceStateAtIndex(index uint) uint

@abstract Find the number of times a state will be read by the graph * @discussion From the set of state (or state batches) passed in to the graph, find the number of times the graph will read a state. This may be needed by your application to correctly set the MPSState.readCount property. @param index The index of the state. The index of the state matches the index of the state in the array returned by the sourceStateHandles property. @return The read count of the state(s) at the index will be reduced by the value returned when the graph is finished encoding. The read count of the state(s) must be at least this value when it is passed into the -encode... method.

func (*MPSNNGraph) ReloadFromDataSources ¶

func (o *MPSNNGraph) ReloadFromDataSources()

@abstract Reinitialize all graph nodes from data sources @discussion A number of the nodes that make up a graph have a data source associated with them, for example a MPSCNNConvolutionDataSource or a MPSCNNBatchNormalizationDataSource. Generally, the data is read from these once at graph initialization time and then not looked at again, except during the weight / parameter update phase of the corresponding gradient nodes and then only if CPU updates are requested. Otherwise, update occurs on the GPU, and the data in the data source is thereafter ignored. It can happen, though, that your application has determined the graph should load a new set of weights from the data source. When this method is called, the graph will find all nodes that support reloading and direct them to reinitialize themselves based on their data source. This process occurs immediately. Your application will need to make sure any GPU work being done by the graph is complete to ensure data coherency. Most nodes do not have a data source and will not be modified. Nodes that are not used by the graph will not be updated.

func (*MPSNNGraph) ResultHandle ¶

func (o *MPSNNGraph) ResultHandle() MPSHandle

@abstract Get a handle for the graph result image

func (*MPSNNGraph) ResultImageIsNeeded ¶

func (o *MPSNNGraph) ResultImageIsNeeded() bool

@abstract Set at -init time. @discussion If NO, nil will be returned from -encode calls and some computation may be omitted.

func (*MPSNNGraph) ResultStateHandles ¶

func (o *MPSNNGraph) ResultStateHandles() *foundation.NSArray[MPSHandle]

@abstract Get a list of identifiers for result state objects produced by the graph @discussion Not guaranteed to be in the same order as sourceStateHandles

func (*MPSNNGraph) SetDestinationImageAllocator ¶

func (o *MPSNNGraph) SetDestinationImageAllocator(destinationImageAllocator mpscore.MPSImageAllocator)

func (*MPSNNGraph) SetFormat ¶

func (o *MPSNNGraph) SetFormat(format mpscore.MPSImageFeatureChannelFormat)

func (*MPSNNGraph) SetOutputStateIsTemporary ¶

func (o *MPSNNGraph) SetOutputStateIsTemporary(outputStateIsTemporary bool)

func (*MPSNNGraph) SourceImageHandles ¶

func (o *MPSNNGraph) SourceImageHandles() *foundation.NSArray[MPSHandle]

@abstract Get a list of identifiers for source images needed to calculate the result image

func (*MPSNNGraph) SourceStateHandles ¶

func (o *MPSNNGraph) SourceStateHandles() *foundation.NSArray[MPSHandle]

@abstract Get a list of identifiers for source state objects needed to calculate the result image @discussion Not guaranteed to be in the same order as resultStateHandles

type MPSNNGridSample ¶

type MPSNNGridSample struct {
	MPSCNNBinaryKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnngridsample

func MPSNNGridSampleFromID ¶

func MPSNNGridSampleFromID(id objc.ID) *MPSNNGridSample

func (*MPSNNGridSample) InitWithCoderDevice ¶

func (o *MPSNNGridSample) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNGridSample

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSNNGridSample) InitWithDevice ¶

func (o *MPSNNGridSample) InitWithDevice(device metal.MTLDevice) *MPSNNGridSample

@abstract Create a grid sample kernel. @param device The device the filter will run on @return A valid MPSNNGridSample object or nil, if failure.

func (*MPSNNGridSample) SetUseGridValueAsInputCoordinate ¶

func (o *MPSNNGridSample) SetUseGridValueAsInputCoordinate(useGridValueAsInputCoordinate bool)

func (*MPSNNGridSample) UseGridValueAsInputCoordinate ¶

func (o *MPSNNGridSample) UseGridValueAsInputCoordinate() bool

@property useGridValueAsInputCoordinate @abstract This determines whether the pixel locations from the grid are used as the input coordinate (if set to YES) or is added to the input coordinate (if set to NO). The default value is YES.

type MPSNNImageNode ¶

type MPSNNImageNode struct {
	foundation.NSObject
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnimagenode

func MPSNNImageNodeExportedNodeWithHandle ¶

func MPSNNImageNodeExportedNodeWithHandle(handle *foundation.NSObject) *MPSNNImageNode

@abstract Create a autoreleased MPSNNImageNode with exportFromGraph = YES. @discussion Note: image is still temporary. See MPSNNImageNode.imageAllocator parameter.

func MPSNNImageNodeFromID ¶

func MPSNNImageNodeFromID(id objc.ID) *MPSNNImageNode

func MPSNNImageNodeNodeWithHandle ¶

func MPSNNImageNodeNodeWithHandle(handle *foundation.NSObject) *MPSNNImageNode

func (*MPSNNImageNode) ExportFromGraph ¶

func (o *MPSNNImageNode) ExportFromGraph() bool

@abstract Tag a image node for view later @discussion Most image nodes are private to the graph. These alias memory heavily and consequently generally have invalid state when the graph exits. When exportFromGraph = YES, the image is preserved and made available through the [MPSNNGraph encode... intermediateImages:... list. CAUTION: exporting an image from a graph prevents MPS from recycling memory. It will nearly always cause the amount of memory used by the graph to increase by the size of the image. There will probably be a performance regression accordingly. This feature should generally be used only when the node is needed as an input for further work and recomputing it is prohibitively costly. Default: NO

func (*MPSNNImageNode) Format ¶

@abstract The preferred precision for the image @discussion Default: MPSImageFeatureChannelFormatNone, meaning MPS should pick a format Typically, this is 16-bit floating-point.

func (*MPSNNImageNode) Handle ¶

func (o *MPSNNImageNode) Handle() MPSHandle

@abstract MPS resource identifier @discussion See MPSHandle protocol description. Default: nil

func (*MPSNNImageNode) ImageAllocator ¶

func (o *MPSNNImageNode) ImageAllocator() mpscore.MPSImageAllocator

@abstract Configurability for image allocation @discussion Allows you to influence how the image is allocated Default: MPSTemporaryImage.defaultAllocator

func (*MPSNNImageNode) InitWithHandle ¶

func (o *MPSNNImageNode) InitWithHandle(handle *foundation.NSObject) *MPSNNImageNode

func (*MPSNNImageNode) SetExportFromGraph ¶

func (o *MPSNNImageNode) SetExportFromGraph(exportFromGraph bool)

func (*MPSNNImageNode) SetFormat ¶

func (*MPSNNImageNode) SetHandle ¶

func (o *MPSNNImageNode) SetHandle(handle MPSHandle)

func (*MPSNNImageNode) SetImageAllocator ¶

func (o *MPSNNImageNode) SetImageAllocator(imageAllocator mpscore.MPSImageAllocator)

func (*MPSNNImageNode) SetStopGradient ¶

func (o *MPSNNImageNode) SetStopGradient(stopGradient bool)

func (*MPSNNImageNode) SetSynchronizeResource ¶

func (o *MPSNNImageNode) SetSynchronizeResource(synchronizeResource bool)

func (*MPSNNImageNode) StopGradient ¶

func (o *MPSNNImageNode) StopGradient() bool

@abstract Stop training graph automatic creation at this node. @discussion An inference graph of MPSNNFilterNodes, MPSNNStateNodes and MPSNNImageNodes can be automatically converted to a training graph using -[MPSNNFilterNode trainingGraphWithSourceGradient:nodeHandler:]. Sometimes, an inference graph may contain extra nodes at start to do operations like resampling or range adjustment that should not be part of the training graph. To prevent gradient operations for these extra nodes from being included in the training graph, set <undesired node>.resultImage.stopGradient = YES. This will prevent gradient propagation beyond this MPSNNImageNode. Default: NO

func (*MPSNNImageNode) SynchronizeResource ¶

func (o *MPSNNImageNode) SynchronizeResource() bool

@abstract Set to true to cause the resource to be synchronized with the CPU @discussion It is not needed on iOS/tvOS devices, where it does nothing.

type MPSNNInitialGradient ¶

type MPSNNInitialGradient struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnninitialgradient

func MPSNNInitialGradientFromID ¶

func MPSNNInitialGradientFromID(id objc.ID) *MPSNNInitialGradient

func (*MPSNNInitialGradient) InitWithDevice ¶

func (o *MPSNNInitialGradient) InitWithDevice(device metal.MTLDevice) *MPSNNInitialGradient

@abstract Initializes a MPSNNInitialGradient kernel. @param device The MTLDevice on which this MPSNNInitialGradient filter will be used. @return A valid MPSNNInitialGradient object or nil, if failure.

type MPSNNInitialGradientNode ¶

type MPSNNInitialGradientNode struct {
	MPSNNFilterNode
}

@class MPSNNInitialGradientNode @abstract A node for a MPSNNInitialGradient kernel @discussion This node can be used to generate a starting point for an arbitrary gradient computation. Simply add this node after the node for which you want to compute gradients and then call the function @ref trainingGraphWithSourceGradient: of this node to automatically generate the nodes needed for gradient computations or add the desired nodes manually. This is generally used with MPSNNLossGradientNode and MPSNNForwardLossNode

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnninitialgradientnode

func MPSNNInitialGradientNodeFromID ¶

func MPSNNInitialGradientNodeFromID(id objc.ID) *MPSNNInitialGradientNode

func MPSNNInitialGradientNodeNodeWithSource ¶

func MPSNNInitialGradientNodeNodeWithSource(source *MPSNNImageNode) *MPSNNInitialGradientNode

@abstract Init a node representing a MPSNNInitialGradient MPSNNPad kernel @param source The MPSNNImageNode representing the source MPSImage for the filter @return A new MPSNNFilter node for a MPSNNInitialGradient kernel.

func (*MPSNNInitialGradientNode) InitWithSource ¶

@abstract Init a node representing a MPSNNInitialGradient MPSNNPad kernel @param source The MPSNNImageNode representing the source MPSImage for the filter @return A new MPSNNFilter node for a MPSNNInitialGradient kernel.

type MPSNNLabelsNode ¶

type MPSNNLabelsNode struct {
	MPSNNStateNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnlabelsnode

func MPSNNLabelsNodeFromID ¶

func MPSNNLabelsNodeFromID(id objc.ID) *MPSNNLabelsNode

type MPSNNLocalCorrelation ¶

type MPSNNLocalCorrelation struct {
	MPSNNReduceBinary
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnlocalcorrelation

func MPSNNLocalCorrelationFromID ¶

func MPSNNLocalCorrelationFromID(id objc.ID) *MPSNNLocalCorrelation

func (*MPSNNLocalCorrelation) InitWithCoderDevice ¶

func (o *MPSNNLocalCorrelation) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNLocalCorrelation

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSCNNPooling object, or nil if failure.

func (*MPSNNLocalCorrelation) InitWithDevice ¶

func (o *MPSNNLocalCorrelation) InitWithDevice(device metal.MTLDevice) *MPSNNLocalCorrelation

@abstract Initialize the MPSNNLocalCorrelation filter with default property values. @param device The device the filter will run on @return A valid MPSNNReduceLocalCorrelation object or nil, if failure.

func (*MPSNNLocalCorrelation) InitWithDeviceWindowInXWindowInYStrideInXStrideInY ¶

func (o *MPSNNLocalCorrelation) InitWithDeviceWindowInXWindowInYStrideInXStrideInY(device metal.MTLDevice, windowInX uint, windowInY uint, strideInX uint, strideInY uint) *MPSNNLocalCorrelation

@abstract Specifies information to apply the local correlation operation on an image. @param device The device the filter will run on @param windowInX Specifies a symmetric window around 0 for offsetting the secondary source in the x dimension. @param windowInY Specifies a symmetric window around 0 for offsetting the secondary source in the y dimension. @param strideInX Specifies the stride for the offset in the x dimension. @param strideInY Specifies the stride for the offset in the y dimension. @return A valid MPSNNReduceLocalCorrelation object or nil, if failure.

func (*MPSNNLocalCorrelation) SetStrideInX ¶

func (o *MPSNNLocalCorrelation) SetStrideInX(strideInX uint)

func (*MPSNNLocalCorrelation) SetStrideInY ¶

func (o *MPSNNLocalCorrelation) SetStrideInY(strideInY uint)

func (*MPSNNLocalCorrelation) SetWindowInX ¶

func (o *MPSNNLocalCorrelation) SetWindowInX(windowInX uint)

func (*MPSNNLocalCorrelation) SetWindowInY ¶

func (o *MPSNNLocalCorrelation) SetWindowInY(windowInY uint)

func (*MPSNNLocalCorrelation) StrideInX ¶

func (o *MPSNNLocalCorrelation) StrideInX() uint

@abstract Specifies the stride for the offset in the x dimension. @discussion strideInX must be > 0. The default value for strideInX is 1.

func (*MPSNNLocalCorrelation) StrideInY ¶

func (o *MPSNNLocalCorrelation) StrideInY() uint

@abstract Specifies the stride for the offset in the y dimension. @discussion strideInY must be > 0. The default value for strideInY is 1.

func (*MPSNNLocalCorrelation) WindowInX ¶

func (o *MPSNNLocalCorrelation) WindowInX() uint

@abstract Specifies a symmetric window around 0 for offsetting the secondary source in the x dimension. @discussion The default value for windowInX is 0.

func (*MPSNNLocalCorrelation) WindowInY ¶

func (o *MPSNNLocalCorrelation) WindowInY() uint

@abstract Specifies a symmetric window around 0 for offsetting the secondary source in the y dimension. @discussion The default value for windowInY is 0.

type MPSNNLossCallback ¶

type MPSNNLossCallback interface {
	foundation.NSSecureCoding
	foundation.NSCopying
	ScalarWeightForSourceImageDestinationImage(sourceImage *mpscore.MPSImage, destinationImage *mpscore.MPSImage) float32
}

MPSNNLossCallback wraps the ObjC protocol MPSNNLossCallback.

type MPSNNLossGradient ¶

type MPSNNLossGradient struct {
	MPSCNNBinaryKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnlossgradient

func MPSNNLossGradientFromID ¶

func MPSNNLossGradientFromID(id objc.ID) *MPSNNLossGradient

func (*MPSNNLossGradient) ComputeLabelGradients ¶

func (o *MPSNNLossGradient) ComputeLabelGradients() bool

@property computeLabelGradients @abstract The computeLabelGradients property is used to control whether the loss gradient filter computes gradients for the primary (predictions) or secondary (labels) source image from the forward pass. Default: NO.

func (*MPSNNLossGradient) Delta ¶

func (o *MPSNNLossGradient) Delta() float32

func (*MPSNNLossGradient) EncodeBatchToCommandBufferSourceGradientsSourceImagesLabelsWeightsSourceStates ¶

func (o *MPSNNLossGradient) EncodeBatchToCommandBufferSourceGradientsSourceImagesLabelsWeightsSourceStates(commandBuffer metal.MTLCommandBuffer, sourceGradients unsafe.Pointer, sourceImages unsafe.Pointer, labels unsafe.Pointer, weights unsafe.Pointer, sourceStates unsafe.Pointer) unsafe.Pointer

@abstract Encode the loss gradient filter and return a gradient @param commandBuffer The MTLCommandBuffer on which to encode @param sourceGradients The gradient images from the "next" filter in the graph @param sourceImages The images used as source image from the forward pass @param labels The source images that contains the labels (targets). @param weights The object containing weights for the labels. Optional. @param sourceStates Optional gradient state - carries dynamical property values from the forward pass (weight, labelSmoothing, epsilon, delta).

func (*MPSNNLossGradient) EncodeBatchToCommandBufferSourceGradientsSourceImagesLabelsWeightsSourceStatesDestinationGradients ¶

func (o *MPSNNLossGradient) EncodeBatchToCommandBufferSourceGradientsSourceImagesLabelsWeightsSourceStatesDestinationGradients(commandBuffer metal.MTLCommandBuffer, sourceGradients unsafe.Pointer, sourceImages unsafe.Pointer, labels unsafe.Pointer, weights unsafe.Pointer, sourceStates unsafe.Pointer, destinationGradients unsafe.Pointer)

@abstract Encode the loss gradient filter and return a gradient @param commandBuffer The MTLCommandBuffer on which to encode @param sourceGradients The gradient images from the "next" filter in the graph @param sourceImages The image used as source images from the forward pass @param labels The source images that contains the labels (targets). @param weights The object containing weights for the labels. Optional. @param sourceStates Optional gradient state - carries dynamical property values from the forward pass (weight, labelSmoothing, epsilon, delta). @param destinationGradients The MPSImages into which to write the filter result

func (*MPSNNLossGradient) Epsilon ¶

func (o *MPSNNLossGradient) Epsilon() float32

func (*MPSNNLossGradient) InitWithCoderDevice ¶

func (o *MPSNNLossGradient) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNLossGradient

@abstract <NSSecureCoding> support

func (*MPSNNLossGradient) InitWithDeviceLossDescriptor ¶

func (o *MPSNNLossGradient) InitWithDeviceLossDescriptor(device metal.MTLDevice, lossDescriptor *MPSCNNLossDescriptor) *MPSNNLossGradient

@abstract Initialize the loss gradient filter with a loss descriptor. @param device The device the filter will run on. @param lossDescriptor The loss descriptor. @return A valid MPSNNLossGradient object or nil, if failure.

func (*MPSNNLossGradient) LabelSmoothing ¶

func (o *MPSNNLossGradient) LabelSmoothing() float32

func (*MPSNNLossGradient) LossType ¶

func (o *MPSNNLossGradient) LossType() MPSCNNLossType

See MPSCNNLossDescriptor for information about the following properties.

func (*MPSNNLossGradient) NumberOfClasses ¶

func (o *MPSNNLossGradient) NumberOfClasses() uint

func (*MPSNNLossGradient) ReduceAcrossBatch ¶

func (o *MPSNNLossGradient) ReduceAcrossBatch() bool

func (*MPSNNLossGradient) ReductionType ¶

func (o *MPSNNLossGradient) ReductionType() MPSCNNReductionType

func (*MPSNNLossGradient) SetComputeLabelGradients ¶

func (o *MPSNNLossGradient) SetComputeLabelGradients(computeLabelGradients bool)

func (*MPSNNLossGradient) SetDelta ¶

func (o *MPSNNLossGradient) SetDelta(delta float32)

func (*MPSNNLossGradient) SetEpsilon ¶

func (o *MPSNNLossGradient) SetEpsilon(epsilon float32)

func (*MPSNNLossGradient) SetLabelSmoothing ¶

func (o *MPSNNLossGradient) SetLabelSmoothing(labelSmoothing float32)

func (*MPSNNLossGradient) SetWeight ¶

func (o *MPSNNLossGradient) SetWeight(weight float32)

func (*MPSNNLossGradient) Weight ¶

func (o *MPSNNLossGradient) Weight() float32

type MPSNNLossGradientNode ¶

type MPSNNLossGradientNode struct {
	MPSNNGradientFilterNode
}

Node representing a @ref MPSNNLossGradient kernel

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnlossgradientnode

func MPSNNLossGradientNodeFromID ¶

func MPSNNLossGradientNodeFromID(id objc.ID) *MPSNNLossGradientNode

func MPSNNLossGradientNodeNodeWithSourceGradientSourceImageLabelsGradientStateLossDescriptorIsLabelsGradientFilter ¶

func MPSNNLossGradientNodeNodeWithSourceGradientSourceImageLabelsGradientStateLossDescriptorIsLabelsGradientFilter(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, labels *MPSNNImageNode, gradientState *MPSNNGradientStateNode, descriptor *MPSCNNLossDescriptor, isLabelsGradientFilter bool) *MPSNNLossGradientNode

func MPSNNLossGradientNodeNodeWithSourceGradientSourceImageLabelsWeightsGradientStateLossDescriptorIsLabelsGradientFilter ¶

func MPSNNLossGradientNodeNodeWithSourceGradientSourceImageLabelsWeightsGradientStateLossDescriptorIsLabelsGradientFilter(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, labels *MPSNNImageNode, weights *MPSNNImageNode, gradientState *MPSNNGradientStateNode, descriptor *MPSCNNLossDescriptor, isLabelsGradientFilter bool) *MPSNNLossGradientNode

func MPSNNLossGradientNodeNodeWithSourcesGradientStateLossDescriptorIsLabelsGradientFilter ¶

func MPSNNLossGradientNodeNodeWithSourcesGradientStateLossDescriptorIsLabelsGradientFilter(sourceNodes *foundation.NSArray[*MPSNNImageNode], gradientState *MPSNNGradientStateNode, descriptor *MPSCNNLossDescriptor, isLabelsGradientFilter bool) *MPSNNLossGradientNode

@abstract Init a gradient loss node from multiple images @param sourceNodes The MPSNNImageNode representing the source MPSImages for the filter Node0: logits, Node1: labels, Node2: weights @return A new MPSNNFilter node.

func (*MPSNNLossGradientNode) Delta ¶

func (o *MPSNNLossGradientNode) Delta() float32

func (*MPSNNLossGradientNode) Epsilon ¶

func (o *MPSNNLossGradientNode) Epsilon() float32

func (*MPSNNLossGradientNode) InitWithSourceGradientSourceImageLabelsGradientStateLossDescriptorIsLabelsGradientFilter ¶

func (o *MPSNNLossGradientNode) InitWithSourceGradientSourceImageLabelsGradientStateLossDescriptorIsLabelsGradientFilter(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, labels *MPSNNImageNode, gradientState *MPSNNGradientStateNode, descriptor *MPSCNNLossDescriptor, isLabelsGradientFilter bool) *MPSNNLossGradientNode

func (*MPSNNLossGradientNode) InitWithSourceGradientSourceImageLabelsWeightsGradientStateLossDescriptorIsLabelsGradientFilter ¶

func (o *MPSNNLossGradientNode) InitWithSourceGradientSourceImageLabelsWeightsGradientStateLossDescriptorIsLabelsGradientFilter(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, labels *MPSNNImageNode, weights *MPSNNImageNode, gradientState *MPSNNGradientStateNode, descriptor *MPSCNNLossDescriptor, isLabelsGradientFilter bool) *MPSNNLossGradientNode

func (*MPSNNLossGradientNode) InitWithSourcesGradientStateLossDescriptorIsLabelsGradientFilter ¶

func (o *MPSNNLossGradientNode) InitWithSourcesGradientStateLossDescriptorIsLabelsGradientFilter(sourceNodes *foundation.NSArray[*MPSNNImageNode], gradientState *MPSNNGradientStateNode, descriptor *MPSCNNLossDescriptor, isLabelsGradientFilter bool) *MPSNNLossGradientNode

func (*MPSNNLossGradientNode) IsLabelsGradientFilter ¶

func (o *MPSNNLossGradientNode) IsLabelsGradientFilter() bool

func (*MPSNNLossGradientNode) LabelSmoothing ¶

func (o *MPSNNLossGradientNode) LabelSmoothing() float32

func (*MPSNNLossGradientNode) LossType ¶

func (o *MPSNNLossGradientNode) LossType() MPSCNNLossType

func (*MPSNNLossGradientNode) NumberOfClasses ¶

func (o *MPSNNLossGradientNode) NumberOfClasses() uint

func (*MPSNNLossGradientNode) PropertyCallBack ¶

func (o *MPSNNLossGradientNode) PropertyCallBack() MPSNNLossCallback

@property propertyCallBack @abstract Optional callback option - setting this allows the scalar weight value to be changed dynamically at encode time. Default value: nil.

func (*MPSNNLossGradientNode) ReduceAcrossBatch ¶

func (o *MPSNNLossGradientNode) ReduceAcrossBatch() bool

func (*MPSNNLossGradientNode) ReductionType ¶

func (o *MPSNNLossGradientNode) ReductionType() MPSCNNReductionType

func (*MPSNNLossGradientNode) SetPropertyCallBack ¶

func (o *MPSNNLossGradientNode) SetPropertyCallBack(propertyCallBack MPSNNLossCallback)

func (*MPSNNLossGradientNode) Weight ¶

func (o *MPSNNLossGradientNode) Weight() float32

type MPSNNMultiplicationGradientNode ¶

type MPSNNMultiplicationGradientNode struct {
	MPSNNArithmeticGradientNode
}

@abstract returns gradient for either primary or secondary source image from the inference pass. Use the isSecondarySourceFilter property to indicate whether this filter is computing the gradient for the primary or secondary source image from the inference pass.

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnmultiplicationgradientnode

func MPSNNMultiplicationGradientNodeFromID ¶

func MPSNNMultiplicationGradientNodeFromID(id objc.ID) *MPSNNMultiplicationGradientNode

type MPSNNMultiplicationNode ¶

type MPSNNMultiplicationNode struct {
	MPSNNBinaryArithmeticNode
}

@abstract returns elementwise product of left * right

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnmultiplicationnode

func MPSNNMultiplicationNodeFromID ¶

func MPSNNMultiplicationNodeFromID(id objc.ID) *MPSNNMultiplicationNode

type MPSNNNeuronDescriptor ¶

type MPSNNNeuronDescriptor struct {
	foundation.NSObject
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnneurondescriptor

func MPSNNNeuronDescriptorCnnNeuronDescriptorWithType ¶

func MPSNNNeuronDescriptorCnnNeuronDescriptorWithType(neuronType MPSCNNNeuronType) *MPSNNNeuronDescriptor

@abstract Make a descriptor for a MPSCNNNeuron object. @param neuronType The type of a neuron filter. @return A valid MPSNNNeuronDescriptor object or nil, if failure.

func MPSNNNeuronDescriptorCnnNeuronDescriptorWithTypeA ¶

func MPSNNNeuronDescriptorCnnNeuronDescriptorWithTypeA(neuronType MPSCNNNeuronType, a float32) *MPSNNNeuronDescriptor

@abstract Make a descriptor for a MPSCNNNeuron object. @param neuronType The type of a neuron filter. @param a Parameter "a". @return A valid MPSNNNeuronDescriptor object or nil, if failure.

func MPSNNNeuronDescriptorCnnNeuronDescriptorWithTypeAB ¶

func MPSNNNeuronDescriptorCnnNeuronDescriptorWithTypeAB(neuronType MPSCNNNeuronType, a float32, b float32) *MPSNNNeuronDescriptor

@abstract Initialize the neuron descriptor. @param neuronType The type of a neuron filter. @param a Parameter "a". @param b Parameter "b". @return A valid MPSNNNeuronDescriptor object or nil, if failure.

func MPSNNNeuronDescriptorCnnNeuronDescriptorWithTypeABC ¶

func MPSNNNeuronDescriptorCnnNeuronDescriptorWithTypeABC(neuronType MPSCNNNeuronType, a float32, b float32, c float32) *MPSNNNeuronDescriptor

@abstract Make a descriptor for a MPSCNNNeuron object. @param neuronType The type of a neuron filter. @param a Parameter "a". @param b Parameter "b". @param c Parameter "c". @return A valid MPSNNNeuronDescriptor object or nil, if failure.

func MPSNNNeuronDescriptorCnnNeuronPReLUDescriptorWithDataNoCopy ¶

func MPSNNNeuronDescriptorCnnNeuronPReLUDescriptorWithDataNoCopy(data *foundation.NSData, noCopy bool) *MPSNNNeuronDescriptor

@abstract Make a descriptor for a neuron of type MPSCNNNeuronTypePReLU. @discussion The PReLU neuron is the same as a ReLU neuron, except parameter "a" is per feature channel. @param data A NSData containing a float array with the per feature channel value of PReLu parameter. The number of float values in this array usually corresponds to number of output channels in a convolution layer. The descriptor retains the NSData object. @param noCopy An optimization flag that tells us whether the NSData allocation is suitable for use directly with no copying of the data into internal storage. This allocation has to match the same restrictions as listed for the newBufferWithBytesNoCopy:length:options:deallocator: method of MTLBuffer. @return A valid MPSNNNeuronDescriptor object for a neuron of type MPSCNNNeuronTypePReLU or nil, if failure

func MPSNNNeuronDescriptorFromID ¶

func MPSNNNeuronDescriptorFromID(id objc.ID) *MPSNNNeuronDescriptor

func (*MPSNNNeuronDescriptor) A ¶

func (*MPSNNNeuronDescriptor) B ¶

func (*MPSNNNeuronDescriptor) C ¶

func (*MPSNNNeuronDescriptor) Data ¶

func (*MPSNNNeuronDescriptor) NeuronType ¶

func (o *MPSNNNeuronDescriptor) NeuronType() MPSCNNNeuronType

func (*MPSNNNeuronDescriptor) SetA ¶

func (o *MPSNNNeuronDescriptor) SetA(a float32)

func (*MPSNNNeuronDescriptor) SetB ¶

func (o *MPSNNNeuronDescriptor) SetB(b float32)

func (*MPSNNNeuronDescriptor) SetC ¶

func (o *MPSNNNeuronDescriptor) SetC(c float32)

func (*MPSNNNeuronDescriptor) SetData ¶

func (o *MPSNNNeuronDescriptor) SetData(data *foundation.NSData)

func (*MPSNNNeuronDescriptor) SetNeuronType ¶

func (o *MPSNNNeuronDescriptor) SetNeuronType(neuronType MPSCNNNeuronType)

type MPSNNOptimizer ¶

type MPSNNOptimizer struct {
	mpscore.MPSKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnoptimizer

func MPSNNOptimizerFromID ¶

func MPSNNOptimizerFromID(id objc.ID) *MPSNNOptimizer

func (*MPSNNOptimizer) ApplyGradientClipping ¶

func (o *MPSNNOptimizer) ApplyGradientClipping() bool

@property applyGradientClipping @abstract A bool which decides if gradient will be clipped @discussion The default value is NO

func (*MPSNNOptimizer) GradientClipMax ¶

func (o *MPSNNOptimizer) GradientClipMax() float32

@property gradientClipMax @abstract The maximum value at which incoming gradient will be clipped before rescaling, applyGradientClipping must be true

func (*MPSNNOptimizer) GradientClipMin ¶

func (o *MPSNNOptimizer) GradientClipMin() float32

@property gradientClipMin @abstract The minimum value at which incoming gradient will be clipped before rescaling, applyGradientClipping must be true

func (*MPSNNOptimizer) GradientRescale ¶

func (o *MPSNNOptimizer) GradientRescale() float32

@property gradientRescale @abstract The gradientRescale at which we apply to incoming gradient values @discussion The default value is 1.0

func (*MPSNNOptimizer) LearningRate ¶

func (o *MPSNNOptimizer) LearningRate() float32

@property learningRate @abstract The learningRate at which we update values @discussion The default value is 1e-3

func (*MPSNNOptimizer) RegularizationScale ¶

func (o *MPSNNOptimizer) RegularizationScale() float32

@property regularizationScale @abstract The regularizationScale at which we apply L1 or L2 regularization, it gets ignored if regularization is None @discussion The default value is 0.0

func (*MPSNNOptimizer) RegularizationType ¶

func (o *MPSNNOptimizer) RegularizationType() MPSNNRegularizationType

@property regularizationType @abstract The regularizationType which we apply. @discussion The default value is MPSRegularizationTypeNone

func (*MPSNNOptimizer) SetApplyGradientClipping ¶

func (o *MPSNNOptimizer) SetApplyGradientClipping(applyGradientClipping bool)

func (*MPSNNOptimizer) SetLearningRate ¶

func (o *MPSNNOptimizer) SetLearningRate(newLearningRate float32)

type MPSNNOptimizerAdam ¶

type MPSNNOptimizerAdam struct {
	MPSNNOptimizer
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnoptimizeradam

func MPSNNOptimizerAdamFromID ¶

func MPSNNOptimizerAdamFromID(id objc.ID) *MPSNNOptimizerAdam

func (*MPSNNOptimizerAdam) Beta1 ¶

func (o *MPSNNOptimizerAdam) Beta1() float64

@property beta1 @abstract The beta1 at which we update values @discussion Default value is 0.9

func (*MPSNNOptimizerAdam) Beta2 ¶

func (o *MPSNNOptimizerAdam) Beta2() float64

@property beta2 @abstract The beta2 at which we update values @discussion Default value is 0.999

func (*MPSNNOptimizerAdam) EncodeToCommandBufferBatchNormalizationGradientStateBatchNormalizationSourceStateInputMomentumVectorsInputVelocityVectorsMaximumVelocityVectorsResultState ¶

func (o *MPSNNOptimizerAdam) EncodeToCommandBufferBatchNormalizationGradientStateBatchNormalizationSourceStateInputMomentumVectorsInputVelocityVectorsMaximumVelocityVectorsResultState(commandBuffer metal.MTLCommandBuffer, batchNormalizationGradientState *MPSCNNBatchNormalizationState, batchNormalizationSourceState *MPSCNNBatchNormalizationState, inputMomentumVectors *foundation.NSArray[*mpscore.MPSVector], inputVelocityVectors *foundation.NSArray[*mpscore.MPSVector], maximumVelocityVectors *foundation.NSArray[*mpscore.MPSVector], resultState *MPSCNNNormalizationGammaAndBetaState)

func (*MPSNNOptimizerAdam) EncodeToCommandBufferBatchNormalizationGradientStateBatchNormalizationSourceStateInputMomentumVectorsInputVelocityVectorsResultState ¶

func (o *MPSNNOptimizerAdam) EncodeToCommandBufferBatchNormalizationGradientStateBatchNormalizationSourceStateInputMomentumVectorsInputVelocityVectorsResultState(commandBuffer metal.MTLCommandBuffer, batchNormalizationGradientState *MPSCNNBatchNormalizationState, batchNormalizationSourceState *MPSCNNBatchNormalizationState, inputMomentumVectors *foundation.NSArray[*mpscore.MPSVector], inputVelocityVectors *foundation.NSArray[*mpscore.MPSVector], resultState *MPSCNNNormalizationGammaAndBetaState)

@abstract Encode an MPSNNOptimizerAdam object to a command buffer to perform out of place update @param commandBuffer A valid MTLCommandBuffer to receive the encoded kernel. @param batchNormalizationGradientState A valid MPSCNNBatchNormalizationState object which specifies the input state with gradients for this update. @param batchNormalizationSourceState A valid MPSCNNBatchNormalizationState object which specifies the input state with original gamma/beta for this update. @param inputMomentumVectors An array MPSVector object which specifies the gradient momentum vectors which will be updated and overwritten. The index 0 corresponds to gamma, index 1 corresponds to beta, array can be of size 1 in which case beta won't be updated @param inputVelocityVectors An array MPSVector object which specifies the gradient velocity vectors which will be updated and overwritten. The index 0 corresponds to gamma, index 1 corresponds to beta, array can be of size 1 in which case beta won't be updated @param resultState A valid MPSCNNNormalizationGammaAndBetaState object which specifies the resultValues state which will be updated and overwritten. @discussion The following operations would be applied t = t + 1 lr[t] = learningRate * sqrt(1 - beta2^t) / (1 - beta1^t) m[t] = beta1 * m[t-1] + (1 - beta1) * g v[t] = beta2 * v[t-1] + (1 - beta2) * (g ^ 2) variable = variable - lr[t] * m[t] / (sqrt(v[t]) + epsilon)

func (*MPSNNOptimizerAdam) EncodeToCommandBufferBatchNormalizationStateInputMomentumVectorsInputVelocityVectorsMaximumVelocityVectorsResultState ¶

func (o *MPSNNOptimizerAdam) EncodeToCommandBufferBatchNormalizationStateInputMomentumVectorsInputVelocityVectorsMaximumVelocityVectorsResultState(commandBuffer metal.MTLCommandBuffer, batchNormalizationState *MPSCNNBatchNormalizationState, inputMomentumVectors *foundation.NSArray[*mpscore.MPSVector], inputVelocityVectors *foundation.NSArray[*mpscore.MPSVector], maximumVelocityVectors *foundation.NSArray[*mpscore.MPSVector], resultState *MPSCNNNormalizationGammaAndBetaState)

func (*MPSNNOptimizerAdam) EncodeToCommandBufferBatchNormalizationStateInputMomentumVectorsInputVelocityVectorsResultState ¶

func (o *MPSNNOptimizerAdam) EncodeToCommandBufferBatchNormalizationStateInputMomentumVectorsInputVelocityVectorsResultState(commandBuffer metal.MTLCommandBuffer, batchNormalizationState *MPSCNNBatchNormalizationState, inputMomentumVectors *foundation.NSArray[*mpscore.MPSVector], inputVelocityVectors *foundation.NSArray[*mpscore.MPSVector], resultState *MPSCNNNormalizationGammaAndBetaState)

@abstract Encode an MPSNNOptimizerAdam object to a command buffer to perform out of place update @param commandBuffer A valid MTLCommandBuffer to receive the encoded kernel. @param batchNormalizationState A valid MPSCNNBatchNormalizationState object which specifies the input state with gradients and original gamma/beta for this update. @param inputMomentumVectors An array MPSVector object which specifies the gradient momentum vectors which will be updated and overwritten. The index 0 corresponds to gamma, index 1 corresponds to beta, array can be of size 1 in which case beta won't be updated @param inputVelocityVectors An array MPSVector object which specifies the gradient velocity vectors which will be updated and overwritten. The index 0 corresponds to gamma, index 1 corresponds to beta, array can be of size 1 in which case beta won't be updated @param resultState A valid MPSCNNNormalizationGammaAndBetaState object which specifies the resultValues state which will be updated and overwritten. @discussion The following operations would be applied t = t + 1 lr[t] = learningRate * sqrt(1 - beta2^t) / (1 - beta1^t) m[t] = beta1 * m[t-1] + (1 - beta1) * g v[t] = beta2 * v[t-1] + (1 - beta2) * (g ^ 2) variable = variable - lr[t] * m[t] / (sqrt(v[t]) + epsilon)

func (*MPSNNOptimizerAdam) EncodeToCommandBufferConvolutionGradientStateConvolutionSourceStateInputMomentumVectorsInputVelocityVectorsMaximumVelocityVectorsResultState ¶

func (o *MPSNNOptimizerAdam) EncodeToCommandBufferConvolutionGradientStateConvolutionSourceStateInputMomentumVectorsInputVelocityVectorsMaximumVelocityVectorsResultState(commandBuffer metal.MTLCommandBuffer, convolutionGradientState *MPSCNNConvolutionGradientState, convolutionSourceState *MPSCNNConvolutionWeightsAndBiasesState, inputMomentumVectors *foundation.NSArray[*mpscore.MPSVector], inputVelocityVectors *foundation.NSArray[*mpscore.MPSVector], maximumVelocityVectors *foundation.NSArray[*mpscore.MPSVector], resultState *MPSCNNConvolutionWeightsAndBiasesState)

func (*MPSNNOptimizerAdam) EncodeToCommandBufferConvolutionGradientStateConvolutionSourceStateInputMomentumVectorsInputVelocityVectorsResultState ¶

func (o *MPSNNOptimizerAdam) EncodeToCommandBufferConvolutionGradientStateConvolutionSourceStateInputMomentumVectorsInputVelocityVectorsResultState(commandBuffer metal.MTLCommandBuffer, convolutionGradientState *MPSCNNConvolutionGradientState, convolutionSourceState *MPSCNNConvolutionWeightsAndBiasesState, inputMomentumVectors *foundation.NSArray[*mpscore.MPSVector], inputVelocityVectors *foundation.NSArray[*mpscore.MPSVector], resultState *MPSCNNConvolutionWeightsAndBiasesState)

@abstract Encode an MPSNNOptimizerAdam object to a command buffer to perform out of place update @param commandBuffer A valid MTLCommandBuffer to receive the encoded kernel. @param convolutionGradientState A valid MPSCNNConvolutionGradientState object which specifies the input state with gradients for this update. @param convolutionSourceState A valid MPSCNNConvolutionWeightsAndBiasesState object which specifies the input state with values to be updated. @param inputMomentumVectors An array MPSVector object which specifies the gradient momentum vectors which will be updated and overwritten. The index 0 corresponds to weights, index 1 corresponds to biases, array can be of size 1 in which case biases won't be updated @param inputVelocityVectors An array MPSVector object which specifies the gradient velocity vectors which will be updated and overwritten. The index 0 corresponds to weights, index 1 corresponds to biases, array can be of size 1 in which case biases won't be updated @param resultState A valid MPSCNNConvolutionWeightsAndBiasesState object which specifies the resultValues state which will be updated and overwritten. @discussion The following operations would be applied t = t + 1 lr[t] = learningRate * sqrt(1 - beta2^t) / (1 - beta1^t) m[t] = beta1 * m[t-1] + (1 - beta1) * g v[t] = beta2 * v[t-1] + (1 - beta2) * (g ^ 2) variable = variable - lr[t] * m[t] / (sqrt(v[t]) + epsilon)

func (*MPSNNOptimizerAdam) EncodeToCommandBufferInputGradientMatrixInputValuesMatrixInputMomentumMatrixInputVelocityMatrixMaximumVelocityMatrixResultValuesMatrix ¶

func (o *MPSNNOptimizerAdam) EncodeToCommandBufferInputGradientMatrixInputValuesMatrixInputMomentumMatrixInputVelocityMatrixMaximumVelocityMatrixResultValuesMatrix(commandBuffer metal.MTLCommandBuffer, inputGradientMatrix *mpscore.MPSMatrix, inputValuesMatrix *mpscore.MPSMatrix, inputMomentumMatrix *mpscore.MPSMatrix, inputVelocityMatrix *mpscore.MPSMatrix, maximumVelocityMatrix *mpscore.MPSMatrix, resultValuesMatrix *mpscore.MPSMatrix)

func (*MPSNNOptimizerAdam) EncodeToCommandBufferInputGradientMatrixInputValuesMatrixInputMomentumMatrixInputVelocityMatrixResultValuesMatrix ¶

func (o *MPSNNOptimizerAdam) EncodeToCommandBufferInputGradientMatrixInputValuesMatrixInputMomentumMatrixInputVelocityMatrixResultValuesMatrix(commandBuffer metal.MTLCommandBuffer, inputGradientMatrix *mpscore.MPSMatrix, inputValuesMatrix *mpscore.MPSMatrix, inputMomentumMatrix *mpscore.MPSMatrix, inputVelocityMatrix *mpscore.MPSMatrix, resultValuesMatrix *mpscore.MPSMatrix)

func (*MPSNNOptimizerAdam) EncodeToCommandBufferInputGradientVectorInputValuesVectorInputMomentumVectorInputVelocityVectorMaximumVelocityVectorResultValuesVector ¶

func (o *MPSNNOptimizerAdam) EncodeToCommandBufferInputGradientVectorInputValuesVectorInputMomentumVectorInputVelocityVectorMaximumVelocityVectorResultValuesVector(commandBuffer metal.MTLCommandBuffer, inputGradientVector *mpscore.MPSVector, inputValuesVector *mpscore.MPSVector, inputMomentumVector *mpscore.MPSVector, inputVelocityVector *mpscore.MPSVector, maximumVelocityVector *mpscore.MPSVector, resultValuesVector *mpscore.MPSVector)

@abstract Encode an AMSGrad variant of MPSNNOptimizerAdam object to a command buffer to perform out of place update @param commandBuffer A valid MTLCommandBuffer to receive the encoded kernel. @param inputGradientVector A valid MPSVector object which specifies the input vector of gradients for this update. @param inputValuesVector A valid MPSVector object which specifies the input vector of values to be updated. @param inputMomentumVector A valid MPSVector object which specifies the gradient momentum vector which will be updated and overwritten. @param inputVelocityVector A valid MPSVector object which specifies the gradient velocity vector which will be updated and overwritten. @param maximumVelocityVector A valid MPSVector object which specifies the maximum velocity vector which will be updated and overwritten. May be nil, if nil then normal Adam optimizer behaviour is followed. @param resultValuesVector A valid MPSCNNConvolutionWeightsAndBiasesState object which specifies the resultValues state which will be updated and overwritten. @discussion The following operations would be applied At update time: t = t + 1 lr[t] = learningRate * sqrt(1 - beta2^t) / (1 - beta1^t) m[t] = beta1 * m[t-1] + (1 - beta1) * g v[t] = beta2 * v[t-1] + (1 - beta2) * (g ^ 2) maxVel[t] = max(maxVel[t-1],v[t]) variable = variable - lr[t] * m[t] / (sqrt(maxVel[t]) + epsilon)

func (*MPSNNOptimizerAdam) EncodeToCommandBufferInputGradientVectorInputValuesVectorInputMomentumVectorInputVelocityVectorResultValuesVector ¶

func (o *MPSNNOptimizerAdam) EncodeToCommandBufferInputGradientVectorInputValuesVectorInputMomentumVectorInputVelocityVectorResultValuesVector(commandBuffer metal.MTLCommandBuffer, inputGradientVector *mpscore.MPSVector, inputValuesVector *mpscore.MPSVector, inputMomentumVector *mpscore.MPSVector, inputVelocityVector *mpscore.MPSVector, resultValuesVector *mpscore.MPSVector)

@abstract Encode an MPSNNOptimizerAdam object to a command buffer to perform out of place update @param commandBuffer A valid MTLCommandBuffer to receive the encoded kernel. @param inputGradientVector A valid MPSVector object which specifies the input vector of gradients for this update. @param inputValuesVector A valid MPSVector object which specifies the input vector of values to be updated. @param inputMomentumVector A valid MPSVector object which specifies the gradient momentum vector which will be updated and overwritten. @param inputVelocityVector A valid MPSVector object which specifies the gradient velocity vector which will be updated and overwritten. @param resultValuesVector A valid MPSVector object which specifies the resultValues vector which will be updated and overwritten. @discussion The following operations would be applied t = t + 1 lr[t] = learningRate * sqrt(1 - beta2^t) / (1 - beta1^t) m[t] = beta1 * m[t-1] + (1 - beta1) * g v[t] = beta2 * v[t-1] + (1 - beta2) * (g ^ 2) variable = variable - lr[t] * m[t] / (sqrt(v[t]) + epsilon)

func (*MPSNNOptimizerAdam) Epsilon ¶

func (o *MPSNNOptimizerAdam) Epsilon() float32

@property epsilon @abstract The epsilon at which we update values @discussion This value is usually used to ensure to avoid divide by 0, default value is 1e-8

func (*MPSNNOptimizerAdam) InitWithDeviceBeta1Beta2EpsilonTimeStepOptimizerDescriptor ¶

func (o *MPSNNOptimizerAdam) InitWithDeviceBeta1Beta2EpsilonTimeStepOptimizerDescriptor(device metal.MTLDevice, beta1 float64, beta2 float64, epsilon float32, timeStep uint, optimizerDescriptor *MPSNNOptimizerDescriptor) *MPSNNOptimizerAdam

@abstract Full initialization for the adam update @param device The device on which the kernel will execute. @param beta1 The beta1 to update values @param beta2 The beta2 to update values @param epsilon The epsilon at which we update values @param timeStep The timeStep at which values will start updating @param optimizerDescriptor The optimizerDescriptor which will have a bunch of properties to be applied @return A valid MPSNNOptimizerAdam object or nil, if failure.

func (*MPSNNOptimizerAdam) InitWithDeviceLearningRate ¶

func (o *MPSNNOptimizerAdam) InitWithDeviceLearningRate(device metal.MTLDevice, learningRate float32) *MPSNNOptimizerAdam

@abstract Convenience initialization for the adam update @param device The device on which the kernel will execute. @param learningRate The learningRate at which we will update values @return A valid MPSNNOptimizerAdam object or nil, if failure.

func (*MPSNNOptimizerAdam) SetTimeStep ¶

func (o *MPSNNOptimizerAdam) SetTimeStep(timeStep uint)

func (*MPSNNOptimizerAdam) TimeStep ¶

func (o *MPSNNOptimizerAdam) TimeStep() uint

@property timeStep @abstract Current timeStep for the update, number of times update has occurred

type MPSNNOptimizerDescriptor ¶

type MPSNNOptimizerDescriptor struct {
	foundation.NSObject
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnoptimizerdescriptor

func MPSNNOptimizerDescriptorFromID ¶

func MPSNNOptimizerDescriptorFromID(id objc.ID) *MPSNNOptimizerDescriptor

func MPSNNOptimizerDescriptorOptimizerDescriptorWithLearningRateGradientRescaleApplyGradientClippingGradientClipMaxGradientClipMinRegularizationTypeRegularizationScale ¶

func MPSNNOptimizerDescriptorOptimizerDescriptorWithLearningRateGradientRescaleApplyGradientClippingGradientClipMaxGradientClipMinRegularizationTypeRegularizationScale(learningRate float32, gradientRescale float32, applyGradientClipping bool, gradientClipMax float32, gradientClipMin float32, regularizationType MPSNNRegularizationType, regularizationScale float32) *MPSNNOptimizerDescriptor

func MPSNNOptimizerDescriptorOptimizerDescriptorWithLearningRateGradientRescaleRegularizationTypeRegularizationScale ¶

func MPSNNOptimizerDescriptorOptimizerDescriptorWithLearningRateGradientRescaleRegularizationTypeRegularizationScale(learningRate float32, gradientRescale float32, regularizationType MPSNNRegularizationType, regularizationScale float32) *MPSNNOptimizerDescriptor

func (*MPSNNOptimizerDescriptor) ApplyGradientClipping ¶

func (o *MPSNNOptimizerDescriptor) ApplyGradientClipping() bool

@property applyGradientClipping @abstract A bool which decides if gradient will be clipped @discussion The default value is NO

func (*MPSNNOptimizerDescriptor) GradientClipMax ¶

func (o *MPSNNOptimizerDescriptor) GradientClipMax() float32

@property gradientClipMax @abstract The maximum value at which incoming gradient will be clipped before rescaling, applyGradientClipping must be true

func (*MPSNNOptimizerDescriptor) GradientClipMin ¶

func (o *MPSNNOptimizerDescriptor) GradientClipMin() float32

@property gradientClipMin @abstract The minimum value at which incoming gradient will be clipped before rescaling, applyGradientClipping must be true

func (*MPSNNOptimizerDescriptor) GradientRescale ¶

func (o *MPSNNOptimizerDescriptor) GradientRescale() float32

@property gradientRescale @abstract The gradientRescale at which we apply to incoming gradient values @discussion The default value is 1.0

func (*MPSNNOptimizerDescriptor) InitWithLearningRateGradientRescaleApplyGradientClippingGradientClipMaxGradientClipMinRegularizationTypeRegularizationScale ¶

func (o *MPSNNOptimizerDescriptor) InitWithLearningRateGradientRescaleApplyGradientClippingGradientClipMaxGradientClipMinRegularizationTypeRegularizationScale(learningRate float32, gradientRescale float32, applyGradientClipping bool, gradientClipMax float32, gradientClipMin float32, regularizationType MPSNNRegularizationType, regularizationScale float32) *MPSNNOptimizerDescriptor

func (*MPSNNOptimizerDescriptor) InitWithLearningRateGradientRescaleRegularizationTypeRegularizationScale ¶

func (o *MPSNNOptimizerDescriptor) InitWithLearningRateGradientRescaleRegularizationTypeRegularizationScale(learningRate float32, gradientRescale float32, regularizationType MPSNNRegularizationType, regularizationScale float32) *MPSNNOptimizerDescriptor

func (*MPSNNOptimizerDescriptor) LearningRate ¶

func (o *MPSNNOptimizerDescriptor) LearningRate() float32

@property learningRate @abstract The learningRate at which we update values @discussion The default value is 0.001f

func (*MPSNNOptimizerDescriptor) RegularizationScale ¶

func (o *MPSNNOptimizerDescriptor) RegularizationScale() float32

@property regularizationScale @abstract The regularizationScale at which we apply L1 or L2 regularization, it gets ignored if regularization is None @discussion The default value is 0.0

func (*MPSNNOptimizerDescriptor) RegularizationType ¶

func (o *MPSNNOptimizerDescriptor) RegularizationType() MPSNNRegularizationType

@property regularizationType @abstract The regularizationType which we apply. @discussion The default value is MPSRegularizationTypeNone

func (*MPSNNOptimizerDescriptor) SetApplyGradientClipping ¶

func (o *MPSNNOptimizerDescriptor) SetApplyGradientClipping(applyGradientClipping bool)

func (*MPSNNOptimizerDescriptor) SetGradientClipMax ¶

func (o *MPSNNOptimizerDescriptor) SetGradientClipMax(gradientClipMax float32)

func (*MPSNNOptimizerDescriptor) SetGradientClipMin ¶

func (o *MPSNNOptimizerDescriptor) SetGradientClipMin(gradientClipMin float32)

func (*MPSNNOptimizerDescriptor) SetGradientRescale ¶

func (o *MPSNNOptimizerDescriptor) SetGradientRescale(gradientRescale float32)

func (*MPSNNOptimizerDescriptor) SetLearningRate ¶

func (o *MPSNNOptimizerDescriptor) SetLearningRate(learningRate float32)

func (*MPSNNOptimizerDescriptor) SetRegularizationScale ¶

func (o *MPSNNOptimizerDescriptor) SetRegularizationScale(regularizationScale float32)

func (*MPSNNOptimizerDescriptor) SetRegularizationType ¶

func (o *MPSNNOptimizerDescriptor) SetRegularizationType(regularizationType MPSNNRegularizationType)

type MPSNNOptimizerRMSProp ¶

type MPSNNOptimizerRMSProp struct {
	MPSNNOptimizer
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnoptimizerrmsprop

func MPSNNOptimizerRMSPropFromID ¶

func MPSNNOptimizerRMSPropFromID(id objc.ID) *MPSNNOptimizerRMSProp

func (*MPSNNOptimizerRMSProp) Decay ¶

func (o *MPSNNOptimizerRMSProp) Decay() float64

@property decay @abstract The decay at which we update sumOfSquares @discussion Default value is 0.9

func (*MPSNNOptimizerRMSProp) EncodeToCommandBufferBatchNormalizationGradientStateBatchNormalizationSourceStateInputSumOfSquaresVectorsResultState ¶

func (o *MPSNNOptimizerRMSProp) EncodeToCommandBufferBatchNormalizationGradientStateBatchNormalizationSourceStateInputSumOfSquaresVectorsResultState(commandBuffer metal.MTLCommandBuffer, batchNormalizationGradientState *MPSCNNBatchNormalizationState, batchNormalizationSourceState *MPSCNNBatchNormalizationState, inputSumOfSquaresVectors *foundation.NSArray[*mpscore.MPSVector], resultState *MPSCNNNormalizationGammaAndBetaState)

@abstract Encode an MPSNNOptimizerRMSProp object to a command buffer to perform out of place update @param commandBuffer A valid MTLCommandBuffer to receive the encoded kernel. @param batchNormalizationGradientState A valid MPSCNNBatchNormalizationState object which specifies the input state with gradients for this update. @param batchNormalizationSourceState A valid MPSCNNBatchNormalizationState object which specifies the input state with original gamma/beta for this update. @param inputSumOfSquaresVectors An array MPSVector object which specifies the gradient sumOfSquares vectors which will be updated and overwritten. The index 0 corresponds to gamma, index 1 corresponds to beta, array can be of size 1 in which case beta won't be updated @param resultState A valid MPSCNNNormalizationGammaAndBetaState object which specifies the resultValues state which will be updated and overwritten. @discussion The following operations would be applied s[t] = decay * s[t-1] + (1 - decay) * (g ^ 2) variable = variable - learningRate * g / (sqrt(s[t]) + epsilon) where, g is gradient of error wrt variable s[t] is weighted sum of squares of gradients

func (*MPSNNOptimizerRMSProp) EncodeToCommandBufferBatchNormalizationStateInputSumOfSquaresVectorsResultState ¶

func (o *MPSNNOptimizerRMSProp) EncodeToCommandBufferBatchNormalizationStateInputSumOfSquaresVectorsResultState(commandBuffer metal.MTLCommandBuffer, batchNormalizationState *MPSCNNBatchNormalizationState, inputSumOfSquaresVectors *foundation.NSArray[*mpscore.MPSVector], resultState *MPSCNNNormalizationGammaAndBetaState)

@abstract Encode an MPSNNOptimizerRMSProp object to a command buffer to perform out of place update @param commandBuffer A valid MTLCommandBuffer to receive the encoded kernel. @param batchNormalizationState A valid MPSCNNBatchNormalizationState object which specifies the input state with gradients and original gamma/beta for this update. @param inputSumOfSquaresVectors An array MPSVector object which specifies the gradient sumOfSquares vectors which will be updated and overwritten. The index 0 corresponds to gamma, index 1 corresponds to beta, array can be of size 1 in which case beta won't be updated @param resultState A valid MPSCNNNormalizationGammaAndBetaState object which specifies the resultValues state which will be updated and overwritten. @discussion The following operations would be applied s[t] = decay * s[t-1] + (1 - decay) * (g ^ 2) variable = variable - learningRate * g / (sqrt(s[t]) + epsilon) where, g is gradient of error wrt variable s[t] is weighted sum of squares of gradients

func (*MPSNNOptimizerRMSProp) EncodeToCommandBufferConvolutionGradientStateConvolutionSourceStateInputSumOfSquaresVectorsResultState ¶

func (o *MPSNNOptimizerRMSProp) EncodeToCommandBufferConvolutionGradientStateConvolutionSourceStateInputSumOfSquaresVectorsResultState(commandBuffer metal.MTLCommandBuffer, convolutionGradientState *MPSCNNConvolutionGradientState, convolutionSourceState *MPSCNNConvolutionWeightsAndBiasesState, inputSumOfSquaresVectors *foundation.NSArray[*mpscore.MPSVector], resultState *MPSCNNConvolutionWeightsAndBiasesState)

@abstract Encode an MPSNNOptimizerRMSProp object to a command buffer to perform out of place update @param commandBuffer A valid MTLCommandBuffer to receive the encoded kernel. @param convolutionGradientState A valid MPSCNNConvolutionGradientState object which specifies the input state with gradients for this update. @param convolutionSourceState A valid MPSCNNConvolutionWeightsAndBiasesState object which specifies the input state with values to be updated. @param inputSumOfSquaresVectors An array MPSVector object which specifies the gradient sumOfSquares vectors which will be updated and overwritten. The index 0 corresponds to weights, index 1 corresponds to biases, array can be of size 1 in which case biases won't be updated @param resultState A valid MPSCNNConvolutionWeightsAndBiasesState object which specifies the resultValues state which will be updated and overwritten. @discussion The following operations would be applied s[t] = decay * s[t-1] + (1 - decay) * (g ^ 2) variable = variable - learningRate * g / (sqrt(s[t]) + epsilon) where, g is gradient of error wrt variable s[t] is weighted sum of squares of gradients

func (*MPSNNOptimizerRMSProp) EncodeToCommandBufferInputGradientMatrixInputValuesMatrixInputSumOfSquaresMatrixResultValuesMatrix ¶

func (o *MPSNNOptimizerRMSProp) EncodeToCommandBufferInputGradientMatrixInputValuesMatrixInputSumOfSquaresMatrixResultValuesMatrix(commandBuffer metal.MTLCommandBuffer, inputGradientMatrix *mpscore.MPSMatrix, inputValuesMatrix *mpscore.MPSMatrix, inputSumOfSquaresMatrix *mpscore.MPSMatrix, resultValuesMatrix *mpscore.MPSMatrix)

func (*MPSNNOptimizerRMSProp) EncodeToCommandBufferInputGradientVectorInputValuesVectorInputSumOfSquaresVectorResultValuesVector ¶

func (o *MPSNNOptimizerRMSProp) EncodeToCommandBufferInputGradientVectorInputValuesVectorInputSumOfSquaresVectorResultValuesVector(commandBuffer metal.MTLCommandBuffer, inputGradientVector *mpscore.MPSVector, inputValuesVector *mpscore.MPSVector, inputSumOfSquaresVector *mpscore.MPSVector, resultValuesVector *mpscore.MPSVector)

@abstract Encode an MPSNNOptimizerRMSProp object to a command buffer to perform out of place update @param commandBuffer A valid MTLCommandBuffer to receive the encoded kernel. @param inputGradientVector A valid MPSVector object which specifies the input vector of gradients for this update. @param inputValuesVector A valid MPSVector object which specifies the input vector of values to be updated. @param inputSumOfSquaresVector A valid MPSVector object which specifies the gradient velocity vector which will be updated and overwritten. @param resultValuesVector A valid MPSVector object which specifies the resultValues vector which will be updated and overwritten. @discussion The following operations would be applied s[t] = decay * s[t-1] + (1 - decay) * (g ^ 2) variable = variable - learningRate * g / (sqrt(s[t]) + epsilon) where, g is gradient of error wrt variable s[t] is weighted sum of squares of gradients

func (*MPSNNOptimizerRMSProp) Epsilon ¶

func (o *MPSNNOptimizerRMSProp) Epsilon() float32

@property epsilon @abstract The epsilon at which we update values @discussion This value is usually used to ensure to avoid divide by 0, default value is 1e-8

func (*MPSNNOptimizerRMSProp) InitWithDeviceDecayEpsilonOptimizerDescriptor ¶

func (o *MPSNNOptimizerRMSProp) InitWithDeviceDecayEpsilonOptimizerDescriptor(device metal.MTLDevice, decay float64, epsilon float32, optimizerDescriptor *MPSNNOptimizerDescriptor) *MPSNNOptimizerRMSProp

@abstract Full initialization for the rmsProp update @param device The device on which the kernel will execute. @param decay The decay to update sumOfSquares @param epsilon The epsilon which will be applied @param optimizerDescriptor The optimizerDescriptor which will have a bunch of properties to be applied @return A valid MPSNNOptimizerRMSProp object or nil, if failure.

func (*MPSNNOptimizerRMSProp) InitWithDeviceLearningRate ¶

func (o *MPSNNOptimizerRMSProp) InitWithDeviceLearningRate(device metal.MTLDevice, learningRate float32) *MPSNNOptimizerRMSProp

@abstract Convenience initialization for the RMSProp update @param device The device on which the kernel will execute. @param learningRate The learningRate which will be applied @return A valid MPSNNOptimizerRMSProp object or nil, if failure.

type MPSNNOptimizerStochasticGradientDescent ¶

type MPSNNOptimizerStochasticGradientDescent struct {
	MPSNNOptimizer
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnoptimizerstochasticgradientdescent

func MPSNNOptimizerStochasticGradientDescentFromID ¶

func MPSNNOptimizerStochasticGradientDescentFromID(id objc.ID) *MPSNNOptimizerStochasticGradientDescent

func (*MPSNNOptimizerStochasticGradientDescent) EncodeToCommandBufferBatchNormalizationGradientStateBatchNormalizationSourceStateInputMomentumVectorsResultState ¶

func (o *MPSNNOptimizerStochasticGradientDescent) EncodeToCommandBufferBatchNormalizationGradientStateBatchNormalizationSourceStateInputMomentumVectorsResultState(commandBuffer metal.MTLCommandBuffer, batchNormalizationGradientState *MPSCNNBatchNormalizationState, batchNormalizationSourceState *MPSCNNBatchNormalizationState, inputMomentumVectors *foundation.NSArray[*mpscore.MPSVector], resultState *MPSCNNNormalizationGammaAndBetaState)

@abstract Encode an MPSNNOptimizerStochasticGradientDescent object to a command buffer to perform out of place update @param commandBuffer A valid MTLCommandBuffer to receive the encoded kernel. @param batchNormalizationGradientState A valid MPSCNNBatchNormalizationState object which specifies the input state with gradients for this update. @param batchNormalizationSourceState A valid MPSCNNBatchNormalizationState object which specifies the input state with original gamma/beta for this update. @param inputMomentumVectors An array MPSVector object which specifies the gradient momentum vectors which will be updated and overwritten. The index 0 corresponds to gamma, index 1 corresponds to beta, array can be of size 1 in which case beta won't be updated @param resultState A valid MPSCNNNormalizationGammaAndBetaState object which specifies the resultValues state which will be updated and overwritten. @discussion The following operations would be applied useNesterov == NO: m[t] = momentumScale * m[t-1] + learningRate * g variable = variable - m[t] useNesterov == YES: m[t] = momentumScale * m[t-1] + g variable = variable - (learningRate * (g + m[t] * momentumScale)) inputMomentumVector == nil variable = variable - (learningRate * g) where, g is gradient of error wrt variable m[t] is momentum of gradients it is a state we keep updating every update iteration

func (*MPSNNOptimizerStochasticGradientDescent) EncodeToCommandBufferBatchNormalizationStateInputMomentumVectorsResultState ¶

func (o *MPSNNOptimizerStochasticGradientDescent) EncodeToCommandBufferBatchNormalizationStateInputMomentumVectorsResultState(commandBuffer metal.MTLCommandBuffer, batchNormalizationState *MPSCNNBatchNormalizationState, inputMomentumVectors *foundation.NSArray[*mpscore.MPSVector], resultState *MPSCNNNormalizationGammaAndBetaState)

@abstract Encode an MPSNNOptimizerStochasticGradientDescent object to a command buffer to perform out of place update @param commandBuffer A valid MTLCommandBuffer to receive the encoded kernel. @param batchNormalizationState A valid MPSCNNBatchNormalizationState object which specifies the input state with gradients and original gamma/beta for this update. @param inputMomentumVectors An array MPSVector object which specifies the gradient momentum vectors which will be updated and overwritten. The index 0 corresponds to gamma, index 1 corresponds to beta, array can be of size 1 in which case beta won't be updated @param resultState A valid MPSCNNNormalizationGammaAndBetaState object which specifies the resultValues state which will be updated and overwritten. @discussion The following operations would be applied useNesterov == NO: m[t] = momentumScale * m[t-1] + learningRate * g variable = variable - m[t] useNesterov == YES: m[t] = momentumScale * m[t-1] + g variable = variable - (learningRate * (g + m[t] * momentumScale)) inputMomentumVector == nil variable = variable - (learningRate * g) where, g is gradient of error wrt variable m[t] is momentum of gradients it is a state we keep updating every update iteration

func (*MPSNNOptimizerStochasticGradientDescent) EncodeToCommandBufferConvolutionGradientStateConvolutionSourceStateInputMomentumVectorsResultState ¶

func (o *MPSNNOptimizerStochasticGradientDescent) EncodeToCommandBufferConvolutionGradientStateConvolutionSourceStateInputMomentumVectorsResultState(commandBuffer metal.MTLCommandBuffer, convolutionGradientState *MPSCNNConvolutionGradientState, convolutionSourceState *MPSCNNConvolutionWeightsAndBiasesState, inputMomentumVectors *foundation.NSArray[*mpscore.MPSVector], resultState *MPSCNNConvolutionWeightsAndBiasesState)

@abstract Encode an MPSNNOptimizerStochasticGradientDescent object to a command buffer to perform out of place update @param commandBuffer A valid MTLCommandBuffer to receive the encoded kernel. @param convolutionGradientState A valid MPSCNNConvolutionGradientState object which specifies the input state with gradients for this update. @param convolutionSourceState A valid MPSCNNConvolutionWeightsAndBiasesState object which specifies the input state with values to be updated. @param inputMomentumVectors An array MPSVector object which specifies the gradient momentum vectors which will be updated and overwritten. The index 0 corresponds to weights, index 1 corresponds to biases, array can be of size 1 in which case biases won't be updated @param resultState A valid MPSCNNConvolutionWeightsAndBiasesState object which specifies the resultValues state which will be updated and overwritten. @discussion The following operations would be applied useNesterov == NO: m[t] = momentumScale * m[t-1] + learningRate * g variable = variable - m[t] useNesterov == YES: m[t] = momentumScale * m[t-1] + g variable = variable - (learningRate * (g + m[t] * momentumScale)) inputMomentumVector == nil variable = variable - (learningRate * g) where, g is gradient of error wrt variable m[t] is momentum of gradients it is a state we keep updating every update iteration

func (*MPSNNOptimizerStochasticGradientDescent) EncodeToCommandBufferInputGradientMatrixInputValuesMatrixInputMomentumMatrixResultValuesMatrix ¶

func (o *MPSNNOptimizerStochasticGradientDescent) EncodeToCommandBufferInputGradientMatrixInputValuesMatrixInputMomentumMatrixResultValuesMatrix(commandBuffer metal.MTLCommandBuffer, inputGradientMatrix *mpscore.MPSMatrix, inputValuesMatrix *mpscore.MPSMatrix, inputMomentumMatrix *mpscore.MPSMatrix, resultValuesMatrix *mpscore.MPSMatrix)

func (*MPSNNOptimizerStochasticGradientDescent) EncodeToCommandBufferInputGradientVectorInputValuesVectorInputMomentumVectorResultValuesVector ¶

func (o *MPSNNOptimizerStochasticGradientDescent) EncodeToCommandBufferInputGradientVectorInputValuesVectorInputMomentumVectorResultValuesVector(commandBuffer metal.MTLCommandBuffer, inputGradientVector *mpscore.MPSVector, inputValuesVector *mpscore.MPSVector, inputMomentumVector *mpscore.MPSVector, resultValuesVector *mpscore.MPSVector)

@abstract Encode an MPSNNOptimizerStochasticGradientDescent object to a command buffer to perform out of place update @param commandBuffer A valid MTLCommandBuffer to receive the encoded kernel. @param inputGradientVector A valid MPSVector object which specifies the input vector of gradients for this update. @param inputValuesVector A valid MPSVector object which specifies the input vector of values to be updated. @param inputMomentumVector A valid MPSVector object which specifies the gradient momentum vector which will be updated and overwritten. @param resultValuesVector A valid MPSVector object which specifies the resultValues vector which will be updated and overwritten. @discussion The following operations would be applied useNesterov == NO: m[t] = momentumScale * m[t-1] + learningRate * g variable = variable - m[t] useNesterov == YES: m[t] = momentumScale * m[t-1] + g variable = variable - (learningRate * (g + m[t] * momentumScale)) inputMomentumVector == nil variable = variable - (learningRate * g) where, g is gradient of error wrt variable m[t] is momentum of gradients it is a state we keep updating every update iteration

func (*MPSNNOptimizerStochasticGradientDescent) InitWithDeviceLearningRate ¶

func (o *MPSNNOptimizerStochasticGradientDescent) InitWithDeviceLearningRate(device metal.MTLDevice, learningRate float32) *MPSNNOptimizerStochasticGradientDescent

@abstract Convenience initialization for the momentum update @param device The device on which the kernel will execute. @param learningRate The learningRate which will be applied @return A valid MPSNNOptimizerStochasticGradientDescent object or nil, if failure.

func (*MPSNNOptimizerStochasticGradientDescent) InitWithDeviceMomentumScaleUseNesterovMomentumOptimizerDescriptor ¶

func (o *MPSNNOptimizerStochasticGradientDescent) InitWithDeviceMomentumScaleUseNesterovMomentumOptimizerDescriptor(device metal.MTLDevice, momentumScale float32, useNesterovMomentum bool, optimizerDescriptor *MPSNNOptimizerDescriptor) *MPSNNOptimizerStochasticGradientDescent

@abstract Full initialization for the momentum update @param device The device on which the kernel will execute. @param momentumScale The momentumScale to update momentum for values array @param useNesterovMomentum Use the Nesterov style momentum update @param optimizerDescriptor The optimizerDescriptor which will have a bunch of properties to be applied @return A valid MPSNNOptimizerMomentum object or nil, if failure.

func (*MPSNNOptimizerStochasticGradientDescent) InitWithDeviceMomentumScaleUseNestrovMomentumOptimizerDescriptor ¶

func (o *MPSNNOptimizerStochasticGradientDescent) InitWithDeviceMomentumScaleUseNestrovMomentumOptimizerDescriptor(device metal.MTLDevice, momentumScale float32, useNestrovMomentum bool, optimizerDescriptor *MPSNNOptimizerDescriptor) *MPSNNOptimizerStochasticGradientDescent

func (*MPSNNOptimizerStochasticGradientDescent) MomentumScale ¶

@property momentumScale @abstract The momentumScale at which we update momentum for values array @discussion Default value is 0.0

func (*MPSNNOptimizerStochasticGradientDescent) UseNesterovMomentum ¶

func (o *MPSNNOptimizerStochasticGradientDescent) UseNesterovMomentum() bool

@property useNesterovMomentum @abstract Nesterov momentum is considered an improvement on the usual momentum update @discussion Default value is NO @note Maps to old useNestrovMomentum property

func (*MPSNNOptimizerStochasticGradientDescent) UseNestrovMomentum ¶

func (o *MPSNNOptimizerStochasticGradientDescent) UseNestrovMomentum() bool

type MPSNNPad ¶

type MPSNNPad struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnpad

func MPSNNPadFromID ¶

func MPSNNPadFromID(id objc.ID) *MPSNNPad

func (*MPSNNPad) FillValue ¶

func (o *MPSNNPad) FillValue() float32

@property fillValue @abstract Determines the constant value to apply when using @ref MPSImageEdgeModeConstant. Default: 0.0f. NOTE: this value is ignored if the filter is initialized with a per-channel fill value using @ref initWithDevice:paddingSizeBefore:paddingSizeAfter:fillValueArray:.

func (*MPSNNPad) InitWithCoderDevice ¶

func (o *MPSNNPad) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNPad

func (*MPSNNPad) InitWithDevice ¶

func (o *MPSNNPad) InitWithDevice(device metal.MTLDevice) *MPSNNPad

func (*MPSNNPad) InitWithDevicePaddingSizeBeforePaddingSizeAfter ¶

func (o *MPSNNPad) InitWithDevicePaddingSizeBeforePaddingSizeAfter(device metal.MTLDevice, paddingSizeBefore mpscore.MPSImageCoordinate, paddingSizeAfter mpscore.MPSImageCoordinate) *MPSNNPad

func (*MPSNNPad) InitWithDevicePaddingSizeBeforePaddingSizeAfterFillValueArray ¶

func (o *MPSNNPad) InitWithDevicePaddingSizeBeforePaddingSizeAfterFillValueArray(device metal.MTLDevice, paddingSizeBefore mpscore.MPSImageCoordinate, paddingSizeAfter mpscore.MPSImageCoordinate, fillValueArray *foundation.NSData) *MPSNNPad

func (*MPSNNPad) PaddingSizeAfter ¶

func (o *MPSNNPad) PaddingSizeAfter() mpscore.MPSImageCoordinate

@property paddingSizeAfter @abstract This property is used for automatically sizing the destination image for the function @ref destinationImageDescriptorForSourceImages:sourceStates:. Defines how much padding to assign on the right, bottom and higher feature channel indices of the image. NOTE: the x and y coordinates of this property are only used through @ref destinationImageDescriptorForSourceImages:sourceStates:, since the clipRect and offset together define the padding sizes in those directions, but the 'channel' size defines the amount of padding to be applied in the feature channel dimension after source feature channel index determined by the sum of @ref sourceFeatureChannelOffset and @ref sourceFeatureChannelMaxCount, naturally clipped to fit the feature channels in the provided source image. Default: { 0, 0, 0 }

func (*MPSNNPad) PaddingSizeBefore ¶

func (o *MPSNNPad) PaddingSizeBefore() mpscore.MPSImageCoordinate

@property paddingSizeBefore @abstract This property is used for automatically sizing the destination image for the function @ref destinationImageDescriptorForSourceImages:sourceStates:. Defines how much padding to assign on the left, top and smaller feature channel indices of the image. NOTE: the x and y coordinates of this property are only used through @ref destinationImageDescriptorForSourceImages:sourceStates:, since the clipRect and offset together define the padding sizes in those directions, but the 'channel' size defines the amount of padding to be applied in the feature channel dimension, before the feature channels starting from feature channel index @ref sourceFeatureChannelOffset. Default: { 0, 0, 0 }

func (*MPSNNPad) SetFillValue ¶

func (o *MPSNNPad) SetFillValue(fillValue float32)

func (*MPSNNPad) SetPaddingSizeAfter ¶

func (o *MPSNNPad) SetPaddingSizeAfter(paddingSizeAfter mpscore.MPSImageCoordinate)

func (*MPSNNPad) SetPaddingSizeBefore ¶

func (o *MPSNNPad) SetPaddingSizeBefore(paddingSizeBefore mpscore.MPSImageCoordinate)

type MPSNNPadGradient ¶

type MPSNNPadGradient struct {
	MPSCNNGradientKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnpadgradient

func MPSNNPadGradientFromID ¶

func MPSNNPadGradientFromID(id objc.ID) *MPSNNPadGradient

func (*MPSNNPadGradient) InitWithCoderDevice ¶

func (o *MPSNNPadGradient) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNPadGradient

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSNNPadGradient. @param device The MTLDevice on which to make the MPSNNPadGradient. @return A new MPSNNPadGradient object, or nil if failure.

func (*MPSNNPadGradient) InitWithDevice ¶

func (o *MPSNNPadGradient) InitWithDevice(device metal.MTLDevice) *MPSNNPadGradient

@abstract Initializes a MPSNNPadGradient filter @param device The MTLDevice on which this filter will be used @return A valid MPSNNPadGradient object or nil, if failure.

type MPSNNPadGradientNode ¶

type MPSNNPadGradientNode struct {
	MPSNNGradientFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnpadgradientnode

func MPSNNPadGradientNodeFromID ¶

func MPSNNPadGradientNodeFromID(id objc.ID) *MPSNNPadGradientNode

func MPSNNPadGradientNodeNodeWithSourceGradientSourceImageGradientState ¶

func MPSNNPadGradientNodeNodeWithSourceGradientSourceImageGradientState(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSNNPadGradientNode

@abstract A node to represent the gradient of a padding node. @param sourceGradient The input gradient from the 'downstream' gradient filter. @param sourceImage The input image from the forward padding node. @return A MPSNNPadGradientNode

func (*MPSNNPadGradientNode) InitWithSourceGradientSourceImageGradientState ¶

func (o *MPSNNPadGradientNode) InitWithSourceGradientSourceImageGradientState(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSNNPadGradientNode

@abstract A node to represent the gradient of a padding node. @param sourceGradient The input gradient from the 'downstream' gradient filter. @param sourceImage The input image from the forward reshape node. @return A MPSNNPadGradientNode

type MPSNNPadNode ¶

type MPSNNPadNode struct {
	MPSNNFilterNode
}

@class MPSNNPadNode @abstract A node for a MPSNNPad kernel @discussion You should not use this node to zero pad your data in the XY-plane. This node copies the input image and therefore should only be used in special circumstances where the normal padding operation, defined for most filters and nodes through @ref MPSNNPadding, cannot achieve the necessary padding. Therefore use this node only when you need one of the special edge modes: @ref MPSImageEdgeModeConstant, @ref MPSImageEdgeModeMirror, @ref MPSImageEdgeModeMirrorWithEdge or, if you need padding in the feature-channel dimesion. In other cases use to @ref MPSNNPadding to get best performance.

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnpadnode

func MPSNNPadNodeFromID ¶

func MPSNNPadNodeFromID(id objc.ID) *MPSNNPadNode

func MPSNNPadNodeNodeWithSourcePaddingSizeBeforePaddingSizeAfterEdgeMode ¶

func MPSNNPadNodeNodeWithSourcePaddingSizeBeforePaddingSizeAfterEdgeMode(source *MPSNNImageNode, paddingSizeBefore mpscore.MPSImageCoordinate, paddingSizeAfter mpscore.MPSImageCoordinate, edgeMode mpscore.MPSImageEdgeMode) *MPSNNPadNode

@abstract Init a node representing a autoreleased MPSNNPad kernel @param source The MPSNNImageNode representing the source MPSImage for the filter @param paddingSizeBefore The amount of padding to apply before the image in each dimension. @param paddingSizeAfter The amount of padding to apply after the image in each dimension. @param edgeMode The @ref MPSImageEdgeMode for the padding node - Note that for now the pad-node and its gradient are the only nodes that support the extended edge-modes, ie. the ones beyond MPSImageEdgeModeClamp. @return A new MPSNNFilter node for a MPSNNPad kernel.

func (*MPSNNPadNode) FillValue ¶

func (o *MPSNNPadNode) FillValue() float32

@property fillValue @abstract Determines the constant value to apply when using @ref MPSImageEdgeModeConstant. Default: 0.0f.

func (*MPSNNPadNode) InitWithSourcePaddingSizeBeforePaddingSizeAfterEdgeMode ¶

func (o *MPSNNPadNode) InitWithSourcePaddingSizeBeforePaddingSizeAfterEdgeMode(source *MPSNNImageNode, paddingSizeBefore mpscore.MPSImageCoordinate, paddingSizeAfter mpscore.MPSImageCoordinate, edgeMode mpscore.MPSImageEdgeMode) *MPSNNPadNode

@abstract Init a node representing a MPSNNPad kernel @param source The MPSNNImageNode representing the source MPSImage for the filter @param paddingSizeBefore The amount of padding to apply before the image in each dimension. @param paddingSizeAfter The amount of padding to apply after the image in each dimension. @param edgeMode The @ref MPSImageEdgeMode for the padding node - Note that for now the pad-node and its gradient are the only nodes that support the extended edge-modes, ie. the ones beyond MPSImageEdgeModeClamp. @return A new MPSNNFilter node for a MPSNNPad kernel.

func (*MPSNNPadNode) SetFillValue ¶

func (o *MPSNNPadNode) SetFillValue(fillValue float32)

type MPSNNPadding ¶

type MPSNNPadding interface {
	foundation.NSSecureCoding
	PaddingMethod() MPSNNPaddingMethod
}

MPSNNPadding wraps the ObjC protocol MPSNNPadding.

type MPSNNPaddingMethod ¶

type MPSNNPaddingMethod uint64
const (
	MPSNNPaddingMethodAlignCentered                MPSNNPaddingMethod = 0
	MPSNNPaddingMethodAlignTopLeft                 MPSNNPaddingMethod = 1
	MPSNNPaddingMethodAlignBottomRight             MPSNNPaddingMethod = 2
	MPSNNPaddingMethodAlign_reserved               MPSNNPaddingMethod = 3
	MPSNNPaddingMethodAlignMask                    MPSNNPaddingMethod = 3
	MPSNNPaddingMethodAddRemainderToTopLeft        MPSNNPaddingMethod = 0
	MPSNNPaddingMethodAddRemainderToTopRight       MPSNNPaddingMethod = 4
	MPSNNPaddingMethodAddRemainderToBottomLeft     MPSNNPaddingMethod = 8
	MPSNNPaddingMethodAddRemainderToBottomRight    MPSNNPaddingMethod = 12
	MPSNNPaddingMethodAddRemainderToMask           MPSNNPaddingMethod = 12
	MPSNNPaddingMethodSizeValidOnly                MPSNNPaddingMethod = 0
	MPSNNPaddingMethodSizeSame                     MPSNNPaddingMethod = 16
	MPSNNPaddingMethodSizeFull                     MPSNNPaddingMethod = 32
	MPSNNPaddingMethodSize_reserved                MPSNNPaddingMethod = 48
	MPSNNPaddingMethodCustomWhitelistForNodeFusion MPSNNPaddingMethod = 8192
	MPSNNPaddingMethodCustomAllowForNodeFusion     MPSNNPaddingMethod = 8192
	MPSNNPaddingMethodCustom                       MPSNNPaddingMethod = 16384
	MPSNNPaddingMethodSizeMask                     MPSNNPaddingMethod = 2032
	// The caffe framework constrains the average pooling area to the limits of the padding area in cases where a pixel would read beyond the padding area. Set this bit for Caffe emulation with average pooling.
	MPSNNPaddingMethodExcludeEdges MPSNNPaddingMethod = 32768
)

func (MPSNNPaddingMethod) String ¶

func (e MPSNNPaddingMethod) String() string

type MPSNNReduceBinary ¶

type MPSNNReduceBinary struct {
	MPSCNNBinaryKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreducebinary

func MPSNNReduceBinaryFromID ¶

func MPSNNReduceBinaryFromID(id objc.ID) *MPSNNReduceBinary

func (*MPSNNReduceBinary) PrimarySourceClipRect ¶

func (o *MPSNNReduceBinary) PrimarySourceClipRect() metal.MTLRegion

@abstract The source rectangle to use when reading data from primary source @discussion A MTLRegion that indicates which part of the primary source to read. If the clipRectPrimarySource does not lie completely within the primary source image, the intersection of the image bounds and clipRectPrimarySource will be used. The primarySourceClipRect replaces the MPSBinaryImageKernel primaryOffset parameter for this filter. The latter is ignored. Default: MPSRectNoClip, use the entire source texture. The clipRect specified in MPSBinaryImageKernel is used to control the origin in the destination texture where the min, max values are written. The clipRect.width must be >=2. The clipRect.height must be >= 1.

func (*MPSNNReduceBinary) SecondarySourceClipRect ¶

func (o *MPSNNReduceBinary) SecondarySourceClipRect() metal.MTLRegion

@abstract The source rectangle to use when reading data from secondary source @discussion A MTLRegion that indicates which part of the secondary source to read. If the clipRectSecondarySource does not lie completely within the secondary source image, the intersection of the image bounds and clipRectSecondarySource will be used. The secondarySourceClipRect replaces the MPSBinaryImageKernel secondaryOffset parameter for this filter. The latter is ignored. Default: MPSRectNoClip, use the entire source texture. The clipRect specified in MPSBinaryImageKernel is used to control the origin in the destination texture where the min, max values are written. The clipRect.width must be >=2. The clipRect.height must be >= 1.

func (*MPSNNReduceBinary) SetPrimarySourceClipRect ¶

func (o *MPSNNReduceBinary) SetPrimarySourceClipRect(primarySourceClipRect metal.MTLRegion)

func (*MPSNNReduceBinary) SetSecondarySourceClipRect ¶

func (o *MPSNNReduceBinary) SetSecondarySourceClipRect(secondarySourceClipRect metal.MTLRegion)

type MPSNNReduceColumnMax ¶

type MPSNNReduceColumnMax struct {
	MPSNNReduceUnary
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreducecolumnmax

func MPSNNReduceColumnMaxFromID ¶

func MPSNNReduceColumnMaxFromID(id objc.ID) *MPSNNReduceColumnMax

func (*MPSNNReduceColumnMax) InitWithCoderDevice ¶

func (o *MPSNNReduceColumnMax) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNReduceColumnMax

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSNNReduceColumnMax object, or nil if failure.

func (*MPSNNReduceColumnMax) InitWithDevice ¶

func (o *MPSNNReduceColumnMax) InitWithDevice(device metal.MTLDevice) *MPSNNReduceColumnMax

type MPSNNReduceColumnMean ¶

type MPSNNReduceColumnMean struct {
	MPSNNReduceUnary
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreducecolumnmean

func MPSNNReduceColumnMeanFromID ¶

func MPSNNReduceColumnMeanFromID(id objc.ID) *MPSNNReduceColumnMean

func (*MPSNNReduceColumnMean) InitWithCoderDevice ¶

func (o *MPSNNReduceColumnMean) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNReduceColumnMean

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSNNReduceColumnMean object, or nil if failure.

func (*MPSNNReduceColumnMean) InitWithDevice ¶

func (o *MPSNNReduceColumnMean) InitWithDevice(device metal.MTLDevice) *MPSNNReduceColumnMean

type MPSNNReduceColumnMin ¶

type MPSNNReduceColumnMin struct {
	MPSNNReduceUnary
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreducecolumnmin

func MPSNNReduceColumnMinFromID ¶

func MPSNNReduceColumnMinFromID(id objc.ID) *MPSNNReduceColumnMin

func (*MPSNNReduceColumnMin) InitWithCoderDevice ¶

func (o *MPSNNReduceColumnMin) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNReduceColumnMin

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSNNReduceColumnMin object, or nil if failure.

func (*MPSNNReduceColumnMin) InitWithDevice ¶

func (o *MPSNNReduceColumnMin) InitWithDevice(device metal.MTLDevice) *MPSNNReduceColumnMin

type MPSNNReduceColumnSum ¶

type MPSNNReduceColumnSum struct {
	MPSNNReduceUnary
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreducecolumnsum

func MPSNNReduceColumnSumFromID ¶

func MPSNNReduceColumnSumFromID(id objc.ID) *MPSNNReduceColumnSum

func (*MPSNNReduceColumnSum) InitWithCoderDevice ¶

func (o *MPSNNReduceColumnSum) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNReduceColumnSum

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSNNReduceColumnSum object, or nil if failure.

func (*MPSNNReduceColumnSum) InitWithDevice ¶

func (o *MPSNNReduceColumnSum) InitWithDevice(device metal.MTLDevice) *MPSNNReduceColumnSum

type MPSNNReduceFeatureChannelsAndWeightsMean ¶

type MPSNNReduceFeatureChannelsAndWeightsMean struct {
	MPSNNReduceBinary
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreducefeaturechannelsandweightsmean

func MPSNNReduceFeatureChannelsAndWeightsMeanFromID ¶

func MPSNNReduceFeatureChannelsAndWeightsMeanFromID(id objc.ID) *MPSNNReduceFeatureChannelsAndWeightsMean

func (*MPSNNReduceFeatureChannelsAndWeightsMean) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSCNNPooling object, or nil if failure.

func (*MPSNNReduceFeatureChannelsAndWeightsMean) InitWithDevice ¶

@abstract Specifies information to apply the reduction operation on an image. @param device The device the filter will run on @return A valid MPSNNReduceFeatureChannelsAndWeightsMean object or nil, if failure.

type MPSNNReduceFeatureChannelsAndWeightsSum ¶

type MPSNNReduceFeatureChannelsAndWeightsSum struct {
	MPSNNReduceBinary
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreducefeaturechannelsandweightssum

func MPSNNReduceFeatureChannelsAndWeightsSumFromID ¶

func MPSNNReduceFeatureChannelsAndWeightsSumFromID(id objc.ID) *MPSNNReduceFeatureChannelsAndWeightsSum

func (*MPSNNReduceFeatureChannelsAndWeightsSum) DoWeightedSumByNonZeroWeights ¶

func (o *MPSNNReduceFeatureChannelsAndWeightsSum) DoWeightedSumByNonZeroWeights() bool

@abstract A boolean to indicate whether the reduction should perform a weighted sum of feature channels with non-zero weights @discussion If false, computes a dot product of the feature channels and weights. If true, computes a dot product of the feature channels and weights divided by the number of non-zero weights

func (*MPSNNReduceFeatureChannelsAndWeightsSum) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSCNNPooling object, or nil if failure.

func (*MPSNNReduceFeatureChannelsAndWeightsSum) InitWithDevice ¶

@abstract Specifies information to apply the reduction operation on an image. @param device The device the filter will run on @return A valid MPSNNReduceFeatureChannelsAndWeightsMean object or nil, if failure.

func (*MPSNNReduceFeatureChannelsAndWeightsSum) InitWithDeviceDoWeightedSumByNonZeroWeights ¶

func (o *MPSNNReduceFeatureChannelsAndWeightsSum) InitWithDeviceDoWeightedSumByNonZeroWeights(device metal.MTLDevice, doWeightedSumByNonZeroWeights bool) *MPSNNReduceFeatureChannelsAndWeightsSum

@abstract Specifies information to apply the reduction operation on an image. @param device The device the filter will run on @param doWeightedSumByNonZeroWeights A boolean to indicate whether to compute a weighted sum or weighted sum divided by the number of non-zero weights @return A valid MPSNNReduceFeatureChannelsAndWeightsSum object or nil, if failure.

type MPSNNReduceFeatureChannelsArgumentMax ¶

type MPSNNReduceFeatureChannelsArgumentMax struct {
	MPSNNReduceUnary
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreducefeaturechannelsargumentmax

func MPSNNReduceFeatureChannelsArgumentMaxFromID ¶

func MPSNNReduceFeatureChannelsArgumentMaxFromID(id objc.ID) *MPSNNReduceFeatureChannelsArgumentMax

func (*MPSNNReduceFeatureChannelsArgumentMax) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSNNReduceFeatureChannelsArgumentMax object, or nil if failure.

func (*MPSNNReduceFeatureChannelsArgumentMax) InitWithDevice ¶

type MPSNNReduceFeatureChannelsArgumentMin ¶

type MPSNNReduceFeatureChannelsArgumentMin struct {
	MPSNNReduceUnary
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreducefeaturechannelsargumentmin

func MPSNNReduceFeatureChannelsArgumentMinFromID ¶

func MPSNNReduceFeatureChannelsArgumentMinFromID(id objc.ID) *MPSNNReduceFeatureChannelsArgumentMin

func (*MPSNNReduceFeatureChannelsArgumentMin) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSNNReduceFeatureChannelsArgumentMin object, or nil if failure.

func (*MPSNNReduceFeatureChannelsArgumentMin) InitWithDevice ¶

type MPSNNReduceFeatureChannelsMax ¶

type MPSNNReduceFeatureChannelsMax struct {
	MPSNNReduceUnary
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreducefeaturechannelsmax

func MPSNNReduceFeatureChannelsMaxFromID ¶

func MPSNNReduceFeatureChannelsMaxFromID(id objc.ID) *MPSNNReduceFeatureChannelsMax

func (*MPSNNReduceFeatureChannelsMax) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSNNReduceFeatureChannelsMax object, or nil if failure.

func (*MPSNNReduceFeatureChannelsMax) InitWithDevice ¶

type MPSNNReduceFeatureChannelsMean ¶

type MPSNNReduceFeatureChannelsMean struct {
	MPSNNReduceUnary
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreducefeaturechannelsmean

func MPSNNReduceFeatureChannelsMeanFromID ¶

func MPSNNReduceFeatureChannelsMeanFromID(id objc.ID) *MPSNNReduceFeatureChannelsMean

func (*MPSNNReduceFeatureChannelsMean) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSNNReduceFeatureChannelsMean object, or nil if failure.

func (*MPSNNReduceFeatureChannelsMean) InitWithDevice ¶

type MPSNNReduceFeatureChannelsMin ¶

type MPSNNReduceFeatureChannelsMin struct {
	MPSNNReduceUnary
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreducefeaturechannelsmin

func MPSNNReduceFeatureChannelsMinFromID ¶

func MPSNNReduceFeatureChannelsMinFromID(id objc.ID) *MPSNNReduceFeatureChannelsMin

func (*MPSNNReduceFeatureChannelsMin) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSNNReduceFeatureChannelsMin object, or nil if failure.

func (*MPSNNReduceFeatureChannelsMin) InitWithDevice ¶

type MPSNNReduceFeatureChannelsSum ¶

type MPSNNReduceFeatureChannelsSum struct {
	MPSNNReduceUnary
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreducefeaturechannelssum

func MPSNNReduceFeatureChannelsSumFromID ¶

func MPSNNReduceFeatureChannelsSumFromID(id objc.ID) *MPSNNReduceFeatureChannelsSum

func (*MPSNNReduceFeatureChannelsSum) InitWithCoderDevice ¶

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSNNReduceFeatureChannelsSum object, or nil if failure.

func (*MPSNNReduceFeatureChannelsSum) InitWithDevice ¶

func (*MPSNNReduceFeatureChannelsSum) SetWeight ¶

func (o *MPSNNReduceFeatureChannelsSum) SetWeight(weight float32)

func (*MPSNNReduceFeatureChannelsSum) Weight ¶

@property weight @abstract The scale factor to apply to each feature channel value @discussion Each feature channel is multiplied by the weight value to compute a weighted sum or mean across feature channels The default value is 1.0.

type MPSNNReduceRowMax ¶

type MPSNNReduceRowMax struct {
	MPSNNReduceUnary
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreducerowmax

func MPSNNReduceRowMaxFromID ¶

func MPSNNReduceRowMaxFromID(id objc.ID) *MPSNNReduceRowMax

func (*MPSNNReduceRowMax) InitWithCoderDevice ¶

func (o *MPSNNReduceRowMax) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNReduceRowMax

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSNNReduceRowMax object, or nil if failure.

func (*MPSNNReduceRowMax) InitWithDevice ¶

func (o *MPSNNReduceRowMax) InitWithDevice(device metal.MTLDevice) *MPSNNReduceRowMax

type MPSNNReduceRowMean ¶

type MPSNNReduceRowMean struct {
	MPSNNReduceUnary
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreducerowmean

func MPSNNReduceRowMeanFromID ¶

func MPSNNReduceRowMeanFromID(id objc.ID) *MPSNNReduceRowMean

func (*MPSNNReduceRowMean) InitWithCoderDevice ¶

func (o *MPSNNReduceRowMean) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNReduceRowMean

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSNNReduceRowMean object, or nil if failure.

func (*MPSNNReduceRowMean) InitWithDevice ¶

func (o *MPSNNReduceRowMean) InitWithDevice(device metal.MTLDevice) *MPSNNReduceRowMean

type MPSNNReduceRowMin ¶

type MPSNNReduceRowMin struct {
	MPSNNReduceUnary
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreducerowmin

func MPSNNReduceRowMinFromID ¶

func MPSNNReduceRowMinFromID(id objc.ID) *MPSNNReduceRowMin

func (*MPSNNReduceRowMin) InitWithCoderDevice ¶

func (o *MPSNNReduceRowMin) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNReduceRowMin

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSNNReduceRowMin object, or nil if failure.

func (*MPSNNReduceRowMin) InitWithDevice ¶

func (o *MPSNNReduceRowMin) InitWithDevice(device metal.MTLDevice) *MPSNNReduceRowMin

type MPSNNReduceRowSum ¶

type MPSNNReduceRowSum struct {
	MPSNNReduceUnary
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreducerowsum

func MPSNNReduceRowSumFromID ¶

func MPSNNReduceRowSumFromID(id objc.ID) *MPSNNReduceRowSum

func (*MPSNNReduceRowSum) InitWithCoderDevice ¶

func (o *MPSNNReduceRowSum) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNReduceRowSum

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSCNNPooling @param device The MTLDevice on which to make the MPSCNNPooling @return A new MPSNNReduceRowSum object, or nil if failure.

func (*MPSNNReduceRowSum) InitWithDevice ¶

func (o *MPSNNReduceRowSum) InitWithDevice(device metal.MTLDevice) *MPSNNReduceRowSum

type MPSNNReduceUnary ¶

type MPSNNReduceUnary struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreduceunary

func MPSNNReduceUnaryFromID ¶

func MPSNNReduceUnaryFromID(id objc.ID) *MPSNNReduceUnary

func (*MPSNNReduceUnary) ClipRectSource ¶

func (o *MPSNNReduceUnary) ClipRectSource() metal.MTLRegion

@property clipRectSource @abstract The source rectangle to use when reading data. @discussion A MTLRegion that indicates which part of the source to read. If the clipRectSource does not lie completely within the source image, the intersection of the image bounds and clipRectSource will be used. The clipRectSource replaces the MPSCNNKernel offset parameter for this filter. The latter is ignored. Default: MPSRectNoClip, use the entire source texture.

func (*MPSNNReduceUnary) SetClipRectSource ¶

func (o *MPSNNReduceUnary) SetClipRectSource(clipRectSource metal.MTLRegion)

type MPSNNReductionFeatureChannelsSumNode ¶

type MPSNNReductionFeatureChannelsSumNode struct {
	MPSNNUnaryReductionNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreductionfeaturechannelssumnode

func MPSNNReductionFeatureChannelsSumNodeFromID ¶

func MPSNNReductionFeatureChannelsSumNodeFromID(id objc.ID) *MPSNNReductionFeatureChannelsSumNode

func (*MPSNNReductionFeatureChannelsSumNode) SetWeight ¶

func (o *MPSNNReductionFeatureChannelsSumNode) SetWeight(weight float32)

func (*MPSNNReductionFeatureChannelsSumNode) Weight ¶

@abstract A scale factor to apply to each feature channel sum.

type MPSNNReductionSpatialMeanGradientNode ¶

type MPSNNReductionSpatialMeanGradientNode struct {
	MPSNNGradientFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreductionspatialmeangradientnode

func MPSNNReductionSpatialMeanGradientNodeFromID ¶

func MPSNNReductionSpatialMeanGradientNodeFromID(id objc.ID) *MPSNNReductionSpatialMeanGradientNode

func MPSNNReductionSpatialMeanGradientNodeNodeWithSourceGradientSourceImageGradientState ¶

func MPSNNReductionSpatialMeanGradientNodeNodeWithSourceGradientSourceImageGradientState(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSNNReductionSpatialMeanGradientNode

@abstract A node to represent the gradient of a spatial mean reduction node. @param sourceGradient The input gradient from the 'downstream' gradient filter. @param sourceImage The input image from the forward spatial mean reduction node. @return A MPSNNReductionSpatialMeanGradientNode

func (*MPSNNReductionSpatialMeanGradientNode) InitWithSourceGradientSourceImageGradientState ¶

func (o *MPSNNReductionSpatialMeanGradientNode) InitWithSourceGradientSourceImageGradientState(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSNNReductionSpatialMeanGradientNode

@abstract A node to represent the gradient of a spatial mean reduction node. @param sourceGradient The input gradient from the 'downstream' gradient filter. @param sourceImage The input image from the forward spatial mean reduction node. @return A MPSNNReductionSpatialMeanGradientNode

type MPSNNRegularizationType ¶

type MPSNNRegularizationType uint64
const (
	MPSNNRegularizationTypeNone MPSNNRegularizationType = 0
	// Apply L1 regularization. L1 norm of weights, will be considered to be added to the loss to be minimized. the gradient of the regularization loss turns to be 1 scaled with regularizationScale, so we add that to the incoming gradient of value.
	MPSNNRegularizationTypeL1 MPSNNRegularizationType = 1
	// Apply L2 regularization. L2 norm of weights, will be considered to be added to the loss to be minimized. the gradient of the regularization loss turns to be the original value scaled with regularizationScale, so we add that to the incoming gradient of value.
	MPSNNRegularizationTypeL2 MPSNNRegularizationType = 2
)

func (MPSNNRegularizationType) String ¶

func (e MPSNNRegularizationType) String() string

type MPSNNReshape ¶

type MPSNNReshape struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreshape

func MPSNNReshapeFromID ¶

func MPSNNReshapeFromID(id objc.ID) *MPSNNReshape

func (*MPSNNReshape) EncodeBatchToCommandBufferSourceImagesDestinationStatesDestinationStateIsTemporaryReshapedWidthReshapedHeightReshapedFeatureChannels ¶

func (o *MPSNNReshape) EncodeBatchToCommandBufferSourceImagesDestinationStatesDestinationStateIsTemporaryReshapedWidthReshapedHeightReshapedFeatureChannels(commandBuffer metal.MTLCommandBuffer, sourceImages unsafe.Pointer, outStates unsafe.Pointer, isTemporary bool, reshapedWidth uint, reshapedHeight uint, reshapedFeatureChannels uint) unsafe.Pointer

@abstract Encode a reshape to a command buffer for a given shape. @param commandBuffer The command buffer on which to encode the reshape operation. @param outStates A batch of states to be created and autoreleased which will hold information about this execution to be provided to a subsequent gradient pass. @param isTemporary YES if the states are to be created as temporary states, NO otherwise. @param sourceImages The batch of input images to be reshaped. @param reshapedWidth The width of the resulting reshaped images. @param reshapedHeight The height of the resulting reshaped images. @param reshapedFeatureChannels The number of feature channels in each of the resulting reshaped images.

func (*MPSNNReshape) EncodeBatchToCommandBufferSourceImagesReshapedWidthReshapedHeightReshapedFeatureChannels ¶

func (o *MPSNNReshape) EncodeBatchToCommandBufferSourceImagesReshapedWidthReshapedHeightReshapedFeatureChannels(commandBuffer metal.MTLCommandBuffer, sourceImages unsafe.Pointer, reshapedWidth uint, reshapedHeight uint, reshapedFeatureChannels uint) unsafe.Pointer

@abstract Encode a reshape to a command buffer for a given shape. @param commandBuffer The command buffer on which to encode the reshape operation. @param sourceImages The image batch containing images to be reshaped. @param reshapedWidth The width of the resulting reshaped images. @param reshapedHeight The height of the resulting reshaped images. @param reshapedFeatureChannels The number of feature channels in each of the resulting reshaped images.

func (*MPSNNReshape) EncodeToCommandBufferSourceImageDestinationStateDestinationStateIsTemporaryReshapedWidthReshapedHeightReshapedFeatureChannels ¶

func (o *MPSNNReshape) EncodeToCommandBufferSourceImageDestinationStateDestinationStateIsTemporaryReshapedWidthReshapedHeightReshapedFeatureChannels(commandBuffer metal.MTLCommandBuffer, sourceImage *mpscore.MPSImage, outState *mpscore.MPSState, isTemporary bool, reshapedWidth uint, reshapedHeight uint, reshapedFeatureChannels uint) *mpscore.MPSImage

@abstract Encode a reshape to a command buffer for a given shape. @param commandBuffer The command buffer on which to encode the reshape operation. @param outState A state to be created and autoreleased which will hold information about this execution to be provided to a subsequent gradient pass. @param isTemporary YES if the state is to be created as a temporary state, NO otherwise. @param sourceImage The input image to be reshaped. @param reshapedWidth The width of the resulting reshaped image. @param reshapedHeight The height of the resulting reshaped image. @param reshapedFeatureChannels The number of feature channels in the resulting reshaped image.

func (*MPSNNReshape) EncodeToCommandBufferSourceImageReshapedWidthReshapedHeightReshapedFeatureChannels ¶

func (o *MPSNNReshape) EncodeToCommandBufferSourceImageReshapedWidthReshapedHeightReshapedFeatureChannels(commandBuffer metal.MTLCommandBuffer, sourceImage *mpscore.MPSImage, reshapedWidth uint, reshapedHeight uint, reshapedFeatureChannels uint) *mpscore.MPSImage

@abstract Encode a reshape to a command buffer for a given shape. @param commandBuffer The command buffer on which to encode the reshape operation. @param sourceImage The input image to be reshaped. @param reshapedWidth The width of the resulting reshaped image. @param reshapedHeight The height of the resulting reshaped image. @param reshapedFeatureChannels The number of feature channels in the resulting reshaped image.

func (*MPSNNReshape) InitWithCoderDevice ¶

func (o *MPSNNReshape) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNReshape

func (*MPSNNReshape) InitWithDevice ¶

func (o *MPSNNReshape) InitWithDevice(device metal.MTLDevice) *MPSNNReshape

@abstract Initialize a MPSNNReshape kernel @param device The device the filter will run on @return A valid MPSNNReshape object or nil, if failure.

type MPSNNReshapeGradient ¶

type MPSNNReshapeGradient struct {
	MPSCNNGradientKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreshapegradient

func MPSNNReshapeGradientFromID ¶

func MPSNNReshapeGradientFromID(id objc.ID) *MPSNNReshapeGradient

func (*MPSNNReshapeGradient) InitWithCoderDevice ¶

func (o *MPSNNReshapeGradient) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNReshapeGradient

@abstract NSSecureCoding compatability @discussion 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. @param aDecoder The NSCoder subclass with your serialized MPSKernel @param device The MTLDevice on which to make the MPSKernel @return A new MPSKernel object, or nil if failure.

func (*MPSNNReshapeGradient) InitWithDevice ¶

func (o *MPSNNReshapeGradient) InitWithDevice(device metal.MTLDevice) *MPSNNReshapeGradient

@abstract Initializes a MPSNNReshapeGradient function @param device The MTLDevice on which this filter will be used @return A valid MPSNNReshapeGradient object or nil, if failure.

type MPSNNReshapeGradientNode ¶

type MPSNNReshapeGradientNode struct {
	MPSNNGradientFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreshapegradientnode

func MPSNNReshapeGradientNodeFromID ¶

func MPSNNReshapeGradientNodeFromID(id objc.ID) *MPSNNReshapeGradientNode

func MPSNNReshapeGradientNodeNodeWithSourceGradientSourceImageGradientState ¶

func MPSNNReshapeGradientNodeNodeWithSourceGradientSourceImageGradientState(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSNNReshapeGradientNode

@abstract A node to represent the gradient of a reshape node. @param sourceGradient The input gradient from the 'downstream' gradient filter. @param sourceImage The input image from the forward reshape node. @return A MPSNNReshapeGradientNode

func (*MPSNNReshapeGradientNode) InitWithSourceGradientSourceImageGradientState ¶

func (o *MPSNNReshapeGradientNode) InitWithSourceGradientSourceImageGradientState(sourceGradient *MPSNNImageNode, sourceImage *MPSNNImageNode, gradientState *MPSNNGradientStateNode) *MPSNNReshapeGradientNode

@abstract A node to represent the gradient of a reshape node. @param sourceGradient The input gradient from the 'downstream' gradient filter. @param sourceImage The input image from the forward reshape node. @return A MPSCNNConvolutionGradientNode

type MPSNNReshapeNode ¶

type MPSNNReshapeNode struct {
	MPSNNFilterNode
}

@abstract A node for a MPSNNReshape kernel

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnreshapenode

func MPSNNReshapeNodeFromID ¶

func MPSNNReshapeNodeFromID(id objc.ID) *MPSNNReshapeNode

func MPSNNReshapeNodeNodeWithSourceResultWidthResultHeightResultFeatureChannels ¶

func MPSNNReshapeNodeNodeWithSourceResultWidthResultHeightResultFeatureChannels(source *MPSNNImageNode, resultWidth uint, resultHeight uint, resultFeatureChannels uint) *MPSNNReshapeNode

@abstract Init a node representing a autoreleased MPSNNReshape kernel @param source The MPSNNImageNode representing the source MPSImage for the filter @param resultWidth The width of the reshaped image. @param resultHeight The height of the reshaped image. @param resultFeatureChannels The number of feature channels in the reshaped image. @return A new MPSNNFilter node for a MPSNNReshape kernel.

func (*MPSNNReshapeNode) InitWithSourceResultWidthResultHeightResultFeatureChannels ¶

func (o *MPSNNReshapeNode) InitWithSourceResultWidthResultHeightResultFeatureChannels(source *MPSNNImageNode, resultWidth uint, resultHeight uint, resultFeatureChannels uint) *MPSNNReshapeNode

@abstract Init a node representing a MPSNNReshape kernel @param source The MPSNNImageNode representing the source MPSImage for the filter @param resultWidth The width of the reshaped image. @param resultHeight The height of the reshaped image. @param resultFeatureChannels The number of feature channels in the reshaped image. @return A new MPSNNFilter node for a MPSNNReshape kernel.

type MPSNNResizeBilinear ¶

type MPSNNResizeBilinear struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnresizebilinear

func MPSNNResizeBilinearFromID ¶

func MPSNNResizeBilinearFromID(id objc.ID) *MPSNNResizeBilinear

func (*MPSNNResizeBilinear) AlignCorners ¶

func (o *MPSNNResizeBilinear) AlignCorners() bool

@property alignCorners @abstract If YES, the centers of the 4 corner pixels of the input and output regions are aligned, preserving the values at the corner pixels. The default is NO.

func (*MPSNNResizeBilinear) InitWithCoderDevice ¶

func (o *MPSNNResizeBilinear) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNResizeBilinear

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSNNResizeBilinear @param device The MTLDevice on which to make the MPSNNResizeBilinear @return A new MPSNNResizeBilinear object, or nil if failure.

func (*MPSNNResizeBilinear) InitWithDeviceResizeWidthResizeHeightAlignCorners ¶

func (o *MPSNNResizeBilinear) InitWithDeviceResizeWidthResizeHeightAlignCorners(device metal.MTLDevice, resizeWidth uint, resizeHeight uint, alignCorners bool) *MPSNNResizeBilinear

func (*MPSNNResizeBilinear) ResizeHeight ¶

func (o *MPSNNResizeBilinear) ResizeHeight() uint

@property resizeHeight @abstract The resize height.

func (*MPSNNResizeBilinear) ResizeWidth ¶

func (o *MPSNNResizeBilinear) ResizeWidth() uint

@property resizeWidth @abstract The resize width.

type MPSNNScaleNode ¶

type MPSNNScaleNode struct {
	MPSNNFilterNode
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnscalenode

func MPSNNScaleNodeFromID ¶

func MPSNNScaleNodeFromID(id objc.ID) *MPSNNScaleNode

func MPSNNScaleNodeNodeWithSourceOutputSize ¶

func MPSNNScaleNodeNodeWithSourceOutputSize(sourceNode *MPSNNImageNode, size metal.MTLSize) *MPSNNScaleNode

@abstract create an autoreleased node to convert a MPSImage to the desired size @param sourceNode A valid MPSNNImageNode @param size The size of the output image {width, height, depth}

func MPSNNScaleNodeNodeWithSourceTransformProviderOutputSize ¶

func MPSNNScaleNodeNodeWithSourceTransformProviderOutputSize(sourceNode *MPSNNImageNode, transformProvider MPSImageTransformProvider, size metal.MTLSize) *MPSNNScaleNode

@abstract create an autoreleased node to convert a MPSImage to the desired size for a region of interest @param sourceNode A valid MPSNNImageNode @param transformProvider If non-nil, a valid MPSImageTransformProvider that provides the region of interest @param size The size of the output image {width, height, depth}

func (*MPSNNScaleNode) InitWithSourceOutputSize ¶

func (o *MPSNNScaleNode) InitWithSourceOutputSize(sourceNode *MPSNNImageNode, size metal.MTLSize) *MPSNNScaleNode

@abstract init a node to convert a MPSImage to the desired size @param sourceNode A valid MPSNNImageNode @param size The size of the output image {width, height, depth}

func (*MPSNNScaleNode) InitWithSourceTransformProviderOutputSize ¶

func (o *MPSNNScaleNode) InitWithSourceTransformProviderOutputSize(sourceNode *MPSNNImageNode, transformProvider MPSImageTransformProvider, size metal.MTLSize) *MPSNNScaleNode

@abstract init a node to convert a MPSImage to the desired size for a region of interest @param sourceNode A valid MPSNNImageNode @param transformProvider If non-nil, a valid MPSImageTransformProvider that provides the region of interest @param size The size of the output image {width, height, depth}

type MPSNNSlice ¶

type MPSNNSlice struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnslice

func MPSNNSliceFromID ¶

func MPSNNSliceFromID(id objc.ID) *MPSNNSlice

func (*MPSNNSlice) InitWithCoderDevice ¶

func (o *MPSNNSlice) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSNNSlice

func (*MPSNNSlice) InitWithDevice ¶

func (o *MPSNNSlice) InitWithDevice(device metal.MTLDevice) *MPSNNSlice

@abstract Initialize a MPSNNSlice kernel @param device The device the filter will run on @return A valid MPSNNSlice object or nil, if failure.

type MPSNNStateNode ¶

type MPSNNStateNode struct {
	foundation.NSObject
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnstatenode

func MPSNNStateNodeFromID ¶

func MPSNNStateNodeFromID(id objc.ID) *MPSNNStateNode

func (*MPSNNStateNode) ExportFromGraph ¶

func (o *MPSNNStateNode) ExportFromGraph() bool

@abstract Tag a state node for view later @discussion Most state nodes are private to the graph. These alias memory heavily and consequently generally have invalid state when the graph exits. When exportFromGraph = YES, the image is preserved and made available through the [MPSNNGraph encode... resultStates:... list. CAUTION: exporting an state from a graph prevents MPS from recycling memory. It will nearly always cause the amount of memory used by the graph to increase by the size of the state. There will probably be a performance regression accordingly. This feature should generally be used only when the node is needed as an input for further work and recomputing it is prohibitively costly. Default: NO

func (*MPSNNStateNode) Handle ¶

func (o *MPSNNStateNode) Handle() MPSHandle

@abstract MPS resource identification @discussion See MPSHandle protocol reference. Default: nil

func (*MPSNNStateNode) SetExportFromGraph ¶

func (o *MPSNNStateNode) SetExportFromGraph(exportFromGraph bool)

func (*MPSNNStateNode) SetHandle ¶

func (o *MPSNNStateNode) SetHandle(handle MPSHandle)

func (*MPSNNStateNode) SetSynchronizeResource ¶

func (o *MPSNNStateNode) SetSynchronizeResource(synchronizeResource bool)

func (*MPSNNStateNode) SynchronizeResource ¶

func (o *MPSNNStateNode) SynchronizeResource() bool

@abstract Set to true to cause the resource to be synchronized with the CPU @discussion Ignored on non-MacOS.

type MPSNNSubtractionGradientNode ¶

type MPSNNSubtractionGradientNode struct {
	MPSNNArithmeticGradientNode
}

@abstract returns gradient for either primary or secondary source image from the inference pass. Use the isSecondarySourceFilter property to indicate whether this filter is computing the gradient for the primary or secondary source image from the inference pass.

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnsubtractiongradientnode

func MPSNNSubtractionGradientNodeFromID ¶

func MPSNNSubtractionGradientNodeFromID(id objc.ID) *MPSNNSubtractionGradientNode

type MPSNNSubtractionNode ¶

type MPSNNSubtractionNode struct {
	MPSNNBinaryArithmeticNode
}

@abstract returns elementwise difference of left - right

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnsubtractionnode

func MPSNNSubtractionNodeFromID ¶

func MPSNNSubtractionNodeFromID(id objc.ID) *MPSNNSubtractionNode

type MPSNNTrainableNode ¶

type MPSNNTrainableNode interface {
	TrainingStyle() MPSNNTrainingStyle
	SetTrainingStyle(trainingStyle MPSNNTrainingStyle)
}

MPSNNTrainableNode wraps the ObjC protocol MPSNNTrainableNode.

type MPSNNTrainingStyle ¶

type MPSNNTrainingStyle uint64
const (
	// Do not train this node, for example in transfer learning
	MPSNNTrainingStyleUpdateDeviceNone MPSNNTrainingStyle = 0
	// The weight update pass will be called in a command buffer completion callback, with a nil command buffer
	MPSNNTrainingStyleUpdateDeviceCPU MPSNNTrainingStyle = 1
	// The weight update pass will be called immediately after the gradient pass is encoded, with a nonnull command buffer
	MPSNNTrainingStyleUpdateDeviceGPU MPSNNTrainingStyle = 2
)

func (MPSNNTrainingStyle) String ¶

func (e MPSNNTrainingStyle) String() string

type MPSNNUnaryReductionNode ¶

type MPSNNUnaryReductionNode struct {
	MPSNNFilterNode
}

@abstract A node for a unary MPSNNReduce node. @discussion This is an abstract base class that does not correspond with any particular MPSCNNKernel. Please make one of the MPSNNReduction subclasses instead.

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsnnunaryreductionnode

func MPSNNUnaryReductionNodeFromID ¶

func MPSNNUnaryReductionNodeFromID(id objc.ID) *MPSNNUnaryReductionNode

func MPSNNUnaryReductionNodeNodeWithSource ¶

func MPSNNUnaryReductionNodeNodeWithSource(sourceNode *MPSNNImageNode) *MPSNNUnaryReductionNode

@abstract Create an autoreleased node representing an MPS reduction kernel. @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @return A new MPSNNFilter node for an MPS reduction kernel.

func (*MPSNNUnaryReductionNode) ClipRectSource ¶

func (o *MPSNNUnaryReductionNode) ClipRectSource() metal.MTLRegion

@abstract The clip rectangle to apply to the source image.

func (*MPSNNUnaryReductionNode) InitWithSource ¶

func (o *MPSNNUnaryReductionNode) InitWithSource(sourceNode *MPSNNImageNode) *MPSNNUnaryReductionNode

@abstract Init a node representing an MPS reduction kernel. @param sourceNode The MPSNNImageNode representing the source MPSImage for the filter @return A new MPSNNFilter node for an MPS reduction kernel.

func (*MPSNNUnaryReductionNode) SetClipRectSource ¶

func (o *MPSNNUnaryReductionNode) SetClipRectSource(clipRectSource metal.MTLRegion)

type MPSRNNBidirectionalCombineMode ¶

type MPSRNNBidirectionalCombineMode uint64
const (
	// The two sequences are kept separate
	MPSRNNBidirectionalCombineModeNone MPSRNNBidirectionalCombineMode = 0
	// The two sequences are summed together to form a single output
	MPSRNNBidirectionalCombineModeAdd MPSRNNBidirectionalCombineMode = 1
	// The two sequences are concatenated together along the feature channels to form a single output
	MPSRNNBidirectionalCombineModeConcatenate MPSRNNBidirectionalCombineMode = 2
)

func (MPSRNNBidirectionalCombineMode) String ¶

type MPSRNNDescriptor ¶

type MPSRNNDescriptor struct {
	foundation.NSObject
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsrnndescriptor

func MPSRNNDescriptorFromID ¶

func MPSRNNDescriptorFromID(id objc.ID) *MPSRNNDescriptor

func (*MPSRNNDescriptor) InputFeatureChannels ¶

func (o *MPSRNNDescriptor) InputFeatureChannels() uint

@property inputFeatureChannels @abstract The number of feature channels per pixel in the input image or number of rows in the input matrix.

func (*MPSRNNDescriptor) LayerSequenceDirection ¶

func (o *MPSRNNDescriptor) LayerSequenceDirection() MPSRNNSequenceDirection

@property layerSequenceDirection @abstract When the layer specified with this descriptor is used to process a sequence of inputs by calling @see encodeBidirectionalSequenceToCommandBuffer then this parameter defines in which direction the sequence is processed. The operation of the layer is: (yt, ht, ct) = f(xt,ht-1,ct-1) for MPSRNNSequenceDirectionForward and (yt, ht, ct) = f(xt,ht+1,ct+1) for MPSRNNSequenceDirectionBackward, where xt is the output of the previous layer that encodes in the same direction as this layer, (or the input image or matrix if this is the first layer in stack with this direction). @see MPSRNNImageInferenceLayer and @see MPSRNNMatrixInferenceLayer.

func (*MPSRNNDescriptor) OutputFeatureChannels ¶

func (o *MPSRNNDescriptor) OutputFeatureChannels() uint

@property outputFeatureChannels @abstract The number of feature channels per pixel in the destination image or number of rows in the destination matrix.

func (*MPSRNNDescriptor) SetInputFeatureChannels ¶

func (o *MPSRNNDescriptor) SetInputFeatureChannels(inputFeatureChannels uint)

func (*MPSRNNDescriptor) SetLayerSequenceDirection ¶

func (o *MPSRNNDescriptor) SetLayerSequenceDirection(layerSequenceDirection MPSRNNSequenceDirection)

func (*MPSRNNDescriptor) SetOutputFeatureChannels ¶

func (o *MPSRNNDescriptor) SetOutputFeatureChannels(outputFeatureChannels uint)

func (*MPSRNNDescriptor) SetUseFloat32Weights ¶

func (o *MPSRNNDescriptor) SetUseFloat32Weights(useFloat32Weights bool)

func (*MPSRNNDescriptor) SetUseLayerInputUnitTransformMode ¶

func (o *MPSRNNDescriptor) SetUseLayerInputUnitTransformMode(useLayerInputUnitTransformMode bool)

func (*MPSRNNDescriptor) UseFloat32Weights ¶

func (o *MPSRNNDescriptor) UseFloat32Weights() bool

@property useFloat32Weights @abstract If YES, then @ref MPSRNNMatrixInferenceLayer uses 32-bit floating point numbers internally for weights when computing matrix transformations. If NO, then 16-bit, half precision floating point numbers are used. Currently @ref MPSRNNImageInferenceLayer ignores this property and the convolution operations always convert FP32 weights into FP16 for better performance. Defaults to NO.

func (*MPSRNNDescriptor) UseLayerInputUnitTransformMode ¶

func (o *MPSRNNDescriptor) UseLayerInputUnitTransformMode() bool

@property useLayerInputUnitTransformMode @abstract if YES then use identity transformation for all weights (W, Wr, Wi, Wf, Wo, Wc) affecting input x_j in this layer, even if said weights are specified as nil. For example 'W_ij * x_j' is replaced by 'x_j' in formulae defined in @ref MPSRNNSingleGateDescriptor. Defaults to NO.

type MPSRNNImageInferenceLayer ¶

type MPSRNNImageInferenceLayer struct {
	MPSCNNKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsrnnimageinferencelayer

func MPSRNNImageInferenceLayerFromID ¶

func MPSRNNImageInferenceLayerFromID(id objc.ID) *MPSRNNImageInferenceLayer

func (*MPSRNNImageInferenceLayer) BidirectionalCombineMode ¶

func (o *MPSRNNImageInferenceLayer) BidirectionalCombineMode() MPSRNNBidirectionalCombineMode

@property bidirectionalCombineMode @abstract Defines how to combine the output-results, when encoding bidirectional layers using @ref encodeBidirectionalSequenceToCommandBuffer. Defaults to @ref MPSRNNBidirectionalCombineModeNone.

func (*MPSRNNImageInferenceLayer) EncodeBidirectionalSequenceToCommandBufferSourceSequenceDestinationForwardImagesDestinationBackwardImages ¶

func (o *MPSRNNImageInferenceLayer) EncodeBidirectionalSequenceToCommandBufferSourceSequenceDestinationForwardImagesDestinationBackwardImages(commandBuffer metal.MTLCommandBuffer, sourceSequence *foundation.NSArray[*mpscore.MPSImage], destinationForwardImages *foundation.NSArray[*mpscore.MPSImage], destinationBackwardImages *foundation.NSArray[*mpscore.MPSImage])

func (*MPSRNNImageInferenceLayer) EncodeSequenceToCommandBufferSourceImagesDestinationImagesRecurrentInputStateRecurrentOutputStates ¶

func (o *MPSRNNImageInferenceLayer) EncodeSequenceToCommandBufferSourceImagesDestinationImagesRecurrentInputStateRecurrentOutputStates(commandBuffer metal.MTLCommandBuffer, sourceImages *foundation.NSArray[*mpscore.MPSImage], destinationImages *foundation.NSArray[*mpscore.MPSImage], recurrentInputState *MPSRNNRecurrentImageState, recurrentOutputStates *foundation.NSMutableArray[*MPSRNNRecurrentImageState])

func (*MPSRNNImageInferenceLayer) InitWithCoderDevice ¶

func (o *MPSRNNImageInferenceLayer) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSRNNImageInferenceLayer

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSRNNImageInferenceLayer @param device The MTLDevice on which to make the MPSRNNImageInferenceLayer @return A new MPSRNNImageInferenceLayer object, or nil if failure.

func (*MPSRNNImageInferenceLayer) InitWithDeviceRnnDescriptor ¶

func (o *MPSRNNImageInferenceLayer) InitWithDeviceRnnDescriptor(device metal.MTLDevice, rnnDescriptor *MPSRNNDescriptor) *MPSRNNImageInferenceLayer

@abstract Initializes a convolutional RNN kernel @param device The MTLDevice on which this MPSRNNImageLayer filter will be used @param rnnDescriptor The descriptor that defines the RNN layer @return A valid MPSRNNImageInferenceLayer object or nil, if failure.

func (*MPSRNNImageInferenceLayer) InitWithDeviceRnnDescriptors ¶

func (o *MPSRNNImageInferenceLayer) InitWithDeviceRnnDescriptors(device metal.MTLDevice, rnnDescriptors *foundation.NSArray[*MPSRNNDescriptor]) *MPSRNNImageInferenceLayer

@abstract Initializes a kernel that implements a stack of convolutional RNN layers @param device The MTLDevice on which this MPSRNNImageLayer filter will be used @param rnnDescriptors 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. @return A valid MPSRNNImageInferenceLayer object or nil, if failure.

func (*MPSRNNImageInferenceLayer) InputFeatureChannels ¶

func (o *MPSRNNImageInferenceLayer) InputFeatureChannels() uint

@property inputFeatureChannels @abstract The number of feature channels per pixel in the input image.

func (*MPSRNNImageInferenceLayer) NumberOfLayers ¶

func (o *MPSRNNImageInferenceLayer) NumberOfLayers() uint

@property numberOfLayers @abstract 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.

func (*MPSRNNImageInferenceLayer) OutputFeatureChannels ¶

func (o *MPSRNNImageInferenceLayer) OutputFeatureChannels() uint

@property outputFeatureChannels @abstract The number of feature channels per pixel in the output image.

func (*MPSRNNImageInferenceLayer) RecurrentOutputIsTemporary ¶

func (o *MPSRNNImageInferenceLayer) RecurrentOutputIsTemporary() bool

@property recurrentOutputIsTemporary @abstract How output states from @ref encodeSequenceToCommandBuffer are constructed. Defaults to NO. For reference @see MPSState.

func (*MPSRNNImageInferenceLayer) SetBidirectionalCombineMode ¶

func (o *MPSRNNImageInferenceLayer) SetBidirectionalCombineMode(bidirectionalCombineMode MPSRNNBidirectionalCombineMode)

func (*MPSRNNImageInferenceLayer) SetRecurrentOutputIsTemporary ¶

func (o *MPSRNNImageInferenceLayer) SetRecurrentOutputIsTemporary(recurrentOutputIsTemporary bool)

func (*MPSRNNImageInferenceLayer) SetStoreAllIntermediateStates ¶

func (o *MPSRNNImageInferenceLayer) SetStoreAllIntermediateStates(storeAllIntermediateStates bool)

func (*MPSRNNImageInferenceLayer) StoreAllIntermediateStates ¶

func (o *MPSRNNImageInferenceLayer) StoreAllIntermediateStates() bool

@property storeAllIntermediateStates @abstract If YES then calls to @ref encodeSequenceToCommandBuffer return every recurrent state in the array: recurrentOutputStates. Defaults to NO.

type MPSRNNMatrixId ¶

type MPSRNNMatrixId uint64
const (
	MPSRNNMatrixIdSingleGateInputWeights           MPSRNNMatrixId = 0
	MPSRNNMatrixIdSingleGateRecurrentWeights       MPSRNNMatrixId = 1
	MPSRNNMatrixIdSingleGateBiasTerms              MPSRNNMatrixId = 2
	MPSRNNMatrixIdLSTMInputGateInputWeights        MPSRNNMatrixId = 3
	MPSRNNMatrixIdLSTMInputGateRecurrentWeights    MPSRNNMatrixId = 4
	MPSRNNMatrixIdLSTMInputGateMemoryWeights       MPSRNNMatrixId = 5
	MPSRNNMatrixIdLSTMInputGateBiasTerms           MPSRNNMatrixId = 6
	MPSRNNMatrixIdLSTMForgetGateInputWeights       MPSRNNMatrixId = 7
	MPSRNNMatrixIdLSTMForgetGateRecurrentWeights   MPSRNNMatrixId = 8
	MPSRNNMatrixIdLSTMForgetGateMemoryWeights      MPSRNNMatrixId = 9
	MPSRNNMatrixIdLSTMForgetGateBiasTerms          MPSRNNMatrixId = 10
	MPSRNNMatrixIdLSTMMemoryGateInputWeights       MPSRNNMatrixId = 11
	MPSRNNMatrixIdLSTMMemoryGateRecurrentWeights   MPSRNNMatrixId = 12
	MPSRNNMatrixIdLSTMMemoryGateMemoryWeights      MPSRNNMatrixId = 13
	MPSRNNMatrixIdLSTMMemoryGateBiasTerms          MPSRNNMatrixId = 14
	MPSRNNMatrixIdLSTMOutputGateInputWeights       MPSRNNMatrixId = 15
	MPSRNNMatrixIdLSTMOutputGateRecurrentWeights   MPSRNNMatrixId = 16
	MPSRNNMatrixIdLSTMOutputGateMemoryWeights      MPSRNNMatrixId = 17
	MPSRNNMatrixIdLSTMOutputGateBiasTerms          MPSRNNMatrixId = 18
	MPSRNNMatrixIdGRUInputGateInputWeights         MPSRNNMatrixId = 19
	MPSRNNMatrixIdGRUInputGateRecurrentWeights     MPSRNNMatrixId = 20
	MPSRNNMatrixIdGRUInputGateBiasTerms            MPSRNNMatrixId = 21
	MPSRNNMatrixIdGRURecurrentGateInputWeights     MPSRNNMatrixId = 22
	MPSRNNMatrixIdGRURecurrentGateRecurrentWeights MPSRNNMatrixId = 23
	MPSRNNMatrixIdGRURecurrentGateBiasTerms        MPSRNNMatrixId = 24
	MPSRNNMatrixIdGRUOutputGateInputWeights        MPSRNNMatrixId = 25
	MPSRNNMatrixIdGRUOutputGateRecurrentWeights    MPSRNNMatrixId = 26
	MPSRNNMatrixIdGRUOutputGateInputGateWeights    MPSRNNMatrixId = 27
	MPSRNNMatrixIdGRUOutputGateBiasTerms           MPSRNNMatrixId = 28
	MPSRNNMatrixId_count                           MPSRNNMatrixId = 29
)

func (MPSRNNMatrixId) String ¶

func (e MPSRNNMatrixId) String() string

type MPSRNNMatrixInferenceLayer ¶

type MPSRNNMatrixInferenceLayer struct {
	mpscore.MPSKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsrnnmatrixinferencelayer

func MPSRNNMatrixInferenceLayerFromID ¶

func MPSRNNMatrixInferenceLayerFromID(id objc.ID) *MPSRNNMatrixInferenceLayer

func (*MPSRNNMatrixInferenceLayer) BidirectionalCombineMode ¶

func (o *MPSRNNMatrixInferenceLayer) BidirectionalCombineMode() MPSRNNBidirectionalCombineMode

@property bidirectionalCombineMode @abstract Defines how to combine the output-results, when encoding bidirectional layers using @ref encodeBidirectionalSequenceToCommandBuffer. Defaults to @ref MPSRNNBidirectionalCombineModeNone.

func (*MPSRNNMatrixInferenceLayer) EncodeBidirectionalSequenceToCommandBufferSourceSequenceDestinationForwardMatricesDestinationBackwardMatrices ¶

func (o *MPSRNNMatrixInferenceLayer) EncodeBidirectionalSequenceToCommandBufferSourceSequenceDestinationForwardMatricesDestinationBackwardMatrices(commandBuffer metal.MTLCommandBuffer, sourceSequence *foundation.NSArray[*mpscore.MPSMatrix], destinationForwardMatrices *foundation.NSArray[*mpscore.MPSMatrix], destinationBackwardMatrices *foundation.NSArray[*mpscore.MPSMatrix])

func (*MPSRNNMatrixInferenceLayer) EncodeSequenceToCommandBufferSourceMatricesDestinationMatricesRecurrentInputStateRecurrentOutputStates ¶

func (o *MPSRNNMatrixInferenceLayer) EncodeSequenceToCommandBufferSourceMatricesDestinationMatricesRecurrentInputStateRecurrentOutputStates(commandBuffer metal.MTLCommandBuffer, sourceMatrices *foundation.NSArray[*mpscore.MPSMatrix], destinationMatrices *foundation.NSArray[*mpscore.MPSMatrix], recurrentInputState *MPSRNNRecurrentMatrixState, recurrentOutputStates *foundation.NSMutableArray[*MPSRNNRecurrentMatrixState])

func (*MPSRNNMatrixInferenceLayer) EncodeSequenceToCommandBufferSourceMatricesSourceOffsetsDestinationMatricesDestinationOffsetsRecurrentInputStateRecurrentOutputStates ¶

func (o *MPSRNNMatrixInferenceLayer) EncodeSequenceToCommandBufferSourceMatricesSourceOffsetsDestinationMatricesDestinationOffsetsRecurrentInputStateRecurrentOutputStates(commandBuffer metal.MTLCommandBuffer, sourceMatrices *foundation.NSArray[*mpscore.MPSMatrix], sourceOffsets *uint, destinationMatrices *foundation.NSArray[*mpscore.MPSMatrix], destinationOffsets *uint, recurrentInputState *MPSRNNRecurrentMatrixState, recurrentOutputStates *foundation.NSMutableArray[*MPSRNNRecurrentMatrixState])

func (*MPSRNNMatrixInferenceLayer) InitWithCoderDevice ¶

func (o *MPSRNNMatrixInferenceLayer) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSRNNMatrixInferenceLayer

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSRNNMatrixInferenceLayer @param device The MTLDevice on which to make the MPSRNNMatrixInferenceLayer @return A new MPSRNNMatrixInferenceLayer object, or nil if failure.

func (*MPSRNNMatrixInferenceLayer) InitWithDeviceRnnDescriptor ¶

func (o *MPSRNNMatrixInferenceLayer) InitWithDeviceRnnDescriptor(device metal.MTLDevice, rnnDescriptor *MPSRNNDescriptor) *MPSRNNMatrixInferenceLayer

@abstract Initializes a linear (fully connected) RNN kernel @param device The MTLDevice on which this MPSRNNMatrixLayer filter will be used @param rnnDescriptor The descriptor that defines the RNN layer @return A valid MPSRNNMatrixInferenceLayer object or nil, if failure.

func (*MPSRNNMatrixInferenceLayer) InitWithDeviceRnnDescriptors ¶

func (o *MPSRNNMatrixInferenceLayer) InitWithDeviceRnnDescriptors(device metal.MTLDevice, rnnDescriptors *foundation.NSArray[*MPSRNNDescriptor]) *MPSRNNMatrixInferenceLayer

@abstract Initializes a kernel that implements a stack of linear (fully connected) RNN layers @param device The MTLDevice on which this MPSRNNMatrixLayer filter will be used @param rnnDescriptors 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. @return A valid MPSRNNMatrixInferenceLayer object or nil, if failure.

func (*MPSRNNMatrixInferenceLayer) InputFeatureChannels ¶

func (o *MPSRNNMatrixInferenceLayer) InputFeatureChannels() uint

@property inputFeatureChannels @abstract The number of feature channels input vector/matrix.

func (*MPSRNNMatrixInferenceLayer) NumberOfLayers ¶

func (o *MPSRNNMatrixInferenceLayer) NumberOfLayers() uint

@property numberOfLayers @abstract 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.

func (*MPSRNNMatrixInferenceLayer) OutputFeatureChannels ¶

func (o *MPSRNNMatrixInferenceLayer) OutputFeatureChannels() uint

@property outputFeatureChannels @abstract The number of feature channels in the output vector/matrix.

func (*MPSRNNMatrixInferenceLayer) RecurrentOutputIsTemporary ¶

func (o *MPSRNNMatrixInferenceLayer) RecurrentOutputIsTemporary() bool

@property recurrentOutputIsTemporary @abstract How output states from @ref encodeSequenceToCommandBuffer are constructed. Defaults to NO. For reference @see MPSState.

func (*MPSRNNMatrixInferenceLayer) SetBidirectionalCombineMode ¶

func (o *MPSRNNMatrixInferenceLayer) SetBidirectionalCombineMode(bidirectionalCombineMode MPSRNNBidirectionalCombineMode)

func (*MPSRNNMatrixInferenceLayer) SetRecurrentOutputIsTemporary ¶

func (o *MPSRNNMatrixInferenceLayer) SetRecurrentOutputIsTemporary(recurrentOutputIsTemporary bool)

func (*MPSRNNMatrixInferenceLayer) SetStoreAllIntermediateStates ¶

func (o *MPSRNNMatrixInferenceLayer) SetStoreAllIntermediateStates(storeAllIntermediateStates bool)

func (*MPSRNNMatrixInferenceLayer) StoreAllIntermediateStates ¶

func (o *MPSRNNMatrixInferenceLayer) StoreAllIntermediateStates() bool

@property storeAllIntermediateStates @abstract If YES then calls to @ref encodeSequenceToCommandBuffer return every recurrent state in the array: recurrentOutputStates. Defaults to NO.

type MPSRNNMatrixTrainingLayer ¶

type MPSRNNMatrixTrainingLayer struct {
	mpscore.MPSKernel
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsrnnmatrixtraininglayer

func MPSRNNMatrixTrainingLayerFromID ¶

func MPSRNNMatrixTrainingLayerFromID(id objc.ID) *MPSRNNMatrixTrainingLayer

func (*MPSRNNMatrixTrainingLayer) AccumulateWeightGradients ¶

func (o *MPSRNNMatrixTrainingLayer) AccumulateWeightGradients() bool

@property accumulateWeightGradients @abstract If yes then the computed weight gradients are accumulated on top of existing values in calls to the gradient computation functions: encodeGradientSequenceToCommandBuffer. Defaults to NO.

func (*MPSRNNMatrixTrainingLayer) CreateTemporaryWeightGradientMatricesDataTypeCommandBuffer ¶

func (o *MPSRNNMatrixTrainingLayer) CreateTemporaryWeightGradientMatricesDataTypeCommandBuffer(matricesOut *foundation.NSMutableArray[*mpscore.MPSMatrix], dataType mpscore.MPSDataType, commandBuffer metal.MTLCommandBuffer)

@abstract As @ref createWeightGradientMatrices, but the matrices will be temporary with readCount = 1, which means that they become invalid after the first encode call that reads them. Note also that as the matrices are temporary, their storage mode will be private which means that you can only access the data using a kernel on the GPU. @param matricesOut An array where the newly created matrices will be stored, will be initialized to zero. @param dataType Datatype for the entries - currently MPSDataTypeFloat32 and MPSDataTypeFloat16 are supported. @param commandBuffer The command buffer that the temporary matrices will live on.

func (*MPSRNNMatrixTrainingLayer) CreateWeightGradientMatricesDataType ¶

func (o *MPSRNNMatrixTrainingLayer) CreateWeightGradientMatricesDataType(matricesOut *foundation.NSMutableArray[*mpscore.MPSMatrix], dataType mpscore.MPSDataType)

@abstract Initializes a set of matrices that can be used in training for weight and bias gradient outputs in @see encodeBackwardSequenceToCommandBuffer. Can be also used to easily create auxiliary matrices for example for ADAM and other advanced optimization schemes. The layout and number of matrices is the same as for the outputs of @see initWithDevice, but the data type may differ. NOTE: These matrices cannot be used as weight matrices in the forward and backward encode calls, but matrices from initWithDevice() or createWeightMatrices() should be used instead. @param matricesOut An array where the newly created matrices will be stored, will be initialized to zero. @param dataType Datatype for the entries - currently MPSDataTypeFloat32 and MPSDataTypeFloat16 are supported.

func (*MPSRNNMatrixTrainingLayer) CreateWeightMatrices ¶

func (o *MPSRNNMatrixTrainingLayer) CreateWeightMatrices(matricesOut *foundation.NSMutableArray[*mpscore.MPSMatrix])

@abstract Initializes a set of matrices that can be used in training for weight and bias matrices in the forward and backward passes. The layout, datatype and number of matrices is the same as for the outputs of @see initWithDevice. @param matricesOut An array where the newly created matrices will be stored, will be initialized to zero.

func (*MPSRNNMatrixTrainingLayer) EncodeCopyWeightsToCommandBufferWeightsMatrixIdMatrixCopyFromWeightsToMatrixMatrixOffset ¶

func (o *MPSRNNMatrixTrainingLayer) EncodeCopyWeightsToCommandBufferWeightsMatrixIdMatrixCopyFromWeightsToMatrixMatrixOffset(commandBuffer metal.MTLCommandBuffer, weights *foundation.NSArray[*mpscore.MPSMatrix], matrixId MPSRNNMatrixId, matrix *mpscore.MPSMatrix, copyFromWeightsToMatrix bool, matrixOffset metal.MTLOrigin)

func (*MPSRNNMatrixTrainingLayer) EncodeForwardSequenceToCommandBufferSourceMatricesDestinationMatricesTrainingStatesWeights ¶

func (o *MPSRNNMatrixTrainingLayer) EncodeForwardSequenceToCommandBufferSourceMatricesDestinationMatricesTrainingStatesWeights(commandBuffer metal.MTLCommandBuffer, sourceMatrices *foundation.NSArray[*mpscore.MPSMatrix], destinationMatrices *foundation.NSArray[*mpscore.MPSMatrix], trainingStates *foundation.NSMutableArray[*MPSRNNMatrixTrainingState], weights *foundation.NSArray[*mpscore.MPSMatrix])

func (*MPSRNNMatrixTrainingLayer) EncodeForwardSequenceToCommandBufferSourceMatricesSourceOffsetsDestinationMatricesDestinationOffsetsTrainingStatesRecurrentInputStateRecurrentOutputStatesWeights ¶

func (o *MPSRNNMatrixTrainingLayer) EncodeForwardSequenceToCommandBufferSourceMatricesSourceOffsetsDestinationMatricesDestinationOffsetsTrainingStatesRecurrentInputStateRecurrentOutputStatesWeights(commandBuffer metal.MTLCommandBuffer, sourceMatrices *foundation.NSArray[*mpscore.MPSMatrix], sourceOffsets *uint, destinationMatrices *foundation.NSArray[*mpscore.MPSMatrix], destinationOffsets *uint, trainingStates *foundation.NSMutableArray[*MPSRNNMatrixTrainingState], recurrentInputState *MPSRNNRecurrentMatrixState, recurrentOutputStates *foundation.NSMutableArray[*MPSRNNRecurrentMatrixState], weights *foundation.NSArray[*mpscore.MPSMatrix])

func (*MPSRNNMatrixTrainingLayer) EncodeGradientSequenceToCommandBufferForwardSourcesForwardSourceOffsetsSourceGradientsSourceGradientOffsetsDestinationGradientsDestinationOffsetsWeightGradientsTrainingStatesRecurrentInputStateRecurrentOutputStatesWeights ¶

func (o *MPSRNNMatrixTrainingLayer) EncodeGradientSequenceToCommandBufferForwardSourcesForwardSourceOffsetsSourceGradientsSourceGradientOffsetsDestinationGradientsDestinationOffsetsWeightGradientsTrainingStatesRecurrentInputStateRecurrentOutputStatesWeights(commandBuffer metal.MTLCommandBuffer, forwardSources *foundation.NSArray[*mpscore.MPSMatrix], forwardSourceOffsets *uint, sourceGradients *foundation.NSArray[*mpscore.MPSMatrix], sourceGradientOffsets *uint, destinationGradients *foundation.NSArray[*mpscore.MPSMatrix], destinationOffsets *uint, weightGradients *foundation.NSArray[*mpscore.MPSMatrix], trainingStates *foundation.NSArray[*MPSRNNMatrixTrainingState], recurrentInputState *MPSRNNRecurrentMatrixState, recurrentOutputStates *foundation.NSMutableArray[*MPSRNNRecurrentMatrixState], weights *foundation.NSArray[*mpscore.MPSMatrix])

func (*MPSRNNMatrixTrainingLayer) EncodeGradientSequenceToCommandBufferForwardSourcesSourceGradientsDestinationGradientsWeightGradientsTrainingStatesWeights ¶

func (o *MPSRNNMatrixTrainingLayer) EncodeGradientSequenceToCommandBufferForwardSourcesSourceGradientsDestinationGradientsWeightGradientsTrainingStatesWeights(commandBuffer metal.MTLCommandBuffer, forwardSources *foundation.NSArray[*mpscore.MPSMatrix], sourceGradients *foundation.NSArray[*mpscore.MPSMatrix], destinationGradients *foundation.NSArray[*mpscore.MPSMatrix], weightGradients *foundation.NSArray[*mpscore.MPSMatrix], trainingStates *foundation.NSArray[*MPSRNNMatrixTrainingState], weights *foundation.NSArray[*mpscore.MPSMatrix])

func (*MPSRNNMatrixTrainingLayer) InitWithCoderDevice ¶

func (o *MPSRNNMatrixTrainingLayer) InitWithCoderDevice(aDecoder *foundation.NSCoder, device metal.MTLDevice) *MPSRNNMatrixTrainingLayer

@abstract NSSecureCoding compatability @discussion See @ref MPSKernel#initWithCoder. @param aDecoder The NSCoder subclass with your serialized MPSRNNMatrixTrainingLayer @param device The MTLDevice on which to make the MPSRNNMatrixTrainingLayer @return A new MPSRNNMatrixTrainingLayer object, or nil if failure.

func (*MPSRNNMatrixTrainingLayer) InitWithDeviceRnnDescriptorTrainableWeights ¶

func (o *MPSRNNMatrixTrainingLayer) InitWithDeviceRnnDescriptorTrainableWeights(device metal.MTLDevice, rnnDescriptor *MPSRNNDescriptor, trainableWeights *foundation.NSMutableArray[*mpscore.MPSMatrix]) *MPSRNNMatrixTrainingLayer

@abstract Initializes a linear (fully connected) RNN kernel for training @param device The MTLDevice on which this MPSRNNMatrixLayer filter will be used @param rnnDescriptor The descriptor that defines the RNN layer @param trainableWeights An array where to store the weights of the layer as MPSMatrices. NOTE: The exact layout and number of matrices may vary between platforms and therefore you should not save out these weights directly, but instead use the function encodeCopyWeightsToCommandBuffer to identify the weights and biases for serialization. Typically you should pass here an initialized but empty NSMutableArray and when this function returns the array will have been populated with the weight matrices needed in the encode-calls, by using initial values from the datasources in rnnDescriptor. @return A valid MPSRNNMatrixTrainingLayer object or nil, if failure.

func (*MPSRNNMatrixTrainingLayer) InputFeatureChannels ¶

func (o *MPSRNNMatrixTrainingLayer) InputFeatureChannels() uint

@property inputFeatureChannels @abstract The number of feature channels input vector/matrix.

func (*MPSRNNMatrixTrainingLayer) OutputFeatureChannels ¶

func (o *MPSRNNMatrixTrainingLayer) OutputFeatureChannels() uint

@property outputFeatureChannels @abstract The number of feature channels in the output vector/matrix.

func (*MPSRNNMatrixTrainingLayer) RecurrentOutputIsTemporary ¶

func (o *MPSRNNMatrixTrainingLayer) RecurrentOutputIsTemporary() bool

@property recurrentOutputIsTemporary @abstract How recurrent output states from @ref encodeForwardSequenceToCommandBuffer and encodeGradientSequenceToCommandBuffer are constructed. Defaults to NO. For reference @see MPSState.

func (*MPSRNNMatrixTrainingLayer) SetAccumulateWeightGradients ¶

func (o *MPSRNNMatrixTrainingLayer) SetAccumulateWeightGradients(accumulateWeightGradients bool)

func (*MPSRNNMatrixTrainingLayer) SetRecurrentOutputIsTemporary ¶

func (o *MPSRNNMatrixTrainingLayer) SetRecurrentOutputIsTemporary(recurrentOutputIsTemporary bool)

func (*MPSRNNMatrixTrainingLayer) SetStoreAllIntermediateStates ¶

func (o *MPSRNNMatrixTrainingLayer) SetStoreAllIntermediateStates(storeAllIntermediateStates bool)

func (*MPSRNNMatrixTrainingLayer) SetTrainingStateIsTemporary ¶

func (o *MPSRNNMatrixTrainingLayer) SetTrainingStateIsTemporary(trainingStateIsTemporary bool)

func (*MPSRNNMatrixTrainingLayer) StoreAllIntermediateStates ¶

func (o *MPSRNNMatrixTrainingLayer) StoreAllIntermediateStates() bool

@property storeAllIntermediateStates @abstract If YES then calls to functions @ref encodeForwardSequenceToCommandBuffer and @ref encodeGradientSequenceToCommandBuffer return every recurrent state in the array: recurrentOutputStates. Defaults to NO.

func (*MPSRNNMatrixTrainingLayer) TrainingStateIsTemporary ¶

func (o *MPSRNNMatrixTrainingLayer) TrainingStateIsTemporary() bool

@property trainingStateIsTemporary @abstract How training output states from @ref encodeForwardSequenceToCommandBuffer are constructed. Defaults to NO. For reference @see MPSState.

type MPSRNNRecurrentImageState ¶

type MPSRNNRecurrentImageState struct {
	mpscore.MPSState
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsrnnrecurrentimagestate

func MPSRNNRecurrentImageStateFromID ¶

func MPSRNNRecurrentImageStateFromID(id objc.ID) *MPSRNNRecurrentImageState

func (*MPSRNNRecurrentImageState) GetMemoryCellImageForLayerIndex ¶

func (o *MPSRNNRecurrentImageState) GetMemoryCellImageForLayerIndex(layerIndex uint) *mpscore.MPSImage

@abstract Access the stored memory cell image data (if present). @param layerIndex Index of the layer whose to get - belongs to { 0, 1,...,@see numberOfLayers - 1 } @return For valid layerIndex the memory cell image data, otherwise nil.

func (*MPSRNNRecurrentImageState) GetRecurrentOutputImageForLayerIndex ¶

func (o *MPSRNNRecurrentImageState) GetRecurrentOutputImageForLayerIndex(layerIndex uint) *mpscore.MPSImage

@abstract Access the stored recurrent image data. @param layerIndex Index of the layer whose to get - belongs to { 0, 1,...,@see numberOfLayers - 1 } @return For valid layerIndex the recurrent output image data, otherwise nil.

type MPSRNNRecurrentMatrixState ¶

type MPSRNNRecurrentMatrixState struct {
	mpscore.MPSState
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsrnnrecurrentmatrixstate

func MPSRNNRecurrentMatrixStateFromID ¶

func MPSRNNRecurrentMatrixStateFromID(id objc.ID) *MPSRNNRecurrentMatrixState

func (*MPSRNNRecurrentMatrixState) GetMemoryCellMatrixForLayerIndex ¶

func (o *MPSRNNRecurrentMatrixState) GetMemoryCellMatrixForLayerIndex(layerIndex uint) *mpscore.MPSMatrix

@abstract Access the stored memory cell matrix data (if present). @param layerIndex Index of the layer whose to get - belongs to { 0, 1,...,@see numberOfLayers - 1 } @return For valid layerIndex the memory cell image matrix, otherwise nil.

func (*MPSRNNRecurrentMatrixState) GetRecurrentOutputMatrixForLayerIndex ¶

func (o *MPSRNNRecurrentMatrixState) GetRecurrentOutputMatrixForLayerIndex(layerIndex uint) *mpscore.MPSMatrix

@abstract Access the stored recurrent matrix data. @param layerIndex Index of the layer whose to get - belongs to { 0, 1,...,@see numberOfLayers - 1 } @return For valid layerIndex the recurrent output matrix data, otherwise nil.

type MPSRNNSequenceDirection ¶

type MPSRNNSequenceDirection uint64
const (
	// The input sequence is processed from index zero to array length minus one
	MPSRNNSequenceDirectionForward MPSRNNSequenceDirection = 0
	// The input sequence is processed from index array length minus one to zero
	MPSRNNSequenceDirectionBackward MPSRNNSequenceDirection = 1
)

func (MPSRNNSequenceDirection) String ¶

func (e MPSRNNSequenceDirection) String() string

type MPSRNNSingleGateDescriptor ¶

type MPSRNNSingleGateDescriptor struct {
	MPSRNNDescriptor
}

Apple documentation: https://developer.apple.com/documentation/mpsneuralnetwork/mpsrnnsinglegatedescriptor

func MPSRNNSingleGateDescriptorCreateRNNSingleGateDescriptorWithInputFeatureChannelsOutputFeatureChannels ¶

func MPSRNNSingleGateDescriptorCreateRNNSingleGateDescriptorWithInputFeatureChannelsOutputFeatureChannels(inputFeatureChannels uint, outputFeatureChannels uint) *MPSRNNSingleGateDescriptor

@abstract Creates a MPSRNNSingleGateDescriptor @param inputFeatureChannels The number of feature channels in the input image/matrix. Must be >= 1. @param outputFeatureChannels The number of feature channels in the output image/matrix. Must be >= 1. @return A valid MPSRNNSingleGateDescriptor object or nil, if failure.

func MPSRNNSingleGateDescriptorFromID ¶

func MPSRNNSingleGateDescriptorFromID(id objc.ID) *MPSRNNSingleGateDescriptor

func (*MPSRNNSingleGateDescriptor) InputWeights ¶

@property inputWeights @abstract Contains weights 'W_ij', bias 'b_i' and neuron 'gi' from the simple RNN layer formula. If nil then assumed zero weights, bias and no neuron (identity mapping). Defaults to nil.

func (*MPSRNNSingleGateDescriptor) RecurrentWeights ¶

@property recurrentWeights @abstract Contains weights 'U_ij' from the simple RNN layer formula. If nil then assumed zero weights. Defaults to nil.

func (*MPSRNNSingleGateDescriptor) SetInputWeights ¶

func (o *MPSRNNSingleGateDescriptor) SetInputWeights(inputWeights MPSCNNConvolutionDataSource)

func (*MPSRNNSingleGateDescriptor) SetRecurrentWeights ¶

func (o *MPSRNNSingleGateDescriptor) SetRecurrentWeights(recurrentWeights MPSCNNConvolutionDataSource)

type Mach_vm_range_flags_t ¶

type Mach_vm_range_flags_t int64
const (
	MACH_VM_RANGE_NONE Mach_vm_range_flags_t = 0
)

func (Mach_vm_range_flags_t) String ¶

func (e Mach_vm_range_flags_t) String() string

type Mach_vm_range_flavor_t ¶

type Mach_vm_range_flavor_t int64
const (
	MACH_VM_RANGE_FLAVOR_INVALID Mach_vm_range_flavor_t = 0
	MACH_VM_RANGE_FLAVOR_V1      Mach_vm_range_flavor_t = 1
)

func (Mach_vm_range_flavor_t) String ¶

func (e Mach_vm_range_flavor_t) String() string

type Mach_vm_range_tag_t ¶

type Mach_vm_range_tag_t int64
const (
	MACH_VM_RANGE_DEFAULT Mach_vm_range_tag_t = 0
	MACH_VM_RANGE_DATA    Mach_vm_range_tag_t = 1
	MACH_VM_RANGE_FIXED   Mach_vm_range_tag_t = 2
)

func (Mach_vm_range_tag_t) String ¶

func (e Mach_vm_range_tag_t) String() string

type Mpo_flags_t ¶

type Mpo_flags_t int64
const (
	MPO_PORT                            Mpo_flags_t = 0
	MPO_SERVICE_PORT                    Mpo_flags_t = 1024
	MPO_CONNECTION_PORT                 Mpo_flags_t = 2048
	MPO_REPLY_PORT                      Mpo_flags_t = 4096
	MPO_WEAK_REPLY_PORT                 Mpo_flags_t = 16384
	MPO_NOTIFICATION_PORT               Mpo_flags_t = 17408
	MPO_EXCEPTION_PORT                  Mpo_flags_t = 32768
	MPO_CONNECTION_PORT_WITH_PORT_ARRAY Mpo_flags_t = 65536
)

func (Mpo_flags_t) String ¶

func (e Mpo_flags_t) String() string

type Os_clockid_t ¶

type Os_clockid_t int64
const (
	OS_CLOCK_MACH_ABSOLUTE_TIME Os_clockid_t = 32
)

func (Os_clockid_t) String ¶

func (e Os_clockid_t) String() string

type Ptrauth_key ¶

type Ptrauth_key int64
const (
	Ptrauth_key_none                     Ptrauth_key = -1
	Ptrauth_key_asia                     Ptrauth_key = 0
	Ptrauth_key_asib                     Ptrauth_key = 1
	Ptrauth_key_asda                     Ptrauth_key = 2
	Ptrauth_key_asdb                     Ptrauth_key = 3
	Ptrauth_key_process_independent_code Ptrauth_key = 0
	Ptrauth_key_process_dependent_code   Ptrauth_key = 1
	Ptrauth_key_process_independent_data Ptrauth_key = 2
	Ptrauth_key_process_dependent_data   Ptrauth_key = 3
	Ptrauth_key_return_address           Ptrauth_key = 1
	Ptrauth_key_frame_pointer            Ptrauth_key = 3
	Ptrauth_key_function_pointer         Ptrauth_key = 0
	Ptrauth_key_block_function           Ptrauth_key = 0
	Ptrauth_key_cxx_vtable_pointer       Ptrauth_key = 2
	Ptrauth_key_method_list_pointer      Ptrauth_key = 2
	Ptrauth_key_objc_isa_pointer         Ptrauth_key = 2
	Ptrauth_key_objc_super_pointer       Ptrauth_key = 2
	Ptrauth_key_objc_sel_pointer         Ptrauth_key = 3
	Ptrauth_key_objc_class_ro_pointer    Ptrauth_key = 2
	Ptrauth_key_block_descriptor_pointer Ptrauth_key = 2
	Ptrauth_key_init_fini_pointer        Ptrauth_key = 0
)

func (Ptrauth_key) String ¶

func (e Ptrauth_key) String() string

type Qos_class_t ¶

type Qos_class_t uint32
const (
	QOS_CLASS_USER_INTERACTIVE Qos_class_t = 33
	QOS_CLASS_USER_INITIATED   Qos_class_t = 25
	QOS_CLASS_DEFAULT          Qos_class_t = 21
	QOS_CLASS_UTILITY          Qos_class_t = 17
	QOS_CLASS_BACKGROUND       Qos_class_t = 9
	QOS_CLASS_UNSPECIFIED      Qos_class_t = 0
)

func (Qos_class_t) String ¶

func (e Qos_class_t) String() string

type Virtual_memory_guard_exception_code_t ¶

type Virtual_memory_guard_exception_code_t int64
const (
	KGUARD_EXC_DEALLOC_GAP                   Virtual_memory_guard_exception_code_t = 1
	KGUARD_EXC_RECLAIM_COPYIO_FAILURE        Virtual_memory_guard_exception_code_t = 2
	KGUARD_EXC_RECLAIM_INDEX_FAILURE         Virtual_memory_guard_exception_code_t = 4
	KGUARD_EXC_RECLAIM_DEALLOCATE_FAILURE    Virtual_memory_guard_exception_code_t = 8
	KGUARD_EXC_RECLAIM_ACCOUNTING_FAILURE    Virtual_memory_guard_exception_code_t = 9
	KGUARD_EXC_SEC_IOPL_ON_EXEC_PAGE         Virtual_memory_guard_exception_code_t = 10
	KGUARD_EXC_SEC_EXEC_ON_IOPL_PAGE         Virtual_memory_guard_exception_code_t = 11
	KGUARD_EXC_SEC_UPL_WRITE_ON_EXEC_REGION  Virtual_memory_guard_exception_code_t = 12
	KGUARD_EXC_LARGE_ALLOCATION_TELEMETRY    Virtual_memory_guard_exception_code_t = 13
	KGUARD_EXC_SEC_ACCESS_FAULT              Virtual_memory_guard_exception_code_t = 98
	KGUARD_EXC_SEC_ASYNC_ACCESS_FAULT        Virtual_memory_guard_exception_code_t = 99
	KGUARD_EXC_SEC_COPY_DENIED               Virtual_memory_guard_exception_code_t = 100
	KGUARD_EXC_SEC_SHARING_DENIED            Virtual_memory_guard_exception_code_t = 101
	KGUARD_EXC_MTE_SYNC_FAULT                Virtual_memory_guard_exception_code_t = 200
	KGUARD_EXC_MTE_ASYNC_USER_FAULT          Virtual_memory_guard_exception_code_t = 201
	KGUARD_EXC_MTE_ASYNC_KERN_FAULT          Virtual_memory_guard_exception_code_t = 202
	KGUARD_EXC_GUARD_OBJECT_ASYNC_USER_FAULT Virtual_memory_guard_exception_code_t = 203
	KGUARD_EXC_GUARD_OBJECT_ASYNC_KERN_FAULT Virtual_memory_guard_exception_code_t = 204
)

func (Virtual_memory_guard_exception_code_t) String ¶

type Xpc_listener_create_flags_t ¶

type Xpc_listener_create_flags_t int64
const (
	XPC_LISTENER_CREATE_NONE             Xpc_listener_create_flags_t = 0
	XPC_LISTENER_CREATE_INACTIVE         Xpc_listener_create_flags_t = 1
	XPC_LISTENER_CREATE_FORCE_MACH       Xpc_listener_create_flags_t = 2
	XPC_LISTENER_CREATE_FORCE_XPCSERVICE Xpc_listener_create_flags_t = 4
)

func (Xpc_listener_create_flags_t) String ¶

type Xpc_session_create_flags_t ¶

type Xpc_session_create_flags_t int64
const (
	XPC_SESSION_CREATE_NONE            Xpc_session_create_flags_t = 0
	XPC_SESSION_CREATE_INACTIVE        Xpc_session_create_flags_t = 1
	XPC_SESSION_CREATE_MACH_PRIVILEGED Xpc_session_create_flags_t = 2
)

func (Xpc_session_create_flags_t) String ¶

Source Files ¶

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL