From aa41fd4432424a19d6e90b83a16c8beead3317fd Mon Sep 17 00:00:00 2001 From: Eugene Zhulenev Date: Thu, 2 May 2024 13:13:19 -0700 Subject: [PATCH] [xla:cpu] NFC: Remove deprecated XLA:CPU mlir based codegen part #5 PiperOrigin-RevId: 630156915 --- xla/mlir/memref/BUILD | 16 ----- xla/mlir/memref/transforms/BUILD | 40 ------------ .../memref/transforms/aligned_allocations.cc | 60 ----------------- xla/mlir/memref/transforms/passes.h | 37 ----------- xla/mlir/memref/transforms/passes.td | 39 ----------- xla/mlir/runtime/transforms/BUILD | 64 ------------------- 6 files changed, 256 deletions(-) delete mode 100644 xla/mlir/memref/BUILD delete mode 100644 xla/mlir/memref/transforms/BUILD delete mode 100644 xla/mlir/memref/transforms/aligned_allocations.cc delete mode 100644 xla/mlir/memref/transforms/passes.h delete mode 100644 xla/mlir/memref/transforms/passes.td diff --git a/xla/mlir/memref/BUILD b/xla/mlir/memref/BUILD deleted file mode 100644 index 7f628aefb16c1..0000000000000 --- a/xla/mlir/memref/BUILD +++ /dev/null @@ -1,16 +0,0 @@ -package_group( - name = "friends", - packages = [ - "//xla/mlir/...", - # copybara:uncomment_begin(google-only) - # # TODO(ezhulenev): Clean up dependencies that are leforvers from Autofusion project. - # "//third_party/py/enzyme_ad/...", - # copybara:uncomment_end(google-only) - ], -) - -package( - # copybara:uncomment default_applicable_licenses = ["//tensorflow:license"], - default_visibility = [":friends"], - licenses = ["notice"], -) diff --git a/xla/mlir/memref/transforms/BUILD b/xla/mlir/memref/transforms/BUILD deleted file mode 100644 index 237b64b4db43b..0000000000000 --- a/xla/mlir/memref/transforms/BUILD +++ /dev/null @@ -1,40 +0,0 @@ -load("@llvm-project//mlir:tblgen.bzl", "gentbl_cc_library") -load("@tsl//tsl/platform:rules_cc.bzl", "cc_library") -load("//xla/tsl:tsl.default.bzl", "get_compatible_with_portable") - -package( - # copybara:uncomment default_applicable_licenses = ["//tensorflow:license"], - default_visibility = ["//xla/mlir/memref:friends"], - licenses = ["notice"], -) - -gentbl_cc_library( - name = "passes_inc_gen", - compatible_with = get_compatible_with_portable(), - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=MemrefTransforms", - ], - "passes.h.inc", - ), - ], - tblgen = "@llvm-project//mlir:mlir-tblgen", - td_file = "passes.td", - deps = ["@llvm-project//mlir:PassBaseTdFiles"], -) - -cc_library( - name = "passes", - srcs = ["aligned_allocations.cc"], - hdrs = ["passes.h"], - compatible_with = get_compatible_with_portable(), - deps = [ - ":passes_inc_gen", - "@llvm-project//mlir:FuncDialect", - "@llvm-project//mlir:IR", - "@llvm-project//mlir:MemRefDialect", - "@llvm-project//mlir:Pass", - ], -) diff --git a/xla/mlir/memref/transforms/aligned_allocations.cc b/xla/mlir/memref/transforms/aligned_allocations.cc deleted file mode 100644 index 8cee23aec11e3..0000000000000 --- a/xla/mlir/memref/transforms/aligned_allocations.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright 2022 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 -#include -#include - -#include "mlir/Dialect/Func/IR/FuncOps.h" // from @llvm-project -#include "mlir/Dialect/MemRef/IR/MemRef.h" // from @llvm-project -#include "mlir/IR/BuiltinAttributes.h" // from @llvm-project -#include "mlir/IR/BuiltinTypes.h" // from @llvm-project -#include "mlir/Pass/Pass.h" // from @llvm-project -#include "xla/mlir/memref/transforms/passes.h" - -namespace xla { - -using namespace mlir; // NOLINT - -#define GEN_PASS_DEF_ALIGNEDALLOCATIONSPASS -#include "xla/mlir/memref/transforms/passes.h.inc" - -struct AlignedAllocationsPass - : public impl::AlignedAllocationsPassBase { - explicit AlignedAllocationsPass(int64_t alignment) { alignment_ = alignment; } - void runOnOperation() override; -}; - -void AlignedAllocationsPass::runOnOperation() { - assert(alignment_ >= 0 && "alignment must be larger or equal to 0"); - if (alignment_ == 0) return; - - auto i64 = IntegerType::get(&getContext(), 64); - auto alignment_attr = IntegerAttr::get(i64, alignment_); - - getOperation().walk([&](memref::AllocOp alloc) { - // Add alignment attribute only if the alignment attribute is missing or the - // current alignment is smaller. - if (!alloc.getAlignment().has_value() || *alloc.getAlignment() < alignment_) - alloc.setAlignmentAttr(alignment_attr); - }); -} - -std::unique_ptr> CreateAlignedAllocationsPass( - int64_t alignment) { - return std::make_unique(alignment); -} - -} // namespace xla diff --git a/xla/mlir/memref/transforms/passes.h b/xla/mlir/memref/transforms/passes.h deleted file mode 100644 index 05b6f5fec2aeb..0000000000000 --- a/xla/mlir/memref/transforms/passes.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2022 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_MLIR_MEMREF_TRANSFORMS_PASSES_H_ -#define XLA_MLIR_MEMREF_TRANSFORMS_PASSES_H_ - -#include - -#include "mlir/Dialect/Func/IR/FuncOps.h" // from @llvm-project -#include "mlir/Pass/Pass.h" // from @llvm-project - -namespace xla { - -#define GEN_PASS_DECL_ALIGNEDALLOCATIONSPASS -#include "xla/mlir/memref/transforms/passes.h.inc" - -std::unique_ptr> -CreateAlignedAllocationsPass(int64_t alignment = 64); - -#define GEN_PASS_REGISTRATION -#include "xla/mlir/memref/transforms/passes.h.inc" - -} // namespace xla - -#endif // XLA_MLIR_MEMREF_TRANSFORMS_PASSES_H_ diff --git a/xla/mlir/memref/transforms/passes.td b/xla/mlir/memref/transforms/passes.td deleted file mode 100644 index 8310e55556294..0000000000000 --- a/xla/mlir/memref/transforms/passes.td +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2022 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_MEMREF_PASSES -#define XLA_MEMREF_PASSES - -include "mlir/Pass/PassBase.td" - -def AlignedAllocationsPass - : Pass<"xla-memref-aligned-allocations", "mlir::func::FuncOp"> { - let summary = "Add alignment attribute to all `alloc` operations."; - - let description = [{ - This pass adds an alignment attribute to all `alloc` operations which don't - have such an attribute yet, or which have a smaller alignment than the one - configured for this pass. - }]; - - let constructor = "::xla::CreateAlignedAllocationsPass()"; - - let options = [ - Option<"alignment_", "alignment", "int64_t", "64", - "Byte alignment for allocated memrefs."> - ]; -} - -#endif // XLA_MEMREF_PASSES diff --git a/xla/mlir/runtime/transforms/BUILD b/xla/mlir/runtime/transforms/BUILD index 6969f7bdbf853..812513a59710b 100644 --- a/xla/mlir/runtime/transforms/BUILD +++ b/xla/mlir/runtime/transforms/BUILD @@ -2,7 +2,6 @@ load("@llvm-project//mlir:tblgen.bzl", "gentbl_cc_library") load( "@tsl//tsl/platform:build_config_root.bzl", "if_llvm_aarch64_available", - "if_llvm_arm_available", "if_llvm_powerpc_available", "if_llvm_system_z_available", "if_llvm_x86_available", @@ -103,69 +102,6 @@ xla_cc_test( ], ) -cc_library( - name = "compilation_pipeline_cpu", - srcs = ["compilation_pipeline_cpu.cc"], - hdrs = ["compilation_pipeline_cpu.h"], - compatible_with = get_compatible_with_portable(), - local_defines = select({ - "//xla/service/cpu:experimental_mlir_gpu_enabled": [ - "EXPERIMENTAL_MLIR_GPU=1", - ], - "//conditions:default": [], - }), - visibility = ["//visibility:public"], - deps = [ - ":compilation_pipeline_options", - ":compiler", - ":passes", - "//xla/mlir/memref/transforms:passes", - "//xla/mlir/runtime/ir:rt", - "//xla/mlir_hlo:transforms_passes", - "//xla/runtime:compiler", - "@llvm-project//mlir:AffineDialect", - "@llvm-project//mlir:AffineToStandard", - "@llvm-project//mlir:ArithDialect", - "@llvm-project//mlir:ArithTransforms", - "@llvm-project//mlir:AsyncDialect", - "@llvm-project//mlir:AsyncToLLVM", - "@llvm-project//mlir:AsyncTransforms", - "@llvm-project//mlir:BuiltinToLLVMIRTranslation", - "@llvm-project//mlir:ComplexToLLVM", - "@llvm-project//mlir:ControlFlowDialect", - "@llvm-project//mlir:FuncDialect", - "@llvm-project//mlir:FuncExtensions", - "@llvm-project//mlir:LLVMToLLVMIRTranslation", - "@llvm-project//mlir:LinalgDialect", - "@llvm-project//mlir:LinalgTransforms", - "@llvm-project//mlir:MathDialect", - "@llvm-project//mlir:MathToLLVM", - "@llvm-project//mlir:MemRefDialect", - "@llvm-project//mlir:MemRefToLLVM", - "@llvm-project//mlir:MemRefTransforms", - "@llvm-project//mlir:Pass", - "@llvm-project//mlir:ReconcileUnrealizedCasts", - "@llvm-project//mlir:SCFDialect", - "@llvm-project//mlir:SparseTensorDialect", - "@llvm-project//mlir:Transforms", - "@tsl//tsl/platform:logging", - ] + select({ - "//xla/service/cpu:experimental_mlir_gpu_enabled": [ - "@llvm-project//mlir:GPUToGPURuntimeTransforms", - "@llvm-project//mlir:GPUTransforms", - ], - "//conditions:default": [], - }) + if_llvm_aarch64_available([ - "@llvm-project//mlir:ArmSVEToLLVMIRTranslation", - ]) + if_llvm_arm_available([ - "@llvm-project//mlir:ArmNeonToLLVMIRTranslation", - ]) + if_llvm_x86_available([ - "@llvm-project//mlir:AMXToLLVMIRTranslation", - "@llvm-project//mlir:X86VectorToLLVMIRTranslation", - ]), - alwayslink = 1, # has pipeline registration -) - cc_library( name = "compilation_pipeline_options", hdrs = ["compilation_pipeline_options.h"],