swift-apis
swift-apis copied to clipboard
[summary] Add annotations to `Recurrent`
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.
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.