Skip to content

Commit

Permalink
Review comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
npanpaliya committed Jun 4, 2020
1 parent 0ca0c44 commit bdf6adf
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 8 deletions.
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 2017 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__))
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
4 changes: 4 additions & 0 deletions tensorflow/compiler/xla/service/cpu/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ tf_cc_test(
"//tensorflow/compiler/xla/service:hlo",
"//tensorflow/compiler/xla/service/cpu:cpu_compiler",
"//tensorflow/compiler/xla/service/cpu/tests:cpu_codegen_test",
"//tensorflow/compiler/xla/service/cpu:test_header_helper",
"//tensorflow/core:lib",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
Expand Down Expand Up @@ -216,6 +217,7 @@ tf_cc_test(
"//tensorflow/compiler/xla/service:hlo_parser",
"//tensorflow/compiler/xla/service/cpu:cpu_compiler",
"//tensorflow/compiler/xla/service/cpu/tests:cpu_codegen_test",
"//tensorflow/compiler/xla/service/cpu:test_header_helper",
"//tensorflow/core:lib",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
Expand All @@ -229,6 +231,7 @@ tf_cc_test(
"//tensorflow/compiler/xla/service:hlo",
"//tensorflow/compiler/xla/service/cpu:cpu_compiler",
"//tensorflow/compiler/xla/service/cpu/tests:cpu_codegen_test",
"//tensorflow/compiler/xla/service/cpu:test_header_helper",
"//tensorflow/core:lib",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
Expand All @@ -242,6 +245,7 @@ tf_cc_test(
"//tensorflow/compiler/xla/service:hlo",
"//tensorflow/compiler/xla/service/cpu:cpu_compiler",
"//tensorflow/compiler/xla/service/cpu/tests:cpu_codegen_test",
"//tensorflow/compiler/xla/service/cpu:test_header_helper",
"//tensorflow/core:lib",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
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";
} else if (target_cpu == "local") {
triple_string = llvm::sys::getDefaultTargetTriple();
} else {
Expand Down

0 comments on commit bdf6adf

Please sign in to comment.