IO

public class IO

A IO class represent the abstract input / output for a model. It can correspond to one or more tensors when the model is materialized.

  • Reshape an IO to a new dimension. You cannot reshape data types.

    Declaration

    Swift

    public func reshaped(
      _ dimensions: TensorShape, offset: TensorShape? = nil, strides: TensorShape? = nil
    )
      -> Model.IO

    Parameters

    dimensions

    The new dimensions for the input.

    offset

    Whether apply certain offset for each dimension.

    strides

    What’s the stride for each dimension.

  • Permute an IO according to the indices.

    Declaration

    Swift

    public func permuted(_ indices: Int...)
      -> Model.IO

    Parameters

    indices

    The dimensions to pick from the input.

  • Apply ReLU activation to the said IO.

    Declaration

    Swift

    public func ReLU() -> Model.IO
  • Apply softmax activation to the said IO.

    Declaration

    Swift

    public func softmax() -> Model.IO
  • Apply sigmoid activation to the said IO.

    Declaration

    Swift

    public func sigmoid() -> Model.IO
  • Apply tanh activation to the said IO.

    Declaration

    Swift

    public func tanh() -> Model.IO
  • Apply swish activation to the said IO.

    Declaration

    Swift

    public func swish() -> Model.IO
  • Apply GELU activation to the said IO.

    Declaration

    Swift

    public func GELU(approximate: GELU.Approximate = .none) -> Model.IO
  • Declaration

    Swift

    public func transposed(_ axisA: Int, _ axisB: Int) -> Model.IO
  • Declaration

    Swift

    public func reduced(_ op: ReduceOp, axis: [Int]) -> Model.IO
  • Add non-functional dependencies between IOs. Normally, dependencies are inferred by usage. However, in some cases you want to hack the dependency such that two unrelated ops can establish a dependency. This is useful to enforce system to share memory for example.

    Declaration

    Swift

    public func add(dependencies: [Model.IO])

    Parameters

    dependencies

    The IOs which will be the dependencies of the current IO.