swift-apis icon indicating copy to clipboard operation
swift-apis copied to clipboard

[summary] Add annotations to `Recurrent`

Open texasmichelle opened this issue 4 years ago • 1 comments

The design of Recurrent layer types is unique, but it should still be possible to add annotations. Tackling this separately from #1067, but the principle should be similar.

texasmichelle avatar Sep 09 '20 19:09 texasmichelle

I expected this to be possible by conforming the associated types for RecurrentLayerCell to DifferentiableTensorProtocol:

public protocol RecurrentLayerCell: Layer
where
  Input == RNNCellInput<TimeStepInput, State>,
  Output == RNNCellOutput<TimeStepOutput, State>
{
  associatedtype TimeStepInput: DifferentiableTensorProtocol
  associatedtype TimeStepOutput: DifferentiableTensorProtocol
  associatedtype State: DifferentiableTensorProtocol
}

This is problematic because LSTMCell defines TimeStepOutput as a custom struct containing both a visible and hidden Tensor<Scalar>.

With the current architecture in its complex form, it is unclear to me how to add annotations without splitting the layer definitions apart.

texasmichelle avatar Dec 16 '20 21:12 texasmichelle