//===- SparseTensorDescriptor.cpp -----------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "SparseTensorDescriptor.h" #include "CodegenUtils.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SparseTensor/IR/SparseTensor.h" #include "mlir/Dialect/SparseTensor/Transforms/Passes.h" #include "mlir/Transforms/DialectConversion.h" usingnamespacemlir; usingnamespacesparse_tensor; //===----------------------------------------------------------------------===// // Private helper methods. //===----------------------------------------------------------------------===// /// Constructs a nullable `LevelAttr` from the `std::optional<Level>`. static IntegerAttr optionalLevelAttr(MLIRContext *ctx, std::optional<Level> lvl) { … } // This is only ever called from `SparseTensorTypeToBufferConverter`, // which is why the first argument is `RankedTensorType` rather than // `SparseTensorType`. static std::optional<LogicalResult> convertSparseTensorType(RankedTensorType rtp, SmallVectorImpl<Type> &fields) { … } //===----------------------------------------------------------------------===// // The sparse tensor type converter (defined in Passes.h). //===----------------------------------------------------------------------===// SparseTensorTypeToBufferConverter::SparseTensorTypeToBufferConverter() { … } //===----------------------------------------------------------------------===// // StorageTensorSpecifier methods. //===----------------------------------------------------------------------===// Value SparseTensorSpecifier::getInitValue(OpBuilder &builder, Location loc, SparseTensorType stt) { … } Value SparseTensorSpecifier::getSpecifierField(OpBuilder &builder, Location loc, StorageSpecifierKind kind, std::optional<Level> lvl) { … } void SparseTensorSpecifier::setSpecifierField(OpBuilder &builder, Location loc, Value v, StorageSpecifierKind kind, std::optional<Level> lvl) { … } //===----------------------------------------------------------------------===// // SparseTensorDescriptor methods. //===----------------------------------------------------------------------===// Value sparse_tensor::SparseTensorDescriptor::getCrdMemRefOrView( OpBuilder &builder, Location loc, Level lvl) const { … }