1 /* Copyright 2020 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/service/gpu/tests/mlir_gpu_test_base.h"
17 #include "tensorflow/core/lib/core/status_test_util.h"
18 #include "tensorflow/core/platform/test.h"
19
20 namespace xla {
21 namespace gpu {
22
23 // Tests XLA GPU compilation using MLIR LMHLO dialect as the input.
24 class CompileTest : public MlirGpuTestBase {};
25
TEST_F(CompileTest,InvalidCollectivePermuteOp)26 TEST_F(CompileTest, InvalidCollectivePermuteOp) {
27 const char* mlir_text = R"(
28 func.func @main(%arg0: memref<4xf32> {lmhlo.params = 0 : index},
29 %arg1: memref<4xf32> {lmhlo.output_index = dense<[0]> : tensor<1xindex>}) -> () {
30 "lmhlo.collective_permute"(%arg0, %arg1) {source_target_pairs = dense<[[0, 1, 2]]> : tensor<1x3xi64>} : (memref<4xf32>, memref<4xf32>) -> ()
31 "func.return" () : () -> ()
32 })";
33 auto executable = CompileMlirText(mlir_text);
34 ASSERT_FALSE(executable.ok());
35 EXPECT_THAT(executable.status().error_message().c_str(),
36 ::testing::HasSubstr("expect source_target_pairs attribute of "
37 "shape (N, 2), but got (1, 3)"));
38 }
39
40 } // namespace gpu
41 } // namespace xla
42