[Mlir-commits] [mlir] 181b04d - [mlir][sparse] Factoring out SparseTensorEnums library
wren romano
llvmlistbot at llvm.org
Tue Oct 18 14:20:41 PDT 2022
Author: wren romano
Date: 2022-10-18T14:20:33-07:00
New Revision: 181b04d276a8976e6ec60bbe178ccaf479ced655
URL: https://github.com/llvm/llvm-project/commit/181b04d276a8976e6ec60bbe178ccaf479ced655
DIFF: https://github.com/llvm/llvm-project/commit/181b04d276a8976e6ec60bbe178ccaf479ced655.diff
LOG: [mlir][sparse] Factoring out SparseTensorEnums library
This differential splits the SparseTensorEnums library out from the SparseTensorRuntime library. The actual moving of files will be handled in the next differential.
Depends On D135996
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D136002
Added:
Modified:
mlir/include/mlir/ExecutionEngine/SparseTensor/Enums.h
mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h
mlir/include/mlir/ExecutionEngine/SparseTensorRuntime.h
mlir/lib/Dialect/SparseTensor/IR/CMakeLists.txt
mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt
mlir/lib/ExecutionEngine/CMakeLists.txt
mlir/lib/ExecutionEngine/SparseTensor/CMakeLists.txt
utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
Removed:
################################################################################
diff --git a/mlir/include/mlir/ExecutionEngine/SparseTensor/Enums.h b/mlir/include/mlir/ExecutionEngine/SparseTensor/Enums.h
index 8dd0a2e1094fb..716c8abc58eb1 100644
--- a/mlir/include/mlir/ExecutionEngine/SparseTensor/Enums.h
+++ b/mlir/include/mlir/ExecutionEngine/SparseTensor/Enums.h
@@ -26,7 +26,8 @@
#ifndef MLIR_EXECUTIONENGINE_SPARSETENSOR_ENUMS_H
#define MLIR_EXECUTIONENGINE_SPARSETENSOR_ENUMS_H
-#include "mlir/ExecutionEngine/Float16bits.h"
+// NOTE: Client code will need to include "mlir/ExecutionEngine/Float16bits.h"
+// if they want to use the `MLIR_SPARSETENSOR_FOREVERY_V` macro.
#include <cinttypes>
#include <complex>
diff --git a/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h b/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h
index c85e2c11f1566..0d733bdc1fd9c 100644
--- a/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h
+++ b/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h
@@ -33,6 +33,7 @@
#ifndef MLIR_EXECUTIONENGINE_SPARSETENSOR_STORAGE_H
#define MLIR_EXECUTIONENGINE_SPARSETENSOR_STORAGE_H
+#include "mlir/ExecutionEngine/Float16bits.h"
#include "mlir/ExecutionEngine/SparseTensor/COO.h"
#include "mlir/ExecutionEngine/SparseTensor/CheckedMul.h"
#include "mlir/ExecutionEngine/SparseTensor/Enums.h"
diff --git a/mlir/include/mlir/ExecutionEngine/SparseTensorRuntime.h b/mlir/include/mlir/ExecutionEngine/SparseTensorRuntime.h
index ba2dc51bb3b93..58d68f76b5051 100644
--- a/mlir/include/mlir/ExecutionEngine/SparseTensorRuntime.h
+++ b/mlir/include/mlir/ExecutionEngine/SparseTensorRuntime.h
@@ -16,6 +16,7 @@
#define MLIR_EXECUTIONENGINE_SPARSETENSORRUNTIME_H
#include "mlir/ExecutionEngine/CRunnerUtils.h"
+#include "mlir/ExecutionEngine/Float16bits.h"
#include "mlir/ExecutionEngine/SparseTensor/Enums.h"
#include <cinttypes>
diff --git a/mlir/lib/Dialect/SparseTensor/IR/CMakeLists.txt b/mlir/lib/Dialect/SparseTensor/IR/CMakeLists.txt
index 27d2cdefb9c0a..0e69813e840ba 100644
--- a/mlir/lib/Dialect/SparseTensor/IR/CMakeLists.txt
+++ b/mlir/lib/Dialect/SparseTensor/IR/CMakeLists.txt
@@ -14,5 +14,5 @@ add_mlir_dialect_library(MLIRSparseTensorDialect
MLIRIR
MLIRInferTypeOpInterface
MLIRSupport
- MLIRSparseTensorRuntime
+ MLIRSparseTensorEnums
)
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt b/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt
index 8d8c84a2001b6..eafee08ae05ea 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt
@@ -31,6 +31,7 @@ add_mlir_dialect_library(MLIRSparseTensorTransforms
MLIRSCFTransforms
MLIRSCFUtils
MLIRSparseTensorDialect
+ MLIRSparseTensorEnums
MLIRSparseTensorUtils
MLIRTensorDialect
MLIRTransforms
diff --git a/mlir/lib/ExecutionEngine/CMakeLists.txt b/mlir/lib/ExecutionEngine/CMakeLists.txt
index 1449bdffd7a23..f8778cdf3a1eb 100644
--- a/mlir/lib/ExecutionEngine/CMakeLists.txt
+++ b/mlir/lib/ExecutionEngine/CMakeLists.txt
@@ -137,6 +137,8 @@ add_mlir_library(mlir_c_runner_utils
EXCLUDE_FROM_LIBMLIR
LINK_LIBS PUBLIC
+ mlir_float16_utils
+ MLIRSparseTensorEnums
MLIRSparseTensorRuntime
)
set_property(TARGET mlir_c_runner_utils PROPERTY CXX_STANDARD 17)
diff --git a/mlir/lib/ExecutionEngine/SparseTensor/CMakeLists.txt b/mlir/lib/ExecutionEngine/SparseTensor/CMakeLists.txt
index 3e8993c1af192..01b0793e67364 100644
--- a/mlir/lib/ExecutionEngine/SparseTensor/CMakeLists.txt
+++ b/mlir/lib/ExecutionEngine/SparseTensor/CMakeLists.txt
@@ -1,3 +1,23 @@
+# This library is shared by both MLIRSparseTensorDialect and
+# MLIRSparseTensorRuntime, so it must not depend on any of the MLIR/LLVM
+# internals or else mlir_c_runner_utils will inherit that dependency.
+#
+# Because this is a header-only (`INTERFACE`) library, we cannot use
+# the `add_mlir_library` function. So we do our best to replicate the
+# relevant portions below. If doing so becomes too complicated, then
+# we should adjust the `add_mlir_library` function to also work for
+# `INTERFACE` libraries.
+set(MLIRSparseTensorEnums_srcs
+ ${MLIR_MAIN_INCLUDE_DIR}/mlir/ExecutionEngine/SparseTensor/Enums.h)
+add_library(MLIRSparseTensorEnums INTERFACE ${MLIRSparseTensorEnums_srcs})
+if(MSVC_IDE OR XCODE)
+ set_source_files_properties(${MLIRSparseTensorEnums_srcs}
+ PROPERTIES HEADER_FILE_ONLY ON)
+endif()
+add_mlir_library_install(MLIRSparseTensorEnums)
+set_property(TARGET MLIRSparseTensorEnums PROPERTY CXX_STANDARD 17)
+
+
# Unlike mlir_float16_utils, mlir_c_runner_utils, etc, we do *not* make
# this a shared library: because doing so causes issues when building
# on Windows. In particular, various functions take/return `std::vector`
@@ -13,6 +33,7 @@ add_mlir_library(MLIRSparseTensorRuntime
EXCLUDE_FROM_LIBMLIR
LINK_LIBS PUBLIC
+ MLIRSparseTensorEnums
mlir_float16_utils
)
set_property(TARGET MLIRSparseTensorRuntime PROPERTY CXX_STANDARD 17)
diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
index db39d9c59c35a..e1a463b8fab98 100644
--- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
@@ -2075,6 +2075,15 @@ gentbl_cc_library(
deps = [":PassBaseTdFiles"],
)
+# This library is shared by both SparseTensorDialect and
+# SparseTensorRuntime, so it must not depend on any of the MLIR/LLVM
+# internals or else mlir_c_runner_utils will inherit that dependency.
+cc_library(
+ name = "SparseTensorEnums",
+ hdrs = ["include/mlir/ExecutionEngine/SparseTensor/Enums.h"],
+ includes = ["include"],
+)
+
cc_library(
name = "SparseTensorDialect",
srcs = ["lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp"],
@@ -2085,8 +2094,8 @@ cc_library(
":IR",
":InferTypeOpInterface",
":SparseTensorAttrDefsIncGen",
+ ":SparseTensorEnums",
":SparseTensorOpsIncGen",
- ":SparseTensorRuntime",
"//llvm:Support",
],
)
@@ -2137,8 +2146,8 @@ cc_library(
":SCFDialect",
":SCFTransforms",
":SparseTensorDialect",
+ ":SparseTensorEnums",
":SparseTensorPassIncGen",
- ":SparseTensorRuntime",
":SparseTensorUtils",
":Support",
":TensorDialect",
@@ -6755,10 +6764,6 @@ cc_binary(
# pragma, therefore it cannot be safely/correctly used across DLL boundaries.
# Consequently, we avoid using the "mlir_xxx_utils" naming scheme,
# since that is reserved/intended for shared libraries only.
-#
-# We relist Float16bits.h because Enums.h includes it; rather than
-# forcing all direct-dependants state that they also directly-depend
-# on :mlir_float16_utils (to satisfy the layering_check).
cc_library(
name = "SparseTensorRuntime",
srcs = [
@@ -6767,20 +6772,19 @@ cc_library(
"lib/ExecutionEngine/SparseTensor/Storage.cpp",
],
hdrs = [
- "include/mlir/ExecutionEngine/Float16bits.h",
"include/mlir/ExecutionEngine/SparseTensor/COO.h",
"include/mlir/ExecutionEngine/SparseTensor/CheckedMul.h",
- "include/mlir/ExecutionEngine/SparseTensor/Enums.h",
"include/mlir/ExecutionEngine/SparseTensor/ErrorHandling.h",
"include/mlir/ExecutionEngine/SparseTensor/File.h",
"include/mlir/ExecutionEngine/SparseTensor/Storage.h",
],
includes = ["include"],
- deps = [":mlir_float16_utils"],
+ deps = [
+ ":SparseTensorEnums",
+ ":mlir_float16_utils",
+ ],
)
-# We relist Enums.h because SparseTensorRuntime.h includes/reexports it
-# as part of the public API.
cc_library(
name = "_mlir_c_runner_utils",
srcs = [
@@ -6790,11 +6794,14 @@ cc_library(
hdrs = [
"include/mlir/ExecutionEngine/CRunnerUtils.h",
"include/mlir/ExecutionEngine/Msan.h",
- "include/mlir/ExecutionEngine/SparseTensor/Enums.h",
"include/mlir/ExecutionEngine/SparseTensorRuntime.h",
],
includes = ["include"],
- deps = [":SparseTensorRuntime"],
+ deps = [
+ ":SparseTensorEnums",
+ ":SparseTensorRuntime",
+ ":mlir_float16_utils",
+ ],
)
# Indirection to avoid 'libmlir_c_runner_utils.so' filename clash.
More information about the Mlir-commits
mailing list