Skip to content
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

Fixed some of the XLA tests for IBM's Power architecture #38980

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions tensorflow/compiler/xla/service/cpu/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ filegroup(
]),
)

cc_library(
name = "test_header_helper",
testonly = True,
hdrs = ["test_target_triple_helper.h"],
deps = [
"//tensorflow/core:test",
],
)

filegroup(
name = "single_threaded_runtime_srcs",
srcs = [
Expand Down Expand Up @@ -1071,6 +1080,7 @@ tf_cc_test(
deps = [
":cpu_compiler",
":cpu_transfer_manager",
":test_header_helper",
"//tensorflow/compiler/xla:test",
"//tensorflow/compiler/xla/tests:hlo_test_base",
"//tensorflow/compiler/xla/tests:xla_internal_test_main",
Expand Down
27 changes: 27 additions & 0 deletions tensorflow/compiler/xla/service/cpu/test_target_triple_helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#ifndef TENSORFLOW_TEST_TARGET_TRIPLE_HELPER_H_
#define TENSORFLOW_TEST_TARGET_TRIPLE_HELPER_H_

#if (defined(__powerpc__) || defined(__ppc__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit odd, why not use a ppc target for big endian PPC? If this is intentional can you clarify the rationale as a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a big endian PPC system where I can verify the exact target triple value. That's why I've explicitly checked for little endian which I work on. It may be same for big endian too but not really sure. Even earlier, the fixes I pushed for ppc64le, had these checks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, we only support TensorFlow on ppc64le (LE) in the community builds.

static const std::string kTargetCpuForHost="ppc";
static const std::string kTargetTripleForHost="ppc64le-ibm-linux-gnu";
#else
static const std::string kTargetCpuForHost="";
static const std::string kTargetTripleForHost="x86_64-pc-linux";
#endif

#endif
5 changes: 5 additions & 0 deletions tensorflow/compiler/xla/service/cpu/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ tf_cc_test(
deps = [
"//tensorflow/compiler/xla/service:hlo",
"//tensorflow/compiler/xla/service/cpu:cpu_compiler",
"//tensorflow/compiler/xla/service/cpu:test_header_helper",
"//tensorflow/compiler/xla/service/cpu/tests:cpu_codegen_test",
"//tensorflow/core:lib",
"//tensorflow/core:test",
Expand Down Expand Up @@ -135,6 +136,7 @@ tf_cc_test(
deps = [
"//tensorflow/compiler/xla/service:hlo",
"//tensorflow/compiler/xla/service/cpu:cpu_compiler",
"//tensorflow/compiler/xla/service/cpu:test_header_helper",
"//tensorflow/compiler/xla/service/cpu/tests:cpu_codegen_test",
"//tensorflow/compiler/xla/tests:test_utils",
"//tensorflow/core:lib",
Expand Down Expand Up @@ -215,6 +217,7 @@ tf_cc_test(
"//tensorflow/compiler/xla/service:hlo",
"//tensorflow/compiler/xla/service:hlo_parser",
"//tensorflow/compiler/xla/service/cpu:cpu_compiler",
"//tensorflow/compiler/xla/service/cpu:test_header_helper",
"//tensorflow/compiler/xla/service/cpu/tests:cpu_codegen_test",
"//tensorflow/core:lib",
"//tensorflow/core:test",
Expand All @@ -228,6 +231,7 @@ tf_cc_test(
deps = [
"//tensorflow/compiler/xla/service:hlo",
"//tensorflow/compiler/xla/service/cpu:cpu_compiler",
"//tensorflow/compiler/xla/service/cpu:test_header_helper",
"//tensorflow/compiler/xla/service/cpu/tests:cpu_codegen_test",
"//tensorflow/core:lib",
"//tensorflow/core:test",
Expand All @@ -241,6 +245,7 @@ tf_cc_test(
deps = [
"//tensorflow/compiler/xla/service:hlo",
"//tensorflow/compiler/xla/service/cpu:cpu_compiler",
"//tensorflow/compiler/xla/service/cpu:test_header_helper",
"//tensorflow/compiler/xla/service/cpu/tests:cpu_codegen_test",
"//tensorflow/core:lib",
"//tensorflow/core:test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.

#include "tensorflow/compiler/xla/service/cpu/cpu_compiler.h"
#include "tensorflow/compiler/xla/service/cpu/tests/cpu_codegen_test.h"
#include "tensorflow/compiler/xla/service/cpu/test_target_triple_helper.h"

namespace xla {
namespace cpu {
Expand Down Expand Up @@ -46,7 +47,7 @@ TEST_F(CpuDynamicShapeTest, DynamicShapeR2) {
)";

CpuAotCompilationOptions options{
/*triple=*/"x86_64", /*cpu_name=*/"", /*features=*/"",
/*triple=*/kTargetTripleForHost, /*cpu_name=*/kTargetCpuForHost, /*features=*/"",
/*entry_point_name=*/"entry",
/*relocation_model=*/CpuAotCompilationOptions::RelocationModel::Static};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/cpu/tests/cpu_codegen_test.h"
#include "tensorflow/compiler/xla/service/hlo_computation.h"
#include "tensorflow/compiler/xla/tests/test_utils.h"
#include "tensorflow/compiler/xla/service/cpu/test_target_triple_helper.h"
#include "tensorflow/core/platform/test.h"

namespace xla {
Expand All @@ -45,7 +46,7 @@ class CpuEigenDotOperationTest
void CompileAndCheck(std::unique_ptr<HloComputation> entry_computation,
const string& filecheck_lines) {
CpuAotCompilationOptions options{
/*triple=*/"x86_64", /*cpu_name=*/"", /*features=*/"",
/*triple=*/kTargetTripleForHost, /*cpu_name=*/kTargetCpuForHost, /*features=*/"",
/*entry_point_name=*/"entry",
/*relocation_model=*/CpuAotCompilationOptions::RelocationModel::Static};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.

#include "tensorflow/compiler/xla/service/cpu/cpu_compiler.h"
#include "tensorflow/compiler/xla/service/cpu/tests/cpu_codegen_test.h"
#include "tensorflow/compiler/xla/service/cpu/test_target_triple_helper.h"

namespace xla {
namespace cpu {
Expand Down Expand Up @@ -48,7 +49,7 @@ CHECK: call void @__xla_cpu_runtime_KeyValueSort
TF_ASSERT_OK_AND_ASSIGN(auto module, ParseAndReturnVerifiedModule(hlo_text));

CpuAotCompilationOptions options{
/*triple=*/"x86_64", /*cpu_name=*/"", /*features=*/"",
/*triple=*/kTargetTripleForHost, /*cpu_name=*/kTargetCpuForHost, /*features=*/"",
/*entry_point_name=*/"entry",
/*relocation_model=*/CpuAotCompilationOptions::RelocationModel::Static};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/cpu/cpu_compiler.h"
#include "tensorflow/compiler/xla/service/cpu/tests/cpu_codegen_test.h"
#include "tensorflow/compiler/xla/service/hlo_parser.h"
#include "tensorflow/compiler/xla/service/cpu/test_target_triple_helper.h"

namespace xla {
namespace cpu {
Expand Down Expand Up @@ -64,7 +65,7 @@ CHECK-NOT: private unnamed_addr constant [48 x i8]
ParseAndReturnVerifiedModule(hlo_text));

CpuAotCompilationOptions options{
/*triple=*/"x86_64-pc-linux", /*cpu_name=*/"", /*features=*/"",
/*triple=*/kTargetTripleForHost, /*cpu_name=*/kTargetCpuForHost, /*features=*/"",
/*entry_point_name=*/"entry",
/*relocation_model=*/CpuAotCompilationOptions::RelocationModel::Static};

Expand Down Expand Up @@ -112,7 +113,7 @@ CHECK-NOT: private unnamed_addr constant [8 x i8]
ParseAndReturnVerifiedModule(hlo_text));

CpuAotCompilationOptions options{
/*triple=*/"x86_64-pc-linux", /*cpu_name=*/"", /*features=*/"",
/*triple=*/kTargetTripleForHost, /*cpu_name=*/kTargetCpuForHost, /*features=*/"",
/*entry_point_name=*/"entry",
/*relocation_model=*/CpuAotCompilationOptions::RelocationModel::Static};

Expand Down
5 changes: 3 additions & 2 deletions tensorflow/compiler/xla/service/cpu/tests/cpu_outfeed_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.

#include "tensorflow/compiler/xla/service/cpu/cpu_compiler.h"
#include "tensorflow/compiler/xla/service/cpu/tests/cpu_codegen_test.h"
#include "tensorflow/compiler/xla/service/cpu/test_target_triple_helper.h"

namespace xla {
namespace cpu {
Expand Down Expand Up @@ -46,7 +47,7 @@ CHECK: private unnamed_addr constant [48 x i8]
TF_ASSERT_OK_AND_ASSIGN(auto module, ParseAndReturnVerifiedModule(hlo_text));

CpuAotCompilationOptions options{
/*triple=*/"x86_64-pc-linux", /*cpu_name=*/"", /*features=*/"",
/*triple=*/kTargetTripleForHost, /*cpu_name=*/kTargetCpuForHost, /*features=*/"",
/*entry_point_name=*/"entry",
/*relocation_model=*/CpuAotCompilationOptions::RelocationModel::Static};

Expand All @@ -73,7 +74,7 @@ CHECK: Outfeed
TF_ASSERT_OK_AND_ASSIGN(auto module, ParseAndReturnVerifiedModule(hlo_text));

CpuAotCompilationOptions options{
/*triple=*/"x86_64-pc-linux", /*cpu_name=*/"", /*features=*/"",
/*triple=*/kTargetTripleForHost, /*cpu_name=*/kTargetCpuForHost, /*features=*/"",
/*entry_point_name=*/"entry",
/*relocation_model=*/CpuAotCompilationOptions::RelocationModel::Static};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ limitations under the License.
#include "tensorflow/compiler/xla/service/cpu/cpu_compiler.h"
#include "tensorflow/compiler/xla/test.h"
#include "tensorflow/compiler/xla/tests/hlo_test_base.h"
#include "tensorflow/compiler/xla/service/cpu/test_target_triple_helper.h"

namespace xla {
namespace {
Expand Down Expand Up @@ -75,7 +76,7 @@ ENTRY main {

// Check that the GetTargetVectorRegisterByteSize is itself working.
TF_ASSERT_OK_AND_ASSIGN(unsigned vector_register_byte_size_for_x86_64,
GetTargetVectorRegisterByteSize("x86_64-pc-linux"));
GetTargetVectorRegisterByteSize(kTargetTripleForHost));
ASSERT_EQ(vector_register_byte_size_for_x86_64, 16);

std::string triple = "i686-none-android";
Expand Down
2 changes: 2 additions & 0 deletions tensorflow/compiler/xla/tests/local_client_aot_test_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ int main(int argc, char** argv) {
triple_string = "aarch64-none-linux-gnu";
} else if (target_cpu == "x64_windows") {
triple_string = "x86_64-pc-windows-msvc19";
} else if (target_cpu == "ppc") {
triple_string = "ppc64le-ibm-linux-gnu";
sanjoy marked this conversation as resolved.
Show resolved Hide resolved
} else if (target_cpu == "local") {
triple_string = llvm::sys::getDefaultTargetTriple();
} else {
Expand Down