OperatorSymbol

public protocol OperatorSymbol: GraphSymbol

Symbol represent an operator calcualtion

  • Input symbols for this operator

    Note

    symbols in this attribute should also be included in inBounds

    Declaration

    Swift

    var inputSymbols: [TensorSymbol]
  • Input shapes tensor symbols in inputSymbols

    Declaration

    Swift

    var inputTensorShapes: [TensorShape]
  • Parameters (weights, bias etc.) symbols for this operator. For operator having no params, this should be an empty array.

    Note

    symbols in this attribute should also be included in inBounds

    Declaration

    Swift

    var paramSymbols: [DataSymbol]
  • The operator instance

    Declaration

    Swift

    var serranoOperator: ComputableOperator
  • Control if update asscoiated operator’s parameter

    updatable of DataSymbol V.S. enabledParameterUpdate of OperatorSymbol

    Both attribute controls data updating in backward training. updatable of a data symbol controls whether updating this symbol’s binded data, while enabledParameterUpdate controls whether updating operator symbol’s inbounds data symbols. If enabledParameterUpdate is false, Serrano will ignore updatable attributes of all data symbols in this operator symbol’s inbounds. So user can think enabledParameterUpdate has high priority over updatable on controlling.

    Declaration

    Swift

    var enabledParameterUpdate: Bool
  • Get output symbols of this operator

    Declaration

    Swift

    func outputSymbols() -> [TensorSymbol]

    Return Value

    Array of SerranoTensorSymbol.

  • addToParamSymbols(_:) Default implementation

    Add to paramSymbols

    Default Implementation

    Add to paramSymbols

    Declaration

    Swift

    func addToParamSymbols(_ symbol: GraphSymbol)

    Parameters

    symbol

    new symbol

  • gradsOnInput(_:) Default implementation

    Get grads on any inbounds symbol

    Default Implementation

    Get grads on any inbounds symbol. Call attached operator’s gradCompute(_:, :) to get grads. Use return tensor’s label to identify corresponding input datasymbol.

    Identify corresponding input

    The tensor label of returned tensors could be used to identify its correspoding input following below rules:

  • Input tensor. input_{i} where i is the corresponding input tensor’s index in inputTensors
  • Parameter. The parameter’s name.

  • Note

    If inputSymbol does not belong to this operator symbol. fatalError() raised.

    Declaration

    Swift

    func gradsOnInput(_ inputSymbol: DataSymbol) -> DataSymbolSupportedDataType

    Parameters

    inputSymbol

    Return Value

    SupportedGradsDataType

  • inboundSymbolForGradLabel(_:) Default implementation

    Get corresponding inbound symbol for a label following rule in Operator method gradCompute(_:).

    Default Implementation

    Get inbound data symbol for target label.

    Identify corresponding input

    The returned label of data could be used to identify its correspoding input following below rules:

  • Input tensor. input_{i} where i is the corresponding input tensor’s index in inputTensors
  • Parameter. The parameter’s name.

  • Note

    may return nil

    Declaration

    Swift

    func inboundSymbolForGradLabel(_ label: String) -> DataSymbol?

    Parameters

    label

    label

    Return Value

    DataSymbol

  • For a given symbol in inbounds, return a list of output symbols that it involves with calculation.

    Default Implementation

    For a given symbol in inbounds, return a list of output symbols that it involves with calculation.

    Declaration

    Swift

    func gradRelatedOutputSymbols(onInboundSymbol symbol: DataSymbol) -> [DataSymbol]

    Parameters

    symbol

    target symbol

    Return Value

    list of output symbol