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-9755] [AD] Crasher in Differentiable derived conformances #52184

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

[SR-9755] [AD] Crasher in Differentiable derived conformances #52184

rxwei opened this issue Jan 25, 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 25, 2019

Previous ID SR-9755
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 @rxwei
Priority Medium

md5: 380f76caae6ca7eb98c1fe7cac806364

Issue Description:

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

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

    public var weight: Tensor<Scalar>
    public var bias: Tensor<Scalar>
    public typealias Activation = @autodiff (Tensor<Scalar>) -> Tensor<Scalar>
    public let activation: Activation

    // FIXME(SR-9716): Remove this once the bug is fixed or worked around.
    public var allKeyPaths: [PartialKeyPath<Dense>] {
        return [\Dense.weight, \Dense.bias]
    }

    @differentiable(wrt: (self, input))
    public func applied(to input: Tensor<Scalar>) -> Tensor<Scalar> {
        return activation(matmul(input, weight) + bias)
    }
}
/Users/rxwei/Development/swift-apis/Sources/DeepLearning/Layer.swift:56:16: warning: stored property has no derivative because it does not conform to 'Differentiable'; add '@noDerivative' to make it explicit
    public let f: (Float) -> Float
               ^
    @noDerivative 
Assertion failed: (loc.isValid() && "Diagnosing attribute with invalid location"), function diagnoseAndRemoveAttr, file /usr/local/src/swift-build/swift/lib/Sema/TypeCheckAttr.cpp, line 43.
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2019-01-24-a.xctoolchain/usr/bin/swift -frontend -c /Users/rxwei/Development/swift-apis/Sources/DeepLearning/Helpers.swift -primary-file /Users/rxwei/Development/swift-apis/Sources/DeepLearning/Layer.swift /Users/rxwei/Development/swift-apis/Sources/DeepLearning/Loss.swift /Users/rxwei/Development/swift-apis/Sources/DeepLearning/Optimizer.swift -emit-module-path /Users/rxwei/Library/Developer/Xcode/DerivedData/DeepLearning-ecphexrowvsgalflnojluvjbiadn/Build/Intermediates.noindex/DeepLearning.build/Debug/DeepLearning.build/Objects-normal/x86_64/Layer~partial.swiftmodule -emit-module-doc-path /Users/rxwei/Library/Developer/Xcode/DerivedData/DeepLearning-ecphexrowvsgalflnojluvjbiadn/Build/Intermediates.noindex/DeepLearning.build/Debug/DeepLearning.build/Objects-normal/x86_64/Layer~partial.swiftdoc -serialize-diagnostics-path /Users/rxwei/Library/Developer/Xcode/DerivedData/DeepLearning-ecphexrowvsgalflnojluvjbiadn/Build/Intermediates.noindex/DeepLearning.build/Debug/DeepLearning.build/Objects-normal/x86_64/Layer.dia -emit-dependencies-path /Users/rxwei/Library/Developer/Xcode/DerivedData/DeepLearning-ecphexrowvsgalflnojluvjbiadn/Build/Intermediates.noindex/DeepLearning.build/Debug/DeepLearning.build/Objects-normal/x86_64/Layer.d -emit-reference-dependencies-path /Users/rxwei/Library/Developer/Xcode/DerivedData/DeepLearning-ecphexrowvsgalflnojluvjbiadn/Build/Intermediates.noindex/DeepLearning.build/Debug/DeepLearning.build/Objects-normal/x86_64/Layer.swiftdeps -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/DeepLearning-ecphexrowvsgalflnojluvjbiadn/Build/Products/Debug -F /Users/rxwei/Library/Developer/Xcode/DerivedData/DeepLearning-ecphexrowvsgalflnojluvjbiadn/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/swift-apis -Xcc -I/Users/rxwei/Library/Developer/Xcode/DerivedData/DeepLearning-ecphexrowvsgalflnojluvjbiadn/Build/Intermediates.noindex/DeepLearning.build/Debug/DeepLearning.build/swift-overrides.hmap -Xcc -I/Users/rxwei/Library/Developer/Xcode/DerivedData/DeepLearning-ecphexrowvsgalflnojluvjbiadn/Build/Products/Debug/include -Xcc -I/Users/rxwei/Library/Developer/Xcode/DerivedData/DeepLearning-ecphexrowvsgalflnojluvjbiadn/Build/Intermediates.noindex/DeepLearning.build/Debug/DeepLearning.build/DerivedSources/x86_64 -Xcc -I/Users/rxwei/Library/Developer/Xcode/DerivedData/DeepLearning-ecphexrowvsgalflnojluvjbiadn/Build/Intermediates.noindex/DeepLearning.build/Debug/DeepLearning.build/DerivedSources -Xcc -DDEBUG=1 -module-name DeepLearning -o /Users/rxwei/Library/Developer/Xcode/DerivedData/DeepLearning-ecphexrowvsgalflnojluvjbiadn/Build/Intermediates.noindex/DeepLearning.build/Debug/DeepLearning.build/Objects-normal/x86_64/Layer.o -index-store-path /Users/rxwei/Library/Developer/Xcode/DerivedData/DeepLearning-ecphexrowvsgalflnojluvjbiadn/Index/DataStore -index-system-modules 
1.  While type-checking 'Dense' (at /Users/rxwei/Development/swift-apis/Sources/DeepLearning/Layer.swift:50:8)
0  swift                    0x000000010597c928 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x000000010597bba5 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x000000010597cf32 SignalHandler(int) + 258
3  libsystem_platform.dylib 0x00007fff76edcb3d _sigtramp + 29
4  libsystem_platform.dylib 0x0000000000004098 _sigtramp + 2299688312
5  libsystem_c.dylib        0x00007fff76d9b1c9 abort + 127
6  libsystem_c.dylib        0x00007fff76d63868 basename_r + 0
7  swift                    0x0000000102d24667 void (anonymous namespace)::diagnoseAndRemoveAttr<swift::Diag<>&>(swift::TypeChecker&, swift::Decl*, swift::DeclAttribute*, swift::Diag<>&) + 199
8  swift                    0x0000000102d1fdd1 swift::TypeChecker::checkDeclAttributes(swift::Decl*) + 49
9  swift                    0x0000000102d61a64 (anonymous namespace)::DeclChecker::visitStructDecl(swift::StructDecl*) + 164
10 swift                    0x0000000102d55213 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 1491
11 swift                    0x0000000102d54c36 swift::TypeChecker::typeCheckDecl(swift::Decl*) + 38
12 swift                    0x0000000102df1948 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 872
13 swift                    0x00000001024bc805 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 629
14 swift                    0x00000001024bbe08 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 616
15 swift                    0x0000000101c8ec8d performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1309
16 swift                    0x0000000101c8d6dd swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3021
17 swift                    0x0000000101c3f2ce main + 686
18 libdyld.dylib            0x00007fff76cf308d start + 1
19 libdyld.dylib            0x0000000000000041 start + 2301677493
@rxwei
Copy link
Member Author

rxwei commented Jan 25, 2019

#22109

@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

1 participant