You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Calls `updateElement(&myX, aX)` on each pair of corresponding elements `myX` and `aX` of/// `self` and `a`, using `combine` (if supplied) to initialize new storage when required.////// - Requires: `self.count == a.count`@differentiable(wrt:(self, a)where Element: Differentiable, E: Differentiable)mutatingfunc update<E>(
elementwiseWith a:ArrayBuffer<E>,
_ updateElement:@differentiable(_ myX:inoutElement, _ aX:E)->Void,
_ combine:Optional<@differentiable(_ a0x:Element, _ a1x:E)->Element>=nil){fatalError()}
The fundamental limitation is that we have no way to say thats updateElement and combine are @differentiable(where: Element: Differentiable, E: Differentiable) (that's a syntax error).
The text was updated successfully, but these errors were encountered:
This is a limitation of the @differentiable function type attribute. Supporting a where-clause within a function type attribute may involve a non-trivial implementation given that there's no precedence of function type attributes containing generic constraints and because @differentiable/@differentiable(linear) is currently just a two-bit flag in AnyFunctionType::ExtInfo. Besides the potential implementation difficulty, function types with such constraints could be long and difficult to read:
Have you tried defining additional update(elementwiseWith::🙂 overloads with more specific generic requirements such that the most specific one will win in overload resolution? What's the specific use case of this method?
@theblixguy If I remember correctly, @_specialize is a DeclAttr. And we did port @_specialize's support for where-clauses to the @differentiable declaration attribute, but this issue in this radar is mainly about the @differentiable function type attribute like @convention. Are you saying there also exists a @_specialize function type attribute today?
Oh, I see. Sorry, I overlooked the “function type” bit. I don’t think we have any function type attributes with where clauses at the moment. I suppose it should still be relatively straightforward to parse the where clause in such a context (with possibility to share code) but I haven’t given it much thought.
Additional Detail from JIRA
md5: 2bdd7e64a6b7e0424705c091ca000b07
Issue Description:
This method won't compile:
The fundamental limitation is that we have no way to say thats
updateElement
andcombine
are@differentiable(where: Element: Differentiable, E: Differentiable)
(that's a syntax error).The text was updated successfully, but these errors were encountered: