1 /* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
2
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15
16 #include "tensorflow/compiler/xla/tests/hlo_test_base.h"
17
18 namespace xla {
19 namespace gpu {
20 namespace {
21
22 class InPlaceOpTest : public HloTestBase {
23 // Don't override any flags.
GetDebugOptionsForTest()24 DebugOptions GetDebugOptionsForTest() override {
25 return GetDebugOptionsFromFlags();
26 }
27 };
28
TEST_F(InPlaceOpTest,DynamicUpdateSliceWithMultipleConsumers)29 TEST_F(InPlaceOpTest, DynamicUpdateSliceWithMultipleConsumers) {
30 const char* hlo_text = R"(
31 HloModule main
32
33 ENTRY %main {
34 %param_0 = s32[4,4] parameter(0)
35 %constant_0 = s32[] constant(0)
36 %constant_1 = s32[] constant(1)
37 %constant_1x1_1 = s32[1,1] constant({ {1} })
38 %slice = s32[1,1] slice(%param_0), slice={[1:2], [0:1]}
39 %add = add(%slice, %constant_1x1_1)
40 %updated = s32[4,4] dynamic-update-slice(%param_0, %add, %constant_1, %constant_0)
41 %transpose = s32[4,4] transpose(%updated), dimensions={1,0}
42 ROOT %tuple = tuple(%transpose, %updated)
43 }
44 )";
45
46 EXPECT_TRUE(RunAndCompare(hlo_text, std::nullopt));
47 }
48
49 } // namespace
50 } // namespace gpu
51 } // namespace xla
52