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

[AST][AutoDiff] Provide Lit test case for AutoDiff GenericTypeParamDecl AST verification failure. #38745

Merged

Conversation

astrotuna201
Copy link
Contributor

@astrotuna201 astrotuna201 commented Aug 4, 2021

Provides reproducer lit test case for AutoDiff implicit auxiliary struct and enum
declarations that clone implicit GenericTypeParamDecls from a generic
signature into a flat GenericParamList, and lead to a compiler assert about GenericTypeParamDecl depth during merge module operation.

Related to #32343.

@astrotuna201
Copy link
Contributor Author

CC: @compnerd @rxwei @dan-zheng

@dan-zheng
Copy link
Contributor

dan-zheng commented Aug 4, 2021

Disabling verification might be considered hacky.

An alternative fix could be to change differentiation to generate nested struct/enum declarations, so that the GenericTypeParamDecl of those struct/enum declarations will have the correct depth, passing verification. Though that would complicate struct/enum declaration generation solely for the purposes of passing verification, which would not be ideal.

Looping in @slavapestov: any advice on how to fix this? Happy to provide more context on struct/enum declaration generation by autodiff, I'm not sure there's precedent for generating implicit struct/enum declarations that potentially have GenericTypeParamDecls.

@dan-zheng
Copy link
Contributor

I don't think we spent time to find a minimal reproducer for this issue. From #32343 (comment):

GenericTypeParamDecl has incorrect depth
Stack dump:
0.	Program arguments: /Users/runner/runners/2.169.1/work/1/toolchain-darwin-x64/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/swiftc -frontend -merge-modules -emit-module Sources/x10/CMakeFiles/x10_tensor.dir/swift_bindings/apis/CrossReplicaSum.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/swift_bindings/apis/DeviceScope.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/swift_bindings/apis/RawOpsManual.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/swift_bindings/Device.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/swift_bindings/XLAScalarType.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/swift_bindings/XLATensor.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Bindings/EagerExecution.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Bindings/RawOpsGenerated.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Bindings/RawOpsAugmented.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Bindings/RawOpsDispatching.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Bindings/TFTensorOperation.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/BroadcastingPullback.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/CopyableToDevice.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/DifferentialOperators.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/PythonConversion.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/ShapedArray.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/Execution.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/TensorShape.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/Threading.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/Utilities.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/Tensor.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/TensorHandle.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/DataTypes.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/MixedPrecision.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/Runtime.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/StringTensor.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/TensorGroup.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/ArrayOps.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/LazyTensorContext.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/LazyTensorOperation.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/LazyTensorShapeInference.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/LazyTensorTFFunctionBuilder.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/LazyTensorTrace.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/LazyTensorTraceCache.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Core/Serialization.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Layers/Convolutional.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Layers/Core.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Layers/Dense.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Layers/Dropout.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Layers/Embedding.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Layers/Initialization.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Layers/Normalization.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Layers/Pooling.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Layers/Recurrent.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Layers/Sequential.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Layers/Upsampling.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Operators/Basic.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Operators/Comparison.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Operators/Dataset.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Operators/Image.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Operators/LinearAlgebra.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Operators/Math.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Operators/NN.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Optimizers/MomentumBased.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Optimizers/Optimizer.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Optimizers/SGD.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/BackwardsCompatibility.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Context.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Exports.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Freezable.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Initializers.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Layer.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/Loss.swift.swiftmodule Sources/x10/CMakeFiles/x10_tensor.dir/__/TensorFlow/StdlibExtensions.swift.swiftmodule -parse-as-library -sil-merge-partial-modules -disable-diagnostic-passes -disable-sil-perf-optzns -target x86_64-apple-macosx10.13 -enable-objc-interop -sdk /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -I /Users/runner/runners/2.169.1/work/1/s/tensorflow-swift-apis/Sources/x10 -I /Users/runner/runners/2.169.1/work/1/s/tensorflow-swift-apis/Sources/CTensorFlow -I swift -I /Users/runner/runners/2.169.1/work/1/s/tensorflow-swift-apis/Sources/CX10 -I /Users/runner/runners/2.169.1/work/1/tensorflow/tensorflow-darwin-x64/Library/tensorflow-2.2.0-rc1/usr/include -module-link-name x10_tensor -resource-dir /Users/runner/runners/2.169.1/work/1/b/swift-stdlib/lib/swift -O -D USING_X10_BACKEND -D x10_tensor_EXPORTS -Xllvm -sil-inline-generics -Xllvm -sil-partial-specialization -target-sdk-version 10.15 -emit-module-doc-path swift/x10_tensor.swiftdoc -emit-module-source-info-path swift/x10_tensor.swiftsourceinfo -module-name x10_tensor -o swift/x10_tensor.swiftmodule 
1.	compnerd.org Swift version 5.3-dev (LLVM 7a5fc24b4c, Swift 09c12c9a39)
2.	While verifying GenericTypeParamDecl 'τ_1_0' (in module 'x10_tensor')

The differentiation transform generates struct/enum declarations representing auxiliary data structures – pullback structs storing captured pullback values, and branching trace enums storing control flow path information – for each function that needs to be automatically differentiated.

To demonstrate the flavor, here's a case where differerentiation would generate struct/enum declarations with non-depth 0 GenericTypeParamDecls:

import _Differentiation

struct A<T>: Differentiable {
  struct B<U>: Differentiable {
    @differentiable(reverse, wrt: (self, x))
    func foo(_ x: Float) -> Float {
      x
    }
  }
}
$ swiftc autodiff.swift -emit-sil -Xllvm -debug-only=differentiation
...
[AD] Generated linear map structs and branching trace enums for @$s8autodiff1AV1BV3fooyS2fF:
@frozen struct _AD__$s8autodiff1AV1BV3fooyS2fF_bb0__PB__src_0_wrt_0_1_r__l<τ_1_0> {
}
@frozen enum _AD__$s8autodiff1AV1BV3fooyS2fF_bb0__Pred__src_0_wrt_0_1_r__l<τ_1_0> {
}

@astrotuna201
Copy link
Contributor Author

I managed to produce a minimal reproducer for the assert supposed to be evaded by this hack:

https://github.com/astrotuna201/ASTVerifierReproducer.git
The assert triggers in a debug build during merge-modules.

@dan-zheng
Copy link
Contributor

dan-zheng commented Aug 4, 2021

Nice, thanks for sharing!

Do you happen to be familiar with how the Swift compiler test suite works?

If you could convert your SwiftPM package reproducer into a multi-module lit test case in test/AutoDiff/compiler_crashers, that would be a big help. Otherwise, I might get to it within a week.

Here's a multi-module (multi-file) lit test case we can use as a template.

@jckarter
Copy link
Contributor

jckarter commented Aug 4, 2021

@swift-ci Please test

@rxwei
Copy link
Contributor

rxwei commented Aug 4, 2021

+1 to what Dan suggested. Perhaps we should look at the reproducer and emit the right level of nesting. I can take a look today and follow up.

@astrotuna201
Copy link
Contributor Author

astrotuna201 commented Aug 4, 2021

Nice, thanks for sharing!

Do you happen to be familiar with how the Swift compiler test suite works?

If you could convert your SwiftPM package reproducer into a multi-module lit test case in test/AutoDiff/compiler_crashers, that would be a big help. Otherwise, I might get to it within a week.

Here's a multi-module (multi-file) lit test case we can use as a template.

I haven't done this before, but here is a try, and indeed I manage to trigger with a single line compile command. Is hope it is helpful.

cat swift/test/AutoDiff/compiler_crashers/pr32302-autodiff-generictypeparamdecl-has-incorrect-depth.swift
// RUN: %empty-directory(%t)
// RUN: %target-build-swift -emit-module -module-name pr32302 -emit-module-path %t/pr32302.swiftmodule -swift-version 5 -c %S/pr32302-autodiff-generictypeparamdecl-has-incorrect-depth.swift -Xfrontend -requirement-machine=off

// pr32302 / pr32343 / pr38745 : reproduce assert with _Differentiation where
// ASTVerifier.cpp asserts "GenericTypeParamDecl has incorrect depth"

import _Differentiation

public protocol Layer: Differentiable {
  associatedtype Input: Differentiable
  associatedtype Output: Differentiable
  var differentiableVectorView: TangentVector { get }
  
  @differentiable(reverse)
  func callAsFunction(_ input: Input) -> Output
}

extension Differentiable {
  @differentiable(reverse)
  public func sequenced<L1: Layer, L2: Layer>(through l1: L1, _ l2: L2) -> L2.Output
  where L1.Input == Self, L1.Output == L2.Input {
    let o1 = l1(self)
    return l2(o1)
  }
}

// GenericTypeParamDecl has incorrect depth
// Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
// Stack dump:
// 0.	Program arguments: /work/software/swift-stocktoolchain/build/ds/swift-linux-x86_64/bin/swift-frontend -frontend -merge-modules -emit-module /tmp/pr32302-autodiff-generictypeparamdecl-has-incorrect-depth-acc95c.swiftmodule -parse-as-library -disable-diagnostic-passes -disable-sil-perf-optzns -target x86_64-unknown-linux-gnu -warn-on-potentially-unavailable-enum-case -disable-objc-interop -module-cache-path /work/software/swift-stocktoolchain/build/ds/swift-linux-x86_64/swift-test-results/x86_64-unknown-linux-gnu/clang-module-cache -swift-version 5 -define-availability "SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0" -requirement-machine=off -emit-module-doc-path /work/software/swift-stocktoolchain/build/ds/swift-linux-x86_64/test-linux-x86_64/AutoDiff/compiler_crashers/Output/pr32302-autodiff-generictypeparamdecl-has-incorrect-depth.swift.tmp/pr32302.swiftdoc -emit-module-source-info-path /work/software/swift-stocktoolchain/build/ds/swift-linux-x86_64/test-linux-x86_64/AutoDiff/compiler_crashers/Output/pr32302-autodiff-generictypeparamdecl-has-incorrect-depth.swift.tmp/pr32302.swiftsourceinfo -module-name pr32302 -o /work/software/swift-stocktoolchain/build/ds/swift-linux-x86_64/test-linux-x86_64/AutoDiff/compiler_crashers/Output/pr32302-autodiff-generictypeparamdecl-has-incorrect-depth.swift.tmp/pr32302.swiftmodule
// 1.	Swift version 5.6-dev (LLVM ba0b85f590c1ba2, Swift 319b3e64aaeb252)
// 2.	Compiling with the current language version
// 3.	While verifying GenericTypeParamDecl 'τ_1_0' (in module 'pr32302')
//  #0 0x000000000632fb13 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /work/software/swift-stocktoolchain/llvm-project/llvm/lib/Support/Unix/Signals.inc:563:13
//  #1 0x000000000632dda0 llvm::sys::RunSignalHandlers() /work/software/swift-stocktoolchain/llvm-project/llvm/lib/Support/Signals.cpp:72:18
//  #2 0x000000000632fe95 SignalHandler(int) /work/software/swift-stocktoolchain/llvm-project/llvm/lib/Support/Unix/Signals.inc:0:3
//  #3 0x00007ffbfc0ab3c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
//  #4 0x00007ffbfbb3618b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4618b)
//  #5 0x00007ffbfbb15859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x25859)
//  #6 0x0000000002417d95 llvm::MutableArrayRef<swift::GenericTypeParamDecl*>::operator[](unsigned long) const /work/software/swift-stocktoolchain/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:425:7
//  #7 0x0000000002417d95 (anonymous namespace)::Verifier::verifyCheckedAlways(swift::GenericTypeParamDecl*) /work/software/swift-stocktoolchain/swift/lib/AST/ASTVerifier.cpp:2866:11
//  #8 0x0000000002417d95 swift::GenericTypeParamDecl* (anonymous namespace)::Verifier::dispatchVisitPost<swift::GenericTypeParamDecl*>(swift::GenericTypeParamDecl*) /work/software/swift-stocktoolchain/swift/lib/AST/ASTVerifier.cpp:426:9
//  #9 0x0000000002417d95 (anonymous namespace)::Verifier::walkToDeclPost(swift::Decl*) /work/software/swift-stocktoolchain/swift/include/swift/AST/DeclNodes.def:159:7
// #10 0x00000000024214c7 (anonymous namespace)::Traversal::doIt(swift::Decl*) /work/software/swift-stocktoolchain/swift/lib/AST/ASTWalker.cpp:1275:12
// #11 0x0000000002421433 swift::Decl::walk(swift::ASTWalker&) /work/software/swift-stocktoolchain/swift/lib/AST/ASTWalker.cpp:1909:3
// #12 0x000000000240c6dd swift::verify(swift::Decl*) /work/software/swift-stocktoolchain/swift/lib/AST/ASTVerifier.cpp:3761:1
// #13 0x0000000001285157 swift::ModuleFile::verify() const /work/software/swift-stocktoolchain/swift/lib/Serialization/ModuleFile.cpp:1244:3
// #14 0x00000000011ead9a swift::SerializedModuleLoaderBase::verifyAllModules() /work/software/swift-stocktoolchain/swift/lib/Serialization/SerializedModuleLoader.cpp:1268:39
// #15 0x000000000236546a swift::ASTContext::verifyAllLoadedModules() const /work/software/swift-stocktoolchain/swift/lib/AST/ASTContext.cpp:1794:21
// #16 0x000000000058259d performEndOfPipelineActions(swift::CompilerInstance&) /work/software/swift-stocktoolchain/swift/lib/FrontendTool/FrontendTool.cpp:933:37
// #17 0x000000000057faa7 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) /work/software/swift-stocktoolchain/swift/lib/FrontendTool/FrontendTool.cpp:1252:10
// #18 0x000000000057ef21 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) /work/software/swift-stocktoolchain/swift/lib/FrontendTool/FrontendTool.cpp:2154:8
// #19 0x00000000004b36e7 run_driver(llvm::StringRef, llvm::ArrayRef<char const*>) /work/software/swift-stocktoolchain/swift/lib/DriverTool/driver.cpp:196:7
// #20 0x00000000004b3312 swift::mainEntry(int, char const**) /work/software/swift-stocktoolchain/swift/lib/DriverTool/driver.cpp:402:5
// #21 0x00000000004b2c72 main /work/software/swift-stocktoolchain/swift/tools/driver/driver.cpp:20:3
// #22 0x00007ffbfbb170b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
// #23 0x00000000004b2b7e _start (/work/software/swift-stocktoolchain/build/ds/swift-linux-x86_64/bin/swift-frontend+0x4b2b7e)

