The article directories

  • Apple Framework Learning (I) Accelerate. Framework

  • 1. Accelerate introduction

  • Neural networks

    • 1.1 Train neural network to recognize numbers
    • 1.2 BNNS
  • 2. Archive directories, files and data

    • 2.1 Compressing a File
    • 2.2 Decompressing a Single file
    • 2.3 Compressing a File System Directory
    • 2.4 Decompress and decompress the archive directory
    • 2.5 Compress and save the Character string to the file system
    • 2.6 Decompress and parse archive strings
  • 3. The compression

    • 3.1 Using Buffer Compression to compress and decompress data
    • 3.2 Compress the string, write it to the file system, and then use buffer compression to decompress the same file.
    • 3.3 Compress and decompress data with input and output filters
    • 3.4 Compressing and Decompressing Files and Swift stream compression
  • 4. Key points of image processing

    • 4.1 Create a core graphical image format
    • 4.2 Create and populate buffers from core graphics images
    • 4.3 Create a core graphic image from the vImage buffer
    • 4.4 Build a basic image processing workflow
    • 4.5 Apply the vImage operation to the area of interest
    • 4.6 Optimize image processing performance
    • 4.7 vImage
  • 5. Key points of signal processing

    • 5.1 Control vDSP operation with Stride
    • 5.2 Use linear interpolation to construct new data points
    • 5.3 Using vDSP to achieve vector-based algorithm
    • 5.4 Resampling the signal by extraction method
    • 5.5 vDSP
  • 6. Core video interoperability

    • 6.1 Reading and writing core video pixel buffer
    • 6.2 Video sample buffer with vImage operation applied
    • 6.3 Real-time Video Effects and vImage
    • 6.4 Core video interoperability
  • 7. Vectors, matrices, and quaternions

    • 7.1 Using Vectors

    • 7.2 Using matrices

    • 7.3 Using quaternions

    • 7.4 Rotate the cube by changing its vertices

    • 7.5 simd

  • Fourier transform and cosine transform

    • 8.1 Finding the frequencies of each component of the complex sine wave
    • 8.2 Using Windows and the Discrete Fourier Transform
    • 8.3 Extraction of noise signal
    • 8.4 Halftone noise reduction and two-dimensional fast Fourier transform
    • 8.5 Fast Fourier Transform
    • 8.6 Discrete Fourier transform
    • 8.7 Discrete cosine transform
  • 9. Audio processing

    • 9.1 Balancing Audio and vDSP
    • 9.2 Biquadratic IIR filter
    • 9.3 Discrete cosine transform
  • 10. Conversion between image formats

    • 10.1 Build a basic transformation workflow
    • 10.2 Converting color images to grayscale
    • 10.3 Any image format for standardized processing
    • 10.4 Convert brightness and chroma planes to ARGB images
    • 10.5 conversion
  • 11. Image resampling

    • 11.1 Resampling at vImage
    • 11.2 Reduce artifacts in resampling images
    • 11.3 Image Clipping
  • 12. Convolution and morphology

    • 12.1 Blurred Image
    • 12.2 Adding bokeh Effect
    • 12.3 convolution
    • 12.4 form
  • 13. Color and tone adjustment

    • 13.1 Adjust the brightness and contrast of the image
    • 13.2. Adjust saturation and apply hue mapping
    • 13.3 Adjust the tone of the image
    • 13.4 Specify histograms with vImage
    • 13.5 transform
  • 13.6 bar charts

  • 14. VImage/vDSP interoperability

    • 14.1 Find the clearest image in a series of captured images
    • 14.2 Visualize sound as a spectrogram
  • 15. Sparse matrix

    • 15.1 Creating a Sparse Matrix
    • 15.2 Implementation of iterative methods
    • 15.3 Solve the system in a direct way
    • 15.4 Use iterative method to solve the system
    • 15.5 Create a sparse matrix from an array of coordinate formats
    • 15.6 Sparse Solver
  • 16. Arithmetic and transcendental functions

  • 17. Linear algebra

    • 17.1 Use Vandermonde method to find interpolation polynomials
    • 17.2 BLAS
  • 18. Explicit integration

  • 19. The enumeration

  • 20. Agreement

Apple Framework Learning (I) Accelerate. Framework

1. Accelerate introduction

What can the Accelerate framework do?

Large-scale mathematical calculations and image calculations are optimized for high performance and low energy consumption.

By leveraging its vector processing capabilities, Accelerate delivers high-performance, energy-efficient computing on cpus. The following accelerators abstract this ability so that the code written for them executes the appropriate processor instructions at runtime:

  • BNNS. Subroutines that construct and run neural networks for training and reasoning.

  • VImage. Extensive image processing capabilities, including core graphics and core video interoperation, format conversion and image processing.

  • VDSP. Digital signal processing functions, including one – and two-dimensional fast Fourier transforms, biquadratic filtering, vector and matrix operations, convolution, and type conversion.

  • VForce. A function that performs arithmetic and transcendental functions on vectors.

  • Sparse Solvers, BLAS, and LAPACK. Library for performing linear algebra on sparse and dense matrices.

Although not part of the acceleration framework, the following libraries are closely related:

  • Apple Archive. A framework for performing multithreaded lossless compression of directories, files, and data.

  • Compression (Compression will). Lossless data compression algorithm supporting LZFSE, LZ4, LZMA and ZLIB algorithms.

  • Simd. A module that computes small vectors and matrices.

Neural networks

1.1 Train neural network to recognize numbers

Apple official training neural network to recognize numbers demo: click here to download

Build a simple neural network and train it to recognize randomly generated numbers.

1.2 BNNS

BNNS implements and runs neural networks for training and reasoning.

The Acceleration framework’s BNNS library is a collection of functions that you can use to build neural networks for training and reasoning. It is supported by macOS, iOS, tvOS, and watchOS. BNNS provides high performance and low power optimization routines for all cpus supported on these platforms.

2. Archive directories, files and data

2.1 Compressing a File

Compress a file Compress a file and store the result on the file system.

2.2 Decompressing a Single file

Unzip a single file To recreate a single file from a compressed file.

2.3 Compressing a File System Directory

Compressing a file system directory compresses the contents of the entire directory and stores the results on the file system.

2.4 Decompress and decompress the archive directory

Set an entire file system directory from an archive file.

2.5 Compress and save the Character string to the file system

Compress and save strings to the file system Compress the contents of Unicode strings and store the results in the file system.

2.6 Decompress and parse archive strings

Unzip and parse archive strings to recreate strings from archive files

3. The compression

3.1 Using Buffer Compression to compress and decompress data

Use buffer compression to compress and unzip the data compression string, write it to the file system, and then unzip the same file using buffer compression.

3.2 Compress the string, write it to the file system, and then use buffer compression to decompress the same file.

Compress the string, write it to the file system, and then unzip the same file using buffer compression. Perform compression or appropriate decompression of the file based on its path extension.

3.3 Compress and decompress data with input and output filters

Compress and decompress data with input and output filters Compress and decompress streaming data or data from memory with input and output filters.

3.4 Compressing and Decompressing Files and Swift stream compression

Compression and decompression files and Swift stream compression Perform compression on all files and decompress files supported by the extension type.

4. Key points of image processing

4.1 Create a core graphical image format

Create a core graphics image format to provide a description of the core graphics image format for conversion between vimages.

4.2 Create and populate buffers from core graphics images

Create and fill buffer from core graphics image Initializes vImage buffer from core graphics image.

4.3 Create a core graphic image from the vImage buffer

Create a core graphics image from the vImage buffer To create a displayable representation of the vImage buffer.

4.4 Build a basic image processing workflow

Build a basic image processing workflow to resize images with vImage.

4.5 Apply the vImage operation to the area of interest

Apply the vImage operation to the region of interest.

4.6 Optimize image processing performance

Optimize image processing performance improve the performance of your application by converting image buffering formats from interlaced to flat.

4.7 vImage

VImage uses the CPU’s vector processor to process large images.

5. Key points of signal processing

5.1 Control vDSP operation with Stride

Stride control vDSP operation is used to selectively operate the elements of the vector on a regular basis.

5.2 Use linear interpolation to construct new data points

Use linear interpolation to construct new data points Use linear interpolation to fill gaps in numeric data arrays.

5.3 Using vDSP to achieve vector-based algorithm

The performance of common mathematical tasks is improved by vDSP vector-vector and vector-scalar operations.

5.4 Resampling the signal by extraction method

Resampling signal by extraction method can reduce the sampling rate of signal by specifying extraction factor and applying custom anti-aliasing filter.

5.5 vDSP

VDSP performs basic arithmetic operations and common digital signal processing programs on large vectors.

6. Core video interoperability

6.1 Reading and writing core video pixel buffer

Read and write The core video pixel buffer transfers image data between the core video pixel buffer and the vImage buffer to integrate vImage operations into the core image workflow

6.2 Video sample buffer with vImage operation applied

The video sample buffer with vImage operation uses the any-to-any function of vImage to perform real-time image processing on the video frames flowing from the camera of the device.

6.3 Real-time Video Effects and vImage

Real-time video effects and vImage Using vImage application effects of the video feed in real time.

6.4 Core video interoperability

Core Video interoperability transfers image data between Core Video and vImage.

7. Vectors, matrices, and quaternions

7.1 Using Vectors

Use vectors use vectors to compute geometric values, to compute dot and cross products, and to interpolate between values.

7.2 Using matrices

Use matrices to solve simultaneous equations and transform points in space.

7.3 Using quaternions

Rotate the points on the surface of the sphere using a quaternion and insert between them.

7.4 Rotate the cube by changing its vertices

Rotate the cube by changing the vertices of it using quaternion interpolation to rotate the cube between a series of keyframes.

7.5 simd

Simd computes small vectors and matrices.

Fourier transform and cosine transform

8.1 Finding the frequencies of each component of the complex sine wave

The frequency components of the composite sine wave are calculated using the one-dimensional Fast Fourier transform.

8.2 Using Windows and the Discrete Fourier Transform

The signal data is multiplied by the window sequence values using window and discrete Fourier transform to reduce spectrum leakage.

8.3 Extraction of noise signal

Noise signal is extracted by accelerated discrete cosine transform (DCT).

8.4 Halftone noise reduction and two-dimensional fast Fourier transform

Halftone denoising and two-dimensional fast Fourier transform reduce or delete periodic artifacts in images.

8.5 Fast Fourier Transform

The FAST Fourier transform transforms vectors and matrices of complex values in the time domain and space domain into the frequency domain and vice versa.

8.6 Discrete Fourier transform

The discrete Fourier transform transforms vectors of complex values in the time domain and space domain into the frequency domain and vice versa.

8.7 Discrete cosine transform

DCT transforms real valued vectors in time domain and space domain into frequency domain and vice versa.

9. Audio processing

9.1 Balancing Audio and vDSP

Audio equalization with vDSP shape audio output using discrete cosine transform and biquadratic filter.

9.2 Biquadratic IIR filter

Biquadratic IIR filters Apply biquadratic filters to single-channel and multi-channel data.

9.3 Discrete cosine transform

DCT transforms real valued vectors in time domain and space domain into frequency domain and vice versa.

10. Conversion between image formats

10.1 Build a basic transformation workflow

Build a basic conversion workflow Learn the basics of converting any-to-any functions by converting CMYK images to RGB images.

10.2 Converting color images to grayscale

Convert color images to grayscale Convert color images to grayscale using matrix multiplication.

10.3 Any image format for standardized processing

Standardized processing of any image format conversion assets with different color Spaces and bit depths to a standard working format applies vImage operations.

10.4 Convert brightness and chroma planes to ARGB images

Convert the brightness and chroma plane to ARGB image Create a displayable ARGB image from the brightness and chroma information provided by the device’s camera.

10.5 conversion

Conversion Converts an image to a different format.

11. Image resampling

11.1 Resampling at vImage

Resampling at vImage Learn how vImage resamples image data during geometry operations.

11.2 Reduce artifacts in resampling images

Reduce artifacts in resampling images Avoid the ringing effect introduced by the default Lanczos algorithm when scaling images using custom resampling filters.

11.3 Image Clipping

Image clipping Horizontal and vertical clipping images.

12. Convolution and morphology

12.1 Blurred Image

Fuzzy image filter images convolved with custom and high speed kernels.

12.2 Adding bokeh Effect

Added bokeh effect to expand simulation bokeh effect.

12.3 convolution

Convolution applies the convolution kernel to the image.

12.4 form

Morphological expansion and erosion images.

13. Color and tone adjustment

13.1 Adjust the brightness and contrast of the image

Adjust the brightness and contrast of the image

Use functions to apply linear or exponential curves.

13.2. Adjust saturation and apply hue mapping

Adjust saturation and apply hue mapping

Convert RGB images to discrete brightness and chromaticity channels and apply color and contrast processing.

13.3 Adjust the tone of the image

Adjust the tone of the image

Convert an RGB image to L

a

B * Color space and application of tone adjustment.

13.4 Specify histograms with vImage

Specify the histogram with vImage

Calculate the histogram of one image and apply it to another image.

13.5 transform

transform

Apply color conversion to the image.

13.6 bar charts

A histogram

Computes and or manipulates histograms of images.

14. VImage/vDSP interoperability

14.1 Find the clearest image in a series of captured images

In a series of captured images find the clearest image sharing image data between vDSP and vImage calculate the sharest image from the parentheses photo sequence.

14.2 Visualize sound as a spectrogram

Visualization of sound as a spectrogram Image data is shared between vDSP and vImage to visualize audio captured by the device’s microphone.

15. Sparse matrix

15.1 Creating a Sparse Matrix

Create a sparse matrix Create a sparse matrix for the decomposition and solution system.

15.2 Implementation of iterative methods

Methods that implement iteration use iterative methods to solve large problems faster and with lower memory overhead than direct methods.

15.3 Solve the system in a direct way

Using the direct method to solve systems using the direct method to solve the coefficient matrix is sparse.

15.4 Use iterative method to solve the system

Using iterative methods to solve systems using iterative methods to solve the coefficient matrix is sparse equations.

15.5 Create a sparse matrix from an array of coordinate formats

Create a sparse matrix from a coordinate format array using a separate coordinate format array to create a sparse matrix.

15.6 Sparse Solver

Sparse solver solution coefficient matrix is sparse system of equations.

16. Arithmetic and transcendental functions

VecLib performs computations on large vectors.

17. Linear algebra

17.1 Use Vandermonde method to find interpolation polynomials

The Vandermonde method is used to solve a linear system with LAPACK and find an interpolation polynomial to construct a new point between a series of known data points.

17.2 BLAS

BLAS Basic Linear Algebra subroutine (BLAS) implemented by Apple.

18. Explicit integration

Quadrature approximates the definite integral of a function over a finite or infinite interval.

19. The enumeration

BNNS acts as an enumeration of the Swift overridden namespace to BNNS.

Base Classes

  • class BNNS.Layer

    The base class for layer objects that wrap filters and manage deinitialization.

  • class BNNS.UnaryLayer

    The base class for layers that accept a single input.

  • class BNNS.BinaryLayer

    The base class for layers that accept two inputs.

Type Methods

– static func applyActivation(activation: BNNS.ActivationFunction, input: –BNNSNDArrayDescriptor, output: BNNSNDArrayDescriptor, batchSize: Int, filterParameters: BNNSFilterParameters?)

– Applies the specified activation function.

– static func applyInTopK(k: Int, input: BNNSNDArrayDescriptor, testIndices:BNNSNDArrayDescriptor, output:BNNSNDArrayDescriptor, axis: Int, batchSize:Int, filterParameters: BNNSFilterParameters?)

Applies an in-top-k filter directly to an input.

– static func applyReduction(BNNS.ReductionFunction,input: BNNSNDArrayDescriptor, output: BNNSNDArrayDescriptor,weights: BNNSNDArrayDescriptor? , filterParameters: BNNSFilterParameters?)

Applies the specified reduction function.

– static func applyTopK(k: Int, input: BNNSNDArrayDescriptor, bestValues: BNNSNDArrayDescriptor, bestIndices: BNNSNDArrayDescriptor,axis: Int, batchSize: Int, filterParameters:BNNSFilterParameters?)

Applies a top-k filter directly to an input.

– static func compare(BNNSNDArrayDescriptor, BNNSNDArrayDescriptor, filterParameters: BNNSFilterParameters?)

– static func transpose(input: BNNSNDArrayDescriptor, output: BNNSNDArrayDescriptor, firstTransposeAxis: Int, secondTransposeAxis: Int, filterParameters: BNNSFilterParameters?)

