borglab / SwiftFusion

Apache License 2.0
115 stars 13 forks source link

A bunch of constraints to AnyVectorArrayBuffer are too strict #254

Open dabrahams opened 3 years ago

dabrahams commented 3 years ago

There are constraints on many AnyArrayBuffer where Dispatch == VectorArrayDispatch that really should be AnyArrayBuffer where Dispatch: VectorArrayDispatch. I couldn't get it to compile at the time but now that we have more parts working maybe we can figure out how to change these. Many are interrelated so one might need to change them all at once.

dabrahams commented 3 years ago

Maybe it has to do with:

extension AnyArrayBuffer: Differentiable where Dispatch: DifferentiableArrayDispatch {
  public typealias TangentVector = AnyVectorArrayBuffer
  ...
}

that typealias forces all tangent vectors of Differentiable-conforming AnyArrayBuffer<D>s to be exactly AnyArrayBuffer<VectorArrayDispatch>.

Instead we want something like:

extension AnyArrayBuffer: Differentiable 
where Dispatch: DifferentiableArrayDispatch, 
      TangentVector == AnyArrayBuffer<D> where D: VectorArrayDispatch 
{
     ...
}

Of course, that's not expressible in the language today; you need to use the protocol AnyArrayBufferProtocol hack to create the equivalent constraint.