@CodaFi
Copy link
Contributor

CodaFi commented Aug 6, 2021

When the compiler builds AST nodes, it should have perfect knowledge of the correct way to do so. We should not be ducking AST construction errors like this. It looks like AutoDiff clones the generic parameters directly from the primary declaration when it's creating the linear map and branch tracing ASTs. This is not correct - you must recontextualize these generic parameters.

…t/AutoDiff/compiler_crashers/pr32302-autodiff-generictypeparamdecl-has-incorrect-depth.swift
Copy link
Contributor Author

@astrotuna201 astrotuna201 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have now reverted hacky patch and provided compiler crash reproducer instead.

@astrotuna201 astrotuna201 marked this pull request as ready for review August 16, 2021 07:23
Copy link
Contributor

@rxwei rxwei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Could you please update the PR title and description to reflect the latest changes?

@astrotuna201 astrotuna201 marked this pull request as draft August 16, 2021 18:01
@astrotuna201 astrotuna201 changed the title [AST][AutoDiff] Skip implicit GenericTypeParamDecl AST verification. [AST][AutoDiff] Provide Lit test case for AutoDiff GenericTypeParamDecl AST verification failure. Aug 16, 2021
@astrotuna201
Copy link
Contributor Author

Thanks. Could you please update the PR title and description to reflect the latest changes?

Ok, done, many thanks!

@astrotuna201 astrotuna201 marked this pull request as ready for review August 16, 2021 18:08
@astrotuna201
Copy link
Contributor Author

@swift-ci Please test

@astrotuna201
Copy link
Contributor Author

@rxwei @dan-zheng sorry, could some someone please trigger a CI test? Thanks!

@dan-zheng
Copy link
Contributor

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - aceec34

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - aceec34

@astrotuna201
Copy link
Contributor Author

@dan-zheng sorry, I think I misunderstood how lit should be configured for expected failing tests: I wrote RUN: not --crash but it still marked as failed, perhaps because it crashed. Now I inserted XFAIL: * ... could you please trigger another CI test? Thanks!

@dan-zheng
Copy link
Contributor

@swift-ci Please test

@rxwei rxwei merged commit 926a59c into swiftlang:main Aug 17, 2021
@ProfFan
Copy link

ProfFan commented Oct 19, 2021

Encountered this issue when compiling swift-apis (after fixing some deprecations).

@ProfFan
Copy link

ProfFan commented Oct 19, 2021

Interestingly, the reproducer by @astrotuna201 does not reproduce this issue anymore.

The bug however can be reproduced by building https://github.com/ProfFan/swift-apis/tree/fan/resurrection with current Swift main.

@astrotuna201
Copy link
Contributor Author

astrotuna201 commented Oct 19, 2021 via email

@dan-zheng
Copy link
Contributor

dan-zheng commented Oct 19, 2021

@ProfFan messaged me privately asking for a follow-up to this crasher. Above, I explained the issue and mentioned fix strategies.

+1 to what Dan suggested. Perhaps we should look at the reproducer and emit the right level of nesting. I can take a look today and follow up.

Following up with @rxwei from above, wonder if you still have time and interest in looking into a fix?

The test/AutoDiff/compiler_crashers/pr32302-autodiff-generictypeparamdecl-has-incorrect-depth.swift file added by this PR is a useful minimal reproducer for verifying a fix. @ProfFan also shared an updated version of tensorflow/swift-apis above that we could use to verify a fix too.

@ProfFan
Copy link

ProfFan commented Oct 19, 2021

@dan-zheng Thank you for the help! :)

@astrotuna201 I tried it on current main (Swift version 5.6-dev (LLVM 4c76989, Swift 8f443ff)
Target: x86_64-unknown-linux-gnu) and it didn't crash.

+1 to what Dan suggested. Perhaps we should look at the reproducer and emit the right level of nesting. I can take a look today and follow up.

@rxwei Wonder if I can help in debugging this? The error message is not really helpful here because the crash happens at emit. Is there a way to print something like a big SIL dump at emit?

I can also try fixing this issue if I can be bootstrapped on Swift dev.

@astrotuna201
Copy link
Contributor Author

astrotuna201 commented Oct 19, 2021 via email

@ProfFan
Copy link

ProfFan commented Oct 20, 2021

After a number of patches I can get swift-apis to build, but only in Debug. Release build fails with:

SIL verification failed: conflicting debug variable type!: DebugVars[argNum].second == DebugVarTy
Verifying instruction:
     %35 = apply %15<τ_0_0>(%14) : $@convention(method) <τ_0_0 where τ_0_0 : TensorFlowFloatingPoint> (@thin BatchNorm<τ_0_0>.TangentVector.Type) -> @owned BatchNorm<τ_0_0>.TangentVector // users: %36, %310, %312
->   debug_value %35 : $BatchNorm<τ_0_0>.TangentVector, let, name "self", argno 2, implicit, expr op_deref // id: %36
In function:
// pullback of BatchNorm.callAsFunction(_:)
<See the Gist>

Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0.      Program arguments: /usr/lib/swift-git/bin/swift-frontend -frontend -c /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/BackwardsCompatibility.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Bindings/EagerExecution.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Bindings/RawOpsAugmented.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Bindings/RawOpsDispatching.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Bindings/RawOpsGenerated.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Bindings/TFTensorOperation.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Context.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/ArrayOps.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/BroadcastingPullback.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/CopyableToDevice.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/DataTypes.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/DifferentialOperators.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/ElementaryFunctions.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/EuclideanDifferentiable.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/Execution.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/KeyPathIterable.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/LazyTensorContext.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/LazyTensorOperation.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/LazyTensorShapeInference.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/LazyTensorTFFunctionBuilder.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/LazyTensorTrace.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/LazyTensorTraceCache.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/MixedPrecision.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/PointwiseMultiplicative.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/PythonConversion.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/Runtime.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/ShapedArray.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/StringTensor.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/Tensor.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/TensorGroup.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/TensorHandle.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/TensorShape.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/Threading.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/Utilities.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Core/VectorProtocol.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Epochs/Algorithms.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Epochs/Backend.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Epochs/Collatable.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Epochs/NonuniformTrainingEpochs.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Epochs/Sampling.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Epochs/Slices.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Epochs/TrainingEpochs.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Exports.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Freezable.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Initializers.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Layer.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Layers/Convolutional.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Layers/Core.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Layers/Dense.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Layers/Dropout.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Layers/Embedding.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Layers/Initialization.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Layers/Morphological.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Layers/Normalization.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Layers/Pooling.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Layers/Recurrent.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Layers/Sequential.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Layers/Upsampling.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Loss.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Operators/Basic.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Operators/Comparison.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Operators/Dataset.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Operators/Image.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Operators/LinearAlgebra.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Operators/Math.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Operators/NN.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Optimizers/MomentumBased.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Optimizers/Optimizer.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Optimizers/SGD.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/StdlibExtensions.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/X10/APIs/CrossReplicaSum.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/X10/APIs/DeviceScope.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/X10/APIs/RawOpsManual.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/X10/Device.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/X10/RawOpsXLAGenerated.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/X10/XLAScalarType.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/X10/XLATensor.swift -supplementary-output-file-map /tmp/TemporaryDirectory.ko2bGr/supplementaryOutputs-1 -target x86_64-unknown-linux-gnu -disable-objc-interop -I /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release -color-diagnostics -enable-testing -g -module-cache-path /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/ModuleCache -swift-version 5 -O -D SWIFT_PACKAGE -D DEFAULT_BACKEND_EAGER -D TENSORFLOW_USE_STANDARD_TOOLCHAIN -new-driver-path /usr/lib/swift-git/bin/swift-driver -resource-dir /usr/lib/swift-git/lib/swift -Xcc -fmodule-map-file=/home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/checkouts/swift-numerics/Sources/_NumericsShims/include/module.modulemap -Xcc -I -Xcc /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/checkouts/swift-numerics/Sources/_NumericsShims/include -Xcc -fmodule-map-file=/home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/CX10Modules/include/module.modulemap -Xcc -I -Xcc /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/CX10Modules/include -Xcc -fmodule-map-file=/home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/CTensorFlow/include/module.modulemap -Xcc -I -Xcc /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/CTensorFlow/include -Xcc -I/home/fan/Projects/PL/Swift/s4tf_2021/Library/tensorflow-linux-x86_64/tensorflow-2.4.3/usr/include -module-name TensorFlow -parse-as-library -num-threads 12 -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/BackwardsCompatibility.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Bindings/EagerExecution.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Bindings/RawOpsAugmented.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Bindings/RawOpsDispatching.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Bindings/RawOpsGenerated.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Bindings/TFTensorOperation.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Context.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/ArrayOps.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/BroadcastingPullback.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/CopyableToDevice.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/DataTypes.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/DifferentialOperators.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/ElementaryFunctions.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/EuclideanDifferentiable.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/Execution.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/KeyPathIterable.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/LazyTensorContext.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/LazyTensorOperation.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/LazyTensorShapeInference.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/LazyTensorTFFunctionBuilder.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/LazyTensorTrace.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/LazyTensorTraceCache.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/MixedPrecision.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/PointwiseMultiplicative.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/PythonConversion.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/Runtime.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/ShapedArray.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/StringTensor.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/Tensor.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/TensorGroup.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/TensorHandle.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/TensorShape.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/Threading.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/Utilities.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Core/VectorProtocol.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Epochs/Algorithms.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Epochs/Backend.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Epochs/Collatable.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Epochs/NonuniformTrainingEpochs.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Epochs/Sampling.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Epochs/Slices.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Epochs/TrainingEpochs.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Exports.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Freezable.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Initializers.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Layer.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Layers/Convolutional.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Layers/Core.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Layers/Dense.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Layers/Dropout.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Layers/Embedding.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Layers/Initialization.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Layers/Morphological.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Layers/Normalization.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Layers/Pooling.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Layers/Recurrent.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Layers/Sequential.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Layers/Upsampling.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Loss.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Operators/Basic.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Operators/Comparison.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Operators/Dataset.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Operators/Image.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Operators/LinearAlgebra.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Operators/Math.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Operators/NN.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Optimizers/MomentumBased.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Optimizers/Optimizer.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/Optimizers/SGD.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/StdlibExtensions.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/X10/APIs/CrossReplicaSum.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/X10/APIs/DeviceScope.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/X10/APIs/RawOpsManual.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/X10/Device.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/X10/RawOpsXLAGenerated.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/X10/XLAScalarType.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlow.build/X10/XLATensor.swift.o
1.      Swift version 5.6-dev (LLVM 4c76989fa680f44, Swift 8f443ffbd430133)
2.      Compiling with the current language version
3.      While verifying SIL function "@$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGFAA0aB13FloatingPointRzlTJpUSpSr".
 for 'callAsFunction(_:)' (at /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Layers/Normalization.swift:102:10)
 #0 0x000055b3e1279f33 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/swift-git/bin/swift-frontend+0x651df33)
 #1 0x000055b3e1277c5e llvm::sys::RunSignalHandlers() (/usr/lib/swift-git/bin/swift-frontend+0x651bc5e)
 #2 0x000055b3e127a2ba SignalHandler(int) (/usr/lib/swift-git/bin/swift-frontend+0x651e2ba)
 #3 0x00007f2dcc6c1870 __restore_rt (/usr/lib/libpthread.so.0+0x13870)
 #4 0x00007f2dcc10dd22 raise (/usr/lib/libc.so.6+0x3cd22)
 #5 0x00007f2dcc0f7862 abort (/usr/lib/libc.so.6+0x26862)
 #6 0x000055b3dbd6a2e2 (/usr/lib/swift-git/bin/swift-frontend+0x100e2e2)
 #7 0x000055b3dbd88d48 (anonymous namespace)::SILVerifier::visitSILInstruction(swift::SILInstruction*) (/usr/lib/swift-git/bin/swift-frontend+0x102cd48)
 #8 0x000055b3dbd6c1c5 (anonymous namespace)::SILVerifier::visitSILBasicBlock(swift::SILBasicBlock*) (/usr/lib/swift-git/bin/swift-frontend+0x10101c5)
 #9 0x000055b3dbd652ce swift::SILFunction::verify(bool) const (/usr/lib/swift-git/bin/swift-frontend+0x10092ce)
