Skip to content

Commit

Permalink
Remove some unused code from csrc/runtime (pytorch#5785)
Browse files Browse the repository at this point in the history
* delete nccl_distributed

* remove async_task

* remove unique

* Remove hashing

* more random cleanup

* formatting

* remove util.cc

* Revert "remove unique"

This reverts commit ebe4567.

* Use upstream Unique
  • Loading branch information
will-cromar authored and chunnienc committed Dec 14, 2023
1 parent c7a04ac commit bc712f8
Show file tree
Hide file tree
Showing 20 changed files with 28 additions and 703 deletions.
2 changes: 0 additions & 2 deletions torch_xla/csrc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,8 @@ ptxla_cc_library(
":layout_manager",
":shape_builder",
":shape_helper",
"//torch_xla/csrc/runtime:async_task",
"//torch_xla/csrc/runtime",
"//torch_xla/csrc/runtime:stablehlo_helper",
"//torch_xla/csrc/runtime:unique",
"//torch_xla/csrc/runtime:xla_util",
"@com_google_absl//absl/hash",
"@com_google_absl//absl/memory",
Expand Down
6 changes: 3 additions & 3 deletions torch_xla/csrc/debug_util.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "torch_xla/csrc/debug_util.h"

#include <torch/csrc/lazy/core/hash.h>
#include <torch/csrc/lazy/core/unique.h>
#include <torch/csrc/lazy/python/python_util.h>

#include <fstream>
Expand All @@ -17,7 +18,6 @@
#include "torch_xla/csrc/ir_dump_util.h"
#include "torch_xla/csrc/runtime/debug_macros.h"
#include "torch_xla/csrc/runtime/sys_util.h"
#include "torch_xla/csrc/runtime/unique.h"
#include "torch_xla/csrc/xla_graph_executor.h"

namespace torch_xla {
Expand Down Expand Up @@ -61,7 +61,7 @@ std::string DebugUtil::GetTensorsGraphHlo(
absl::Span<const XLATensorPtr> tensors, const std::vector<size_t>* indices,
bool dump_stablehlo) {
std::vector<torch::lazy::Value> root_values;
runtime::util::Unique<torch::lazy::BackendDevice> unique_device;
torch::lazy::Unique<torch::lazy::BackendDevice> unique_device;
if (indices != nullptr) {
for (auto index : *indices) {
const XLATensorPtr& tensor = tensors[index];
Expand Down Expand Up @@ -91,7 +91,7 @@ std::string DebugUtil::GetTensorsGraphInfo(
std::vector<const torch::lazy::Node*> root_nodes;
std::vector<torch::lazy::Value> root_values;
std::vector<torch::lazy::hash_t> root_hashes;
runtime::util::Unique<torch::lazy::BackendDevice> unique_device;
torch::lazy::Unique<torch::lazy::BackendDevice> unique_device;
if (indices != nullptr) {
for (auto index : *indices) {
const XLATensorPtr& tensor = tensors[index];
Expand Down
3 changes: 2 additions & 1 deletion torch_xla/csrc/layout_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class LayoutManager {

struct DimensionsHasher {
size_t operator()(const absl::Span<const int64_t>& dimensions) const {
return runtime::util::HashReduce(runtime::util::MHash(dimensions));
return torch::lazy::HashReduce(torch::lazy::MHash(
std::vector<int64_t>({dimensions.begin(), dimensions.end()})));
}
};

Expand Down
52 changes: 7 additions & 45 deletions torch_xla/csrc/runtime/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,15 @@ load(
"if_cuda_is_configured",
)

load(
"//bazel:rules_def.bzl",
"ptxla_cc_test",
)

licenses(["notice"]) # Apache 2.0

package(default_visibility = ["//visibility:public"])

cc_library(
name = "async_task",
hdrs = ["async_task.h"],
deps = [
":debug_macros",
":thread_pool",
"@com_google_absl//absl/types:optional",
],
)

cc_test(
name = "async_task_test",
size = "small",
srcs = ["async_task_test.cc"],
deps = [
":async_task",
"@com_google_googletest//:gtest_main",
],
)

cc_library(
name = "runtime",
srcs = [
Expand Down Expand Up @@ -202,20 +187,6 @@ cc_library(
],
)

cc_library(
name = "nccl_distributed",
srcs = ["nccl_distributed.cc"],
hdrs = ["nccl_distributed.h"],
deps = [
":debug_macros",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:span",
"@xla//xla:types",
] + if_cuda_is_configured([
"@local_config_nccl//:nccl",
]),
)

cc_library(
name = "profiler",
srcs = ["profiler.cc"],
Expand Down Expand Up @@ -303,18 +274,8 @@ cc_library(
],
)

cc_library(
name = "unique",
hdrs = ["unique.h"],
deps = [
":debug_macros",
"@com_google_absl//absl/types:optional",
],
)

cc_library(
name = "util",
srcs = ["util.cc"],
hdrs = ["util.h"],
deps = [
":types",
Expand Down Expand Up @@ -357,10 +318,11 @@ cc_library(
"@xla//xla/service:platform_util",
"@xla//xla/service/spmd:spmd_partitioner",
"@tsl//tsl/platform:errors",
"@torch//:headers",
],
)

cc_test(
ptxla_cc_test(
name = "xla_util_test",
size = "small",
srcs = ["xla_util_test.cc"],
Expand Down
93 changes: 0 additions & 93 deletions torch_xla/csrc/runtime/async_task.h

This file was deleted.

65 changes: 0 additions & 65 deletions torch_xla/csrc/runtime/async_task_test.cc

This file was deleted.

71 changes: 0 additions & 71 deletions torch_xla/csrc/runtime/nccl_distributed.cc

This file was deleted.

19 changes: 0 additions & 19 deletions torch_xla/csrc/runtime/nccl_distributed.h

This file was deleted.

Loading

0 comments on commit bc712f8

Please sign in to comment.