Skip to content

Commit

Permalink
Resolve Swift toolchain build errors (#316)
Browse files Browse the repository at this point in the history
This week, the S4TF team encountered several failures building toolchains:

1. Outdated Package.resolved in [swift/FastaiNotebook_11_imagenette](https://github.com/fastai/fastai_dev/blob/master/swift/FastaiNotebook_11_imagenette/Package.resolved).
2. A regression in `ParameterlessLayer` caused by a change in type inference behavior in [swiftlang/swift#32578](swiftlang/swift#32578).

This PR includes two workarounds that unblock toolchain builds:
1. Remove Package.resolved ([swift-apis/1036](tensorflow/swift-apis#1036)). Since this file is regenerated on build, it's often not necessary to include in source control.
2. Add a typealias to instances conforming to `ParameterlessLayer`, which was effective in swift-apis and swift-models (see [tensorflow/swift-apis#1037](tensorflow/swift-apis#1037)).

I'm happy to create an additional PR to remove the other Package.resolved files in this repo and add to .gitignore, if desired.
  • Loading branch information
texasmichelle authored Jul 3, 2020
1 parent 9ba4512 commit 4a33cb2
Show file tree
Hide file tree
Showing 18 changed files with 67 additions and 34 deletions.
4 changes: 4 additions & 0 deletions swift/01a_fastai_layers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@
"\n",
"@frozen\n",
"public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {\n",
" // swift-apis#1037 workaround.\n",
" public typealias TangentVector = EmptyTangentVector\n",
" // TF-603 workaround.\n",
" public typealias Input = Tensor<Scalar>\n",
" public typealias Output = Tensor<Scalar>\n",
Expand Down Expand Up @@ -508,6 +510,8 @@
"\n",
"@frozen\n",
"public struct FAGlobalAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {\n",
" // swift-apis#1037 workaround.\n",
" public typealias TangentVector = EmptyTangentVector\n",
" // TF-603 workaround.\n",
" public typealias Input = Tensor<Scalar>\n",
" public typealias Output = Tensor<Scalar>\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public extension FAConv2D {

@frozen
public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down Expand Up @@ -263,6 +265,8 @@ public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,Parameterles

@frozen
public struct FAGlobalAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public extension FAConv2D {

@frozen
public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down Expand Up @@ -263,6 +265,8 @@ public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,Parameterles

@frozen
public struct FAGlobalAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public extension FAConv2D {

@frozen
public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down Expand Up @@ -263,6 +265,8 @@ public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,Parameterles

@frozen
public struct FAGlobalAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public extension FAConv2D {

@frozen
public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down Expand Up @@ -263,6 +265,8 @@ public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,Parameterles

@frozen
public struct FAGlobalAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public extension FAConv2D {

@frozen
public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down Expand Up @@ -263,6 +265,8 @@ public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,Parameterles

@frozen
public struct FAGlobalAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public extension FAConv2D {

@frozen
public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down Expand Up @@ -263,6 +265,8 @@ public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,Parameterles

@frozen
public struct FAGlobalAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public extension FAConv2D {

@frozen
public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down Expand Up @@ -263,6 +265,8 @@ public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,Parameterles

@frozen
public struct FAGlobalAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public extension FAConv2D {

@frozen
public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down Expand Up @@ -263,6 +265,8 @@ public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,Parameterles

@frozen
public struct FAGlobalAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public extension FAConv2D {

@frozen
public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down Expand Up @@ -263,6 +265,8 @@ public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,Parameterles

@frozen
public struct FAGlobalAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public extension FAConv2D {

@frozen
public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down Expand Up @@ -263,6 +265,8 @@ public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,Parameterles

@frozen
public struct FAGlobalAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public extension FAConv2D {

@frozen
public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down Expand Up @@ -263,6 +265,8 @@ public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,Parameterles

@frozen
public struct FAGlobalAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public extension FAConv2D {

@frozen
public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down Expand Up @@ -263,6 +265,8 @@ public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,Parameterles

@frozen
public struct FAGlobalAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public extension FAConv2D {

@frozen
public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down Expand Up @@ -263,6 +265,8 @@ public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,Parameterles

@frozen
public struct FAGlobalAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public extension FAConv2D {

@frozen
public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down Expand Up @@ -263,6 +265,8 @@ public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,Parameterles

@frozen
public struct FAGlobalAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down
34 changes: 0 additions & 34 deletions swift/FastaiNotebook_11_imagenette/Package.resolved

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public extension FAConv2D {

@frozen
public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down Expand Up @@ -263,6 +265,8 @@ public struct FAAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,Parameterles

@frozen
public struct FAGlobalAvgPool2D<Scalar: TensorFlowFloatingPoint>: FALayer,ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector
// TF-603 workaround.
public typealias Input = Tensor<Scalar>
public typealias Output = Tensor<Scalar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public struct ConvLayer: Layer {
}

public struct MaybeAvgPool2D: ParameterlessLayer {
// swift-apis#1037 workaround.
public typealias TangentVector = EmptyTangentVector

@noDerivative let poolSize: (Int, Int, Int, Int)
@noDerivative let strides: (Int, Int, Int, Int)
@noDerivative let padding: Padding
Expand Down

0 comments on commit 4a33cb2

Please sign in to comment.