#10 0x000055b3dbd6926b swift::SILModule::verify() const (/usr/lib/swift-git/bin/swift-frontend+0x100d26b)
#11 0x000055b3dbc9c1d6 swift::CompilerInstance::performSILProcessing(swift::SILModule*) (/usr/lib/swift-git/bin/swift-frontend+0xf401d6)
#12 0x000055b3dbaa864a performCompileStepsPostSILGen(swift::CompilerInstance&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) (/usr/lib/swift-git/bin/swift-frontend+0xd4c64a)
#13 0x000055b3dbaa8022 performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) (/usr/lib/swift-git/bin/swift-frontend+0xd4c022)
#14 0x000055b3dba9bb64 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/usr/lib/swift-git/bin/swift-frontend+0xd3fb64)
#15 0x000055b3dba67c3b swift::mainEntry(int, char const**) (/usr/lib/swift-git/bin/swift-frontend+0xd0bc3b)
#16 0x00007f2dcc0f8b25 __libc_start_main (/usr/lib/libc.so.6+0x27b25)
#17 0x000055b3dba6782e _start (/usr/lib/swift-git/bin/swift-frontend+0xd0b82e)
error: fatalError

SIL dump: https://gist.github.com/ProfFan/9a7788d3a99a27b2fc863d8e0d89e848

@ProfFan
Copy link

ProfFan commented Oct 20, 2021

Maybe related to https://bugs.swift.org/browse/SR-13263.

@ProfFan
Copy link

ProfFan commented Nov 1, 2021

The strange thing with BatchNorm is that it is not a mutating function. I don't know whether it's intended, but adding mutating to the callAsFunction immediately pointed out that the function is not differentiable. It changes some fields in the structure, so why is is not mutating? And why doesn't the compiler complain?

@ProfFan
Copy link

ProfFan commented Nov 2, 2021

@astrotuna201 Unfortunately after working around SR-13263 I also encountered the crash you are experiencing.

$ swift test -c release -Xswiftc -DTENSORFLOW_USE_STANDARD_TOOLCHAIN -Xcc -I/home/fan/Projects/PL/Swift/s4tf_2021/Library/tensorflow-linux-x86_64/tensorflow-2.4.3/usr/include \
        -Xlinker -L/home/fan/Projects/PL/Swift/s4tf_2021/Library/tensorflow-linux-x86_64/tensorflow-2.4.3/usr/lib
/home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Layers/Normalization.swift:108:10: warning: variable 'offset' was never mutated; consider changing to 'let' constant
    var (offset, scale) = {x in (x.offset, x.scale) }(self)
         ^
/home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/TensorFlow/Layers/Normalization.swift:108:18: warning: variable 'scale' was never mutated; consider changing to 'let' constant
    var (offset, scale) = {x in (x.offset, x.scale) }(self)
                 ^
GenericTypeParamDecl has incorrect depth
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0.      Program arguments: /usr/lib/swift-git/bin/swift-frontend -frontend -c /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/CollectionTesting.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/ContextTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/EpochsTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/FreezableTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/Helpers.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/InitializerTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/KeyPathIterableTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/LayerTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/LazyTensorEvaluationTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/LazyTensorExplicitTraceTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/LazyTensorHandleTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/LazyTensorOperationTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/LazyTensorShapeInferenceTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/LazyTensorTFFunctionBuilderTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/LazyTensorTestHelper.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/LazyTensorTraceCacheTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/LazyTensorTraceTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/LossTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/OperatorTests/BasicTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/OperatorTests/ComparisonTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/OperatorTests/ImageTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/OperatorTests/LinearAlgebraTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/OperatorTests/MathTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/OperatorTests/MatrixTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/OperatorTests/NNTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/OptimizerTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/RuntimeTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/SamplingTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/SequencedTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/SequentialTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/SlicesTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/TensorAutoDiffTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/TensorGroupTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/TensorTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/TrivialModelTests.swift /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Tests/TensorFlowTests/XCTestManifests.swift -supplementary-output-file-map /tmp/TemporaryDirectory.f6Demt/supplementaryOutputs-1 -target x86_64-unknown-linux-gnu -disable-objc-interop -I /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release -color-diagnostics -enable-testing -g -module-cache-path /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/ModuleCache -swift-version 5 -O -D SWIFT_PACKAGE -D TENSORFLOW_USE_STANDARD_TOOLCHAIN -new-driver-path /usr/lib/swift-git/bin/swift-driver -resource-dir /usr/lib/swift-git/lib/swift -Xcc -fmodule-map-file=/home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/checkouts/swift-numerics/Sources/_NumericsShims/include/module.modulemap -Xcc -I -Xcc /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/checkouts/swift-numerics/Sources/_NumericsShims/include -Xcc -fmodule-map-file=/home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/CX10Modules/include/module.modulemap -Xcc -I -Xcc /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/CX10Modules/include -Xcc -fmodule-map-file=/home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/CTensorFlow/include/module.modulemap -Xcc -I -Xcc /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/Sources/CTensorFlow/include -Xcc -I/home/fan/Projects/PL/Swift/s4tf_2021/Library/tensorflow-linux-x86_64/tensorflow-2.4.3/usr/include -module-name TensorFlowTests -parse-as-library -num-threads 12 -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/CollectionTesting.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/ContextTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/EpochsTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/FreezableTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/Helpers.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/InitializerTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/KeyPathIterableTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/LayerTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/LazyTensorEvaluationTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/LazyTensorExplicitTraceTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/LazyTensorHandleTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/LazyTensorOperationTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/LazyTensorShapeInferenceTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/LazyTensorTFFunctionBuilderTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/LazyTensorTestHelper.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/LazyTensorTraceCacheTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/LazyTensorTraceTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/LossTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/OperatorTests/BasicTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/OperatorTests/ComparisonTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/OperatorTests/ImageTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/OperatorTests/LinearAlgebraTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/OperatorTests/MathTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/OperatorTests/MatrixTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/OperatorTests/NNTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/OptimizerTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/RuntimeTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/SamplingTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/SequencedTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/SequentialTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/SlicesTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/TensorAutoDiffTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/TensorGroupTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/TensorTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/TrivialModelTests.swift.o -o /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/TensorFlowTests.build/XCTestManifests.swift.o -index-store-path /home/fan/Projects/PL/Swift/s4tf_2021/swift-apis/.build/x86_64-unknown-linux-gnu/release/index/store -index-system-modules
1.      Swift version 5.6-dev (LLVM 30010bf3b070441, Swift 7349283a41ab6d8)
2.      Compiling with the current language version
3.      While verifying GenericTypeParamDecl 'τ_1_0' (in module 'TensorFlow')
 #0 0x00005555e981bc13 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/swift-git/bin/swift-frontend+0x652ec13)
 #1 0x00005555e981993e llvm::sys::RunSignalHandlers() (/usr/lib/swift-git/bin/swift-frontend+0x652c93e)
 #2 0x00005555e981bf9a SignalHandler(int) (/usr/lib/swift-git/bin/swift-frontend+0x652ef9a)
 #3 0x00007fbd9f237870 __restore_rt (/usr/lib/libpthread.so.0+0x13870)
 #4 0x00007fbd9ec83d22 raise (/usr/lib/libc.so.6+0x3cd22)
 #5 0x00007fbd9ec6d862 abort (/usr/lib/libc.so.6+0x26862)
 #6 0x00005555e5394935 (anonymous namespace)::Verifier::walkToDeclPost(swift::Decl*) (/usr/lib/swift-git/bin/swift-frontend+0x20a7935)
 #7 0x00005555e539d617 (anonymous namespace)::Traversal::doIt(swift::Decl*) (/usr/lib/swift-git/bin/swift-frontend+0x20b0617)
 #8 0x00005555e539d583 swift::Decl::walk(swift::ASTWalker&) (/usr/lib/swift-git/bin/swift-frontend+0x20b0583)
 #9 0x00005555e5389f94 swift::verify(swift::Decl*) (/usr/lib/swift-git/bin/swift-frontend+0x209cf94)
#10 0x00005555e4785fd6 swift::ModuleFile::verify() const (/usr/lib/swift-git/bin/swift-frontend+0x1498fd6)
#11 0x00005555e4728e08 swift::SerializedModuleLoaderBase::verifyAllModules() (/usr/lib/swift-git/bin/swift-frontend+0x143be08)
#12 0x00005555e52fd48a swift::ASTContext::verifyAllLoadedModules() const (/usr/lib/swift-git/bin/swift-frontend+0x201048a)
#13 0x00005555e4032e05 performEndOfPipelineActions(swift::CompilerInstance&) (/usr/lib/swift-git/bin/swift-frontend+0xd45e05)
#14 0x00005555e402e94e swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/usr/lib/swift-git/bin/swift-frontend+0xd4194e)
#15 0x00005555e3ff996b swift::mainEntry(int, char const**) (/usr/lib/swift-git/bin/swift-frontend+0xd0c96b)
#16 0x00007fbd9ec6eb25 __libc_start_main (/usr/lib/libc.so.6+0x27b25)
#17 0x00005555e3ff955e _start (/usr/lib/swift-git/bin/swift-frontend+0xd0c55e)

error: fatalError

So I think this issue has not been fixed. Actually this and SR-13263 may have the same underlying source.

@philipturner
Copy link
Contributor

philipturner commented Jul 7, 2022

With the patches to debug info generation in recent months, I thought this would have been fixed. But the crash still happens on top-of-tree S4TF, so it has not been fixed. The behavior of SR-13263 has changed enough to warrant removing workarounds for it, but the SR reproducer still crashes.

Crash
SIL verification failed: conflicting debug variable type!: DebugVars[argNum].second == DebugVarTy
Verifying instruction:
->   %42 = alloc_stack $BatchNorm<τ_0_0>.TangentVector, let, name "self", argno 2, implicit, expr op_deref // users: %97, %93, %112, %44, %218, %464
     store %43 to %42 : $*BatchNorm<τ_0_0>.TangentVector // id: %44
     %93 = struct_element_addr %42 : $*BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.offset // users: %255, %94
     %97 = struct_element_addr %42 : $*BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.scale // users: %256, %98
     store %9 to %42 : $*BatchNorm<τ_0_0>.TangentVector // id: %112
     %218 = apply %217<BatchNorm<τ_0_0>.TangentVector>(%42, %202, %216) : $@convention(method) <τ_0_0 where τ_0_0 : AdditiveArithmetic> (@inout τ_0_0, @in_guaranteed τ_0_0, @thick τ_0_0.Type) -> ()
     dealloc_stack %42 : $*BatchNorm<τ_0_0>.TangentVector // id: %464
