tensorflow / swift

Swift for TensorFlow
https://tensorflow.org/swift
Apache License 2.0
6.13k stars 606 forks source link

Errors while switching to stock toolchain #610

Open porterchild opened 3 years ago

porterchild commented 3 years ago

While switching from the 0.12 S4TF release to a stock toolchain from https://swift.org/download/#releases, I've gotten some compiler errors.

  1. When extending Optional and using TangentVector, the compiler says'TangentVector' is not a member type of 'Optional'. This surprises me. Am I missing something?
  2. When using the KeyPathIterable implementation from swift-apis, I get the error "Cannot find '_forEachFieldWithKeyPath' in scope ", which I thought would be fixed by this PR. I've made sure to use @_spi(Reflection) to import the special function.

Any help would be appreciated.

dan-zheng commented 3 years ago

Hi Porter,

Thanks for reporting. Could you please share the stock toolchain that you've downloaded?

porterchild commented 3 years ago

Sure it's the Tag: swift-5.3.3-RELEASE

dan-zheng commented 3 years ago

Sure it's the Tag: swift-5.3.3-RELEASE

Could you try a trunk development snapshot instead? Those are tested in the "stock toolchain" migration PRs, be sure to follow the build instructions in the PR descriptions:

Trunk development snapshots are built from apple/swift:main branch, similar to the old Swift for TensorFlow toolchains. Release toolchains are built from release branches and often are missing recent changes related to differentiable programming.

porterchild commented 3 years ago

Thanks Dan, that fixed it!

porterchild commented 3 years ago

I'm going to miss asking you obvious questions

dan-zheng commented 3 years ago

I'm going to miss asking you obvious questions

I'm still around! Feel free to ping or email me anytime :)

porterchild commented 3 years ago

Cool! Glad to know you'll still be around I like TabNine

porterchild commented 3 years ago

Many errors later :) , I have a few more questions:

  1. It seems like a lot of AdditiveArithmetic, KeyPathIterable, PointwiseMultiplicative.. etc. automatic synthesis is gone. I've pulled just the protocols I need from swift-apis, and I'm importing Numerics for ElementaryFunctions. I'd like to understand if I'm just missing bringing some code over from swift-apis or Numerics, or if automatic synthesis has changed since the 0.12 release compared to the latest swift mainline. I've had to write a lot more conformances manually compared to the 0.12 release.
  2. SIMDX<Float>.sum() is no longer automatically differentiable, I'm not sure why. I see no mention of it in swift-apis.

For context, I'm on the 1/14 snapshot (the latest snapshot has a new compiler crash

porterchild commented 3 years ago

Ah, I just found the comment // FIXME(TF-1103): Derivative registration does not yet support @_alwaysEmitIntoClient original functions like SIMD.sum() at https://github.com/apple/swift/blob/e3db926e0ce7bb5535e357623b8744c2c276b236/stdlib/public/Differentiation/SIMDDifferentiation.swift.gyb. So that explains why SIMDX<Float>.sum() isn't differentiable.