[mlir][sparse] Removing DLL attributes from ExecutionEngine/SparseTensor/Enums.h
authorwren romano <2998727+wrengr@users.noreply.github.com>
Sat, 8 Oct 2022 01:17:27 +0000 (18:17 -0700)
committerwren romano <2998727+wrengr@users.noreply.github.com>
Mon, 10 Oct 2022 18:22:12 +0000 (11:22 -0700)
This differential attempts to resolve certain issues on Windows (e.g., https://reviews.llvm.org/D134933#3843372 and https://reviews.llvm.org/D133462#3844195).

Reviewed By: stella.stamenova, aganea

Differential Revision: https://reviews.llvm.org/D135502

mlir/include/mlir/ExecutionEngine/SparseTensor/Enums.h
mlir/lib/ExecutionEngine/SparseTensor/CMakeLists.txt
utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

index 14f52a5..1ead713 100644 (file)
 #include <cinttypes>
 #include <complex>
 
-#ifdef _WIN32
-#ifdef mlir_sparse_tensor_utils_EXPORTS // We are building this library
-#define MLIR_SPARSETENSOR_EXPORT __declspec(dllexport)
-#define MLIR_SPARSETENSOR_DEFINE_FUNCTIONS
-#else // We are using this library
-#define MLIR_SPARSETENSOR_EXPORT __declspec(dllimport)
-#endif // mlir_sparse_tensor_utils_EXPORTS
-#else  // Non-windows: use visibility attributes.
-#define MLIR_SPARSETENSOR_EXPORT __attribute__((visibility("default")))
-#define MLIR_SPARSETENSOR_DEFINE_FUNCTIONS
-#endif // _WIN32
-
 namespace mlir {
 namespace sparse_tensor {
 
@@ -55,7 +43,7 @@ using index_type = uint64_t;
 
 /// Encoding of overhead types (both pointer overhead and indices
 /// overhead), for "overloading" @newSparseTensor.
-enum class MLIR_SPARSETENSOR_EXPORT OverheadType : uint32_t {
+enum class OverheadType : uint32_t {
   kIndex = 0,
   kU64 = 1,
   kU32 = 2,
@@ -86,7 +74,7 @@ using complex64 = std::complex<double>;
 using complex32 = std::complex<float>;
 
 /// Encoding of the elemental type, for "overloading" @newSparseTensor.
-enum class MLIR_SPARSETENSOR_EXPORT PrimaryType : uint32_t {
+enum class PrimaryType : uint32_t {
   kF64 = 1,
   kF32 = 2,
   kF16 = 3,
@@ -112,27 +100,24 @@ enum class MLIR_SPARSETENSOR_EXPORT PrimaryType : uint32_t {
   DO(C64, complex64)                                                           \
   DO(C32, complex32)
 
-constexpr MLIR_SPARSETENSOR_EXPORT bool
-isFloatingPrimaryType(PrimaryType valTy) {
+constexpr bool isFloatingPrimaryType(PrimaryType valTy) {
   return PrimaryType::kF64 <= valTy && valTy <= PrimaryType::kBF16;
 }
 
-constexpr MLIR_SPARSETENSOR_EXPORT bool
-isIntegralPrimaryType(PrimaryType valTy) {
+constexpr bool isIntegralPrimaryType(PrimaryType valTy) {
   return PrimaryType::kI64 <= valTy && valTy <= PrimaryType::kI8;
 }
 
-constexpr MLIR_SPARSETENSOR_EXPORT bool isRealPrimaryType(PrimaryType valTy) {
+constexpr bool isRealPrimaryType(PrimaryType valTy) {
   return PrimaryType::kF64 <= valTy && valTy <= PrimaryType::kI8;
 }
 
-constexpr MLIR_SPARSETENSOR_EXPORT bool
-isComplexPrimaryType(PrimaryType valTy) {
+constexpr bool isComplexPrimaryType(PrimaryType valTy) {
   return PrimaryType::kC64 <= valTy && valTy <= PrimaryType::kC32;
 }
 
 /// The actions performed by @newSparseTensor.
-enum class MLIR_SPARSETENSOR_EXPORT Action : uint32_t {
+enum class Action : uint32_t {
   kEmpty = 0,
   kFromFile = 1,
   kFromCOO = 2,
@@ -145,7 +130,7 @@ enum class MLIR_SPARSETENSOR_EXPORT Action : uint32_t {
 /// This enum mimics `SparseTensorEncodingAttr::DimLevelType` for
 /// breaking dependency cycles.  `SparseTensorEncodingAttr::DimLevelType`
 /// is the source of truth and this enum should be kept consistent with it.
-enum class MLIR_SPARSETENSOR_EXPORT DimLevelType : uint8_t {
+enum class DimLevelType : uint8_t {
   kDense = 4,           // 0b001_00
   kCompressed = 8,      // 0b010_00
   kCompressedNu = 9,    // 0b010_01
@@ -158,29 +143,29 @@ enum class MLIR_SPARSETENSOR_EXPORT DimLevelType : uint8_t {
 };
 
 /// Check if the `DimLevelType` is dense.
-constexpr MLIR_SPARSETENSOR_EXPORT bool isDenseDLT(DimLevelType dlt) {
+constexpr bool isDenseDLT(DimLevelType dlt) {
   return dlt == DimLevelType::kDense;
 }
 
 /// Check if the `DimLevelType` is compressed (regardless of properties).
-constexpr MLIR_SPARSETENSOR_EXPORT bool isCompressedDLT(DimLevelType dlt) {
+constexpr bool isCompressedDLT(DimLevelType dlt) {
   return static_cast<uint8_t>(dlt) &
          static_cast<uint8_t>(DimLevelType::kCompressed);
 }
 
 /// Check if the `DimLevelType` is singleton (regardless of properties).
-constexpr MLIR_SPARSETENSOR_EXPORT bool isSingletonDLT(DimLevelType dlt) {
+constexpr bool isSingletonDLT(DimLevelType dlt) {
   return static_cast<uint8_t>(dlt) &
          static_cast<uint8_t>(DimLevelType::kSingleton);
 }
 
 /// Check if the `DimLevelType` is ordered (regardless of storage format).
-constexpr MLIR_SPARSETENSOR_EXPORT bool isOrderedDLT(DimLevelType dlt) {
+constexpr bool isOrderedDLT(DimLevelType dlt) {
   return !(static_cast<uint8_t>(dlt) & 2);
 }
 
 /// Check if the `DimLevelType` is unique (regardless of storage format).
-constexpr MLIR_SPARSETENSOR_EXPORT bool isUniqueDLT(DimLevelType dlt) {
+constexpr bool isUniqueDLT(DimLevelType dlt) {
   return !(static_cast<uint8_t>(dlt) & 1);
 }
 
index 89b1b2d..cf18a8c 100644 (file)
@@ -11,7 +11,6 @@ add_mlir_library(mlir_sparse_tensor_utils
   mlir_float16_utils
   )
 set_property(TARGET mlir_sparse_tensor_utils PROPERTY CXX_STANDARD 17)
-target_compile_definitions(mlir_sparse_tensor_utils PRIVATE mlir_sparse_tensor_utils_EXPORTS)
 
 # To make sure we adhere to the style guide:
 # <https://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers>
index 301d5fb..39014d6 100644 (file)
@@ -6721,7 +6721,6 @@ cc_library(
         "include/mlir/ExecutionEngine/SparseTensor/File.h",
         "include/mlir/ExecutionEngine/SparseTensor/Storage.h",
     ],
-    copts = ["-Dmlir_sparse_tensor_utils_EXPORTS"],
     includes = ["include"],
     deps = [":mlir_float16_utils"],
 )