In function:
// pullback of BatchNorm.callAsFunction(_:)
sil private @$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGFAA0aB13FloatingPointRzlTJpUSpSr : $@convention(thin) <τ_0_0 where τ_0_0 : TensorFlowFloatingPoint> (@guaranteed Tensor<τ_0_0>, @owned _AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb6__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>) -> @out BatchNorm<τ_0_0>.TangentVector {
// %0                                             // users: %352, %348, %374, %370, %397, %361, %15, %410, %420
// %1                                             // users: %130, %203
// %2                                             // user: %62
bb0(%0 : $*BatchNorm<τ_0_0>.TangentVector, %1 : $Tensor<τ_0_0>, %2 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb6__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>):
  %3 = metatype $@thin Tensor<τ_0_0>.Type         // users: %235, %232, %213, %210, %421, %417, %414, %412, %407, %404, %347, %343, %338, %335, %332, %327, %322, %320, %298, %297, %284, %283, %162, %159, %140, %137, %121, %120, %116, %92, %91, %86, %81, %72, %49, %46, %40, %37, %32, %30, %26, %23, %18, %16, %12, %10, %6, %5
  // function_ref static Tensor<>.zero.getter
  %4 = function_ref @$s10TensorFlow0A0VAASjRzrlE4zeroACyxGvgZ : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %417, %407, %338, %322, %298, %297, %284, %283, %121, %120, %116, %92, %91, %86, %81, %72, %49, %46, %40, %37, %32, %30, %26, %23, %18, %16, %12, %10, %6, %5
  %5 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %78, %119, %113, %89, %77
  %6 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %71, %67, %114, %84, %64
  %7 = metatype $@thin BatchNorm<τ_0_0>.TangentVector.Type // users: %52, %43, %34, %28, %20, %14, %9
  // function_ref static BatchNorm.TangentVector.zero.getter
  %8 = function_ref @$s10TensorFlow9BatchNormV13TangentVectorV4zeroAEyx_GvgZ : $@convention(method) <τ_0_0 where τ_0_0 : TensorFlowFloatingPoint> (@thin BatchNorm<τ_0_0>.TangentVector.Type) -> @owned BatchNorm<τ_0_0>.TangentVector // users: %52, %43, %34, %28, %20, %14, %9
  %9 = apply %8<τ_0_0>(%7) : $@convention(method) <τ_0_0 where τ_0_0 : TensorFlowFloatingPoint> (@thin BatchNorm<τ_0_0>.TangentVector.Type) -> @owned BatchNorm<τ_0_0>.TangentVector // users: %66, %65, %112, %63
  %10 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %390, %359, %11
  debug_value %10 : $Tensor<τ_0_0>, var, name "scale" // id: %11
  %12 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %389, %358, %13
  debug_value %12 : $Tensor<τ_0_0>, var, name "offset" // id: %13
  %14 = apply %8<τ_0_0>(%7) : $@convention(method) <τ_0_0 where τ_0_0 : TensorFlowFloatingPoint> (@thin BatchNorm<τ_0_0>.TangentVector.Type) -> @owned BatchNorm<τ_0_0>.TangentVector // user: %15
  store %14 to %0 : $*BatchNorm<τ_0_0>.TangentVector // id: %15
  %16 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %306, %17
  debug_value %16 : $Tensor<τ_0_0>, var, name "scale" // id: %17
  %18 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %305, %19
  debug_value %18 : $Tensor<τ_0_0>, var, name "offset" // id: %19
  %20 = apply %8<τ_0_0>(%7) : $@convention(method) <τ_0_0 where τ_0_0 : TensorFlowFloatingPoint> (@thin BatchNorm<τ_0_0>.TangentVector.Type) -> @owned BatchNorm<τ_0_0>.TangentVector // users: %303, %301, %21
  debug_value %20 : $BatchNorm<τ_0_0>.TangentVector, let, name "self", argno 2, implicit, expr op_deref // id: %21
  %22 = alloc_stack $Tensor<τ_0_0>, var, name "scale" // users: %177, %289, %250, %364, %323, %307, %294, %275, %24, %332, %468
  %23 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // user: %24
  store %23 to %22 : $*Tensor<τ_0_0>              // id: %24
  %25 = alloc_stack $Tensor<τ_0_0>, var, name "offset" // users: %173, %285, %246, %362, %339, %334, %293, %276, %27, %347, %467
  %26 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // user: %27
  store %26 to %25 : $*Tensor<τ_0_0>              // id: %27
  %28 = apply %8<τ_0_0>(%7) : $@convention(method) <τ_0_0 where τ_0_0 : TensorFlowFloatingPoint> (@thin BatchNorm<τ_0_0>.TangentVector.Type) -> @owned BatchNorm<τ_0_0>.TangentVector // users: %244, %242, %171, %169, %29
  debug_value %28 : $BatchNorm<τ_0_0>.TangentVector, let, name "self", argno 2, implicit, expr op_deref // id: %29
  %30 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %241, %168, %31
  debug_value %30 : $Tensor<τ_0_0>, var, name "scale" // id: %31
  %32 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %240, %167, %33
  debug_value %32 : $Tensor<τ_0_0>, var, name "offset" // id: %33
  %34 = apply %8<τ_0_0>(%7) : $@convention(method) <τ_0_0 where τ_0_0 : TensorFlowFloatingPoint> (@thin BatchNorm<τ_0_0>.TangentVector.Type) -> @owned BatchNorm<τ_0_0>.TangentVector // users: %238, %236, %165, %163, %35
  debug_value %34 : $BatchNorm<τ_0_0>.TangentVector, let, name "self", argno 2, implicit, expr op_deref // id: %35
  %36 = alloc_stack $Tensor<τ_0_0>, var, name "scale" // users: %107, %259, %119, %113, %38, %232, %466
  %37 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // user: %38
  store %37 to %36 : $*Tensor<τ_0_0>              // id: %38
  %39 = alloc_stack $Tensor<τ_0_0>, var, name "offset" // users: %103, %257, %114, %41, %235, %465
  %40 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // user: %41
  store %40 to %39 : $*Tensor<τ_0_0>              // id: %41
  %42 = alloc_stack $BatchNorm<τ_0_0>.TangentVector, let, name "self", argno 2, implicit, expr op_deref // users: %97, %93, %112, %44, %218, %464
  %43 = apply %8<τ_0_0>(%7) : $@convention(method) <τ_0_0 where τ_0_0 : TensorFlowFloatingPoint> (@thin BatchNorm<τ_0_0>.TangentVector.Type) -> @owned BatchNorm<τ_0_0>.TangentVector // user: %44
  store %43 to %42 : $*BatchNorm<τ_0_0>.TangentVector // id: %44
  %45 = alloc_stack $Tensor<τ_0_0>, var, name "scale" // users: %73, %188, %89, %77, %47, %159, %463
  %46 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // user: %47
  store %46 to %45 : $*Tensor<τ_0_0>              // id: %47
  %48 = alloc_stack $Tensor<τ_0_0>, var, name "offset" // users: %53, %186, %84, %64, %50, %162, %462
  %49 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // user: %50
  store %49 to %48 : $*Tensor<τ_0_0>              // id: %50
  %51 = alloc_stack $BatchNorm<τ_0_0>.TangentVector, let, name "self", argno 2, implicit, expr op_deref // users: %184, %182, %426, %422, %63, %57, %145, %461
  %52 = apply %8<τ_0_0>(%7) : $@convention(method) <τ_0_0 where τ_0_0 : TensorFlowFloatingPoint> (@thin BatchNorm<τ_0_0>.TangentVector.Type) -> @owned BatchNorm<τ_0_0>.TangentVector // users: %60, %58, %57
  %53 = struct_element_addr %48 : $*Tensor<τ_0_0>, #Tensor.handle // user: %54
  %54 = struct_element_addr %53 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // users: %432, %82, %55
  %55 = load %54 : $*_AnyTensorHandle             // user: %56
  strong_release %55 : $_AnyTensorHandle          // id: %56
  store %52 to %51 : $*BatchNorm<τ_0_0>.TangentVector // id: %57
  %58 = struct_extract %52 : $BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.offset // user: %59
  release_value %58 : $Tensor<τ_0_0>              // id: %59
  %60 = struct_extract %52 : $BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.scale // user: %61
  release_value %60 : $Tensor<τ_0_0>              // id: %61
  %62 = struct_extract %2 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb6__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>, #_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb6__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl.predecessor // user: %123
  store %9 to %51 : $*BatchNorm<τ_0_0>.TangentVector // id: %63
  store %6 to %48 : $*Tensor<τ_0_0>               // id: %64
  %65 = struct_extract %9 : $BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.offset // user: %69
  %66 = struct_extract %9 : $BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.scale // user: %70
  %67 = struct_extract %6 : $Tensor<τ_0_0>, #Tensor.handle // user: %68
  %68 = struct_extract %67 : $TensorHandle<τ_0_0>, #TensorHandle.handle // user: %85
  retain_value %65 : $Tensor<τ_0_0>               // id: %69
  retain_value %66 : $Tensor<τ_0_0>               // id: %70
  retain_value %6 : $Tensor<τ_0_0>                // id: %71
  %72 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %416, %414
  %73 = struct_element_addr %45 : $*Tensor<τ_0_0>, #Tensor.handle // user: %74
  %74 = struct_element_addr %73 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // users: %434, %87, %75
  %75 = load %74 : $*_AnyTensorHandle             // user: %76
  strong_release %75 : $_AnyTensorHandle          // id: %76
  store %5 to %45 : $*Tensor<τ_0_0>               // id: %77
  %78 = struct_extract %5 : $Tensor<τ_0_0>, #Tensor.handle // user: %79
  %79 = struct_extract %78 : $TensorHandle<τ_0_0>, #TensorHandle.handle // users: %115, %90, %80
  strong_retain %79 : $_AnyTensorHandle           // id: %80
  %81 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %406, %404
  %82 = load %54 : $*_AnyTensorHandle             // user: %83
  strong_release %82 : $_AnyTensorHandle          // id: %83
  store %6 to %48 : $*Tensor<τ_0_0>               // id: %84
  strong_retain %68 : $_AnyTensorHandle           // id: %85
  %86 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %198, %139, %137
  %87 = load %74 : $*_AnyTensorHandle             // user: %88
  strong_release %87 : $_AnyTensorHandle          // id: %88
  store %5 to %45 : $*Tensor<τ_0_0>               // id: %89
  strong_retain %79 : $_AnyTensorHandle           // id: %90
  %91 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %199, %142, %140
  %92 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // user: %111
  %93 = struct_element_addr %42 : $*BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.offset // users: %255, %94
  %94 = struct_element_addr %93 : $*Tensor<τ_0_0>, #Tensor.handle // user: %95
  %95 = struct_element_addr %94 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // users: %436, %96
  %96 = load %95 : $*_AnyTensorHandle             // user: %101
  %97 = struct_element_addr %42 : $*BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.scale // users: %256, %98
  %98 = struct_element_addr %97 : $*Tensor<τ_0_0>, #Tensor.handle // user: %99
  %99 = struct_element_addr %98 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // users: %437, %100
  %100 = load %99 : $*_AnyTensorHandle            // user: %102
  strong_release %96 : $_AnyTensorHandle          // id: %101
  strong_release %100 : $_AnyTensorHandle         // id: %102
  %103 = struct_element_addr %39 : $*Tensor<τ_0_0>, #Tensor.handle // user: %104
  %104 = struct_element_addr %103 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // users: %440, %105
  %105 = load %104 : $*_AnyTensorHandle           // user: %106
  strong_release %105 : $_AnyTensorHandle         // id: %106
  %107 = struct_element_addr %36 : $*Tensor<τ_0_0>, #Tensor.handle // user: %108
  %108 = struct_element_addr %107 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // users: %442, %117, %109
  %109 = load %108 : $*_AnyTensorHandle           // user: %110
  strong_release %109 : $_AnyTensorHandle         // id: %110
  release_value %92 : $Tensor<τ_0_0>              // id: %111
  store %9 to %42 : $*BatchNorm<τ_0_0>.TangentVector // id: %112
  store %5 to %36 : $*Tensor<τ_0_0>               // id: %113
  store %6 to %39 : $*Tensor<τ_0_0>               // id: %114
  strong_retain %79 : $_AnyTensorHandle           // id: %115
  %116 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %125, %212, %210
  %117 = load %108 : $*_AnyTensorHandle           // user: %118
  strong_release %117 : $_AnyTensorHandle         // id: %118
  store %5 to %36 : $*Tensor<τ_0_0>               // id: %119
  %120 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %215, %126, %213
  %121 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // user: %122
  release_value %121 : $Tensor<τ_0_0>             // id: %122
  switch_enum %62 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb6__Pred__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>, case #_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb6__Pred__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl.bb5!enumelt: bb1, case #_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb6__Pred__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl.bb4!enumelt: bb2 // id: %123

// %124                                           // users: %128, %127
bb1(%124 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb5__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>): // Preds: bb0
  release_value %116 : $Tensor<τ_0_0>             // id: %125
  release_value %120 : $Tensor<τ_0_0>             // id: %126
  %127 = struct_extract %124 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb5__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>, #_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb5__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl.predecessor // user: %190
  %128 = struct_extract %124 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb5__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>, #_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb5__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl.pullback_3 // users: %131, %130
  %129 = alloc_stack $BatchNorm<τ_0_0>.TangentVector // users: %150, %146, %135, %145, %156
  %130 = apply %128(%1) : $@callee_guaranteed @substituted <τ_0_0, τ_0_1, τ_0_2, τ_0_3, τ_0_4, τ_0_5, τ_0_6, τ_0_7 where τ_0_0 : TensorFlowScalar, τ_0_0 == τ_0_1, τ_0_2 : TensorFlowScalar, τ_0_2 == τ_0_3, τ_0_4 : TensorFlowScalar, τ_0_4 == τ_0_5, τ_0_6 : TensorFlowFloatingPoint, τ_0_6 == τ_0_7> (@guaranteed Tensor<τ_0_0>) -> (@owned Tensor<τ_0_2>, @owned Tensor<τ_0_4>, @owned BatchNorm<τ_0_6>.TangentVector) for <τ_0_0, τ_0_0, τ_0_0, τ_0_0, τ_0_0, τ_0_0, τ_0_0, τ_0_0> // users: %134, %133, %132
  strong_release %128 : $@callee_guaranteed @substituted <τ_0_0, τ_0_1, τ_0_2, τ_0_3, τ_0_4, τ_0_5, τ_0_6, τ_0_7 where τ_0_0 : TensorFlowScalar, τ_0_0 == τ_0_1, τ_0_2 : TensorFlowScalar, τ_0_2 == τ_0_3, τ_0_4 : TensorFlowScalar, τ_0_4 == τ_0_5, τ_0_6 : TensorFlowFloatingPoint, τ_0_6 == τ_0_7> (@guaranteed Tensor<τ_0_0>) -> (@owned Tensor<τ_0_2>, @owned Tensor<τ_0_4>, @owned BatchNorm<τ_0_6>.TangentVector) for <τ_0_0, τ_0_0, τ_0_0, τ_0_0, τ_0_0, τ_0_0, τ_0_0, τ_0_0> // id: %131
  %132 = tuple_extract %130 : $(Tensor<τ_0_0>, Tensor<τ_0_0>, BatchNorm<τ_0_0>.TangentVector), 0 // users: %138, %137
  %133 = tuple_extract %130 : $(Tensor<τ_0_0>, Tensor<τ_0_0>, BatchNorm<τ_0_0>.TangentVector), 1 // users: %141, %140
  %134 = tuple_extract %130 : $(Tensor<τ_0_0>, Tensor<τ_0_0>, BatchNorm<τ_0_0>.TangentVector), 2 // user: %135
  store %134 to %129 : $*BatchNorm<τ_0_0>.TangentVector // id: %135
  // function_ref static Tensor<>.+ infix(_:_:)
  %136 = function_ref @$s10TensorFlow0A0VAASjRzrlE1poiyACyxGAE_AEtFZ : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@guaranteed Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %140, %137
  %137 = apply %136<τ_0_0>(%132, %86, %3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@guaranteed Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %181, %162, %161
  release_value %132 : $Tensor<τ_0_0>             // id: %138
  release_value %86 : $Tensor<τ_0_0>              // id: %139
  %140 = apply %136<τ_0_0>(%133, %91, %3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@guaranteed Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %160, %159, %157
  release_value %133 : $Tensor<τ_0_0>             // id: %141
  release_value %91 : $Tensor<τ_0_0>              // id: %142
  %143 = metatype $@thick BatchNorm<τ_0_0>.TangentVector.Type // user: %145
  // function_ref static AdditiveArithmetic.+= infix(_:_:)
  %144 = function_ref @$ss18AdditiveArithmeticPsE2peoiyyxz_xtFZ : $@convention(method) <τ_0_0 where τ_0_0 : AdditiveArithmetic> (@inout τ_0_0, @in_guaranteed τ_0_0, @thick τ_0_0.Type) -> () // user: %145
  %145 = apply %144<BatchNorm<τ_0_0>.TangentVector>(%51, %129, %143) : $@convention(method) <τ_0_0 where τ_0_0 : AdditiveArithmetic> (@inout τ_0_0, @in_guaranteed τ_0_0, @thick τ_0_0.Type) -> ()
  %146 = struct_element_addr %129 : $*BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.offset // user: %147
  %147 = struct_element_addr %146 : $*Tensor<τ_0_0>, #Tensor.handle // user: %148
  %148 = struct_element_addr %147 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // user: %149
  %149 = load %148 : $*_AnyTensorHandle           // user: %154
  %150 = struct_element_addr %129 : $*BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.scale // user: %151
  %151 = struct_element_addr %150 : $*Tensor<τ_0_0>, #Tensor.handle // user: %152
  %152 = struct_element_addr %151 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // user: %153
  %153 = load %152 : $*_AnyTensorHandle           // user: %155
  strong_release %149 : $_AnyTensorHandle         // id: %154
  strong_release %153 : $_AnyTensorHandle         // id: %155
  dealloc_stack %129 : $*BatchNorm<τ_0_0>.TangentVector // id: %156
  debug_value %140 : $Tensor<τ_0_0>               // id: %157
  // function_ref static Tensor<>.+= infix(_:_:)
  %158 = function_ref @$s10TensorFlow0A0VAASjRzrlE2peoiyyACyxGz_AEtFZ : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@inout Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> () // users: %162, %159
  %159 = apply %158<τ_0_0>(%45, %140, %3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@inout Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> ()
  release_value %140 : $Tensor<τ_0_0>             // id: %160
  debug_value %137 : $Tensor<τ_0_0>               // id: %161
  %162 = apply %158<τ_0_0>(%48, %137, %3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@inout Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> ()
  %163 = struct_extract %34 : $BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.offset // user: %164
  release_value %163 : $Tensor<τ_0_0>             // id: %164
  %165 = struct_extract %34 : $BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.scale // user: %166
  release_value %165 : $Tensor<τ_0_0>             // id: %166
  release_value %32 : $Tensor<τ_0_0>              // id: %167
  release_value %30 : $Tensor<τ_0_0>              // id: %168
  %169 = struct_extract %28 : $BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.offset // user: %170
  release_value %169 : $Tensor<τ_0_0>             // id: %170
  %171 = struct_extract %28 : $BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.scale // user: %172
  release_value %171 : $Tensor<τ_0_0>             // id: %172
  %173 = struct_element_addr %25 : $*Tensor<τ_0_0>, #Tensor.handle // user: %174
  %174 = struct_element_addr %173 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // user: %175
  %175 = load %174 : $*_AnyTensorHandle           // user: %176
  strong_release %175 : $_AnyTensorHandle         // id: %176
  %177 = struct_element_addr %22 : $*Tensor<τ_0_0>, #Tensor.handle // user: %178
  %178 = struct_element_addr %177 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // user: %179
  %179 = load %178 : $*_AnyTensorHandle           // user: %180
  strong_release %179 : $_AnyTensorHandle         // id: %180
  release_value %137 : $Tensor<τ_0_0>             // id: %181
  %182 = struct_element_addr %51 : $*BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.offset // user: %183
  %183 = load %182 : $*Tensor<τ_0_0>              // users: %192, %196
  %184 = struct_element_addr %51 : $*BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.scale // user: %185
  %185 = load %184 : $*Tensor<τ_0_0>              // users: %193, %196
  %186 = load %48 : $*Tensor<τ_0_0>               // users: %194, %196, %187
  debug_value %186 : $Tensor<τ_0_0>, var, name "offset" // id: %187
  %188 = load %45 : $*Tensor<τ_0_0>               // users: %195, %196, %189
  debug_value %188 : $Tensor<τ_0_0>, var, name "scale" // id: %189
  %190 = unchecked_enum_data %127 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb5__Pred__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>, #_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb5__Pred__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl.bb3!enumelt // user: %191
  %191 = struct_extract %190 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb3__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>, #_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb3__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl.predecessor // user: %196
  retain_value %183 : $Tensor<τ_0_0>              // id: %192
  retain_value %185 : $Tensor<τ_0_0>              // id: %193
  retain_value %186 : $Tensor<τ_0_0>              // id: %194
  retain_value %188 : $Tensor<τ_0_0>              // id: %195
  br bb3(%191 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb3__Pred__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>, %186 : $Tensor<τ_0_0>, %188 : $Tensor<τ_0_0>, %183 : $Tensor<τ_0_0>, %185 : $Tensor<τ_0_0>) // id: %196

// %197                                           // users: %201, %200
bb2(%197 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb4__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>): // Preds: bb0
  release_value %86 : $Tensor<τ_0_0>              // id: %198
  release_value %91 : $Tensor<τ_0_0>              // id: %199
  %200 = struct_extract %197 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb4__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>, #_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb4__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl.predecessor // user: %261
  %201 = struct_extract %197 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb4__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>, #_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb4__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl.pullback_2 // users: %204, %203
  %202 = alloc_stack $BatchNorm<τ_0_0>.TangentVector // users: %223, %219, %208, %218, %229
  %203 = apply %201(%1) : $@callee_guaranteed @substituted <τ_0_0, τ_0_1, τ_0_2, τ_0_3, τ_0_4, τ_0_5, τ_0_6, τ_0_7 where τ_0_0 : TensorFlowScalar, τ_0_0 == τ_0_1, τ_0_2 : TensorFlowScalar, τ_0_2 == τ_0_3, τ_0_4 : TensorFlowScalar, τ_0_4 == τ_0_5, τ_0_6 : TensorFlowFloatingPoint, τ_0_6 == τ_0_7> (@guaranteed Tensor<τ_0_0>) -> (@owned Tensor<τ_0_2>, @owned Tensor<τ_0_4>, @owned BatchNorm<τ_0_6>.TangentVector) for <τ_0_0, τ_0_0, τ_0_0, τ_0_0, τ_0_0, τ_0_0, τ_0_0, τ_0_0> // users: %207, %206, %205
  strong_release %201 : $@callee_guaranteed @substituted <τ_0_0, τ_0_1, τ_0_2, τ_0_3, τ_0_4, τ_0_5, τ_0_6, τ_0_7 where τ_0_0 : TensorFlowScalar, τ_0_0 == τ_0_1, τ_0_2 : TensorFlowScalar, τ_0_2 == τ_0_3, τ_0_4 : TensorFlowScalar, τ_0_4 == τ_0_5, τ_0_6 : TensorFlowFloatingPoint, τ_0_6 == τ_0_7> (@guaranteed Tensor<τ_0_0>) -> (@owned Tensor<τ_0_2>, @owned Tensor<τ_0_4>, @owned BatchNorm<τ_0_6>.TangentVector) for <τ_0_0, τ_0_0, τ_0_0, τ_0_0, τ_0_0, τ_0_0, τ_0_0, τ_0_0> // id: %204
  %205 = tuple_extract %203 : $(Tensor<τ_0_0>, Tensor<τ_0_0>, BatchNorm<τ_0_0>.TangentVector), 0 // users: %211, %210
  %206 = tuple_extract %203 : $(Tensor<τ_0_0>, Tensor<τ_0_0>, BatchNorm<τ_0_0>.TangentVector), 1 // users: %214, %213
  %207 = tuple_extract %203 : $(Tensor<τ_0_0>, Tensor<τ_0_0>, BatchNorm<τ_0_0>.TangentVector), 2 // user: %208
  store %207 to %202 : $*BatchNorm<τ_0_0>.TangentVector // id: %208
  // function_ref static Tensor<>.+ infix(_:_:)
  %209 = function_ref @$s10TensorFlow0A0VAASjRzrlE1poiyACyxGAE_AEtFZ : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@guaranteed Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %213, %210
  %210 = apply %209<τ_0_0>(%205, %116, %3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@guaranteed Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %254, %235, %234
  release_value %205 : $Tensor<τ_0_0>             // id: %211
  release_value %116 : $Tensor<τ_0_0>             // id: %212
  %213 = apply %209<τ_0_0>(%206, %120, %3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@guaranteed Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %233, %232, %230
  release_value %206 : $Tensor<τ_0_0>             // id: %214
  release_value %120 : $Tensor<τ_0_0>             // id: %215
  %216 = metatype $@thick BatchNorm<τ_0_0>.TangentVector.Type // user: %218
  // function_ref static AdditiveArithmetic.+= infix(_:_:)
  %217 = function_ref @$ss18AdditiveArithmeticPsE2peoiyyxz_xtFZ : $@convention(method) <τ_0_0 where τ_0_0 : AdditiveArithmetic> (@inout τ_0_0, @in_guaranteed τ_0_0, @thick τ_0_0.Type) -> () // user: %218
  %218 = apply %217<BatchNorm<τ_0_0>.TangentVector>(%42, %202, %216) : $@convention(method) <τ_0_0 where τ_0_0 : AdditiveArithmetic> (@inout τ_0_0, @in_guaranteed τ_0_0, @thick τ_0_0.Type) -> ()
  %219 = struct_element_addr %202 : $*BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.offset // user: %220
  %220 = struct_element_addr %219 : $*Tensor<τ_0_0>, #Tensor.handle // user: %221
  %221 = struct_element_addr %220 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // user: %222
  %222 = load %221 : $*_AnyTensorHandle           // user: %227
  %223 = struct_element_addr %202 : $*BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.scale // user: %224
  %224 = struct_element_addr %223 : $*Tensor<τ_0_0>, #Tensor.handle // user: %225
  %225 = struct_element_addr %224 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // user: %226
  %226 = load %225 : $*_AnyTensorHandle           // user: %228
  strong_release %222 : $_AnyTensorHandle         // id: %227
  strong_release %226 : $_AnyTensorHandle         // id: %228
  dealloc_stack %202 : $*BatchNorm<τ_0_0>.TangentVector // id: %229
  debug_value %213 : $Tensor<τ_0_0>               // id: %230
  // function_ref static Tensor<>.+= infix(_:_:)
  %231 = function_ref @$s10TensorFlow0A0VAASjRzrlE2peoiyyACyxGz_AEtFZ : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@inout Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> () // users: %235, %232
  %232 = apply %231<τ_0_0>(%36, %213, %3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@inout Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> ()
  release_value %213 : $Tensor<τ_0_0>             // id: %233
  debug_value %210 : $Tensor<τ_0_0>               // id: %234
  %235 = apply %231<τ_0_0>(%39, %210, %3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@inout Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> ()
  %236 = struct_extract %34 : $BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.offset // user: %237
  release_value %236 : $Tensor<τ_0_0>             // id: %237
  %238 = struct_extract %34 : $BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.scale // user: %239
  release_value %238 : $Tensor<τ_0_0>             // id: %239
  release_value %32 : $Tensor<τ_0_0>              // id: %240
  release_value %30 : $Tensor<τ_0_0>              // id: %241
  %242 = struct_extract %28 : $BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.offset // user: %243
  release_value %242 : $Tensor<τ_0_0>             // id: %243
  %244 = struct_extract %28 : $BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.scale // user: %245
  release_value %244 : $Tensor<τ_0_0>             // id: %245
  %246 = struct_element_addr %25 : $*Tensor<τ_0_0>, #Tensor.handle // user: %247
  %247 = struct_element_addr %246 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // user: %248
  %248 = load %247 : $*_AnyTensorHandle           // user: %249
  strong_release %248 : $_AnyTensorHandle         // id: %249
  %250 = struct_element_addr %22 : $*Tensor<τ_0_0>, #Tensor.handle // user: %251
  %251 = struct_element_addr %250 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // user: %252
  %252 = load %251 : $*_AnyTensorHandle           // user: %253
  strong_release %252 : $_AnyTensorHandle         // id: %253
  release_value %210 : $Tensor<τ_0_0>             // id: %254
  %255 = load %93 : $*Tensor<τ_0_0>               // users: %263, %267
  %256 = load %97 : $*Tensor<τ_0_0>               // users: %264, %267
  %257 = load %39 : $*Tensor<τ_0_0>               // users: %265, %267, %258
  debug_value %257 : $Tensor<τ_0_0>, var, name "offset" // id: %258
  %259 = load %36 : $*Tensor<τ_0_0>               // users: %266, %267, %260
  debug_value %259 : $Tensor<τ_0_0>, var, name "scale" // id: %260
  %261 = unchecked_enum_data %200 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb4__Pred__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>, #_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb4__Pred__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl.bb3!enumelt // user: %262
  %262 = struct_extract %261 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb3__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>, #_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb3__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl.predecessor // user: %267
  retain_value %255 : $Tensor<τ_0_0>              // id: %263
  retain_value %256 : $Tensor<τ_0_0>              // id: %264
  retain_value %257 : $Tensor<τ_0_0>              // id: %265
  retain_value %259 : $Tensor<τ_0_0>              // id: %266
  br bb3(%262 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb3__Pred__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>, %257 : $Tensor<τ_0_0>, %259 : $Tensor<τ_0_0>, %255 : $Tensor<τ_0_0>, %256 : $Tensor<τ_0_0>) // id: %267

// %268                                           // user: %311
// %269                                           // users: %446, %456, %319, %386, %382, %296, %282, %400, %398, %309, %276, %293
// %270                                           // users: %447, %457, %318, %385, %381, %378, %295, %281, %320, %400, %399, %310, %275, %294, %307
// %271                                           // users: %391, %444, %448, %454, %316, %383, %379, %279, %277, %273
// %272                                           // users: %392, %445, %449, %455, %317, %384, %380, %280, %278, %273
bb3(%268 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb3__Pred__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>, %269 : $Tensor<τ_0_0>, %270 : $Tensor<τ_0_0>, %271 : $Tensor<τ_0_0>, %272 : $Tensor<τ_0_0>): // Preds: bb2 bb1
  %273 = struct $BatchNorm<τ_0_0>.TangentVector (%271 : $Tensor<τ_0_0>, %272 : $Tensor<τ_0_0>) // users: %397, %361, %274, %308
  debug_value %273 : $BatchNorm<τ_0_0>.TangentVector, let, name "self", argno 2, implicit, expr op_deref // id: %274
  store %270 to %22 : $*Tensor<τ_0_0>             // id: %275
  store %269 to %25 : $*Tensor<τ_0_0>             // id: %276
  retain_value %271 : $Tensor<τ_0_0>              // id: %277
  retain_value %272 : $Tensor<τ_0_0>              // id: %278
  retain_value %271 : $Tensor<τ_0_0>              // id: %279
  retain_value %272 : $Tensor<τ_0_0>              // id: %280
  retain_value %270 : $Tensor<τ_0_0>              // id: %281
  retain_value %269 : $Tensor<τ_0_0>              // id: %282
  %283 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %393, %345, %343
  %284 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %394, %337, %335
  %285 = struct_element_addr %25 : $*Tensor<τ_0_0>, #Tensor.handle // user: %286
  %286 = struct_element_addr %285 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // users: %450, %287
  %287 = load %286 : $*_AnyTensorHandle           // user: %288
  strong_release %287 : $_AnyTensorHandle         // id: %288
  %289 = struct_element_addr %22 : $*Tensor<τ_0_0>, #Tensor.handle // user: %290
  %290 = struct_element_addr %289 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // users: %452, %299, %291
  %291 = load %290 : $*_AnyTensorHandle           // user: %292
  strong_release %291 : $_AnyTensorHandle         // id: %292
  store %269 to %25 : $*Tensor<τ_0_0>             // id: %293
  store %270 to %22 : $*Tensor<τ_0_0>             // id: %294
  retain_value %270 : $Tensor<τ_0_0>              // id: %295
  retain_value %269 : $Tensor<τ_0_0>              // id: %296
  %297 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %395, %329, %327
  %298 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %396, %321, %320
  %299 = load %290 : $*_AnyTensorHandle           // user: %300
  strong_release %299 : $_AnyTensorHandle         // id: %300
  %301 = struct_extract %20 : $BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.offset // user: %302
  release_value %301 : $Tensor<τ_0_0>             // id: %302
  %303 = struct_extract %20 : $BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.scale // user: %304
  release_value %303 : $Tensor<τ_0_0>             // id: %304
  release_value %18 : $Tensor<τ_0_0>              // id: %305
  release_value %16 : $Tensor<τ_0_0>              // id: %306
  store %270 to %22 : $*Tensor<τ_0_0>             // id: %307
  debug_value %273 : $BatchNorm<τ_0_0>.TangentVector, let, name "self", argno 2, implicit, expr op_deref // id: %308
  debug_value %269 : $Tensor<τ_0_0>, var, name "offset" // id: %309
  debug_value %270 : $Tensor<τ_0_0>, var, name "scale" // id: %310
  switch_enum %268 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb3__Pred__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>, case #_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb3__Pred__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl.bb1!enumelt: bb4, case #_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb3__Pred__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl.bb2!enumelt: bb5 // id: %311

// %312                                           // users: %314, %313
bb4(%312 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb1__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>): // Preds: bb3
  %313 = struct_extract %312 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb1__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>, #_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb1__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl.pullback_0 // users: %342, %340
  %314 = struct_extract %312 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb1__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>, #_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb1__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl.pullback_1 // users: %326, %324
  // function_ref static Tensor<>.+ infix(_:_:)
  %315 = function_ref @$s10TensorFlow0A0VAASjRzrlE1poiyACyxGAE_AEtFZ : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@guaranteed Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %343, %335, %327, %320
  retain_value %271 : $Tensor<τ_0_0>              // id: %316
  retain_value %272 : $Tensor<τ_0_0>              // id: %317
  retain_value %270 : $Tensor<τ_0_0>              // id: %318
  retain_value %269 : $Tensor<τ_0_0>              // id: %319
  %320 = apply %315<τ_0_0>(%270, %298, %3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@guaranteed Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %325, %324
  release_value %298 : $Tensor<τ_0_0>             // id: %321
  %322 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // user: %323
  store %322 to %22 : $*Tensor<τ_0_0>             // id: %323
  %324 = apply %314(%320) : $@callee_guaranteed @substituted <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 : TensorFlowScalar, τ_0_0 == τ_0_1, τ_0_2 : TensorFlowScalar, τ_0_2 == τ_0_3> (@guaranteed Tensor<τ_0_0>) -> @owned Tensor<τ_0_2> for <τ_0_0, τ_0_0, τ_0_0, τ_0_0> // users: %328, %327
  release_value %320 : $Tensor<τ_0_0>             // id: %325
  strong_release %314 : $@callee_guaranteed @substituted <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 : TensorFlowScalar, τ_0_0 == τ_0_1, τ_0_2 : TensorFlowScalar, τ_0_2 == τ_0_3> (@guaranteed Tensor<τ_0_0>) -> @owned Tensor<τ_0_2> for <τ_0_0, τ_0_0, τ_0_0, τ_0_0> // id: %326
  %327 = apply %315<τ_0_0>(%324, %297, %3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@guaranteed Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %333, %332, %330
  release_value %324 : $Tensor<τ_0_0>             // id: %328
  release_value %297 : $Tensor<τ_0_0>             // id: %329
  debug_value %327 : $Tensor<τ_0_0>               // id: %330
  // function_ref static Tensor<>.+= infix(_:_:)
  %331 = function_ref @$s10TensorFlow0A0VAASjRzrlE2peoiyyACyxGz_AEtFZ : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@inout Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> () // users: %347, %332
  %332 = apply %331<τ_0_0>(%22, %327, %3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@inout Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> ()
  release_value %327 : $Tensor<τ_0_0>             // id: %333
  %334 = load %25 : $*Tensor<τ_0_0>               // users: %336, %335
  %335 = apply %315<τ_0_0>(%334, %284, %3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@guaranteed Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %341, %340
  release_value %334 : $Tensor<τ_0_0>             // id: %336
  release_value %284 : $Tensor<τ_0_0>             // id: %337
  %338 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // user: %339
  store %338 to %25 : $*Tensor<τ_0_0>             // id: %339
  %340 = apply %313(%335) : $@callee_guaranteed @substituted <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 : TensorFlowScalar, τ_0_0 == τ_0_1, τ_0_2 : TensorFlowScalar, τ_0_2 == τ_0_3> (@guaranteed Tensor<τ_0_0>) -> @owned Tensor<τ_0_2> for <τ_0_0, τ_0_0, τ_0_0, τ_0_0> // users: %344, %343
  release_value %335 : $Tensor<τ_0_0>             // id: %341
  strong_release %313 : $@callee_guaranteed @substituted <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 : TensorFlowScalar, τ_0_0 == τ_0_1, τ_0_2 : TensorFlowScalar, τ_0_2 == τ_0_3> (@guaranteed Tensor<τ_0_0>) -> @owned Tensor<τ_0_2> for <τ_0_0, τ_0_0, τ_0_0, τ_0_0> // id: %342
  %343 = apply %315<τ_0_0>(%340, %283, %3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@guaranteed Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %360, %347, %346
  release_value %340 : $Tensor<τ_0_0>             // id: %344
  release_value %283 : $Tensor<τ_0_0>             // id: %345
  debug_value %343 : $Tensor<τ_0_0>               // id: %346
  %347 = apply %331<τ_0_0>(%25, %343, %3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@inout Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> ()
  %348 = struct_element_addr %0 : $*BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.offset // user: %349
  %349 = struct_element_addr %348 : $*Tensor<τ_0_0>, #Tensor.handle // user: %350
  %350 = struct_element_addr %349 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // user: %351
  %351 = load %350 : $*_AnyTensorHandle           // user: %356
  %352 = struct_element_addr %0 : $*BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.scale // user: %353
  %353 = struct_element_addr %352 : $*Tensor<τ_0_0>, #Tensor.handle // user: %354
  %354 = struct_element_addr %353 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // user: %355
  %355 = load %354 : $*_AnyTensorHandle           // user: %357
  strong_release %351 : $_AnyTensorHandle         // id: %356
  strong_release %355 : $_AnyTensorHandle         // id: %357
  release_value %12 : $Tensor<τ_0_0>              // id: %358
  release_value %10 : $Tensor<τ_0_0>              // id: %359
  release_value %343 : $Tensor<τ_0_0>             // id: %360
  store %273 to %0 : $*BatchNorm<τ_0_0>.TangentVector // id: %361
  %362 = load %25 : $*Tensor<τ_0_0>               // users: %366, %368, %363
  debug_value %362 : $Tensor<τ_0_0>, var, name "offset" // id: %363
  %364 = load %22 : $*Tensor<τ_0_0>               // users: %367, %368, %365
  debug_value %364 : $Tensor<τ_0_0>, var, name "scale" // id: %365
  retain_value %362 : $Tensor<τ_0_0>              // id: %366
  retain_value %364 : $Tensor<τ_0_0>              // id: %367
  br bb6(%362 : $Tensor<τ_0_0>, %364 : $Tensor<τ_0_0>) // id: %368

bb5(%369 : $_AD__$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGF_bb2__PB__src_0_wrt_1_10TensorFlow0aB13FloatingPointRzl<τ_0_0>): // Preds: bb3
  %370 = struct_element_addr %0 : $*BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.offset // user: %371
  %371 = struct_element_addr %370 : $*Tensor<τ_0_0>, #Tensor.handle // user: %372
  %372 = struct_element_addr %371 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // user: %373
  %373 = load %372 : $*_AnyTensorHandle           // user: %387
  %374 = struct_element_addr %0 : $*BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.scale // user: %375
  %375 = struct_element_addr %374 : $*Tensor<τ_0_0>, #Tensor.handle // user: %376
  %376 = struct_element_addr %375 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // user: %377
  %377 = load %376 : $*_AnyTensorHandle           // user: %388
  retain_value %270 : $Tensor<τ_0_0>              // id: %378
  retain_value %271 : $Tensor<τ_0_0>              // id: %379
  retain_value %272 : $Tensor<τ_0_0>              // id: %380
  retain_value %270 : $Tensor<τ_0_0>              // id: %381
  retain_value %269 : $Tensor<τ_0_0>              // id: %382
  retain_value %271 : $Tensor<τ_0_0>              // id: %383
  retain_value %272 : $Tensor<τ_0_0>              // id: %384
  retain_value %270 : $Tensor<τ_0_0>              // id: %385
  retain_value %269 : $Tensor<τ_0_0>              // id: %386
  strong_release %373 : $_AnyTensorHandle         // id: %387
  strong_release %377 : $_AnyTensorHandle         // id: %388
  release_value %12 : $Tensor<τ_0_0>              // id: %389
  release_value %10 : $Tensor<τ_0_0>              // id: %390
  release_value %271 : $Tensor<τ_0_0>             // id: %391
  release_value %272 : $Tensor<τ_0_0>             // id: %392
  release_value %283 : $Tensor<τ_0_0>             // id: %393
  release_value %284 : $Tensor<τ_0_0>             // id: %394
  release_value %297 : $Tensor<τ_0_0>             // id: %395
  release_value %298 : $Tensor<τ_0_0>             // id: %396
  store %273 to %0 : $*BatchNorm<τ_0_0>.TangentVector // id: %397
  debug_value %269 : $Tensor<τ_0_0>, var, name "offset" // id: %398
  debug_value %270 : $Tensor<τ_0_0>, var, name "scale" // id: %399
  br bb6(%269 : $Tensor<τ_0_0>, %270 : $Tensor<τ_0_0>) // id: %400

// %401                                           // users: %415, %414
// %402                                           // users: %405, %404
bb6(%401 : $Tensor<τ_0_0>, %402 : $Tensor<τ_0_0>): // Preds: bb4 bb5
  // function_ref static Tensor<>.+ infix(_:_:)
  %403 = function_ref @$s10TensorFlow0A0VAASjRzrlE1poiyACyxGAE_AEtFZ : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@guaranteed Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %414, %404
  %404 = apply %403<τ_0_0>(%402, %81, %3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@guaranteed Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %413, %412, %409
  release_value %402 : $Tensor<τ_0_0>             // id: %405
  release_value %81 : $Tensor<τ_0_0>              // id: %406
  %407 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %459, %408
  debug_value %407 : $Tensor<τ_0_0>, var, name "scale" // id: %408
  debug_value %404 : $Tensor<τ_0_0>               // id: %409
  %410 = struct_element_addr %0 : $*BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.scale // user: %412
  // function_ref static Tensor<>.+= infix(_:_:)
  %411 = function_ref @$s10TensorFlow0A0VAASjRzrlE2peoiyyACyxGz_AEtFZ : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@inout Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> () // users: %421, %412
  %412 = apply %411<τ_0_0>(%410, %404, %3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@inout Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> ()
  release_value %404 : $Tensor<τ_0_0>             // id: %413
  %414 = apply %403<τ_0_0>(%401, %72, %3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@guaranteed Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %460, %421, %419
  release_value %401 : $Tensor<τ_0_0>             // id: %415
  release_value %72 : $Tensor<τ_0_0>              // id: %416
  %417 = apply %4<τ_0_0>(%3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@thin Tensor<τ_0_0>.Type) -> @owned Tensor<τ_0_0> // users: %458, %418
  debug_value %417 : $Tensor<τ_0_0>, var, name "offset" // id: %418
  debug_value %414 : $Tensor<τ_0_0>               // id: %419
  %420 = struct_element_addr %0 : $*BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.offset // user: %421
  %421 = apply %411<τ_0_0>(%420, %414, %3) : $@convention(method) <τ_0_0 where τ_0_0 : Numeric, τ_0_0 : TensorFlowScalar> (@inout Tensor<τ_0_0>, @guaranteed Tensor<τ_0_0>, @thin Tensor<τ_0_0>.Type) -> ()
  %422 = struct_element_addr %51 : $*BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.offset // user: %423
  %423 = struct_element_addr %422 : $*Tensor<τ_0_0>, #Tensor.handle // user: %424
  %424 = struct_element_addr %423 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // user: %425
  %425 = load %424 : $*_AnyTensorHandle           // user: %430
  %426 = struct_element_addr %51 : $*BatchNorm<τ_0_0>.TangentVector, #BatchNorm.TangentVector.scale // user: %427
  %427 = struct_element_addr %426 : $*Tensor<τ_0_0>, #Tensor.handle // user: %428
  %428 = struct_element_addr %427 : $*TensorHandle<τ_0_0>, #TensorHandle.handle // user: %429
  %429 = load %428 : $*_AnyTensorHandle           // user: %431
  strong_release %425 : $_AnyTensorHandle         // id: %430
  strong_release %429 : $_AnyTensorHandle         // id: %431
  %432 = load %54 : $*_AnyTensorHandle            // user: %433
  strong_release %432 : $_AnyTensorHandle         // id: %433
  %434 = load %74 : $*_AnyTensorHandle            // user: %435
  strong_release %434 : $_AnyTensorHandle         // id: %435
  %436 = load %95 : $*_AnyTensorHandle            // user: %438
  %437 = load %99 : $*_AnyTensorHandle            // user: %439
  strong_release %436 : $_AnyTensorHandle         // id: %438
  strong_release %437 : $_AnyTensorHandle         // id: %439
  %440 = load %104 : $*_AnyTensorHandle           // user: %441
  strong_release %440 : $_AnyTensorHandle         // id: %441
  %442 = load %108 : $*_AnyTensorHandle           // user: %443
  strong_release %442 : $_AnyTensorHandle         // id: %443
  release_value %271 : $Tensor<τ_0_0>             // id: %444
  release_value %272 : $Tensor<τ_0_0>             // id: %445
  release_value %269 : $Tensor<τ_0_0>             // id: %446
  release_value %270 : $Tensor<τ_0_0>             // id: %447
  release_value %271 : $Tensor<τ_0_0>             // id: %448
  release_value %272 : $Tensor<τ_0_0>             // id: %449
  %450 = load %286 : $*_AnyTensorHandle           // user: %451
  strong_release %450 : $_AnyTensorHandle         // id: %451
  %452 = load %290 : $*_AnyTensorHandle           // user: %453
  strong_release %452 : $_AnyTensorHandle         // id: %453
  release_value %271 : $Tensor<τ_0_0>             // id: %454
  release_value %272 : $Tensor<τ_0_0>             // id: %455
  release_value %269 : $Tensor<τ_0_0>             // id: %456
  release_value %270 : $Tensor<τ_0_0>             // id: %457
  release_value %417 : $Tensor<τ_0_0>             // id: %458
  release_value %407 : $Tensor<τ_0_0>             // id: %459
  release_value %414 : $Tensor<τ_0_0>             // id: %460
  dealloc_stack %51 : $*BatchNorm<τ_0_0>.TangentVector // id: %461
  dealloc_stack %48 : $*Tensor<τ_0_0>             // id: %462
  dealloc_stack %45 : $*Tensor<τ_0_0>             // id: %463
  dealloc_stack %42 : $*BatchNorm<τ_0_0>.TangentVector // id: %464
  dealloc_stack %39 : $*Tensor<τ_0_0>             // id: %465
  dealloc_stack %36 : $*Tensor<τ_0_0>             // id: %466
  dealloc_stack %25 : $*Tensor<τ_0_0>             // id: %467
  dealloc_stack %22 : $*Tensor<τ_0_0>             // id: %468
  %469 = tuple ()                                 // user: %470
  return %469 : $()                               // id: %470
} // end sil function '$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGFAA0aB13FloatingPointRzlTJpUSpSr'

Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0.	Program arguments: /Library/Developer/Toolchains/swift-5.7-DEVELOPMENT-SNAPSHOT-2022-06-26-a.xctoolchain/usr/bin/swift-frontend -frontend -c /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/BackwardsCompatibility.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Bindings/EagerExecution.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Bindings/RawOpsAugmented.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Bindings/RawOpsDispatching.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Bindings/RawOpsGenerated.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Bindings/TFTensorOperation.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Context.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/ArrayOps.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/BroadcastingPullback.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/CopyableToDevice.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/DataTypes.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/DifferentialOperators.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/ElementaryFunctions.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/EuclideanDifferentiable.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/Execution.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/KeyPathIterable.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/LazyTensorContext.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/LazyTensorOperation.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/LazyTensorShapeInference.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/LazyTensorTFFunctionBuilder.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/LazyTensorTrace.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/LazyTensorTraceCache.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/MixedPrecision.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/PointwiseMultiplicative.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/PythonConversion.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/Random.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/Runtime.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/ShapedArray.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/StringTensor.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/Tensor.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/TensorGroup.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/TensorHandle.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/TensorShape.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/TensorUtilities.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/Threading.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/Utilities.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Core/VectorProtocol.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Epochs/Algorithms.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Epochs/Backend.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Epochs/Collatable.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Epochs/NonuniformTrainingEpochs.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Epochs/Sampling.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Epochs/Slices.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Epochs/TrainingEpochs.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Freezable.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Initializers.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Layer.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Layers/Convolutional.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Layers/Core.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Layers/Dense.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Layers/Dropout.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Layers/Embedding.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Layers/Initialization.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Layers/Morphological.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Layers/Normalization.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Layers/Pooling.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Layers/Recurrent.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Layers/Sequential.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Layers/Upsampling.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Loss.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Operators/Basic.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Operators/Comparison.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Operators/Image.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Operators/LinearAlgebra.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Operators/Math.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Operators/NN.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Optimizers/MomentumBased.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Optimizers/Optimizer.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Optimizers/SGD.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/StdlibExtensions.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/X10/APIs/CrossReplicaSum.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/X10/APIs/DeviceScope.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/X10/APIs/RawOpsManual.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/X10/Device.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/X10/RawOpsXLAGenerated.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/X10/XLAScalarType.swift /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/X10/XLATensor.swift -supplementary-output-file-map /var/folders/qn/86czb43d3pv03bfnxvb3x66h0000gn/T/TemporaryDirectory.0qENdP/supplementaryOutputs-1 -target arm64-apple-macosx10.13 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -I /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -color-diagnostics -g -module-cache-path /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/ModuleCache -swift-version 5 -O -D SWIFT_PACKAGE -D DEFAULT_BACKEND_EAGER -new-driver-path /Library/Developer/Toolchains/swift-5.7-DEVELOPMENT-SNAPSHOT-2022-06-26-a.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Library/Developer/Toolchains/swift-5.7-DEVELOPMENT-SNAPSHOT-2022-06-26-a.xctoolchain/usr/lib/swift -Xcc -fmodule-map-file=/Users/philipturner/Documents/building-tensorflow/s4tf/.build/checkouts/swift-numerics/Sources/_NumericsShims/include/module.modulemap -Xcc -I -Xcc /Users/philipturner/Documents/building-tensorflow/s4tf/.build/checkouts/swift-numerics/Sources/_NumericsShims/include -Xcc -fmodule-map-file=/Users/philipturner/Documents/building-tensorflow/s4tf/Sources/CX10Modules/include/module.modulemap -Xcc -I -Xcc /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/CX10Modules/include -Xcc -fmodule-map-file=/Users/philipturner/Documents/building-tensorflow/s4tf/Sources/CTensorFlow/include/module.modulemap -Xcc -I -Xcc /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/CTensorFlow/include -Xcc -I/Users/philipturner/Documents/building-tensorflow/Library/tensorflow-2.9.1/usr/include -module-name TensorFlow -target-sdk-version 12.3 -parse-as-library -num-threads 10 -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/BackwardsCompatibility.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Bindings/EagerExecution.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Bindings/RawOpsAugmented.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Bindings/RawOpsDispatching.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Bindings/RawOpsGenerated.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Bindings/TFTensorOperation.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Context.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/ArrayOps.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/BroadcastingPullback.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/CopyableToDevice.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/DataTypes.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/DifferentialOperators.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/ElementaryFunctions.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/EuclideanDifferentiable.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/Execution.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/KeyPathIterable.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/LazyTensorContext.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/LazyTensorOperation.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/LazyTensorShapeInference.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/LazyTensorTFFunctionBuilder.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/LazyTensorTrace.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/LazyTensorTraceCache.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/MixedPrecision.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/PointwiseMultiplicative.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/PythonConversion.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/Random.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/Runtime.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/ShapedArray.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/StringTensor.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/Tensor.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/TensorGroup.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/TensorHandle.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/TensorShape.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/TensorUtilities.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/Threading.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/Utilities.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Core/VectorProtocol.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Epochs/Algorithms.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Epochs/Backend.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Epochs/Collatable.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Epochs/NonuniformTrainingEpochs.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Epochs/Sampling.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Epochs/Slices.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Epochs/TrainingEpochs.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Freezable.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Initializers.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Layer.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Layers/Convolutional.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Layers/Core.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Layers/Dense.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Layers/Dropout.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Layers/Embedding.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Layers/Initialization.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Layers/Morphological.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Layers/Normalization.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Layers/Pooling.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Layers/Recurrent.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Layers/Sequential.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Layers/Upsampling.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Loss.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Operators/Basic.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Operators/Comparison.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Operators/Image.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Operators/LinearAlgebra.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Operators/Math.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Operators/NN.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Optimizers/MomentumBased.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Optimizers/Optimizer.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/Optimizers/SGD.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/StdlibExtensions.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/X10/APIs/CrossReplicaSum.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/X10/APIs/DeviceScope.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/X10/APIs/RawOpsManual.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/X10/Device.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/X10/RawOpsXLAGenerated.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/X10/XLAScalarType.swift.o -o /Users/philipturner/Documents/building-tensorflow/s4tf/.build/arm64-apple-macosx/release/TensorFlow.build/X10/XLATensor.swift.o
1.	Apple Swift version 5.7-dev (LLVM eecf02df5133efe, Swift ad06e7d7251311a)
2.	Compiling with the current language version
3.	While verifying SIL function "@$s10TensorFlow9BatchNormV14callAsFunctionyAA0A0VyxGAGFAA0aB13FloatingPointRzlTJpUSpSr".
 for 'callAsFunction(_:)' (at /Users/philipturner/Documents/building-tensorflow/s4tf/Sources/TensorFlow/Layers/Normalization.swift:106:10)
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x000000010496b144 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x000000010496a3a4 llvm::sys::RunSignalHandlers() + 128
2  swift-frontend           0x000000010496b7a8 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x00000001877974a4 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018777fee0 pthread_kill + 288
5  libsystem_c.dylib        0x00000001876ba340 abort + 168
6  swift-frontend           0x000000010061c7e4 (anonymous namespace)::SILVerifier::_require(bool, llvm::Twine const&, std::__1::function<void ()> const&) + 1444
7  swift-frontend           0x00000001006364d8 (anonymous namespace)::SILVerifier::visitSILInstruction(swift::SILInstruction*) + 5192
8  swift-frontend           0x00000001006210f0 swift::SILInstructionVisitor<(anonymous namespace)::SILVerifier, void>::visit(swift::SILInstruction*) + 2112
9  swift-frontend           0x00000001006204d0 (anonymous namespace)::SILVerifier::visitSILBasicBlock(swift::SILBasicBlock*) + 1336
10 swift-frontend           0x000000010061eef8 (anonymous namespace)::SILVerifier::visitSILFunction(swift::SILFunction*) + 8368
11 swift-frontend           0x000000010061bcd0 swift::SILModule::verify() const + 216
12 swift-frontend           0x00000001004daa9c swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 636
13 swift-frontend           0x000000010047f40c performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 716
14 swift-frontend           0x000000010047edd0 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1028
15 swift-frontend           0x000000010048ca34 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 160
16 swift-frontend           0x0000000100480a78 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3388
17 swift-frontend           0x000000010038708c swift::mainEntry(int, char const**) + 3764
18 dyld                     0x000000010d2a108c start + 520

The crash in this pull request only occurs on development toolchains, with -c release appended to SwiftPM build options. It does not occur on debug builds, which presumably pass -Onone into the compiler. Interestingly, the 5.7 release toolchain can compile S4TF in release mode. This is probably due to _Differentiation being built externally to the Swift standard library.

The crash happens on development toolchains when you import philipturner/differentiation in place of the Stdlib module. Perhaps the reason it doesn't crash on release toolchains is a bit more involved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants