Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-9666] [AD] @differentiable deserialization failure #52110

Closed
rxwei opened this issue Jan 15, 2019 · 1 comment
Closed

[SR-9666] [AD] @differentiable deserialization failure #52110

rxwei opened this issue Jan 15, 2019 · 1 comment
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. swift for tensorflow

Comments

@rxwei
Copy link
Member

rxwei commented Jan 15, 2019

Previous ID SR-9666
Radar None
Original Reporter @rxwei
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Swift for TensorFlow
Labels Bug
Assignee @dan-zheng
Priority Medium

md5: 31bfe8a506984a6122c98b39d55347f2

Issue Description:

public protocol Layer: Differentiable & KeyPathIterable
    where AllDifferentiableVariables: KeyPathIterable {
    /// The input type of the layer.
    associatedtype Input: TensorGroup & Differentiable
    /// The output type of the layer.
    associatedtype Output: TensorGroup & Differentiable

    /// Returns the output obtained from applying to an input.
    @differentiable(wrt: (self, .0))
    func applied(to input: Input) -> Output
}
public struct Dense<Scalar>: VectorNumeric, Layer
    where Scalar : FloatingPoint & Differentiable & TensorFlowScalar {
    public var weight: Tensor<Scalar>
    public var bias: Tensor<Scalar>

    @differentiable(wrt: (self, .0), vjp: _vjpApplied(to:))
    public func applied(to input: Tensor<Scalar>) -> Tensor<Scalar> {
        return matmul(input, weight) + bias
    }

    @usableFromInline
    func _vjpApplied(to input: Tensor<Scalar>)
        -> (Tensor<Scalar>, (Tensor<Scalar>) -> (Dense, Tensor<Scalar>)) {
      let r0 = matmul(input, weight)
      let r1 = r0 + bias
      func pullback(_ v: Tensor<Scalar>) -> (Dense, Tensor<Scalar>) {
        return (Dense(weight: matmul(input.transposed(), v), bias: v),
                matmul(v, weight.transposed()))
      }
      return (r1, pullback)
    }
}
Assertion failed: (kind == SIL_REVERSE_DIFFERENTIABLE_ATTR && "Missing reverse differentiable attribute"), function readSILFunctionChecked, file /usr/local/src/swift-build/swift/lib/Serialization/DeserializeSIL.cpp, line 627.
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2019-01-14-a.xctoolchain/usr/bin/swift -frontend -merge-modules -emit-module /Users/rxwei/Library/Developer/Xcode/DerivedData/MachineLearning-fmaewvvsqpggjjgofqfchyiwysiq/Build/Intermediates.noindex/MachineLearning.build/Debug/MachineLearning.build/Objects-normal/x86_64/Layer~partial.swiftmodule /Users/rxwei/Library/Developer/Xcode/DerivedData/MachineLearning-fmaewvvsqpggjjgofqfchyiwysiq/Build/Intermediates.noindex/MachineLearning.build/Debug/MachineLearning.build/Objects-normal/x86_64/Loss~partial.swiftmodule /Users/rxwei/Library/Developer/Xcode/DerivedData/MachineLearning-fmaewvvsqpggjjgofqfchyiwysiq/Build/Intermediates.noindex/MachineLearning.build/Debug/MachineLearning.build/Objects-normal/x86_64/Optimizer~partial.swiftmodule /Users/rxwei/Library/Developer/Xcode/DerivedData/MachineLearning-fmaewvvsqpggjjgofqfchyiwysiq/Build/Intermediates.noindex/MachineLearning.build/Debug/MachineLearning.build/Objects-normal/x86_64/Trainer~partial.swiftmodule /Users/rxwei/Library/Developer/Xcode/DerivedData/MachineLearning-fmaewvvsqpggjjgofqfchyiwysiq/Build/Intermediates.noindex/MachineLearning.build/Debug/MachineLearning.build/Objects-normal/x86_64/Utilities~partial.swiftmodule -parse-as-library -sil-merge-partial-modules -disable-diagnostic-passes -disable-sil-perf-optzns -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I /Users/rxwei/Library/Developer/Xcode/DerivedData/MachineLearning-fmaewvvsqpggjjgofqfchyiwysiq/Build/Products/Debug -F /Users/rxwei/Library/Developer/Xcode/DerivedData/MachineLearning-fmaewvvsqpggjjgofqfchyiwysiq/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /Users/rxwei/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 4.2 -enforce-exclusivity=checked -Onone -D SWIFT_PACKAGE -D DEBUG -D Xcode -serialize-debugging-options -Xcc -working-directory -Xcc /Users/rxwei/Development/MachineLearning -Xllvm -tf-dynamic-compilation -Xcc -I/Users/rxwei/Library/Developer/Xcode/DerivedData/MachineLearning-fmaewvvsqpggjjgofqfchyiwysiq/Build/Intermediates.noindex/MachineLearning.build/Debug/MachineLearning.build/swift-overrides.hmap -Xcc -I/Users/rxwei/Library/Developer/Xcode/DerivedData/MachineLearning-fmaewvvsqpggjjgofqfchyiwysiq/Build/Products/Debug/include -Xcc -I/Users/rxwei/Library/Developer/Xcode/DerivedData/MachineLearning-fmaewvvsqpggjjgofqfchyiwysiq/Build/Intermediates.noindex/MachineLearning.build/Debug/MachineLearning.build/DerivedSources/x86_64 -Xcc -I/Users/rxwei/Library/Developer/Xcode/DerivedData/MachineLearning-fmaewvvsqpggjjgofqfchyiwysiq/Build/Intermediates.noindex/MachineLearning.build/Debug/MachineLearning.build/DerivedSources -Xcc -DDEBUG=1 -emit-module-doc-path /Users/rxwei/Library/Developer/Xcode/DerivedData/MachineLearning-fmaewvvsqpggjjgofqfchyiwysiq/Build/Intermediates.noindex/MachineLearning.build/Debug/MachineLearning.build/Objects-normal/x86_64/MachineLearning.swiftdoc -emit-objc-header-path /Users/rxwei/Library/Developer/Xcode/DerivedData/MachineLearning-fmaewvvsqpggjjgofqfchyiwysiq/Build/Intermediates.noindex/MachineLearning.build/Debug/MachineLearning.build/Objects-normal/x86_64/MachineLearning-Swift.h -module-name MachineLearning -o /Users/rxwei/Library/Developer/Xcode/DerivedData/MachineLearning-fmaewvvsqpggjjgofqfchyiwysiq/Build/Intermediates.noindex/MachineLearning.build/Debug/MachineLearning.build/Objects-normal/x86_64/MachineLearning.swiftmodule 
1.  While deserializing SIL function "$s15MachineLearning5DenseVyxGAA5LayerA2aEP7applied2to6OutputQz5InputQz_tFTW"
2.  While deserializing SIL function "$s15MachineLearning5DenseV7applied2to10TensorFlow0F0VyxGAI_tF"
0  swift                    0x0000000107c6e4f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x0000000107c6d775 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x0000000107c6eb02 SignalHandler(int) + 258
3  libsystem_platform.dylib 0x00007fff66804b3d _sigtramp + 29
4  libsystem_platform.dylib 0x000000010d9e4938 _sigtramp + 2803760664
5  libsystem_c.dylib        0x00007fff666c21c9 abort + 127
6  libsystem_c.dylib        0x00007fff6668a868 basename_r + 0
7  swift                    0x000000010513ffa4 swift::SILDeserializer::readSILFunctionChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, swift::SILFunction*, llvm::StringRef, bool, bool) + 8836
8  swift                    0x000000010513db97 swift::SILDeserializer::getFuncForReference(llvm::StringRef, swift::SILType) + 391
9  swift                    0x00000001051482e3 swift::SILDeserializer::readSILInstruction(swift::SILFunction*, swift::SILBasicBlock*, swift::SILBuilder&, unsigned int, llvm::SmallVectorImpl<unsigned long long>&) + 28499
10 swift                    0x000000010513fa95 swift::SILDeserializer::readSILFunctionChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, swift::SILFunction*, llvm::StringRef, bool, bool) + 7541
11 swift                    0x0000000105153f0a swift::SILDeserializer::getAllSILFunctions() + 586
12 swift                    0x00000001051c5e8f swift::SerializedSILLoader::getAllForModule(swift::Identifier, swift::FileUnit*) + 127
13 swift                    0x0000000103f9f1a8 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 11032
14 swift                    0x0000000103f9b5fd swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3021
15 swift                    0x0000000103f4d38e main + 686
16 libdyld.dylib            0x00007fff66619ed9 start + 1
17 libdyld.dylib            0x000000000000003f start + 2577293671
@dan-zheng
Copy link
Collaborator

Done in #21837

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. swift for tensorflow
Projects
None yet
Development

No branches or pull requests

2 participants