One Logo Pool Ball
Accelerate · IOS API REFERENCE

BNNS.UnaryArithmeticLayer

class · iOS 14.0+ · SDK 27.1

class UnaryArithmeticLayer

A unary arithmetic layer. Use a `UnaryArithmeticLayer` to perform arithmetic functions that accept one operand. For example, the following code calculates the element-wise square roots of the values in tensor `a`: let a = BNNSNDArrayDescriptor.allocate(initializingFrom: [4, 9, 16, 25] as [Float], shape: [4]) let out = BNNSNDArrayDescriptor.allocateUninitialized(scalarType: Float.self, shape: [4]) let layer = BNNS.UnaryArithmeticLayer(input: a, inputDescriptorType: .sample, output: out, outputDescriptorType: .sample, function: .squareRoot) try? layer?.apply(batchSize: 1, input: a, output: out) On return, the output tensor contains the the values `[2, 3, 4, 5]`.

Members (3)

method · iOS 14.0+

applyBackward

TypeScript
applyBackward(batchSize: number, input: BNNSNDArrayDescriptor, output: BNNSNDArrayDescriptor, outputGradient: BNNSNDArrayDescriptor, inputGradient: BNNSNDArrayDescriptor): void
Swift declaration
func applyBackward(batchSize: Int, input: BNNSNDArrayDescriptor, output: BNNSNDArrayDescriptor, outputGradient: BNNSNDArrayDescriptor, generatingInputGradient inputGradient: BNNSNDArrayDescriptor) throws

Applies the layer backward to generate gradients. - Parameter batchSize: The number of input-output pairs to process. - Parameter input: The input descriptor. - Parameter output: The output descriptor. - Parameter outputGradient: The output gradient descriptor. - Parameter inputGradient: The input gradient descriptor.

method · iOS 14.0+

apply

TypeScript
apply(batchSize: number, input: BNNSNDArrayDescriptor, output: BNNSNDArrayDescriptor): void
Swift declaration
func apply(batchSize: Int, input: BNNSNDArrayDescriptor, output: BNNSNDArrayDescriptor) throws

Applies the layer, writing the result to the output descriptor. - Parameter batchSize: The number of input-output pairs to process. - Parameter input: The input descriptor. - Parameter output: The output descriptor.

init · iOS 14.0+

init

TypeScript
static init(input: BNNSNDArrayDescriptor, inputDescriptorType: BNNS_DescriptorType, output: BNNSNDArrayDescriptor, outputDescriptorType: BNNS_DescriptorType, function_: BNNS_ArithmeticUnaryFunction, activation?: BNNS_ActivationFunction, filterParameters?: (BNNSFilterParameters) | null): (BNNS_UnaryArithmeticLayer) | null
Swift declaration
convenience init?(input: BNNSNDArrayDescriptor, inputDescriptorType: BNNS.DescriptorType, output: BNNSNDArrayDescriptor, outputDescriptorType: BNNS.DescriptorType, function: BNNS.ArithmeticUnaryFunction, activation: BNNS.ActivationFunction = .identity, filterParameters: BNNSFilterParameters? = nil)

Creates a new unary arithmetic layer. - Parameter input: The input descriptor. - Parameter inputDescriptorType: The descriptor type of the input. - Parameter output: The output descriptor. - Parameter outputDescriptorType: The descriptor type of the output. - Parameter function: The arithmetic operation. - Parameter activation: The activation function to apply to the result. - Parameter filterParameters: Runtime filter parameters. - Returns: A new unary arithmetic layer.

Skipped declarations

No declarations were skipped in this snapshot.

All Accelerate types →