Repository navigation
C++ gradient for Select - #14862
C++ gradient for Select#14862
Conversation
|
Can one of the admins verify this patch? |
|
@suharshs Hi, since |
cd2bf45 to
88a2671
Compare
88a2671 to
172dcec
Compare
|
Sorry for the delay, was on vacation :) I believe at the kernel level, the op is still "Select" so you should register it for that. |
| auto zeros = ZerosLike(scope, x); | ||
| auto grad = grad_inputs[0]; | ||
|
|
||
| Scope grad_scope = scope.WithControlDependencies(grad); |
There was a problem hiding this comment.
Why do you need this control dependency? Isn't there a data dependency with grad already?
| } | ||
|
|
||
| TEST_F(NaryGradTest, Select) { | ||
| TensorShape x_shape({3, 4}); |
There was a problem hiding this comment.
Nit: Since x_shape is the same as y_shape, maybe rename one to 'shape' and use that everywhere?
|
Welcome back, @suharshs . I have removed grad_scope, x_shape, y_shape as requested. |
|
@tensorflow-jenkins test this please |
|
Correction, this is the cause of the flakes. reverting this PR instead. |
| TensorShape shape({3, 4}); | ||
| auto x1 = Placeholder(scope_, DT_FLOAT, Placeholder::Shape(shape)); | ||
| auto x2 = Placeholder(scope_, DT_FLOAT, Placeholder::Shape(shape)); | ||
| auto y = Where3(scope_, Greater(scope_, x1, x2), x1, x2); |
There was a problem hiding this comment.
@drpngx I want to confirm that: Is NaryGradTest.Select the only one failed test?
There was a problem hiding this comment.
I can't remember on the top of my head. I thought there was another one. You can try bazel test --runs_per_test=100 and you should find it.
There was a problem hiding this comment.
Fine, I'll look into it later. Thanks for your quick reply, @drpngx .
There was a problem hiding this comment.
I have opened #15807 to fix the unstable test case. Might you take a look? Thanks.
…her/scatter. Imported from GitHub PR openxla/xla#14862 Issue #13304 In SPMD handling of gather/scatter the partition strategy is hardcoded to IndexParallel strategy. This is not optimal for all topology. This PR makes this option an SPMD config, but defaults to IndexParallel to maintain existing behavior. Clang-format also fixed some formatting. Tests were added and all tests pass. Copybara import of the project: -- 7f83c21573f24cd4e314b13ce2e349dd6194b451 by ptoulme-aws <[email protected]>: Add SPMD config option to specify zero cost method for gather/scatter. Merging this change closes #14862 FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#14862 from ptoulme-aws:gather_scatter_config 7f83c21573f24cd4e314b13ce2e349dd6194b451 PiperOrigin-RevId: 652473292
…her/scatter. Imported from GitHub PR openxla/xla#14862 Issue #13304 In SPMD handling of gather/scatter the partition strategy is hardcoded to IndexParallel strategy. This is not optimal for all topology. This PR makes this option an SPMD config, but defaults to IndexParallel to maintain existing behavior. Clang-format also fixed some formatting. Tests were added and all tests pass. Copybara import of the project: -- 7f83c21573f24cd4e314b13ce2e349dd6194b451 by ptoulme-aws <[email protected]>: Add SPMD config option to specify zero cost method for gather/scatter. Merging this change closes #14862 FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#14862 from ptoulme-aws:gather_scatter_config 7f83c21573f24cd4e314b13ce2e349dd6194b451 PiperOrigin-RevId: 652473292
…her/scatter. Imported from GitHub PR openxla/xla#14862 Issue #13304 In SPMD handling of gather/scatter the partition strategy is hardcoded to IndexParallel strategy. This is not optimal for all topology. This PR makes this option an SPMD config, but defaults to IndexParallel to maintain existing behavior. Clang-format also fixed some formatting. Tests were added and all tests pass. Copybara import of the project: -- 7f83c21573f24cd4e314b13ce2e349dd6194b451 by ptoulme-aws <[email protected]>: Add SPMD config option to specify zero cost method for gather/scatter. Merging this change closes #14862 FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#14862 from ptoulme-aws:gather_scatter_config 7f83c21573f24cd4e314b13ce2e349dd6194b451 PiperOrigin-RevId: 652473292
…her/scatter. Imported from GitHub PR openxla/xla#14862 Issue #13304 In SPMD handling of gather/scatter the partition strategy is hardcoded to IndexParallel strategy. This is not optimal for all topology. This PR makes this option an SPMD config, but defaults to IndexParallel to maintain existing behavior. Clang-format also fixed some formatting. Tests were added and all tests pass. Copybara import of the project: -- 7f83c21573f24cd4e314b13ce2e349dd6194b451 by ptoulme-aws <[email protected]>: Add SPMD config option to specify zero cost method for gather/scatter. Merging this change closes #14862 FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#14862 from ptoulme-aws:gather_scatter_config 7f83c21573f24cd4e314b13ce2e349dd6194b451 PiperOrigin-RevId: 652514718
…her/scatter. Imported from GitHub PR openxla/xla#14862 Issue #13304 In SPMD handling of gather/scatter the partition strategy is hardcoded to IndexParallel strategy. This is not optimal for all topology. This PR makes this option an SPMD config, but defaults to IndexParallel to maintain existing behavior. Clang-format also fixed some formatting. Tests were added and all tests pass. Copybara import of the project: -- 7f83c21573f24cd4e314b13ce2e349dd6194b451 by ptoulme-aws <[email protected]>: Add SPMD config option to specify zero cost method for gather/scatter. Merging this change closes #14862 FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#14862 from ptoulme-aws:gather_scatter_config 7f83c21573f24cd4e314b13ce2e349dd6194b451 PiperOrigin-RevId: 652514718
…her/scatter. Imported from GitHub PR openxla/xla#14862 Issue #13304 In SPMD handling of gather/scatter the partition strategy is hardcoded to IndexParallel strategy. This is not optimal for all topology. This PR makes this option an SPMD config, but defaults to IndexParallel to maintain existing behavior. Clang-format also fixed some formatting. Tests were added and all tests pass. Copybara import of the project: -- 7f83c21573f24cd4e314b13ce2e349dd6194b451 by ptoulme-aws <[email protected]>: Add SPMD config option to specify zero cost method for gather/scatter. Merging this change closes #14862 FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#14862 from ptoulme-aws:gather_scatter_config 7f83c21573f24cd4e314b13ce2e349dd6194b451 PiperOrigin-RevId: 652473292
…her/scatter. Imported from GitHub PR openxla/xla#14862 Issue #13304 In SPMD handling of gather/scatter the partition strategy is hardcoded to IndexParallel strategy. This is not optimal for all topology. This PR makes this option an SPMD config, but defaults to IndexParallel to maintain existing behavior. Clang-format also fixed some formatting. Tests were added and all tests pass. Copybara import of the project: -- 7f83c21573f24cd4e314b13ce2e349dd6194b451 by ptoulme-aws <[email protected]>: Add SPMD config option to specify zero cost method for gather/scatter. Merging this change closes #14862 PiperOrigin-RevId: 652736743
Fix #14845
migrate python implementation to c++ side, source:
tensorflow/tensorflow/python/ops/math_grad.py
Line 919 in 27767d8
How to test