tensorflow / swift-models

Models and examples built with Swift for TensorFlow
Apache License 2.0
645 stars 146 forks source link

Translation example #148

Open saeta opened 5 years ago

saeta commented 5 years ago

It'd be great to have a neural machine translation model incorporated into our models repository.

palle-k commented 4 years ago

I have started an implementation of Seq2Seq with LSTMs and Attention here. It currently crashes the compiler though (something in the callAsFunction method in the Seq2Seq struct) and I can't find a way around that crash.

Shashi456 commented 4 years ago

@palle-k could you comment in the error in your file? Would be easier to understand if it's API issue or some trivial error

palle-k commented 4 years ago

Apparently, there are multiple crashes involved. I have updated the code in my fork and marked the pieces of code that crash the compiler with // MARK: Crash 1 and // MARK: Crash 2 in Seq2Seq/Models.swift starting at line 237.

The relevant pieces are commented out and can be uncommented individually.

Crash 1 seems to occur when an empty if-statement or a empty for-loop is present:

Assertion failed: (pullbackStructElements.count(field) && "Pullback struct element for this field does not exist!"), function getPullbackStructElement, file /Users/swiftninjas/s4tf/swift/lib/SILOptimizer/Mandatory/Differentiation.cpp, line 5127.

Crash 2 seems to occur when a for-loop with a non-empty body is present:

Assertion failed: (lhs->getType() == rhs->getType() && "Adjoints must have equal types!"), function accumulateDirect, file /Users/swiftninjas/s4tf/swift/lib/SILOptimizer/Mandatory/Differentiation.cpp, line 6923.

Also, I'm using the 0.5 release of S4TF.

$ swift --version
Swift version 5.1-dev (LLVM 200186e28b, Swift 1238976565)
Target: x86_64-apple-darwin19.0.0
dan-zheng commented 4 years ago

Apparently, there are multiple crashes involved. I have updated the code in my fork and marked the pieces of code that crash the compiler with // MARK: Crash 1 and // MARK: Crash 2 in Seq2Seq/Models.swift starting at line 237.

Thanks for reporting! Both crashers you reported are known issues:

We'll visit these issues soon, thanks for your patience!