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

[AD] Crash for active `tuple` instruction with non-tuple tangent type

    XMLWordPrintable

    Details

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

      Description

      @differentiable
      func TF_964(_ x: Float) -> Float {
        let tuple = (x, 1)
        return tuple.0
      }
      
      $ swift tf-964.swift
      Assertion failed: (Operand->getType().is<TupleType>() && "Expected a tuple typed operand?!"), function create, file /Users/danielzheng/swift-bart/swift/lib/SIL/SILInstructions.cpp, line 2676.
      Stack dump:
      0.	Program arguments: /Users/danielzheng/swift-bart/build/Ninja-ReleaseAssert+stdlib-Release/swift-macosx-x86_64/bin/swift -frontend -interpret tf-964.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -color-diagnostics -module-name main
      1.	Swift version 5.1.1-dev (Swift f655d9e91a)
      2.	While running pass #17 SILModuleTransform "Differentiation".
      3.	While processing `[differentiable source 0 wrt 0]` attribute on SIL function "@$s4main3fooyS2fF".
       for 'foo(_:)' (at tf-964.swift:2:1)
      0  swift                    0x000000010d1e2515 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
      1  swift                    0x000000010d1e1518 llvm::sys::RunSignalHandlers() + 248
      2  swift                    0x000000010d1e2b08 SignalHandler(int) + 264
      3  libsystem_platform.dylib 0x00007fff728e4b5d _sigtramp + 29
      4  swift                    0x000000010f70f810 cmark_strbuf__initbuf + 143819
      5  libsystem_c.dylib        0x00007fff7279e6a6 abort + 127
      6  libsystem_c.dylib        0x00007fff7276720d basename_r + 0
      7  swift                    0x000000010d45b113 swift::DestructureTupleInst::create(swift::SILFunction const&, swift::SILDebugLocation, swift::SILValue) (.cold.3) + 35
      8  swift                    0x0000000109a8db34 swift::DestructureTupleInst::create(swift::SILFunction const&, swift::SILDebugLocation, swift::SILValue) + 388
      9  swift                    0x000000010978ab33 swift::SILInstructionVisitor<(anonymous namespace)::PullbackEmitter, void>::visit(swift::SILInstruction*) + 8931
      

      This is because PullbackEmitter::visitTupleInst currently assumes active tuple values have a tuple tangent type, which is not the case for tuple values that have only a single element with a tangent space.
      We should test more variants of this issue (array literal initialization, indirectness, etc).

        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: