-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move XLA:CPU plugin API integration point into the PJRT Plugin direct…
…ory. PiperOrigin-RevId: 694571064
- Loading branch information
1 parent
d9e4ec5
commit a6d880d
Showing
6 changed files
with
138 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
load("@tsl//tsl/platform:rules_cc.bzl", "cc_library") | ||
load("//xla:xla.bzl", "xla_cc_test") | ||
|
||
package( | ||
# copybara:uncomment default_applicable_licenses = ["//tensorflow:license"], | ||
default_visibility = ["//visibility:public"], | ||
licenses = ["notice"], | ||
) | ||
|
||
cc_library( | ||
name = "xla_cpu_pjrt_client", | ||
srcs = [ | ||
"xla_cpu_pjrt_client.cc", | ||
], | ||
hdrs = ["xla_cpu_pjrt_client.h"], | ||
deps = [ | ||
"//xla/pjrt:pjrt_client", | ||
"//xla/pjrt/cpu:cpu_client", | ||
"@com_google_absl//absl/status:statusor", | ||
], | ||
) | ||
|
||
xla_cc_test( | ||
name = "xla_cpu_pjrt_client_test", | ||
srcs = ["xla_cpu_pjrt_client_test.cc"], | ||
deps = [ | ||
":xla_cpu_pjrt_client", | ||
"//xla/pjrt:pjrt_client", | ||
"//xla/pjrt/cpu:cpu_client", | ||
"//xla/tests:xla_internal_test_main", | ||
"@tsl//tsl/platform:statusor", | ||
"@tsl//tsl/platform:test", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Public PJRT entry point for XLA:CPU. Please use PJRT to access XLA:CPU | ||
functionality. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* Copyright 2024 The OpenXLA Authors. | ||
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. | ||
==============================================================================*/ | ||
|
||
#include "xla/pjrt/plugin/xla_cpu/xla_cpu_pjrt_client.h" | ||
|
||
#include <memory> | ||
|
||
#include "absl/status/statusor.h" | ||
#include "xla/pjrt/cpu/cpu_client.h" | ||
#include "xla/pjrt/pjrt_client.h" | ||
|
||
namespace xla { | ||
|
||
absl::StatusOr<std::unique_ptr<PjRtClient>> GetXlaPjrtCpuClient( | ||
CpuClientOptions options) { | ||
// TODO(masonchang): Wrap the TFRTCPU Client inside the PJRT Sandwich | ||
return xla::GetTfrtCpuClient(options); | ||
} | ||
|
||
} // namespace xla |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* Copyright 2024 The OpenXLA Authors. | ||
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 XLA_PJRT_PLUGIN_XLA_CPU_XLA_CPU_PJRT_CLIENT_H_ | ||
#define XLA_PJRT_PLUGIN_XLA_CPU_XLA_CPU_PJRT_CLIENT_H_ | ||
|
||
#include <memory> | ||
|
||
#include "absl/status/statusor.h" | ||
#include "xla/pjrt/cpu/cpu_client.h" | ||
#include "xla/pjrt/pjrt_client.h" | ||
|
||
namespace xla { | ||
|
||
// Public entry point to get an XLA:CPU PjRtClient | ||
absl::StatusOr<std::unique_ptr<PjRtClient>> GetXlaPjrtCpuClient( | ||
CpuClientOptions options); | ||
|
||
} // namespace xla | ||
|
||
#endif // XLA_PJRT_PLUGIN_XLA_CPU_XLA_CPU_PJRT_CLIENT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* Copyright 2024 The OpenXLA Authors. | ||
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. | ||
==============================================================================*/ | ||
|
||
#include "xla/pjrt/plugin/xla_cpu/xla_cpu_pjrt_client.h" | ||
|
||
#include "xla/pjrt/cpu/cpu_client.h" | ||
#include "xla/pjrt/pjrt_client.h" | ||
#include "tsl/platform/statusor.h" | ||
#include "tsl/platform/test.h" | ||
|
||
namespace xla { | ||
|
||
TEST(XlaCpuPjrtClientTest, GetXlaPjrtCpuClient) { | ||
TF_ASSERT_OK_AND_ASSIGN(auto client, GetXlaPjrtCpuClient(CpuClientOptions())); | ||
EXPECT_EQ(client->platform_name(), "cpu"); | ||
} | ||
|
||
} // namespace xla |