profile
viewpoint
Dan Zheng dan-zheng Google Bay Area danzheng.me Principled engineering

apple/swift 53957

The Swift Programming Language

apple/swift-lldb 645

This is the version of LLDB that supports the Swift programming language & REPL.

apple/llvm-project 275

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. This fork is used to manage Apple’s stable releases of Clang as well as support the Swift project.

dabrahams/llvm-project 0

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. This fork is used to manage Apple’s stable releases of Clang as well as support the Swift project.

dan-zheng/Adjective 0

Programming is an exercise in linguistics; spice-up Scala types with Adjective.

dan-zheng/algebra 0

Experimental project to lay out basic algebra type classes

dan-zheng/Android-Jigsaw-Puzzle 0

Android draw and jigsaw puzzle app using a user's own drawings.

dan-zheng/BaseMath 0

Basic math functions for float and double in Swift

PullRequestReviewEvent

startedapple/swift-system

started time in a month

push eventdan-zheng/swift

Brian Gontowski

commit sha 3425a6dbb16e5fa7ad4b735eff4533c279d61442

Added protocol to support CVarArg objects that need to be retained

view details

Brian Gontowski

commit sha 0e7749bcde5eb1bc9fec82ef0eb3896ec8d6de6f

Fixed comment

view details

Yuta Saito

commit sha d6cddaabb59958737e048ff1a5dd4d283c555661

[LTO] Support LLVM LTO for driver This commit adds LTO support for handling linker options and LLVM BC emission. Even for ELF, swift-autolink-extract is unnecessary because linker options are embeded in LLVM BC content when LTO.

view details

Brian Gontowski

commit sha 17c77ba703b32c11e127573d414d31c9ec635188

Only use _CVarArgObject on non-ObjC platforms

view details

Brian Gontowski

commit sha 515c371be434ff49debfd145ebd9047bd148d47f

Avoid a warning when not modifying arg

view details

Nathan Hawes

commit sha cf60b2fe610616dd8f3dd7838a0cee7f0090eee7

[CodeCompletion] Pass the CodeCompletionExpr rather than just the base expression to the DotExpr completion callback.

view details

Nathan Hawes

commit sha fe9df72d554aa15d2d0ccc933c213938953c1c79

[CodeCompletion] Add initial implementation of solver-based member completion. This hooks up member completion to the new typeCheckForCodeCompletion API to generate completions from all solutions the constraint solver produces (include ones requiring fixes) rather than relying purely the single solution being applied to the AST (if any). This lets us still give completion results in ambiguous and invalid code.

view details

Pavel Yaskevich

commit sha a49404d593c36056158cded398f97aeb3b37c8e6

[CodeCompletion] Adjust `DotExprLookup::sawSolution` to use new `Solution` APIs

view details

Pavel Yaskevich

commit sha 5bd19d28ac82b137d266909cdf90946fa02ae738

[CSSolver] add debug logging to `solveForCodeCompletion`

view details

Pavel Yaskevich

commit sha 53de10fd3cb7d10eb7d2845e922029867b24da60

[CSSolver] Update expression after constraint generation while solving for code completion

view details

Nathan Hawes

commit sha 3d8561502bee5644c23f7fa2fe26143c50f72b3f

[CodeCompletion] Move CompletionCollector to ASTContext + bug fixes.

view details

Pavel Yaskevich

commit sha 5872cef2ff8a096612b0e5cccd1ebfbc69967236

[CSSolver/CodeCompletion] If pre-check fails extract code completion expression and use it If there was an invalid reference which was caught by pre-check, let's remove all context besides code completion itself and use it to produce code completion results.

view details

Pavel Yaskevich

commit sha 97de1781519a58022429224089f09dea47a5baeb

[CSSolver] Solution: Resolve holes as underlying generic parameters for code completion To aid code completion, we need to attempt to convert type holes back into underlying generic parameters if possible, since type of the code completion expression is used as "expected" (or contextual) type so it's helpful to know what requirements it has to filter the list of possible member candidates e.g. ```swift func test<T: P>(_: [T]) {} test(42.#^MEMBERS^#) ``` It's impossible to resolve `T` in this case but code completion expression should still have a type of `[T]` instead of `[<<hole>>]` because it helps to produce correct contextual member list based on a conformance requirement associated with generic parameter `T`.

view details

Nathan Hawes

commit sha 5100de42935bcc853047b7e1b99ade17953f5c5e

[CodeCompletion] Fallback to typechecking just the completion expression in cases where typeCheckExpression is never called. This happens when, e.g. an expression being switched on is invalid so expression patterns in the switch cases (which may contain the completion expression) are not checked. Also setup the Lookup object to handle member completion in ObjC selector expressions correctly, and fix passing the wrong expression when computing isStaticallyDerivedMetatype().

view details

Pavel Yaskevich

commit sha b71fdb5704e4c969ff49baabd8f146c0b9b38ef4

[CSSolver] Augment `solveForCodeCompletion` to indicate when it fails

view details

Pavel Yaskevich

commit sha d6d083ecf87718ba78007a76e719adc437dbd00d

[TypeChecker] Mode code completion fallback to `typeCheckForCodeCompletion` If an expression fails pre-check or constraint generation, code completion should be performed directly on the `CodeCompletionExpr` as a fallback. Let's factor that logic out from `solveForCodeCompletion` and put it directly into `typeCheckForCodeCompletion` because it's easier to establish fault conditions there.

view details

Pavel Yaskevich

commit sha 74f0ec5b973edea1311226978124c9cc9c17fd16

[TypeChecker/CodeCompletion] Allow `{typeCheck, solve}ForCodeCompletion` to operate on target instead of expression Using `SolutionApplicationTarget` make it easier to propage contextual information and avoid mistakes of using incorrect accessors for constraint generation.

view details

Pavel Yaskevich

commit sha d97a7f3d19d813540a2f42c11b29ef988afadad7

[TypeChecker/CodeCompletion] Make viability checking responsibility of `typeCheckForCodeCompletion` There is no way to separate viability/applicability checking from `TypeChecker::typeCheckForCodeCompletion` because multi-statement closures could be either type-checked together with enclosing context (e.g. when closure represents a function builder body), or separately - when it's just a regular closure. Due to this "duality" we need to attempt to run code completion code to determine whether body of the closure participated in type-check and if it didn't, fallback to a `typeCheckExpression`.

view details

Pavel Yaskevich

commit sha 7a9c59a4cad9013dfaad590993860066bb98cbf3

[ConstraintSystem] Add `Solution::hasType(ASTNode)`

view details

Pavel Yaskevich

commit sha 8d5c94f232a244355292ace32e9d6322f0a9a16c

[TypeChecker/CodeCompletion] Implement a fallback from code completion to `typeCheckExpression` This fallback to `typeCheckExpression` is triggered when it's determined that code completion expression is located inside of a multi-statement closure and its body is going going to participate in type-check.

view details

push time in a month

create barnchdan-zheng/swift

branch : autodiff-forward-mode-fatal-error

created branch time in a month

delete branch dan-zheng/swift

delete branch : SR-13455

delete time in a month

push eventapple/swift

Dan Zheng

commit sha 9afad737eb6915b29276dbe485041bb56ecb4835

[AutoDiff] [Sema] Limit implicit `@differentiable` attribute creation. (#33776) During protocol witness matching for a protocol requirement with `@differentiable` attributes, implicit `@differentiable` attributes may be created for the witness under specific conditions (when the witness has a `@differentiable` attribute with superset differentiability parameters, or when the witness has less-than-public visibility). Do not generate implicit `@differentiable` attributes for protocol witnesses when the protocol conformance is declared from a separate file or type context from the witness. Resolves SR-13455.

view details

push time in a month

PR merged apple/swift

Reviewers
[AutoDiff] [Sema] Limit implicit `@differentiable` attribute creation.

During protocol witness matching for a protocol requirement with @differentiable attributes, implicit @differentiable attributes may be created for the witness under specific conditions (when the witness has a @differentiable attribute with superset differentiability parameters, or when the witness has less-than-public visibility). This avoids requiring users to explicitly write unnecessary @differentiable attributes.

Do not generate implicit @differentiable attributes for protocol witnesses when the protocol conformance is declared from a separate file from the witness.

Otherwise, compilation of the file containing the conformance creates references to external symbols for the implicit @differentiable attributes, even though no such symbols exist.

Resolves SR-13455.


Example:

// file1.swift
import _Differentiation

protocol P1: Differentiable {
  @differentiable(wrt: self)
  func callAsFunction(_ input: Float) -> Float
}

protocol P2: P1 {}

extension P2 {
  // Previously, protocol witness matching created this implicit attribute:
  // @differentiable(wrt: self)
  @differentiable(wrt: (self, input))
  public func callAsFunction(_ input: Float) -> Float {
    return input
  }
}
// main.swift
import _Differentiation

struct S: P2 {}

Before:

$ swiftc file1.swift main.swift
Undefined symbols for architecture x86_64:
  "_AD__$s4main2P2PAAE14callAsFunctionyS2fF_PUSRS4main2P2Rzl", referenced from:
      _AD__$s4main1SVAA2P1A2aDP14callAsFunctionyS2fFTW_jvp_US in main-bddbaa.o
      _AD__$s4main1SVAA2P1A2aDP14callAsFunctionyS2fFTW_vjp_US in main-bddbaa.o
ld: symbol(s) not found for architecture x86_64
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)

After:

$ swiftc file1.swift main.swift
main.swift:4:8: error: type 'S' does not conform to protocol 'P1'
struct S: P2 {}
       ^
file1.swift:14:15: note: instance method 'callAsFunction' must have explicit '@differentiable(wrt: self)' attribute to satisfy requirement instance method 'callAsFunction' (in protocol 'P1') because it is declared in a different file than the conformance of 'S' to 'P1'
  public func callAsFunction(_ input: Float) -> Float {
              ^
         @differentiable(wrt: self)
file1.swift:5:8: note: protocol requires function 'callAsFunction' with type '(Float) -> Float'
  func callAsFunction(_ input: Float) -> Float
       ^
+157 -30

8 comments

6 changed files

dan-zheng

pr closed time in a month

pull request commentapple/swift

[AutoDiff] [Sema] Limit implicit `@differentiable` attribute creation.

@swift-ci Please test

dan-zheng

comment created time in a month

PullRequestEvent

PR closed apple/swift

[WIP] [AutoDiff] Revamp differentiation diagnostics internals. tensorflow

Revamp DifferentiationInvoker: simplify the representation and support indirect differentiation diagnostics.

DifferentiationInvoker has two cases:

  • [differentiable]: differentiation triggered by an attribute. We treat this invoker as top-level, with no parent invoker.
  • autodiff_function: differentiation triggered by an AutoDiffFunctionInst. This invoker can have a parent (differentiation transform can generated new autodiff_function instructions).
+225 -73

5 comments

1 changed file

dan-zheng

pr closed time in a month

pull request commentapple/swift

[WIP] [AutoDiff] Revamp differentiation diagnostics internals.

Closing due to staleness. It would be nice to revive this sometime.

dan-zheng

comment created time in a month

push eventdan-zheng/swift

swift_jenkins

commit sha de9c8e4ebb4f362cbd1ec12f3bd0b7d88472ed39

Merge remote-tracking branch 'origin/master' into master-next

view details

swift_jenkins

commit sha e45b3a79ea03f120bb9bb9a6363b4adf799bf9fb

Merge remote-tracking branch 'origin/master' into master-next

view details

swift_jenkins

commit sha f4daa62b344ad550935072da38f417e3247f7629

Merge remote-tracking branch 'origin/master' into master-next

view details

swift_jenkins

commit sha 2e841559730c48099411c655ff20198acd7de64b

Merge remote-tracking branch 'origin/master' into master-next

view details

swift_jenkins

commit sha 80242034202a8a8885fb2977369b503c6abc8666

Merge remote-tracking branch 'origin/master' into master-next

view details

swift_jenkins

commit sha f503f422cc2113d5d62b4d429eb684f0e7bb0a96

Merge remote-tracking branch 'origin/master' into master-next

view details

swift_jenkins

commit sha 72970485d997c84225484533849bdaf1628a6d71

Merge remote-tracking branch 'origin/master' into master-next

view details

swift_jenkins

commit sha f9d51789afd90e90709d4d387d35ce3fdabc6dec

Merge remote-tracking branch 'origin/master' into master-next

view details

David Zarzycki

commit sha b7664fa3200c4d7be6299ffb814e3210078b05e6

[IRGen] Adjust to upstream LLVM change GlobalValue::getAlignment() was removed in a2caa3b61497b6be8c8b77823d0fd62b4be1f177.

view details

swift_jenkins

commit sha 7a4bbbfeb213b271bd3db5a201bf4ddd32edccd9

Merge remote-tracking branch 'origin/master' into master-next

view details

swift_jenkins

commit sha f7b349f97e0912262be6332bdafb0fb452e16a3e

Merge remote-tracking branch 'origin/master' into master-next

view details

swift_jenkins

commit sha c2e08c2d455260440718247ab842d35c969c7cf6

Merge remote-tracking branch 'origin/master' into master-next

view details

swift_jenkins

commit sha d11b67bd8a3507b5941f74a43a0a6416a79dfbab

Merge remote-tracking branch 'origin/master' into master-next

view details

swift_jenkins

commit sha ba9df5bb4ed05e7d1ce6daace9927d67b7e0dcd3

Merge remote-tracking branch 'origin/master' into master-next

view details

swift_jenkins

commit sha 151b0a931de808db71e58f8805c9aabd19a9e24a

Merge remote-tracking branch 'origin/master' into master-next

view details

swift_jenkins

commit sha 9b2a99f1aca564c95aef2acb8ad9b1b0ab37f2ee

Merge remote-tracking branch 'origin/master' into master-next

view details

swift_jenkins

commit sha 3d47362b5c821c86ba332a56d8ae79e87ce826c3

Merge remote-tracking branch 'origin/master' into master-next

view details

swift_jenkins

commit sha 58c7db6b11fb40700b1a489621e83d56cffa419b

Merge remote-tracking branch 'origin/master' into master-next

view details

swift_jenkins

commit sha 6bea8ff31e5613c08d54502e18b20fbed9820d04

Merge remote-tracking branch 'origin/master' into master-next

view details

swift_jenkins

commit sha eeb5d35f9c5f3bf50cc2e843ae4cf34960c6866c

Merge remote-tracking branch 'origin/master' into master-next

view details

push time in a month

create barnchdan-zheng/swift

branch : autodiff-sil-optimizations-mandatory

created branch time in a month

delete branch dan-zheng/swift

delete branch : tensorflow-test

delete time in a month

push eventapple/swift

Dan Zheng

commit sha bab85007292cf972300e227866b5cd78a155af44

Fix completion tests. (#33996) Adding KeyPathIterable conformance to Optional changes the code completions for optional members. Co-authored-by: Dave Abrahams <dabrahams@google.com>

view details

push time in a month

PR merged apple/swift

Reviewers
[TF] Fix `Optional` completion tests. tensorflow

Adding KeyPathIterable conformance to Optional changes the code completions for optional members.


Follow-up fix to https://github.com/apple/swift/pull/33992.

+11 -8

1 comment

4 changed files

dan-zheng

pr closed time in a month

pull request commentapple/swift

[TF] Fix `Optional` completion tests.

@swift-ci Please test tensorflow

dan-zheng

comment created time in a month

PR opened apple/swift

Reviewers
[TF] Fix `Optional` completion tests. tensorflow

Adding KeyPathIterable conformance to Optional changes the code completions for optional members.


Follow-up fix to https://github.com/apple/swift/pull/33992.

+11 -8

0 comment

4 changed files

pr created time in a month

create barnchdan-zheng/swift

branch : tensorflow-test

created branch time in a month

Pull request review commenttensorflow/swift-apis

[WIP] Change `Dense.bias` type to `Optional`

 extension Dense {       bias: useBias ? biasInitializer([outputSize]) : nil,       activation: activation)   }++  /// Creates a `Dense` layer with the specified input size, output size, and element-wise+  /// activation function. The weight matrix is created with shape `[inputSize, outputSize]` and+  /// the bias vector is created with shape `[outputSize]`.+  ///+  /// - Parameters:+  ///   - inputSize: The dimensionality of the input space.+  ///   - outputSize: The dimensionality of the output space.+  ///   - activation: The activation function to use. The default value is `identity(_:)`.+  ///   - weightInitializer: Initializer to use for `weight`.+  ///   - biasInitializer: Initializer to use for `bias`.+  public init(+    inputSize: Int,+    outputSize: Int,+    activation: @escaping Activation = identity,+    weightInitializer: ParameterInitializer<Scalar> = glorotUniform(),+    biasInitializer: ParameterInitializer<Scalar>? = nil+  ) {+    self.init(+      weight: weightInitializer([inputSize, outputSize]),+      bias: biasInitializer?([outputSize]),+      activation: activation)+  }+}++extension Dense.TangentVector {+  public init(+    weight: Tensor<Scalar>,+    bias: Tensor<Scalar>+  ) {+    self.init(weight: weight, optionalBias: .init(bias))+  }+  +  /// The bias vector.+  ///+  /// - Note: returns `Tensor.zero` if the underlying `optionalBias`  does not exist.+  //@differentiable+  public var bias: Tensor<Scalar> {+    get { optionalBias.value ?? .zero }+    set { optionalBias.value = newValue }+  }+}++extension Optional: KeyPathIterable {+  public var allKeyPaths: [PartialKeyPath<Self>] {+    if self != nil {+      return [\.!]+    }+    return []+  }++  public typealias AllKeyPaths = [PartialKeyPath<Self>]

Please remove this extension, since it's added in https://github.com/apple/swift/pull/33992.

efremale

comment created time in a month

Pull request review commenttensorflow/swift-apis

[WIP] Change `Dense.bias` type to `Optional`

 extension Dense {       bias: useBias ? biasInitializer([outputSize]) : nil,       activation: activation)   }++  /// Creates a `Dense` layer with the specified input size, output size, and element-wise+  /// activation function. The weight matrix is created with shape `[inputSize, outputSize]` and+  /// the bias vector is created with shape `[outputSize]`.+  ///+  /// - Parameters:+  ///   - inputSize: The dimensionality of the input space.+  ///   - outputSize: The dimensionality of the output space.+  ///   - activation: The activation function to use. The default value is `identity(_:)`.+  ///   - weightInitializer: Initializer to use for `weight`.+  ///   - biasInitializer: Initializer to use for `bias`.+  public init(+    inputSize: Int,+    outputSize: Int,+    activation: @escaping Activation = identity,+    weightInitializer: ParameterInitializer<Scalar> = glorotUniform(),+    biasInitializer: ParameterInitializer<Scalar>? = nil+  ) {+    self.init(+      weight: weightInitializer([inputSize, outputSize]),+      bias: biasInitializer?([outputSize]),+      activation: activation)+  }+}++extension Dense.TangentVector {+  public init(+    weight: Tensor<Scalar>,+    bias: Tensor<Scalar>+  ) {+    self.init(weight: weight, optionalBias: .init(bias))+  }+  +  /// The bias vector.+  ///+  /// - Note: returns `Tensor.zero` if the underlying `optionalBias`  does not exist.+  //@differentiable

Removing this @differentiable attribute should be fine, since Dense.TangentVector isn't differentiated in practice.

efremale

comment created time in a month

PullRequestReviewEvent
PullRequestReviewEvent

delete branch dan-zheng/swift

delete branch : optional-key-path-iterable

delete time in a month

push eventapple/swift

Dan Zheng

commit sha 74a17cdacac8afff2ecfe2e667b565b888cb9c3f

[TF] Add `Optional: KeyPathIterable` conformance. (#33992) Add `KeyPathIterable` conformances for `Optional` and `Optional.TangentVector`.

view details

push time in a month

PR merged apple/swift

Reviewers
[TF] Add `Optional: KeyPathIterable` conformance. tensorflow

Add KeyPathIterable conformances for Optional and Optional.TangentVector.


Unblocks https://github.com/tensorflow/swift-apis/pull/1062.

+33 -1

2 comments

2 changed files

dan-zheng

pr closed time in a month

pull request commentapple/swift

[TF] Add `Optional: KeyPathIterable` conformance.

There are some unrelated test failures, to be investigated:

Failing Tests (3):
    Swift(linux-x86_64) :: IDE/complete_unresolved_members.swift
    Swift(linux-x86_64) :: IDE/complete_stmt_controlling_expr.swift
    Swift(linux-x86_64) :: IDE/complete_generic_optional.swift

Merging to unblock progress.

dan-zheng

comment created time in a month

PullRequestReviewEvent
PullRequestReviewEvent

pull request commentapple/swift

[TF] Add `Optional: KeyPathIterable` conformance.

@swift-ci Please test tensorflow

dan-zheng

comment created time in a month

PR opened apple/swift

Reviewers
[TF] Add `Optional: KeyPathIterable` conformance. tensorflow

Add KeyPathIterable conformances for Optional and Optional.TangentVector.


Unblocks https://github.com/tensorflow/swift-apis/pull/1062.

+33 -1

0 comment

2 changed files

pr created time in a month

create barnchdan-zheng/swift

branch : optional-key-path-iterable

created branch time in a month

push eventdan-zheng/SwiftFusion

Dan Zheng

commit sha 2f7b6f8a529fa6bee0bd24d14856935ac957595b

Add forward vs reverse Jacobian factor benchmarks.

view details

push time in a month

create barnchtensorflow/swift-apis

branch : forward-mode-differentiation

created branch time in a month

issue commenttensorflow/swift

Recent development snapshots cause Xcode runtime popup: "LLDB provided no error string"

Thanks for sharing all the context! Unfortunately, I still wasn't able to reproduce the issue (screen recording).

Environment:

Does anyone have ideas on how to reproduce the issue?

porterchild

comment created time in a month

push eventefremale/swift-apis

Dan Zheng

commit sha ee249facfce5804655b9e119b97b24450494c6a6

Clean up. There are two remaining test failures: ``` $ swift test --filter OptimizerTests Tests/TensorFlowTests/OptimizerTests.swift:117: error: -[TensorFlowTests.OptimizerTests testAdaMax] : XCTAssertTrue failed Tests/TensorFlowTests/OptimizerTests.swift:123: error: -[TensorFlowTests.OptimizerTests testAMSGrad] : XCTAssertTrue failed ```

view details

push time in a month

create barnchdan-zheng/swift

branch : tensorflow-merge-autodiff

created branch time in a month

push eventefremale/swift-apis

Dan Zheng

commit sha 6d1a85044db1782c0f11b4be426e7863f750cf6e

Clean up. There are two remaining test failures: ``` $ swift test --filter OptimizerTests Tests/TensorFlowTests/OptimizerTests.swift:117: error: -[TensorFlowTests.OptimizerTests testAdaMax] : XCTAssertTrue failed Tests/TensorFlowTests/OptimizerTests.swift:123: error: -[TensorFlowTests.OptimizerTests testAMSGrad] : XCTAssertTrue failed ```

view details

push time in a month

delete branch dan-zheng/swiftrt

delete branch : autodiff-math-vjps

delete time in a month

delete branch dan-zheng/swiftrt

delete branch : autodiff-comparison-vjps

delete time in a month

delete branch dan-zheng/tensorflow-swift

delete branch : macos-toolchains

delete time in a month

push eventtensorflow/swift

Dan Zheng

commit sha 7811a47f833f944982f6dc04301413854d76953b

Release 2020-09-16 toolchain for macOS. (#536) https://github.com/apple/swift/commit/c08d0804e2e44acba1c86937f738114a0ba6b0e4 https://github.com/tensorflow/swift-apis/commit/b719d997beca0f6ddb8576776ee917556cfc485c

view details

push time in a month

PR merged tensorflow/swift

Release 2020-09-16 toolchain for macOS.

https://github.com/apple/swift/commit/c08d0804e2e44acba1c86937f738114a0ba6b0e4 https://github.com/tensorflow/swift-apis/commit/b719d997beca0f6ddb8576776ee917556cfc485c


Notable changes since last toolchain: various autodiff fixes (https://github.com/apple/swift/pull/33868, https://github.com/apple/swift/pull/33897, https://github.com/apple/swift/pull/33969).

+2 -1

0 comment

1 changed file

dan-zheng

pr closed time in a month

PR opened tensorflow/swift

Release 2020-09-16 toolchain for macOS.

https://github.com/apple/swift/commit/c08d0804e2e44acba1c86937f738114a0ba6b0e4 https://github.com/tensorflow/swift-apis/commit/b719d997beca0f6ddb8576776ee917556cfc485c


Notable changes since last toolchain: various autodiff fixes (https://github.com/apple/swift/pull/33868, https://github.com/apple/swift/pull/33897, https://github.com/apple/swift/pull/33969).

+2 -1

0 comment

1 changed file

pr created time in a month

create barnchdan-zheng/tensorflow-swift

branch : macos-toolchains

created branch time in a month

push eventapple/swift

Dan Zheng

commit sha 566a671aa3af3738353372263f94fe1578092ae5

[AutoDiff] Fix pullback subset thunk generation crash. (#33968) Fix pullback subset thunk generation crash due to unmapped parameter index for `inout` differentiability parameters. Resolves TF-1315.

view details

push time in a month

delete branch dan-zheng/swift

delete branch : TF-1315

delete time in a month

PR merged apple/swift

Reviewers
[AutoDiff] Fix pullback subset thunk generation crash.

Fix pullback subset thunk generation crash due to unmapped parameter index for inout differentiability parameters.

Resolves TF-1315.


Fixes this assertion failure:

$ swiftc tf1315-pullback-subset-parameter-thunk-generation.swift 
Assertion failed: (I <= this->end() && "Inserting past the end of the vector."), function insert, file llvm-project/llvm/include/llvm/ADT/SmallVector.h, line 550.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.	Program arguments: build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swift-frontend -target x86_64-apple-macosx10.9 -module-cache-path build/Ninja-ReleaseAssert/swift-macosx-x86_64/swift-test-results/x86_64-apple-macosx10.9/clang-module-cache -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.16.sdk -swift-version 4 -ignore-module-source-info -typo-correction-limit 10 -emit-sil test/AutoDiff/compiler_crashers_fixed/tf1315-pullback-subset-parameter-thunk-generation.swift
1.	Swift version 5.3-dev (LLVM 32ba33c87eb2475, Swift d90d0b390c96816)
2.	While evaluating request ExecuteSILPipelineRequest(Run pipelines { Mandatory Diagnostic Passes + Enabling Optimization Passes } on SIL for main.main)
3.	While running pass #33 SILModuleTransform "Differentiation".
4.	While canonicalizing `differentiable_function` SIL node   %17 = differentiable_function [parameters 2] [results 0] %13 : $@convention(thin) (Int, Float, @inout Float) -> () // users: %19, %18
5.	While ...in SIL function "@AD__$s4main7TF_1315yS2fF__vjp_src_0_wrt_0".
 for 'TF_1315(_:)' (at test/AutoDiff/compiler_crashers_fixed/tf1315-pullback-subset-parameter-thunk-generation.swift:19:1)
0  swift-frontend           0x0000000107be25a5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift-frontend           0x0000000107be14e8 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x0000000107be2b86 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff6e0115fd _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338670598688
5  libsystem_c.dylib        0x00007fff6dee7808 abort + 120
6  libsystem_c.dylib        0x00007fff6dee6ac6 err + 0
7  swift-frontend           0x0000000107de03a3 llvm::SmallVectorImpl<swift::SILValue>::insert(swift::SILValue*, swift::SILValue const&) (.cold.3) + 35
8  swift-frontend           0x00000001038e3594 llvm::SmallVectorImpl<swift::SILValue>::insert(swift::SILValue*, swift::SILValue const&) + 276
9  swift-frontend           0x00000001038e2e96 swift::autodiff::getOrCreateSubsetParametersThunkForLinearMap(swift::SILOptFunctionBuilder&, swift::SILFunction*, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::AutoDiffDerivativeFunctionKind, swift::SILAutoDiffI  1 [AutoDiff] Fix pullback subset thunk generation crash.
ndices, swift::SILAutoDiffIndices) + 8262
10 swift-frontend           0x00000001038e4eab swift::autodiff::getOrCreateSubsetParametersThunkForDerivativeFunction(swift::SILOptFunctionBuilder&, swift::SILValue, swift::SILValue, swift::AutoDiffDerivativeFunctionKind, swift::SILAutoDiffIndices, swift::SILAutoDiffIndices) + 6395
11 swift-frontend           0x0000000103a2ca32 (anonymous namespace)::DifferentiationTransformer::promoteToDifferentiableFunction(swift::DifferentiableFunctionInst*, swift::SILBuilder&, swift::SILLocation, swift::autodiff::DifferentiationInvoker) + 7842
+29 -1

1 comment

2 changed files

dan-zheng

pr closed time in a month

push eventapple/swift

Dan Zheng

commit sha c08d0804e2e44acba1c86937f738114a0ba6b0e4

[AutoDiff] Fix pullback subset thunk generation crash. (#33969) Fix pullback subset thunk generation crash due to unmapped parameter index for `inout` differentiability parameters. Resolves TF-1315.

view details

push time in a month

delete branch dan-zheng/swift

delete branch : tensorflow-TF-1315

delete time in a month

PR merged apple/swift

Reviewers
[AutoDiff] Fix pullback subset thunk generation crash. tensorflow

Cherry-pick of https://github.com/apple/swift/pull/33968 to tensorflow branch.


Fix pullback subset thunk generation crash due to unmapped parameter index for inout differentiability parameters.

Resolves TF-1315:

$ swiftc tf1315-pullback-subset-parameter-thunk-generation.swift 
Assertion failed: (I <= this->end() && "Inserting past the end of the vector."), function insert, file llvm-project/llvm/include/llvm/ADT/SmallVector.h, line 550.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.	Program arguments: build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swift-frontend -target x86_64-apple-macosx10.9 -module-cache-path build/Ninja-ReleaseAssert/swift-macosx-x86_64/swift-test-results/x86_64-apple-macosx10.9/clang-module-cache -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.16.sdk -swift-version 4 -ignore-module-source-info -typo-correction-limit 10 -emit-sil test/AutoDiff/compiler_crashers_fixed/tf1315-pullback-subset-parameter-thunk-generation.swift
1.	Swift version 5.3-dev (LLVM 32ba33c87eb2475, Swift d90d0b390c96816)
2.	While evaluating request ExecuteSILPipelineRequest(Run pipelines { Mandatory Diagnostic Passes + Enabling Optimization Passes } on SIL for main.main)
3.	While running pass #33 SILModuleTransform "Differentiation".
4.	While canonicalizing `differentiable_function` SIL node   %17 = differentiable_function [parameters 2] [results 0] %13 : $@convention(thin) (Int, Float, @inout Float) -> () // users: %19, %18
5.	While ...in SIL function "@AD__$s4main7TF_1315yS2fF__vjp_src_0_wrt_0".
 for 'TF_1315(_:)' (at test/AutoDiff/compiler_crashers_fixed/tf1315-pullback-subset-parameter-thunk-generation.swift:19:1)
0  swift-frontend           0x0000000107be25a5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift-frontend           0x0000000107be14e8 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x0000000107be2b86 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff6e0115fd _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338670598688
5  libsystem_c.dylib        0x00007fff6dee7808 abort + 120
6  libsystem_c.dylib        0x00007fff6dee6ac6 err + 0
7  swift-frontend           0x0000000107de03a3 llvm::SmallVectorImpl<swift::SILValue>::insert(swift::SILValue*, swift::SILValue const&) (.cold.3) + 35
8  swift-frontend           0x00000001038e3594 llvm::SmallVectorImpl<swift::SILValue>::insert(swift::SILValue*, swift::SILValue const&) + 276
9  swift-frontend           0x00000001038e2e96 swift::autodiff::getOrCreateSubsetParametersThunkForLinearMap(swift::SILOptFunctionBuilder&, swift::SILFunction*, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::AutoDiffDerivativeFunctionKind, swift::SILAutoDiffI  1 [AutoDiff] Fix pullback subset thunk generation crash.
ndices, swift::SILAutoDiffIndices) + 8262
10 swift-frontend           0x00000001038e4eab swift::autodiff::getOrCreateSubsetParametersThunkForDerivativeFunction(swift::SILOptFunctionBuilder&, swift::SILValue, swift::SILValue, swift::AutoDiffDerivativeFunctionKind, swift::SILAutoDiffIndices, swift::SILAutoDiffIndices) + 6395
11 swift-frontend           0x0000000103a2ca32 (anonymous namespace)::DifferentiationTransformer::promoteToDifferentiableFunction(swift::DifferentiableFunctionInst*, swift::SILBuilder&, swift::SILLocation, swift::autodiff::DifferentiationInvoker) + 7842
+29 -1

1 comment

2 changed files

dan-zheng

pr closed time in a month

pull request commentapple/swift

[AutoDiff] Fix pullback subset thunk generation crash.

@swift-ci Please test tensorflow

dan-zheng

comment created time in a month

PR opened apple/swift

Reviewers
[AutoDiff] Fix pullback subset thunk generation crash. tensorflow

Cherry-pick of https://github.com/apple/swift/pull/33968 to tensorflow branch.


Fix pullback subset thunk generation crash due to unmapped parameter index for inout differentiability parameters.

Resolves TF-1315:

$ swiftc tf1315-pullback-subset-parameter-thunk-generation.swift 
Assertion failed: (I <= this->end() && "Inserting past the end of the vector."), function insert, file llvm-project/llvm/include/llvm/ADT/SmallVector.h, line 550.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.	Program arguments: build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swift-frontend -target x86_64-apple-macosx10.9 -module-cache-path build/Ninja-ReleaseAssert/swift-macosx-x86_64/swift-test-results/x86_64-apple-macosx10.9/clang-module-cache -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.16.sdk -swift-version 4 -ignore-module-source-info -typo-correction-limit 10 -emit-sil test/AutoDiff/compiler_crashers_fixed/tf1315-pullback-subset-parameter-thunk-generation.swift
1.	Swift version 5.3-dev (LLVM 32ba33c87eb2475, Swift d90d0b390c96816)
2.	While evaluating request ExecuteSILPipelineRequest(Run pipelines { Mandatory Diagnostic Passes + Enabling Optimization Passes } on SIL for main.main)
3.	While running pass #33 SILModuleTransform "Differentiation".
4.	While canonicalizing `differentiable_function` SIL node   %17 = differentiable_function [parameters 2] [results 0] %13 : $@convention(thin) (Int, Float, @inout Float) -> () // users: %19, %18
5.	While ...in SIL function "@AD__$s4main7TF_1315yS2fF__vjp_src_0_wrt_0".
 for 'TF_1315(_:)' (at test/AutoDiff/compiler_crashers_fixed/tf1315-pullback-subset-parameter-thunk-generation.swift:19:1)
0  swift-frontend           0x0000000107be25a5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift-frontend           0x0000000107be14e8 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x0000000107be2b86 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff6e0115fd _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338670598688
5  libsystem_c.dylib        0x00007fff6dee7808 abort + 120
6  libsystem_c.dylib        0x00007fff6dee6ac6 err + 0
7  swift-frontend           0x0000000107de03a3 llvm::SmallVectorImpl<swift::SILValue>::insert(swift::SILValue*, swift::SILValue const&) (.cold.3) + 35
8  swift-frontend           0x00000001038e3594 llvm::SmallVectorImpl<swift::SILValue>::insert(swift::SILValue*, swift::SILValue const&) + 276
9  swift-frontend           0x00000001038e2e96 swift::autodiff::getOrCreateSubsetParametersThunkForLinearMap(swift::SILOptFunctionBuilder&, swift::SILFunction*, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::AutoDiffDerivativeFunctionKind, swift::SILAutoDiffI  1 [AutoDiff] Fix pullback subset thunk generation crash.
ndices, swift::SILAutoDiffIndices) + 8262
10 swift-frontend           0x00000001038e4eab swift::autodiff::getOrCreateSubsetParametersThunkForDerivativeFunction(swift::SILOptFunctionBuilder&, swift::SILValue, swift::SILValue, swift::AutoDiffDerivativeFunctionKind, swift::SILAutoDiffIndices, swift::SILAutoDiffIndices) + 6395
11 swift-frontend           0x0000000103a2ca32 (anonymous namespace)::DifferentiationTransformer::promoteToDifferentiableFunction(swift::DifferentiableFunctionInst*, swift::SILBuilder&, swift::SILLocation, swift::autodiff::DifferentiationInvoker) + 7842
+29 -1

0 comment

2 changed files

pr created time in a month

create barnchdan-zheng/swift

branch : tensorflow-TF-1315

created branch time in a month

pull request commentapple/swift

[AutoDiff] Fix pullback subset thunk generation crash.

@swift-ci Please test

dan-zheng

comment created time in a month

PR opened apple/swift

Reviewers
[AutoDiff] Fix pullback subset thunk generation crash.

Fix pullback subset thunk generation crash due to unmapped parameter index for inout differentiability parameters.

Resolves TF-1315.


Fixes this assertion failure:

$ swiftc tf1315-pullback-subset-parameter-thunk-generation.swift 
Assertion failed: (I <= this->end() && "Inserting past the end of the vector."), function insert, file llvm-project/llvm/include/llvm/ADT/SmallVector.h, line 550.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.	Program arguments: build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swift-frontend -target x86_64-apple-macosx10.9 -module-cache-path build/Ninja-ReleaseAssert/swift-macosx-x86_64/swift-test-results/x86_64-apple-macosx10.9/clang-module-cache -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.16.sdk -swift-version 4 -ignore-module-source-info -typo-correction-limit 10 -emit-sil test/AutoDiff/compiler_crashers_fixed/tf1315-pullback-subset-parameter-thunk-generation.swift
1.	Swift version 5.3-dev (LLVM 32ba33c87eb2475, Swift d90d0b390c96816)
2.	While evaluating request ExecuteSILPipelineRequest(Run pipelines { Mandatory Diagnostic Passes + Enabling Optimization Passes } on SIL for main.main)
3.	While running pass #33 SILModuleTransform "Differentiation".
4.	While canonicalizing `differentiable_function` SIL node   %17 = differentiable_function [parameters 2] [results 0] %13 : $@convention(thin) (Int, Float, @inout Float) -> () // users: %19, %18
5.	While ...in SIL function "@AD__$s4main7TF_1315yS2fF__vjp_src_0_wrt_0".
 for 'TF_1315(_:)' (at test/AutoDiff/compiler_crashers_fixed/tf1315-pullback-subset-parameter-thunk-generation.swift:19:1)
0  swift-frontend           0x0000000107be25a5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift-frontend           0x0000000107be14e8 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x0000000107be2b86 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff6e0115fd _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338670598688
5  libsystem_c.dylib        0x00007fff6dee7808 abort + 120
6  libsystem_c.dylib        0x00007fff6dee6ac6 err + 0
7  swift-frontend           0x0000000107de03a3 llvm::SmallVectorImpl<swift::SILValue>::insert(swift::SILValue*, swift::SILValue const&) (.cold.3) + 35
8  swift-frontend           0x00000001038e3594 llvm::SmallVectorImpl<swift::SILValue>::insert(swift::SILValue*, swift::SILValue const&) + 276
9  swift-frontend           0x00000001038e2e96 swift::autodiff::getOrCreateSubsetParametersThunkForLinearMap(swift::SILOptFunctionBuilder&, swift::SILFunction*, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::AutoDiffDerivativeFunctionKind, swift::SILAutoDiffI  1 [AutoDiff] Fix pullback subset thunk generation crash.
ndices, swift::SILAutoDiffIndices) + 8262
10 swift-frontend           0x00000001038e4eab swift::autodiff::getOrCreateSubsetParametersThunkForDerivativeFunction(swift::SILOptFunctionBuilder&, swift::SILValue, swift::SILValue, swift::AutoDiffDerivativeFunctionKind, swift::SILAutoDiffIndices, swift::SILAutoDiffIndices) + 6395
11 swift-frontend           0x0000000103a2ca32 (anonymous namespace)::DifferentiationTransformer::promoteToDifferentiableFunction(swift::DifferentiableFunctionInst*, swift::SILBuilder&, swift::SILLocation, swift::autodiff::DifferentiationInvoker) + 7842
+29 -1

0 comment

2 changed files

pr created time in a month

create barnchdan-zheng/swift

branch : TF-1315

created branch time in a month

delete branch dan-zheng/swift

delete branch : tensorflow-test

delete time in a month

PR closed apple/swift

[DoNotMerge] Test TensorFlow CI. tensorflow
+1 -0

2 comments

1 changed file

dan-zheng

pr closed time in a month

push eventapple/swift

Dan Zheng

commit sha d8dbd7146cd8e0197599eb35371778627014417a

[AutoDiff] Make `DifferentiableActivityInfo::dump` print an end marker. End markers are useful for FileCheck.

view details

Dan Zheng

commit sha 596787bcf63f08f57038f244a52c35d1f6e18e55

[AutoDiff] Fix PullbackCloner tangent value category mismatch issues. Fix SIL pullback function type calculation: remap original `unowned` results to the correct pullback parameter convention depending on the `TangentVector` type lowering. Make `PullbackCloner` visitors for the following instructions check and handle tangent value categories: `struct`, `struct_extract`, `tuple`, `destructure_tuple`. Add differentiation tests for `Optional` struct and class stored properties, exercising the instruction visitors above. Resolves SR-13430.

view details

Dan Zheng

commit sha 2ee26da46288bb7e1519889849aad5a38973e764

Change `getAdjointBuffer` to return `SILValue` instead of `SILValue &`. Fixes a use-after-free crash.

view details

Dan Zheng

commit sha 54fe5119e13c0966a3759808628ee2f2d3e4e847

Merge pull request #33964 from dan-zheng/tensorflow-autodiff-fixes [AutoDiff] Fix PullbackCloner tangent value category mismatch issues.

view details

Dan Zheng

commit sha 28ca98e6fec1949b80892cc6d1e2cc4670767965

Merge branch 'tensorflow' into tensorflow-merge

view details

push time in a month

delete branch dan-zheng/swift

delete branch : tensorflow-autodiff-fixes

delete time in a month

push eventapple/swift

Dan Zheng

commit sha d8dbd7146cd8e0197599eb35371778627014417a

[AutoDiff] Make `DifferentiableActivityInfo::dump` print an end marker. End markers are useful for FileCheck.

view details

Dan Zheng

commit sha 596787bcf63f08f57038f244a52c35d1f6e18e55

[AutoDiff] Fix PullbackCloner tangent value category mismatch issues. Fix SIL pullback function type calculation: remap original `unowned` results to the correct pullback parameter convention depending on the `TangentVector` type lowering. Make `PullbackCloner` visitors for the following instructions check and handle tangent value categories: `struct`, `struct_extract`, `tuple`, `destructure_tuple`. Add differentiation tests for `Optional` struct and class stored properties, exercising the instruction visitors above. Resolves SR-13430.

view details

Dan Zheng

commit sha 2ee26da46288bb7e1519889849aad5a38973e764

Change `getAdjointBuffer` to return `SILValue` instead of `SILValue &`. Fixes a use-after-free crash.

view details

Dan Zheng

commit sha 54fe5119e13c0966a3759808628ee2f2d3e4e847

Merge pull request #33964 from dan-zheng/tensorflow-autodiff-fixes [AutoDiff] Fix PullbackCloner tangent value category mismatch issues.

view details

push time in a month

PR merged apple/swift

[AutoDiff] Fix PullbackCloner tangent value category mismatch issues. tensorflow

Cherry-pick of https://github.com/apple/swift/pull/33611 to tensorflow branch.


Fix SIL pullback function type calculation: remap original unowned results to the correct pullback parameter convention depending on the TangentVector type lowering.

Make PullbackCloner visitors for the following instructions check and handle tangent value categories: struct, struct_extract, tuple, destructure_tuple.

Add differentiation tests for Optional struct and class stored properties, exercising the instruction visitors above.

Resolves SR-13430.

+473 -134

2 comments

6 changed files

dan-zheng

pr closed time in a month

push eventdan-zheng/swift-apis

Dan Zheng

commit sha b3ec2dfc0c5c0728d47cad1a998e152df8ccdac2

Initial commit. Add simple benchmark testing `gradient(at:in:)` performance.

view details

push time in a month

push eventdan-zheng/swift-apis

Dan Zheng

commit sha 6b4a0147d307679f38f4116b55cc35817006a8f2

Initial commit. Add simple benchmark testing `gradient(at:in:)` performance.

view details

push time in a month

create barnchdan-zheng/swift-apis

branch : TF-1302

created branch time in a month

pull request commentapple/swift

[AutoDiff] Fix PullbackCloner tangent value category mismatch issues.

@swift-ci Please test tensorflow

dan-zheng

comment created time in a month

pull request commentapple/swift

[AutoDiff] Fix PullbackCloner tangent value category mismatch issues.

@swift-ci Please test tensorflow

dan-zheng

comment created time in a month

push eventdan-zheng/swift

Dan Zheng

commit sha d8dbd7146cd8e0197599eb35371778627014417a

[AutoDiff] Make `DifferentiableActivityInfo::dump` print an end marker. End markers are useful for FileCheck.

view details

Dan Zheng

commit sha 596787bcf63f08f57038f244a52c35d1f6e18e55

[AutoDiff] Fix PullbackCloner tangent value category mismatch issues. Fix SIL pullback function type calculation: remap original `unowned` results to the correct pullback parameter convention depending on the `TangentVector` type lowering. Make `PullbackCloner` visitors for the following instructions check and handle tangent value categories: `struct`, `struct_extract`, `tuple`, `destructure_tuple`. Add differentiation tests for `Optional` struct and class stored properties, exercising the instruction visitors above. Resolves SR-13430.

view details

Dan Zheng

commit sha 2ee26da46288bb7e1519889849aad5a38973e764

Change `getAdjointBuffer` to return `SILValue` instead of `SILValue &`. Fixes a use-after-free crash.

view details

push time in a month

create barnchapple/swift

branch : tensorflow-autodiff-fixes

created branch time in a month

pull request commentapple/swift

[AutoDiff] Fix PullbackCloner tangent value category mismatch issues.

@swift-ci Please test tensorflow

dan-zheng

comment created time in a month

PR opened apple/swift

Reviewers
[AutoDiff] Fix PullbackCloner tangent value category mismatch issues. tensorflow

Cherry-pick of https://github.com/apple/swift/pull/33611 to tensorflow branch.


Fix SIL pullback function type calculation: remap original unowned results to the correct pullback parameter convention depending on the TangentVector type lowering.

Make PullbackCloner visitors for the following instructions check and handle tangent value categories: struct, struct_extract, tuple, destructure_tuple.

Add differentiation tests for Optional struct and class stored properties, exercising the instruction visitors above.

Resolves SR-13430.

+463 -126

0 comment

5 changed files

pr created time in a month

create barnchdan-zheng/swift

branch : tensorflow-autodiff-fixes

created branch time in a month

PullRequestReviewEvent

PR opened ewconnell/swiftrt

[AutoDiff] Add tensor-scalar max/min VJPs.

Add DeviceQueue.mapOp overload with type (tensor, tensor, scalar) -> (out, out).

Add tensor-scalar DeviceQueue.cpu_vjp{Max,Min} overloads in addition to existing tensor-tensor versions.

swift test --filter test_Comparative now passes.


min/max gradient Python reference implementation:

<details>

import tensorflow as tf

a = tf.constant([[0, 1], [-2, -3], [-4, 5]], dtype=tf.float32)
b = tf.constant([[0, -1], [-2, 3], [-4, 5]], dtype=tf.float32)


def test_grad(op, tensor, scalar):
    with tf.GradientTape(persistent=True) as tape:
        tape.watch(tensor)
        result = op(tensor, scalar)
    print("Result")
    print(result)
    print()
    print("Gradient")
    print(tape.gradient(result, tensor))


test_grad(tf.math.maximum, a, -2)
# Result
# tf.Tensor(
# [[ 0.  1.]
#  [-2. -2.]
#  [-2.  5.]], shape=(3, 2), dtype=float32)
#
# Gradient
# tf.Tensor(
# [[1. 1.]
#  [1. 0.]
#  [0. 1.]], shape=(3, 2), dtype=float32)

test_grad(tf.math.minimum, a, -2)
# Result
# tf.Tensor(
# [[-2. -2.]
#  [-2. -3.]
#  [-4. -2.]], shape=(3, 2), dtype=float32)
#
# Gradient
# tf.Tensor(
# [[0. 0.]
#  [1. 1.]
#  [1. 0.]], shape=(3, 2), dtype=float32)
+151 -12

0 comment

3 changed files

pr created time in a month

push eventdan-zheng/swiftrt

Dan Zheng

commit sha 7ac596903bace0be94af278eb13cd385e1d0c949

[AutoDiff] Add tensor-scalar max/min VJPs. Add `DeviceQueue.mapOp` overload with type `(tensor, tensor, scalar) -> (out, out)`. Add tensor-scalar `DeviceQueue.cpu_vjp{Max,Min}` overloads in addition to existing tensor-tensor versions. `swift test --filter test_Comparative` now passes.

view details

push time in a month

create barnchdan-zheng/swiftrt

branch : autodiff-comparison-vjps

created branch time in a month

PR opened ewconnell/swiftrt

[AutoDiff] Add VJPs for atan2 and erf.

atan2 VJP reference implementation:

<details>

import tensorflow as tf

x = tf.constant([[1, 2], [3, 4], [5, 6]], dtype=tf.float32)
y = tf.constant([[1, -2], [-3, 4], [5, -6]], dtype=tf.float32)

with tf.GradientTape(persistent=True) as tape:
    tape.watch([x, y])
    result = tf.atan2(x, y)

print("Result")
print(result)
# tf.Tensor(
# [[0.7853982 2.3561945]
#  [2.3561945 0.7853982]
#  [0.7853982 2.3561945]], shape=(3, 2), dtype=float32)

print("Gradient (dx)")
dx = tape.gradient(result, x)
print(dx)
# tf.Tensor(
# [[ 0.5        -0.25      ]
#  [-0.16666667  0.125     ]
#  [ 0.09999999 -0.08333334]], shape=(3, 2), dtype=float32)

print("Gradient (dy)")
dy = tape.gradient(result, y)
print(dy)
# tf.Tensor(
# [[-0.5        -0.25      ]
#  [-0.16666667 -0.125     ]
#  [-0.09999999 -0.08333334]], shape=(3, 2), dtype=float32)

</details>

erf VJP reference implementation:

<details>

import tensorflow as tf

x = tf.constant([[0, -1], [2, -3], [4, 5]], dtype=tf.float32)

with tf.GradientTape(persistent=True) as tape:
    tape.watch(x)
    result = tf.math.erf(x)

print('Result')
print(result)
# tf.Tensor(
# [[0.7853982 2.3561945]
#  [2.3561945 0.7853982]
#  [0.7853982 2.3561945]], shape=(3, 2), dtype=float32)

print('Gradient (dx)')
dx = tape.gradient(result, x)
print(dx)
# tf.Tensor(
# [[ 0.5        -0.25      ]
#  [-0.16666667  0.125     ]
#  [ 0.09999999 -0.08333334]], shape=(3, 2), dtype=float32)

</details>

+34 -4

0 comment

2 changed files

pr created time in a month

create barnchdan-zheng/swiftrt

branch : autodiff-math-vjps

created branch time in a month

PullRequestReviewEvent

PR opened apple/swift-community-hosted-continuous-integration

Reviewers
Remove Swift for TensorFlow GPU CI node.

The Swift for TensorFlow GPU CI node is no longer necessary.


After the GPU CI started working again, we realized that the test preset is actually unused, so the CI node can be removed. We don't foresee needing it again, sorry for the thrash.

+0 -20

0 comment

2 changed files

pr created time in a month

PullRequestReviewEvent

delete branch dan-zheng/swift-apis

delete branch : ZeroTagging

delete time in a month

pull request commentapple/swift

[AutoDiff] WIP: Add forward mode differentiation control flow support

@swift-ci Please smoke test

efremale

comment created time in a month

push eventdan-zheng/swift-community-hosted-continuous-integration

Mishal Shah

commit sha 0753f5ecb6c85711cc0f2103de47f8c0b805c4a4

Merge pull request #33 from dan-zheng/tensorflow Update Swift for TensorFlow nodes.

view details

Dan Zheng

commit sha 10d324f9c65abe57832c03678e47f9dd153052ee

Remove Swift for TensorFlow GPU CI node. The Swift for TensorFlow GPU CI node is no longer necessary.

view details

push time in a month

PR opened tensorflow/swift-apis

Tagging zero scalar tensors.

A fork of https://github.com/tensorflow/swift-apis/pull/1022 with an attempt to work around SR-13263: a debug info generation crash.

+22 -2

0 comment

1 changed file

pr created time in a month

create barnchdan-zheng/swift-apis

branch : ZeroTagging

created branch time in a month

push eventdan-zheng/swift

Dan Zheng

commit sha 5c3efaecfbf11070ddeb7618457dc7c25f20c93b

[WIP] Attempt to fold `differentiable_function_extract` instructions during autodiff transform. This doesn't work because `differentiable_function` has non-trivial users (like `convert_escape_to_noescape`) that cannot be trivially folded away. Example Gist with details: https://gist.github.com/dan-zheng/56840a135d5847cc0a679e71736b0925

view details

push time in a month

create barnchdan-zheng/swift

branch : autodiff-sil-optimizations-transform

created branch time in a month

push eventdan-zheng/swift

Dan Zheng

commit sha 72ee516657108e7bbf923b54917244c081ef5194

[WIP] Implement autodiff SIL peephole optimizations. This adds peephole optimizations for autodiff-related SIL instructions, critical for unblocking later optimizations like inlining. Summary of optimizations: ``` // 1. Simplify `differentiable_function_extract` of `differentiable_function`. // Before: %x = differentiable_function(%orig, %jvp, %vjp) %y = differentiable_function_extract [original] %x // After: %y = %orig // 2. Push conversion instructions inside of `differentiable_function`. // This unblocks inlining and specialization. // Before: %x = differentiable_function(%orig, %jvp, %vjp) %y = convert_escape_to_noescape %x // After: %orig' = convert_escape_to_noescape %orig %jvp' = convert_escape_to_noescape %jvp %vjp' = convert_escape_to_noescape %vjp %y = differentiable_function(%orig', %jvp', %vjp') ```

view details

push time in a month

push eventdan-zheng/swift

Dan Zheng

commit sha b572b39c7ec1be4b32c054aa14837371f8db2c70

[WIP] Implement autodiff SIL peephole optimizations. This adds peephole optimizations for autodiff-related SIL instructions, critical for unblocking later optimizations like inlining. Summary of optimizations: ``` // 1. Simplify `differentiable_function_extract` of `differentiable_function`. // Before: %x = differentiable_function(%orig, %jvp, %vjp) %y = differentiable_function_extract [original] %x // After: %y = %orig // 2. Push conversion instructions inside of `differentiable_function`. // This unblocks inlining and specialization. // Before: %x = differentiable_function(%orig, %jvp, %vjp) %y = convert_escape_to_noescape %x // After: %orig' = convert_escape_to_noescape %orig %jvp' = convert_escape_to_noescape %jvp %vjp' = convert_escape_to_noescape %vjp %y = differentiable_function(%orig', %jvp', %vjp') ```

view details

push time in a month

push eventdan-zheng/swift

Dan Zheng

commit sha a0faf767206db14bb6f42a5ad8235828522e504f

[WIP] Implement autodiff SIL peephole optimizations. This adds peephole optimizations for autodiff-related SIL instructions, critical for unblocking later optimizations like inlining. Summary of optimizations: ``` // 1. Simplify `differentiable_function_extract` of `differentiable_function`. // Before: %x = differentiable_function(%orig, %jvp, %vjp) %y = differentiable_function_extract [original] %x // After: %y = %orig // 2. Push conversion instructions inside of `differentiable_function`. // This unblocks inlining and specialization. // Before: %x = differentiable_function(%orig, %jvp, %vjp) %y = convert_escape_to_noescape %x // After: %orig' = convert_escape_to_noescape %orig %jvp' = convert_escape_to_noescape %jvp %vjp' = convert_escape_to_noescape %vjp %y = differentiable_function(%orig', %jvp', %vjp') ```

view details

push time in a month

push eventdan-zheng/swift

Dan Zheng

commit sha e7fbec4d271f18e19932fac0dd6fa98c62e73a10

[WIP] Implement autodiff SIL peephole optimizations. This adds peephole optimizations for autodiff-related SIL instructions, critical for unblocking later optimizations like inlining. Summary of optimizations: ``` // 1. Simplify `differentiable_function_extract` of `differentiable_function`. // Before: %x = differentiable_function(%orig, %jvp, %vjp) %y = differentiable_function_extract [original] %x // After: %y = %orig // 2. Push conversion instructions inside of `differentiable_function`. // This unblocks inlining and specialization. // Before: %x = differentiable_function(%orig, %jvp, %vjp) %y = convert_escape_to_noescape %x // After: %orig' = convert_escape_to_noescape %orig %jvp' = convert_escape_to_noescape %jvp %vjp' = convert_escape_to_noescape %vjp %y = differentiable_function(%orig', %jvp', %vjp') ```

view details

push time in a month

push eventdan-zheng/swift

swift-ci

commit sha 3bf6d1f05dc586747d12fa139e51e0b7cf14be50

Merge remote-tracking branch 'origin/master' into master-rebranch

view details

swift-ci

commit sha 1490315a8486d366a81620e755c873ee33bbe37f

Merge remote-tracking branch 'origin/master' into master-rebranch

view details

swift-ci

commit sha 792e6268ded7cec440b8c29bff02339f6c71a09c

Merge remote-tracking branch 'origin/master' into master-rebranch

view details

swift-ci

commit sha 3096012cecd113fcebc9bb2a7d8666392ece968a

Merge remote-tracking branch 'origin/master' into master-rebranch

view details

swift-ci

commit sha 899c7d3565322cf55ba2fc1b84d599e814c63b41

Merge remote-tracking branch 'origin/master' into master-rebranch

view details

swift-ci

commit sha daa79d6b12d414bad49f37b379aef73f125bd2af

Merge remote-tracking branch 'origin/master' into master-rebranch

view details

swift-ci

commit sha c8828f59d57f3e2f08d3b63e42f3a91b7cb4afbb

Merge remote-tracking branch 'origin/master' into master-rebranch

view details

swift-ci

commit sha cb55c32bfbb172cea01fc51f1315d1ccb9ac847c

Merge remote-tracking branch 'origin/master' into master-rebranch

view details

swift-ci

commit sha 211b843076ed0c248f9e1651f8a48fd44c248050

Merge remote-tracking branch 'origin/master' into master-rebranch

view details

Dario Rexin

commit sha 27102e2a997d3ccbf1614136692ab29908c206ed

Don't build with stdlib assertions on Linux

view details

swift-ci

commit sha f0dedafa3263562ccf104ed4efb6e5109ff342d2

Merge remote-tracking branch 'origin/master' into master-rebranch

view details

swift-ci

commit sha 3f190e6c4bb00a53a5567232cd92279d4f6f7b92

Merge remote-tracking branch 'origin/master' into master-rebranch

view details

swift-ci

commit sha ea4fbf04613b3530110a58ab5a1d142fad8b4468

Merge remote-tracking branch 'origin/master' into master-rebranch

view details

swift-ci

commit sha 6d5dbe2bf31d1c2e2f3273e8e2631ee55777a963

Merge remote-tracking branch 'origin/master' into master-rebranch

view details

swift-ci

commit sha 0c593cb41cbc61c5cf3dd97e1c2542f831d47869

Merge remote-tracking branch 'origin/master' into master-rebranch

view details

swift-ci

commit sha b513625fccd83214647404d1a536fe381d203d39

Merge remote-tracking branch 'origin/master' into master-rebranch

view details

swift-ci

commit sha 55919a501e1d9e478b1d9f4c58fb4af9fe23f94d

Merge remote-tracking branch 'origin/master' into master-rebranch

view details

swift-ci

commit sha 4b5cdc140296d5f90253eb6f19ecdf9d16e7ed5b

Merge remote-tracking branch 'origin/master' into master-rebranch

view details

swift-ci

commit sha ea1b01feea3d7cf448a708179f6feb652d70965f

Merge remote-tracking branch 'origin/master' into master-rebranch

view details

Arnold Schwaighofer

commit sha a5dfae23805be2061a90dbb941c3abd37ffdf96e

Update test IRGen/pic.swift for changed code generation rdar://66790508

view details

push time in a month

create barnchdan-zheng/swift

branch : autodiff-sil-optimizations-old

created branch time in a month

push eventapple/swift

Dan Zheng

commit sha 8bffdff0db4894b8ca23c91726e2fb68b5c41739

Clean up.

view details

Dan Zheng

commit sha 18797317f456b421e6968be053af3f1f24a4a0b8

Fix SIL FileCheck test.

view details

push time in a month

push eventapple/swift

Dan Zheng

commit sha a36f7ac03f913c0e628fb53284d6b779edb74421

Clean up.

view details

push time in a month

create barnchapple/swift

branch : forward-mode-control-flow

created branch time in a month

PullRequestReviewEvent
PullRequestReviewEvent
more