The following protocols are available globally.
-
Provides customization points for
MutableCollection
algorithms.If incorporated into the standard library, these requirements would just be part of
MutableCollection
. In the meantime, you can declare conformance of a collection toMutableCollectionAlgorithms
to get these customization points to be used from other algorithms defined onMutableCollectionAlgorithms
.Declaration
public protocol MutableCollectionAlgorithms: MutableCollection where SubSequence: MutableCollectionAlgorithms
-
Declaration
public protocol TensorFlowScalar : _TensorFlowDataTypeCompatible
-
Declaration
public protocol TensorRangeExpression
-
Types whose elements can be collated in some higher-rank element of the same type (example: tensors, tuple of tensors)
Declaration
public protocol Collatable
-
A type whose nested properties and elements can be copied to a
Device
.Declaration
public protocol CopyableToDevice : _CopyableToDevice
-
A type whose values provides custom key paths to properties or elements.
Declaration
public protocol KeyPathIterable : _KeyPathIterableBase
-
A scalar data type compatible with TensorFlow.
Types that conform to
TensorFlowScalar
can be used as theScalar
associated type ofTensor
. -
An integer data type that represents integer types which can be used as tensor indices in TensorFlow.
Declaration
public protocol TensorFlowIndex : BinaryInteger, TensorFlowScalar
-
A floating-point data type that conforms to
Differentiable
and is compatible with TensorFlow.Note
Tensor
conditionally conforms toDifferentiable
when theScalar
associated type conforms toTensorFlowFloatingPoint
.Declaration
public protocol TensorFlowFloatingPoint: TensorFlowScalar & BinaryFloatingPoint & Differentiable & ElementaryFunctions where Self.RawSignificand: FixedWidthInteger, Self == Self.TangentVector
-
A type that mathematically represents a differentiable manifold whose tangent spaces are finite-dimensional.
Declaration
public protocol Differentiable
-
A type with values that support pointwise multiplication.
Declaration
public protocol PointwiseMultiplicative : AdditiveArithmetic
-
A type that represents an unranked vector space. Values of this type are elements in this vector space and have either no shape or a static shape.
Declaration
public protocol VectorProtocol : AdditiveArithmetic
-
A type that is differentiable in the Euclidean space. The type may represent a vector space, or consist of a vector space and some other non-differentiable component.
Mathematically, this represents a product manifold that consists of a differentiable vector space and some arbitrary manifold, where the tangent bundle of the entire product manifold is equal to the vector space component.
This abstraction is useful for representing common differentiable data structures that contain both differentiable vector properties and other stored properties that do not have a derivative, e.g.
struct Perceptron: @memberwise EuclideanDifferentiable { var weight: SIMD16<Float> var bias: Float @noDerivative var useBias: Bool }
Note
Conform a type toEuclideanDifferentiable
if it is differentiable only with respect to its vector space component and when itsTangentVector
is equal to its vector space component.Declaration
public protocol EuclideanDifferentiable : Differentiable
-
Declaration
public protocol Module: EuclideanDifferentiable, KeyPathIterable where TangentVector: VectorProtocol & ElementaryFunctions & PointwiseMultiplicative & KeyPathIterable
-
A neural network layer.
Types that conform to
Layer
represent functions that map inputs to outputs. They may have an internal state represented by parameters, such as weight tensors.Layer
instances define a differentiablecallAsFunction(_:)
method for mapping inputs to outputs.Declaration
public protocol Layer : Module where Self.Input : Differentiable
-
A parameterless neural network layer.
The
TangentVector
of parameterless layers is alwaysEmptyTangentVector
.Declaration
public protocol ParameterlessLayer : Layer where Self.TangentVector == EmptyTangentVector
-
A type that has elementary functions available.
An “elementary function” is a function built up from powers, roots, exponentials, logarithms, trigonometric functions (sin, cos, tan) and their inverses, and the hyperbolic functions (sinh, cosh, tanh) and their inverses.
Conformance to this protocol means that all of these building blocks are available as static functions on the type.
let x: Float = 1 let y = Float.sin(x) // 0.84147096
Declaration
public protocol ElementaryFunctions
-
A type whose nested floating-point tensor properties and elements can be converted from full precision to reduced precision and vice versa.
-
An implementation detail used to work around the fact that Swift can’t express a generic constraint that some type must be an instance of
Sampling
.Declaration
public protocol SamplingProtocol : Collection
-
A type that can be initialized from a
numpy.ndarray
instance represented as aPythonObject
.Declaration
public protocol ConvertibleFromNumpyArray
-
A type that is bitwise compatible with one or more NumPy scalar types.
Declaration
public protocol NumpyScalarCompatible
-
A type whose values can be converted to a
PythonObject
.Declaration
public protocol PythonConvertible
-
A type that can be initialized from a
PythonObject
.Declaration
public protocol ConvertibleFromPython
-
A type that provides seedable deterministic pseudo-random data.
A SeedableRandomNumberGenerator can be used anywhere where a RandomNumberGenerator would be used. It is useful when the pseudo-random data needs to be reproducible across runs.
Conforming to the SeedableRandomNumberGenerator Protocol
To make a custom type conform to the
SeedableRandomNumberGenerator
protocol, implement theinit(seed: [UInt8])
initializer, as well as the requirements forRandomNumberGenerator
. The values returned bynext()
must form a deterministic sequence that depends only on the seed provided upon initialization.Declaration
public protocol SeedableRandomNumberGenerator : RandomNumberGenerator
-
Declaration
public protocol RandomDistribution
-
A recurrent layer cell.
Declaration
public protocol RecurrentLayerCell: Layer where Input == RNNCellInput<TimeStepInput, State>, Output == RNNCellOutput<TimeStepOutput, State>
-
A type with values that support differentiable binary operations.
Used by
BidirectionalRecurrentLayer
as a generic requirement for merge functions.Declaration
public protocol Mergeable : AdditiveArithmetic, Differentiable
-
Declaration
public protocol TensorOperation
-
Declaration
public protocol TFTensorOperation : TensorOperation
-
Special protocol for calling tensorflow operations that take heterogeneous arrays as input.
Declaration
public protocol AnyTensor
-
Declaration
public protocol TensorProtocol
-
Declaration
public protocol DifferentiableTensorProtocol: TensorProtocol & Differentiable & EuclideanDifferentiable where Scalar: TensorFlowFloatingPoint
-
A protocol representing types that can be mapped to
Array<CTensorHandle>
.This protocol is defined separately from
TensorGroup
in order for the number of tensors to be determined at runtime. For example,[Tensor<Float>]
may have an unknown number of elements at compile time.This protocol can be derived automatically for structs whose stored properties all conform to the
TensorGroup
protocol. It cannot be derived automatically for structs whose properties all conform toTensorArrayProtocol
due to the constructor requirement (i.e., in such cases it would be impossible to know how to break downcount
among the stored properties).Declaration
public protocol TensorArrayProtocol
-
A protocol representing types that can be mapped to and from
Array<CTensorHandle>
.When a
TensorGroup
is used as an argument to a tensor operation, it is passed as an argument list whose elements are the tensor fields of the type.When a
TensorGroup
is returned as a result of a tensor operation, it is initialized with its tensor fields set to the tensor operation’s tensor results.Declaration
public protocol TensorGroup : TensorArrayProtocol
-
A supported datatype in x10.
Declaration
public protocol XLAScalarType