Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

NFC: fix warnings related to VectorProtocol.VectorSpaceScalar. #1178

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dan-zheng
Copy link
Member

VectorProtocol.VectorSpaceScalar was changed from an associated type to a hardcoded typealias for Float.

(I believe this simplification (removing VectorSpaceScalar as a customization point) made it easier to enable building tensorflow/swift-apis with standard toolchains.)

Fix warnings related to this change.


Example warnings:

$ swift build -Xcc -I$HOME/Library/tensorflow-2.4.0/usr/include -Xlinker -L$HOME/Library/tensorflow-2.4.0/usr/lib -Xswiftc -DTENSORFLOW_USE_STANDARD_TOOLCHAIN

[1/4] Compiling TensorFlow SGD.swift
Sources/TensorFlow/Optimizers/SGD.swift:42:41: warning: neither type in same-type constraint ('Model.TangentVector.VectorSpaceScalar' (aka 'Float') or 'Float') refers to a generic parameter or associated type
  Model.TangentVector.VectorSpaceScalar == Float
                                        ^
[2/4] Compiling TensorFlow MomentumBased.swift
Sources/TensorFlow/Optimizers/MomentumBased.swift:37:41: warning: neither type in same-type constraint ('Model.TangentVector.VectorSpaceScalar' (aka 'Float') or 'Float') refers to a generic parameter or associated type
  Model.TangentVector.VectorSpaceScalar == Float
                                        ^
Sources/TensorFlow/Optimizers/MomentumBased.swift:112:41: warning: neither type in same-type constraint ('Model.TangentVector.VectorSpaceScalar' (aka 'Float') or 'Float') refers to a generic parameter or associated type
  Model.TangentVector.VectorSpaceScalar == Float
                                        ^
Sources/TensorFlow/Optimizers/MomentumBased.swift:173:41: warning: neither type in same-type constraint ('Model.TangentVector.VectorSpaceScalar' (aka 'Float') or 'Float') refers to a generic parameter or associated type
  Model.TangentVector.VectorSpaceScalar == Float
                                        ^
Sources/TensorFlow/Optimizers/MomentumBased.swift:323:41: warning: neither type in same-type constraint ('Model.TangentVector.VectorSpaceScalar' (aka 'Float') or 'Float') refers to a generic parameter or associated type
  Model.TangentVector.VectorSpaceScalar == Float
                                        ^
Sources/TensorFlow/Optimizers/MomentumBased.swift:407:41: warning: neither type in same-type constraint ('Model.TangentVector.VectorSpaceScalar' (aka 'Float') or 'Float') refers to a generic parameter or associated type
  Model.TangentVector.VectorSpaceScalar == Float
                                        ^
Sources/TensorFlow/Optimizers/MomentumBased.swift:493:41: warning: neither type in same-type constraint ('Model.TangentVector.VectorSpaceScalar' (aka 'Float') or 'Float') refers to a generic parameter or associated type
  Model.TangentVector.VectorSpaceScalar == Float
                                        ^
Sources/TensorFlow/Optimizers/MomentumBased.swift:586:41: warning: neither type in same-type constraint ('Model.TangentVector.VectorSpaceScalar' (aka 'Float') or 'Float') refers to a generic parameter or associated type
  Model.TangentVector.VectorSpaceScalar == Float
                                        ^
[3/4] Compiling TensorFlow Sequential.swift
Sources/TensorFlow/Layers/Sequential.swift:51:42: warning: neither type in same-type constraint ('Layer1.TangentVector.VectorSpaceScalar' (aka 'Float') or 'Layer2.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  Layer1.TangentVector.VectorSpaceScalar == Layer2.TangentVector.VectorSpaceScalar
                                         ^
Sources/TensorFlow/Layers/Sequential.swift:82:38: warning: neither type in same-type constraint ('L1.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L2.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L1.TangentVector.VectorSpaceScalar == L2.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:83:38: warning: neither type in same-type constraint ('L2.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L3.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L2.TangentVector.VectorSpaceScalar == L3.TangentVector.VectorSpaceScalar
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:91:38: warning: neither type in same-type constraint ('L1.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L2.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L1.TangentVector.VectorSpaceScalar == L2.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:92:38: warning: neither type in same-type constraint ('L2.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L3.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L2.TangentVector.VectorSpaceScalar == L3.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:93:38: warning: neither type in same-type constraint ('L3.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L4.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L3.TangentVector.VectorSpaceScalar == L4.TangentVector.VectorSpaceScalar
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:101:38: warning: neither type in same-type constraint ('L1.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L2.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L1.TangentVector.VectorSpaceScalar == L2.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:102:38: warning: neither type in same-type constraint ('L2.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L3.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L2.TangentVector.VectorSpaceScalar == L3.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:103:38: warning: neither type in same-type constraint ('L3.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L4.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L3.TangentVector.VectorSpaceScalar == L4.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:104:38: warning: neither type in same-type constraint ('L4.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L5.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L4.TangentVector.VectorSpaceScalar == L5.TangentVector.VectorSpaceScalar
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:112:38: warning: neither type in same-type constraint ('L1.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L2.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L1.TangentVector.VectorSpaceScalar == L2.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:113:38: warning: neither type in same-type constraint ('L2.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L3.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L2.TangentVector.VectorSpaceScalar == L3.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:114:38: warning: neither type in same-type constraint ('L3.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L4.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L3.TangentVector.VectorSpaceScalar == L4.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:115:38: warning: neither type in same-type constraint ('L4.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L5.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L4.TangentVector.VectorSpaceScalar == L5.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:116:38: warning: neither type in same-type constraint ('L5.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L6.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L5.TangentVector.VectorSpaceScalar == L6.TangentVector.VectorSpaceScalar
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:127:38: warning: neither type in same-type constraint ('L1.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L2.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L1.TangentVector.VectorSpaceScalar == L2.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:128:38: warning: neither type in same-type constraint ('L2.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L3.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L2.TangentVector.VectorSpaceScalar == L3.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:129:38: warning: neither type in same-type constraint ('L3.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L4.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L3.TangentVector.VectorSpaceScalar == L4.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:130:38: warning: neither type in same-type constraint ('L4.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L5.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L4.TangentVector.VectorSpaceScalar == L5.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:131:38: warning: neither type in same-type constraint ('L5.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L6.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L5.TangentVector.VectorSpaceScalar == L6.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:132:38: warning: neither type in same-type constraint ('L6.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L7.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L6.TangentVector.VectorSpaceScalar == L7.TangentVector.VectorSpaceScalar
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:144:38: warning: neither type in same-type constraint ('L1.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L2.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L1.TangentVector.VectorSpaceScalar == L2.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:145:38: warning: neither type in same-type constraint ('L2.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L3.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L2.TangentVector.VectorSpaceScalar == L3.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:146:38: warning: neither type in same-type constraint ('L3.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L4.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L3.TangentVector.VectorSpaceScalar == L4.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:147:38: warning: neither type in same-type constraint ('L4.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L5.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L4.TangentVector.VectorSpaceScalar == L5.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:148:38: warning: neither type in same-type constraint ('L5.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L6.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L5.TangentVector.VectorSpaceScalar == L6.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:149:38: warning: neither type in same-type constraint ('L6.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L7.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L6.TangentVector.VectorSpaceScalar == L7.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:150:38: warning: neither type in same-type constraint ('L7.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L8.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L7.TangentVector.VectorSpaceScalar == L8.TangentVector.VectorSpaceScalar
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:167:38: warning: neither type in same-type constraint ('L1.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L2.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L1.TangentVector.VectorSpaceScalar == L2.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:168:38: warning: neither type in same-type constraint ('L2.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L3.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L2.TangentVector.VectorSpaceScalar == L3.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:169:38: warning: neither type in same-type constraint ('L3.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L4.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L3.TangentVector.VectorSpaceScalar == L4.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:170:38: warning: neither type in same-type constraint ('L4.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L5.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L4.TangentVector.VectorSpaceScalar == L5.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:171:38: warning: neither type in same-type constraint ('L5.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L6.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L5.TangentVector.VectorSpaceScalar == L6.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:172:38: warning: neither type in same-type constraint ('L6.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L7.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L6.TangentVector.VectorSpaceScalar == L7.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:173:38: warning: neither type in same-type constraint ('L7.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L8.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L7.TangentVector.VectorSpaceScalar == L8.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:174:38: warning: neither type in same-type constraint ('L8.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L9.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L8.TangentVector.VectorSpaceScalar == L9.TangentVector.VectorSpaceScalar
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:196:38: warning: neither type in same-type constraint ('L1.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L2.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L1.TangentVector.VectorSpaceScalar == L2.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:197:38: warning: neither type in same-type constraint ('L2.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L3.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L2.TangentVector.VectorSpaceScalar == L3.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:198:38: warning: neither type in same-type constraint ('L3.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L4.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L3.TangentVector.VectorSpaceScalar == L4.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:199:38: warning: neither type in same-type constraint ('L4.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L5.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L4.TangentVector.VectorSpaceScalar == L5.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:200:38: warning: neither type in same-type constraint ('L5.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L6.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L5.TangentVector.VectorSpaceScalar == L6.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:201:38: warning: neither type in same-type constraint ('L6.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L7.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L6.TangentVector.VectorSpaceScalar == L7.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:202:38: warning: neither type in same-type constraint ('L7.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L8.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L7.TangentVector.VectorSpaceScalar == L8.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:203:38: warning: neither type in same-type constraint ('L8.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L9.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L8.TangentVector.VectorSpaceScalar == L9.TangentVector.VectorSpaceScalar,
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:204:38: warning: neither type in same-type constraint ('L9.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L10.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
  L9.TangentVector.VectorSpaceScalar == L10.TangentVector.VectorSpaceScalar
                                     ^
Sources/TensorFlow/Layers/Sequential.swift:222:40: warning: neither type in same-type constraint ('L1.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L2.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L1.TangentVector.VectorSpaceScalar == L2.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:223:40: warning: neither type in same-type constraint ('L2.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L3.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L2.TangentVector.VectorSpaceScalar == L3.TangentVector.VectorSpaceScalar
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:239:40: warning: neither type in same-type constraint ('L1.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L2.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L1.TangentVector.VectorSpaceScalar == L2.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:240:40: warning: neither type in same-type constraint ('L2.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L3.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L2.TangentVector.VectorSpaceScalar == L3.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:241:40: warning: neither type in same-type constraint ('L3.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L4.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L3.TangentVector.VectorSpaceScalar == L4.TangentVector.VectorSpaceScalar
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:259:40: warning: neither type in same-type constraint ('L1.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L2.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L1.TangentVector.VectorSpaceScalar == L2.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:260:40: warning: neither type in same-type constraint ('L2.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L3.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L2.TangentVector.VectorSpaceScalar == L3.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:261:40: warning: neither type in same-type constraint ('L3.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L4.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L3.TangentVector.VectorSpaceScalar == L4.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:262:40: warning: neither type in same-type constraint ('L4.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L5.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L4.TangentVector.VectorSpaceScalar == L5.TangentVector.VectorSpaceScalar
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:282:40: warning: neither type in same-type constraint ('L1.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L2.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L1.TangentVector.VectorSpaceScalar == L2.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:283:40: warning: neither type in same-type constraint ('L2.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L3.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L2.TangentVector.VectorSpaceScalar == L3.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:284:40: warning: neither type in same-type constraint ('L3.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L4.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L3.TangentVector.VectorSpaceScalar == L4.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:285:40: warning: neither type in same-type constraint ('L4.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L5.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L4.TangentVector.VectorSpaceScalar == L5.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:286:40: warning: neither type in same-type constraint ('L5.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L6.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L5.TangentVector.VectorSpaceScalar == L6.TangentVector.VectorSpaceScalar
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:310:40: warning: neither type in same-type constraint ('L1.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L2.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L1.TangentVector.VectorSpaceScalar == L2.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:311:40: warning: neither type in same-type constraint ('L2.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L3.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L2.TangentVector.VectorSpaceScalar == L3.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:312:40: warning: neither type in same-type constraint ('L3.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L4.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L3.TangentVector.VectorSpaceScalar == L4.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:313:40: warning: neither type in same-type constraint ('L4.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L5.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L4.TangentVector.VectorSpaceScalar == L5.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:314:40: warning: neither type in same-type constraint ('L5.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L6.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L5.TangentVector.VectorSpaceScalar == L6.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:315:40: warning: neither type in same-type constraint ('L6.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L7.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L6.TangentVector.VectorSpaceScalar == L7.TangentVector.VectorSpaceScalar
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:345:40: warning: neither type in same-type constraint ('L1.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L2.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L1.TangentVector.VectorSpaceScalar == L2.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:346:40: warning: neither type in same-type constraint ('L2.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L3.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L2.TangentVector.VectorSpaceScalar == L3.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:347:40: warning: neither type in same-type constraint ('L3.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L4.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L3.TangentVector.VectorSpaceScalar == L4.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:348:40: warning: neither type in same-type constraint ('L4.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L5.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L4.TangentVector.VectorSpaceScalar == L5.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:349:40: warning: neither type in same-type constraint ('L5.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L6.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L5.TangentVector.VectorSpaceScalar == L6.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:350:40: warning: neither type in same-type constraint ('L6.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L7.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L6.TangentVector.VectorSpaceScalar == L7.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:351:40: warning: neither type in same-type constraint ('L7.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L8.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L7.TangentVector.VectorSpaceScalar == L8.TangentVector.VectorSpaceScalar
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:388:40: warning: neither type in same-type constraint ('L1.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L2.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L1.TangentVector.VectorSpaceScalar == L2.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:389:40: warning: neither type in same-type constraint ('L2.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L3.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L2.TangentVector.VectorSpaceScalar == L3.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:390:40: warning: neither type in same-type constraint ('L3.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L4.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L3.TangentVector.VectorSpaceScalar == L4.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:391:40: warning: neither type in same-type constraint ('L4.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L5.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L4.TangentVector.VectorSpaceScalar == L5.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:392:40: warning: neither type in same-type constraint ('L5.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L6.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L5.TangentVector.VectorSpaceScalar == L6.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:393:40: warning: neither type in same-type constraint ('L6.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L7.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L6.TangentVector.VectorSpaceScalar == L7.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:394:40: warning: neither type in same-type constraint ('L7.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L8.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L7.TangentVector.VectorSpaceScalar == L8.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:395:40: warning: neither type in same-type constraint ('L8.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L9.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L8.TangentVector.VectorSpaceScalar == L9.TangentVector.VectorSpaceScalar
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:442:40: warning: neither type in same-type constraint ('L1.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L2.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L1.TangentVector.VectorSpaceScalar == L2.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:443:40: warning: neither type in same-type constraint ('L2.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L3.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L2.TangentVector.VectorSpaceScalar == L3.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:444:40: warning: neither type in same-type constraint ('L3.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L4.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L3.TangentVector.VectorSpaceScalar == L4.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:445:40: warning: neither type in same-type constraint ('L4.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L5.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L4.TangentVector.VectorSpaceScalar == L5.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:446:40: warning: neither type in same-type constraint ('L5.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L6.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L5.TangentVector.VectorSpaceScalar == L6.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:447:40: warning: neither type in same-type constraint ('L6.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L7.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L6.TangentVector.VectorSpaceScalar == L7.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:448:40: warning: neither type in same-type constraint ('L7.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L8.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L7.TangentVector.VectorSpaceScalar == L8.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:449:40: warning: neither type in same-type constraint ('L8.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L9.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L8.TangentVector.VectorSpaceScalar == L9.TangentVector.VectorSpaceScalar,
                                       ^
Sources/TensorFlow/Layers/Sequential.swift:450:40: warning: neither type in same-type constraint ('L9.TangentVector.VectorSpaceScalar' (aka 'Float') or 'L10.TangentVector.VectorSpaceScalar' (aka 'Float')) refers to a generic parameter or associated type
    L9.TangentVector.VectorSpaceScalar == L10.TangentVector.VectorSpaceScalar
                                       ^
[4/37] Compiling TensorFlow Context.swift
[5/37] Compiling TensorFlow BroadcastingPullback.swift
[6/37] Compiling TensorFlow Algorithms.swift
[7/37] Compiling TensorFlow Backend.swift
[8/37] Compiling TensorFlow LazyTensorTFFunctionBuilder.swift
[9/37] Compiling TensorFlow LazyTensorTraceCache.swift
[10/37] Compiling TensorFlow Collatable.swift
[11/37] Compiling TensorFlow NonuniformTrainingEpochs.swift
[12/37] Compiling TensorFlow LazyTensorContext.swift
[13/37] Compiling TensorFlow LazyTensorOperation.swift
[14/37] Compiling TensorFlow ShapedArray.swift
[15/37] Compiling TensorFlow Tensor.swift
[16/37] Compiling TensorFlow Image.swift
[17/37] Compiling TensorFlow LinearAlgebra.swift
[18/37] Compiling TensorFlow Initializers.swift
[19/37] Compiling TensorFlow Layer.swift
[20/37] Compiling TensorFlow RawOpsManual.swift
[21/37] Compiling TensorFlow XLATensor.swift
[22/37] Compiling TensorFlow Dropout.swift
[23/37] Compiling TensorFlow Embedding.swift
[24/37] Compiling TensorFlow Basic.swift
[25/37] Compiling TensorFlow Dataset.swift
[26/37] Compiling TensorFlow Morphological.swift
[27/37] Compiling TensorFlow Normalization.swift
[28/37] Compiling TensorFlow Convolutional.swift
[29/37] Compiling TensorFlow Dense.swift
[30/37] Compiling TensorFlow Math.swift
[31/37] Compiling TensorFlow NN.swift
[32/37] Compiling TensorFlow Recurrent.swift
[33/37] Compiling TensorFlow Loss.swift
[34/37] Compiling TensorFlow EagerExecution.swift
[35/37] Compiling TensorFlow RawOpsDispatching.swift
[36/37] Compiling TensorFlow RawOpsGenerated.swift
[37/38] Merging module TensorFlow
ld: warning: dylib (Library/tensorflow-2.4.0/usr/lib/libx10.dylib) was built for newer macOS version (10.15) than being linked (10.13)
[38/38] Linking libTensorFlow.dylib
[38/38] Linking libTensorFlow.dylib

* Build Completed!

`VectorProtocol.VectorSpaceScalar` was changed from an associated type
to a hardcoded typealias for `Float`.

Fix warnings related to this change.
@@ -33,8 +33,7 @@ import Numerics
public class RMSProp<Model: Differentiable>: Optimizer
where
Model.TangentVector: VectorProtocol & PointwiseMultiplicative
& ElementaryFunctions & KeyPathIterable,
Model.TangentVector.VectorSpaceScalar == Float
& ElementaryFunctions & KeyPathIterable
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nifty Vim search-and-replace command: :%s/,\_s*Model.TangentVector.VectorSpaceScalar == Float//g.

Apparently the \_s pattern matches a whitespace, tab, or newline character (source).

@@ -47,8 +47,7 @@ import _Differentiation
/// ````
public struct Sequential<Layer1: Module, Layer2: Layer>: Module
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kokoro CI fails (for TENSORFLOW_USE_STANDARD_TOOLCHAIN=NO):

/swift-apis/Sources/TensorFlow/Layers/Sequential.swift:68:1: error: type 'Sequential<Layer1, Layer2>.TangentVector' does not conform to protocol 'VectorProtocol'
}
^
Swift.VectorProtocol:2:20: note: protocol requires nested type 'VectorSpaceScalar'; do you want to add it?
    associatedtype VectorSpaceScalar : AdditiveArithmetic
                   ^

It may be possible to fix this by adding an explicit typealias VectorSpaceScalar = Float definition for Sequential.TangentVector.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried doing this in 34fca6a but it didn't work, so I'm not sure what to try next.

Does anyone else have ideas? @BradLarson @compnerd

One option is to bite the bullet and drop support for the old baked-in-TensorFlow toolchains (which is what's causing the failure). I think that's a good option if we and the community are all on-board with it. That also allows us to drop custom internal support for CI and building OSS toolchains - we can just use GitHub Actions, which is much simpler.

Fix type-checking error stating that `Sequential.TangentVector` does not
satisfy `VectorProtocol.VectorSpaceScalar` requirement.
@dan-zheng dan-zheng force-pushed the fix-vectorspacescalar-warnings branch from 727c600 to 34fca6a Compare January 6, 2021 19:53
@dan-zheng dan-zheng added the help wanted Extra attention is needed label Jan 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant