Uploaded image for project: ' Swift for TensorFlow'
  1. Swift for TensorFlow
  2. TF-1011

[AD] Forward-mode crash: Assertion failed: (Operand->getType().is<TupleType>() && "Expected a tuple typed operand?!")

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Done
    • Component/s: Autodiff
    • Labels:

      Description

      @differentiable
      func arrayLiteral(_ x: Float, _ y: Float) -> [Float] {
        var result = [x * y, x * y]
        return result
      }
      
      $ swift -enable-experimental-forward-mode-differentiation forward.swift
      forward.swift:3:7: warning: variable 'result' was never mutated; consider changing to 'let' constant
        var result = [x * y, x * y]
        ~~~ ^
        let
      Assertion failed: (Operand->getType().is<TupleType>() && "Expected a tuple typed operand?!"), function create, file /Users/danielzheng/swift-dev/swift/lib/SIL/SILInstructions.cpp, line 2678.
      Stack dump:
      0.	Program arguments: /Users/danielzheng/swift-dev/build/Ninja-ReleaseAssert+stdlib-Release/swift-macosx-x86_64/bin/swift -frontend -interpret forward.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -color-diagnostics -enable-experimental-forward-mode-differentiation -module-name forward
      1.	Swift version 5.1.1-dev (Swift bb93258885)
      2.	While running pass #66 SILModuleTransform "Differentiation".
      3.	While processing `[differentiable source 0 wrt 0, 1]` attribute on SIL function "@$s7forward12arrayLiteralySaySfGSf_SftF".
       for 'arrayLiteral(_:_:)' (at forward.swift:2:1)
      4.	While generating JVP and differential for SIL function "@$s7forward12arrayLiteralySaySfGSf_SftF".
       for 'arrayLiteral(_:_:)' (at forward.swift:2:1)
      0  swift                    0x0000000104e80fd5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
      1  swift                    0x0000000104e7ffd8 llvm::sys::RunSignalHandlers() + 248
      2  swift                    0x0000000104e815c8 SignalHandler(int) + 264
      3  libsystem_platform.dylib 0x00007fff728e4b5d _sigtramp + 29
      4  swift                    0x00000001073bd9d0 cmark_strbuf__initbuf + 144571
      5  libsystem_c.dylib        0x00007fff7279e6a6 abort + 127
      6  libsystem_c.dylib        0x00007fff7276720d basename_r + 0
      7  swift                    0x00000001050fd2c3 swift::DestructureTupleInst::create(swift::SILFunction const&, swift::SILDebugLocation, swift::SILValue) (.cold.3) + 35
      8  swift                    0x0000000101718844 swift::DestructureTupleInst::create(swift::SILFunction const&, swift::SILDebugLocation, swift::SILValue) + 388
      

      This is because forward-mode differentiation does not handle destructure_tuple for non-tuple-typed tangent values correctly. A patch similar to https://github.com/apple/swift/pull/28281 is necessary.

        Attachments

          Activity

            People

            Assignee:
            danzheng Dan Zheng
            Reporter:
            danzheng Dan Zheng
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: