mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-19 11:36:41 +00:00
[mlir][sparse] Moving Enums.h into Dialect/SparseTensor/IR
Move the SparseTensorEnums library out of the ExecutionEngine directory and into Dialect/SparseTensor/IR. Depends On D136002 Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D136005
This commit is contained in:
parent
67957368ae
commit
062f29c8d0
@ -1,4 +1,4 @@
|
||||
//===- Enums.h - Enums shared with the runtime ------------------*- C++ -*-===//
|
||||
//===- Enums.h - Enums for the SparseTensor dialect -------------*- C++ -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
@ -6,25 +6,27 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Typedefs and enums for the lightweight runtime support library for
|
||||
// sparse tensor manipulations. These are required to be public so that
|
||||
// they can be shared with `Transforms/SparseTensorConversion.cpp`, since
|
||||
// they define the arguments to the public functions declared later on.
|
||||
// Typedefs and enums shared between MLIR code for manipulating the
|
||||
// IR, and the lightweight runtime support library for sparse tensor
|
||||
// manipulations. That is, all the enums are used to define the API
|
||||
// of the runtime library and hence are also needed when generating
|
||||
// calls into the runtime library. Moveover, the `DimLevelType` enum
|
||||
// is also used as the internal IR encoding of dimension level types,
|
||||
// to avoid code duplication (e.g., for the predicates).
|
||||
//
|
||||
// This file also defines x-macros <https://en.wikipedia.org/wiki/X_Macro>
|
||||
// so that we can generate variations of the public functions for each
|
||||
// supported primary- and/or overhead-type.
|
||||
//
|
||||
// This file is part of the lightweight runtime support library for sparse
|
||||
// tensor manipulations. The functionality of the support library is meant
|
||||
// to simplify benchmarking, testing, and debugging MLIR code operating on
|
||||
// sparse tensors. However, the provided functionality is **not** part of
|
||||
// core MLIR itself.
|
||||
// Because this file defines a library which is a dependency of the
|
||||
// runtime library itself, this file must not depend on any MLIR internals
|
||||
// (e.g., operators, attributes, ArrayRefs, etc) lest the runtime library
|
||||
// inherit those dependencies.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef MLIR_EXECUTIONENGINE_SPARSETENSOR_ENUMS_H
|
||||
#define MLIR_EXECUTIONENGINE_SPARSETENSOR_ENUMS_H
|
||||
#ifndef MLIR_DIALECT_SPARSETENSOR_IR_ENUMS_H
|
||||
#define MLIR_DIALECT_SPARSETENSOR_IR_ENUMS_H
|
||||
|
||||
// NOTE: Client code will need to include "mlir/ExecutionEngine/Float16bits.h"
|
||||
// if they want to use the `MLIR_SPARSETENSOR_FOREVERY_V` macro.
|
||||
@ -128,9 +130,14 @@ enum class Action : uint32_t {
|
||||
kToIterator = 6,
|
||||
};
|
||||
|
||||
/// 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.
|
||||
/// This enum defines all the sparse representations supportable by
|
||||
/// the SparseTensor dialect. We use a lightweight encoding to encode
|
||||
/// both the "format" per se (dense, compressed, singleton) as well as
|
||||
/// the "properties" (ordered, unique). The encoding is chosen for
|
||||
/// performance of the runtime library, and thus may change in future
|
||||
/// versions; consequently, client code should use the predicate functions
|
||||
/// defined below, rather than relying on knowledge about the particular
|
||||
/// binary encoding.
|
||||
enum class DimLevelType : uint8_t {
|
||||
Dense = 4, // 0b001_00
|
||||
Compressed = 8, // 0b010_00
|
||||
@ -218,4 +225,4 @@ static_assert((isUniqueDLT(DimLevelType::Dense) &&
|
||||
} // namespace sparse_tensor
|
||||
} // namespace mlir
|
||||
|
||||
#endif // MLIR_EXECUTIONENGINE_SPARSETENSOR_ENUMS_H
|
||||
#endif // MLIR_DIALECT_SPARSETENSOR_IR_ENUMS_H
|
@ -9,7 +9,7 @@
|
||||
#ifndef MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSOR_H_
|
||||
#define MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSOR_H_
|
||||
|
||||
#include "mlir/ExecutionEngine/SparseTensor/Enums.h"
|
||||
#include "mlir/Dialect/SparseTensor/IR/Enums.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/Dialect.h"
|
||||
#include "mlir/IR/OpDefinition.h"
|
||||
|
@ -33,10 +33,10 @@
|
||||
#ifndef MLIR_EXECUTIONENGINE_SPARSETENSOR_STORAGE_H
|
||||
#define MLIR_EXECUTIONENGINE_SPARSETENSOR_STORAGE_H
|
||||
|
||||
#include "mlir/Dialect/SparseTensor/IR/Enums.h"
|
||||
#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"
|
||||
|
||||
namespace mlir {
|
||||
|
@ -15,9 +15,9 @@
|
||||
#ifndef MLIR_EXECUTIONENGINE_SPARSETENSORRUNTIME_H
|
||||
#define MLIR_EXECUTIONENGINE_SPARSETENSORRUNTIME_H
|
||||
|
||||
#include "mlir/Dialect/SparseTensor/IR/Enums.h"
|
||||
#include "mlir/ExecutionEngine/CRunnerUtils.h"
|
||||
#include "mlir/ExecutionEngine/Float16bits.h"
|
||||
#include "mlir/ExecutionEngine/SparseTensor/Enums.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <complex>
|
||||
|
@ -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/Dialect/SparseTensor/IR/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)
|
||||
|
||||
|
||||
add_mlir_dialect_library(MLIRSparseTensorDialect
|
||||
SparseTensorDialect.cpp
|
||||
|
||||
|
@ -17,9 +17,9 @@
|
||||
#include "mlir/Dialect/Complex/IR/Complex.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
|
||||
#include "mlir/Dialect/SparseTensor/IR/Enums.h"
|
||||
#include "mlir/Dialect/SparseTensor/IR/SparseTensor.h"
|
||||
#include "mlir/Dialect/Utils/ReshapeOpsUtils.h"
|
||||
#include "mlir/ExecutionEngine/SparseTensor/Enums.h"
|
||||
#include "mlir/IR/Builders.h"
|
||||
|
||||
namespace mlir {
|
||||
|
@ -23,10 +23,10 @@
|
||||
#include "mlir/Dialect/Linalg/Utils/Utils.h"
|
||||
#include "mlir/Dialect/MemRef/IR/MemRef.h"
|
||||
#include "mlir/Dialect/SCF/IR/SCF.h"
|
||||
#include "mlir/Dialect/SparseTensor/IR/Enums.h"
|
||||
#include "mlir/Dialect/SparseTensor/IR/SparseTensor.h"
|
||||
#include "mlir/Dialect/SparseTensor/Transforms/Passes.h"
|
||||
#include "mlir/Dialect/Tensor/IR/Tensor.h"
|
||||
#include "mlir/ExecutionEngine/SparseTensor/Enums.h"
|
||||
#include "mlir/Transforms/DialectConversion.h"
|
||||
|
||||
using namespace mlir;
|
||||
|
@ -1,23 +1,3 @@
|
||||
# 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`
|
||||
|
@ -2080,7 +2080,7 @@ gentbl_cc_library(
|
||||
# internals or else mlir_c_runner_utils will inherit that dependency.
|
||||
cc_library(
|
||||
name = "SparseTensorEnums",
|
||||
hdrs = ["include/mlir/ExecutionEngine/SparseTensor/Enums.h"],
|
||||
hdrs = ["include/mlir/Dialect/SparseTensor/IR/Enums.h"],
|
||||
includes = ["include"],
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user