Classes

class BNNS.ActivationLayer

A layer object that wraps an activation filter and manages its deinitialization.

class BNNS.BinaryArithmeticLayer

A layer object that wraps a binary arithmetic filter and manages its deinitialization.

class BNNS.BroadcastMatrixMultiplyLayer

A layer object that wraps a broadcast matrix multiply filter and manages its deinitialization.

class BNNS.ConvolutionLayer

A layer object that wraps a convolution filter and manages its deinitialization.

class BNNS.DropoutLayer

A layer object that wraps a dropout filter and manages its deinitialization.

class BNNS.FullyConnectedLayer

A layer object that wraps a fully connected filter and manages its deinitialization.

class BNNS.FusedConvolutionNormalizationLayer

A layer object that wraps a fused, convolution normalization layer and manages its deinitialization.

class BNNS.FusedFullyConnectedNormalizationLayer

A layer object that wraps a fused, fully connected normalization layer and manages its deinitialization.

class BNNS.FusedLayer

The base class for fused convolution-normalization and fully connected-normalization layers.

class BNNS.GramLayer

A layer object that wraps a Gram matrix filter and manages its deinitialization.

class BNNS.LossLayer

A layer object that wraps a loss filter and manages its deinitialization.

class BNNS.NormalizationLayer

A layer object that wraps a normalization filter and manages its deinitialization.

class BNNS.PaddingLayer

A layer object that wraps a padding filter and manages its deinitialization.

class BNNS.PermuteLayer

A layer object that wraps a permute filter and manages its deinitialization.

class BNNS.PoolingLayer

A layer object that wraps a pooling filter and manages its deinitialization.

class BNNS.ReductionLayer

A layer object that wraps a reduction filter and manages its deinitialization.

class BNNS.ResizeLayer

A layer object that wraps a resize filter and manages its deinitialization.

class BNNS.UnaryArithmeticLayer

A layer object that wraps a unary arithmetic filter and manages its deinitialization.

Structures

struct BNNS.AdamOptimizer

An optimizer that uses the Adam optimization algorithm.

struct BNNS.RMSPropOptimizer

An optimizer that uses the root-mean-square prop (RMSProp) optimization method.

struct BNNS.RelationalOperator

Constants that describe relational operations.

struct BNNS.SGDMomentumOptimizer

An optimizer that uses the stochastic gradient descent (SGD) with the momentum optimization method.

Enumerations

enum BNNS.ActivationFunction

Constants that describe activation functions.

enum BNNS.ArithmeticBinaryFunction

Constants that describe binary arithmetic functions.

enum BNNS.ArithmeticUnaryFunction

Constants that describe unary arithmetic functions.

enum BNNS.ConvolutionPadding

Constants that describe convolution padding modes.

enum BNNS.ConvolutionType

Constants that describe convolution types.

enum BNNS.DataLayout

Constants that describe the data layout of an n-dimensional array descriptor shape.

enum BNNS.DescriptorType

Constants that describe the input and output types of an arithmetic operation.

enum BNNS.Error

enum BNNS.InterpolationMethod

enum BNNS.LearningPhase

Constants that describe the learning phase of a normalization operation.

enum BNNS.LossFunction

Constants that describe loss functions.

enum BNNS.LossReduction

An enumeration that describes loss reduction functions.

enum BNNS.NormalizationType

Constants that describe normalization types.

enum BNNS.PaddingMode

Constants that define padding modes.

enum BNNS.PoolingType

Constants that describe pooling types.

enum BNNS.ReductionFunction

Constants that describe reduction functions.

enum BNNS.Shape

Constants that describe the size and data layout of an n-dimensional array descriptor.

20. Agreement

protocol BNNSOptimizer

protocol BNNSScalar

* * due to the limited space, only point to namely to introduce current some work and thinking, the framework and some new directions in exploration, if you have the iOS underlying principle, architecture, design, building systems and are interested to know how to interview, * * you can also direct messages I get the latest information in time and the interview. If you have any comments and suggestions welcome to give me a message!

Those who like iOS can follow me and learn and communicate with me!!

The original link: blog.csdn.net/kyl28288954…