Skip to content

[AutoDiff] Simplify varied propagation in activity analysis. #28191

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

Merged

Conversation

dan-zheng
Copy link
Contributor

  • Remove setVaried.
  • Remove setVariedAcrossArrayInitialization.
    • Activity info does not change when removing special variedness propagation
      support for array.uninitialized_intrinsic applications.
    • Verified with array initialization activity info test case.

- Remove `setVaried`.
  - `setVaried` has only one user and can be inlined.
- Remove `setVariedAcrossArrayInitialization`.
  - Activity info does not change when removing special variedness propagation
    support for `array.uninitialized_intrinsic` applications.
  - Verified with array initialization activity info test case.
@dan-zheng
Copy link
Contributor Author

@swift-ci Please test tensorflow

@rxwei
Copy link
Contributor

rxwei commented Nov 11, 2019

Activity info does not change when removing special variedness propagation
support for array.uninitialized_intrinsic applications.
Verified with array initialization activity info test case.

Could you please add a test to make sure this still holds true for indirectly initialized array literals? Indirectness should always be considered in these sorts of test cases.

func testArrayUninitializedIntrinsic<T>(_ x: T, _ y: T) -> [T] {
   return [x, y]
}

@dan-zheng
Copy link
Contributor Author

dan-zheng commented Nov 11, 2019

Could you please add a test to make sure this still holds true for indirectly initialized array literals? Indirectness should always be considered in these sorts of test cases.

Done in 05122fb. Verified that activity info for array.uninitialized_intrinsic applications didn't change before/after this patch.

There already exist runtime tests for array.uninitialized_intrinsic applications in test/AutoDiff/array.swift for these cases and more.

@dan-zheng
Copy link
Contributor Author

@swift-ci Please test tensorflow

@rxwei
Copy link
Contributor

rxwei commented Nov 11, 2019

Great. To throw another example here: Consider testing an indirect type (e.g. struct S<T> { var x: T }) that conforms to ExpressibleByArrayLiteral. This is different from Array because Array is always directly passed.

No activity analysis test added because activity info for the
`array.uninitialized_intrinsic` application is the same.
@dan-zheng
Copy link
Contributor Author

dan-zheng commented Nov 11, 2019

Great. To throw another example here: Consider testing an indirect type (e.g. struct S<T> { var x: T }) that conforms to ExpressibleByArrayLiteral. This is different from Array because Array is always directly passed.

Added an "indirect ExpressibleByArrayLiteral type" test in bb57241.

I didn't add a corresponding activity analysis test because activity info around the array.uninitialized_intrinsic application is the same.

[NONE]   // function_ref _allocateUninitializedArray<A>(_:)
  %6 = function_ref @$ss27_allocateUninitializedArrayySayxG_BptBwlF : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %7
[ACTIVE]   %7 = apply %6<T>(%5) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer) // user: %8
[ACTIVE] (**%8**, %9) = destructure_tuple %7 : $(Array<T>, Builtin.RawPointer) // user: %17
[VARIED] (%8, **%9**) = destructure_tuple %7 : $(Array<T>, Builtin.RawPointer) // user: %10
[VARIED]   %10 = pointer_to_address %9 : $Builtin.RawPointer to [strict] $*T // users: %13, %11
[VARIED]   %12 = integer_literal $Builtin.Word, 1          // user: %13
[VARIED]   %13 = index_addr %10 : $*T, %12 : $Builtin.Word // user: %14

@dan-zheng
Copy link
Contributor Author

@swift-ci Please test tensorflow

@dan-zheng dan-zheng merged commit bd156e3 into swiftlang:tensorflow Nov 12, 2019
@dan-zheng dan-zheng deleted the autodiff-simplify-activity-analysis branch November 12, 2019 02:05
bgogul pushed a commit that referenced this pull request Nov 19, 2019
- Remove `setVaried`.
  - `setVaried` has only one user and can be inlined.
- Remove `setVariedAcrossArrayInitialization`.
  - Activity info does not change when removing special variedness propagation
    support for `array.uninitialized_intrinsic` applications.
  - Verified with array initialization activity info test cases.
- Add indirect `ExpressibleByArrayLiteral` test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tensorflow This is for "tensorflow" branch PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants