@@ -1376,11 +1376,12 @@ inheritance must maintain the differentiability.
1376
1376
1377
1377
The ` @differentiable ` attribute can be used on protocol requirements. A
1378
1378
` @differentiable ` protocol requirement requires that all conforming types
1379
- implement this protocol requirement with a differentiable body with respect to
1380
- the specified parameters.
1379
+ implement this requirement with a differentiable body with respect to the
1380
+ specified parameters. Conforming implementations are not required to be marked
1381
+ with ` @differentiable ` attribute unless they are ` public ` .
1381
1382
1382
1383
``` swift
1383
- protocol Layer : Differentiable {
1384
+ public protocol Layer : Differentiable {
1384
1385
associatedtype Input : Differentiable
1385
1386
associatedtype Output : Differentiable
1386
1387
@differentiable // w.r.t. `input` and `self`
@@ -1389,7 +1390,7 @@ protocol Layer: Differentiable {
1389
1390
struct Perceptron : @memberwise Differentiable , Layer {
1390
1391
var weight: SIMD4<Float >
1391
1392
var bias: Float
1392
- @differentiable // w.r.t. `input` and `self`
1393
+
1393
1394
func callAsFunction (_ input : SIMD4<Float >) -> Float {
1394
1395
(weight * input).sum () + b
1395
1396
}
@@ -1401,14 +1402,14 @@ with a `@differentiable` attribute that declares differentiability with respect
1401
1402
to more parameters.
1402
1403
1403
1404
``` swift
1404
- protocol Module : Differentiable {
1405
+ public protocol Module : Differentiable {
1405
1406
associatedtype Input
1406
1407
associatedtype Output : Differentiable
1407
1408
@differentiable (wrt: self )
1408
1409
func callAsFunction (_ : Input) -> Output
1409
1410
}
1410
1411
1411
- protocol Layer : Module where Input: Differentiable {
1412
+ public protocol Layer : Module where Input: Differentiable {
1412
1413
@differentiable (wrt: (self , input))
1413
1414
func callAsFunction (_ : Input) -> Output
1414
1415
}
0 commit comments