8000 [XLA:GPU] Init output data with -1. · linux-on-ibm-z/tensorflow@1b776c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1b776c9

Browse files
olegshyshkovtensorflower-gardener
authored andcommitted
[XLA:GPU] Init output data with -1.
Makes it easier to detect cases when we overwrite data out of the update range. PiperOrigin-RevId: 730867242
1 parent 522b1b9 commit 1b776c9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

third_party/xla/xla/tests/collective_ops_e2e_test.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,13 @@ class RaggedAllToAllTest : public AsyncMemcpyCollectiveOps {
19241924
ragged_all_to_all->shape().dimensions().begin(),
19251925
ragged_all_to_all->shape().dimensions().end()};
19261926

1927+
// The ragged-all-to-all accepts an output tensor as a parameter to allow
1928+
// buffer reuse. We initialize the output tensor with -1 to make sure that
1929+
// we don't accidentally overwrite data that is not part of the
1930+
// ragged-all-to-all update.
1931+
Array<float> output_init_data(ragged_tensor_sizes);
1932+
output_init_data.Fill(-1);
1933+
19271934
Array<IndexType> output_sizes = input_sizes;
19281935
output_sizes.TransposeDimensions({1, 0, 2});
19291936

@@ -1934,8 +1941,7 @@ class RaggedAllToAllTest : public AsyncMemcpyCollectiveOps {
19341941
int64_t num_replicas = input_sizes.dim(0);
19351942
std::vector<Array<float>> input_data(num_replicas,
19361943
Array<float>(ragged_tensor_sizes));
1937-
std::vector<Array<float>> output_data(num_replicas,
1938-
Array<float>(ragged_tensor_sizes));
1944+
std::vector<Array<float>> output_data(num_replicas, output_init_data);
19391945
FillWithRandomData(input_data, output_data, input_offsets, output_offsets,
19401946
input_sizes);
19411947

@@ -1955,9 +1961,7 @@ class RaggedAllToAllTest : public AsyncMemcpyCollectiveOps {
19551961
GetReplicaSlice(replica_id, output_sizes)));
19561962
}
19571963

1958-
// The ragged-all-to-all accepts an output tensor as a parameter to allow
1959-
// buffer reuse. We initialize the output tensor with zeros.
1960-
output_init_ = LiteralUtil::CreateFull(ragged_tensor_sizes, 0);
1964+
output_init_ = LiteralUtil::CreateFromArray(output_init_data);
19611965
}
19621966

19631967
// Returns a vector of pointers to the literals in the format needed for

0 commit comments

Comments
 (0)
0