diff --git a/mlir/include/mlir/ExecutionEngine/SparseTensor/File.h b/mlir/include/mlir/ExecutionEngine/SparseTensor/File.h index be1c4f72e120..78c1a0544e3a 100644 --- a/mlir/include/mlir/ExecutionEngine/SparseTensor/File.h +++ b/mlir/include/mlir/ExecutionEngine/SparseTensor/File.h @@ -1,4 +1,4 @@ -//===- File.h - Parsing sparse tensors from files ---------------*- C++ -*-===// +//===- File.h - Reading/writing sparse tensors from/to files ----*- 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,8 +6,8 @@ // //===----------------------------------------------------------------------===// // -// This file implements reading and writing files in one of the following -// external formats: +// This file implements reading and writing sparse tensor files in one of the +// following external formats: // // (1) Matrix Market Exchange (MME): *.mtx // https://math.nist.gov/MatrixMarket/formats.html diff --git a/mlir/lib/ExecutionEngine/SparseTensor/File.cpp b/mlir/lib/ExecutionEngine/SparseTensor/File.cpp index bb227bf2c2dd..c49ec0998fb4 100644 --- a/mlir/lib/ExecutionEngine/SparseTensor/File.cpp +++ b/mlir/lib/ExecutionEngine/SparseTensor/File.cpp @@ -1,4 +1,4 @@ -//===- File.cpp - Parsing sparse tensors from files -----------------------===// +//===- File.cpp - Reading/writing sparse tensors from/to files ------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,20 +6,7 @@ // //===----------------------------------------------------------------------===// // -// This file implements parsing and printing of files in one of the -// following external formats: -// -// (1) Matrix Market Exchange (MME): *.mtx -// https://math.nist.gov/MatrixMarket/formats.html -// -// (2) Formidable Repository of Open Sparse Tensors and Tools (FROSTT): *.tns -// http://frostt.io/tensors/file-formats.html -// -// 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. +// This file implements reading and writing sparse tensor files. // //===----------------------------------------------------------------------===// diff --git a/mlir/lib/ExecutionEngine/SparseTensor/NNZ.cpp b/mlir/lib/ExecutionEngine/SparseTensor/NNZ.cpp index c6fd669ad513..d3c3951c1546 100644 --- a/mlir/lib/ExecutionEngine/SparseTensor/NNZ.cpp +++ b/mlir/lib/ExecutionEngine/SparseTensor/NNZ.cpp @@ -8,19 +8,12 @@ // // This file contains method definitions for `SparseTensorNNZ`. // -// 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. -// //===----------------------------------------------------------------------===// #include "mlir/ExecutionEngine/SparseTensor/Storage.h" using namespace mlir::sparse_tensor; -//===----------------------------------------------------------------------===// SparseTensorNNZ::SparseTensorNNZ(const std::vector &lvlSizes, const std::vector &lvlTypes) : lvlSizes(lvlSizes), lvlTypes(lvlTypes), nnz(getLvlRank()) { diff --git a/mlir/lib/ExecutionEngine/SparseTensor/Storage.cpp b/mlir/lib/ExecutionEngine/SparseTensor/Storage.cpp index 2c4f0123ed44..77861e074e93 100644 --- a/mlir/lib/ExecutionEngine/SparseTensor/Storage.cpp +++ b/mlir/lib/ExecutionEngine/SparseTensor/Storage.cpp @@ -9,14 +9,7 @@ // This file contains method definitions for `SparseTensorStorageBase`. // In particular we want to ensure that the default implementations of // the "partial method specialization" trick aren't inline (since there's -// no benefit). Though this also helps ensure that we avoid weak-vtables: -// -// -// 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. +// no benefit). // //===----------------------------------------------------------------------===// @@ -32,10 +25,6 @@ SparseTensorStorageBase::SparseTensorStorageBase( // NOLINT lvlSizes(lvlSizes, lvlSizes + lvlRank), lvlTypes(lvlTypes, lvlTypes + lvlRank), lvl2dim(lvl2dim, lvl2dim + lvlRank) { - // TODO: If we do get any nullptrs, I'm pretty sure these assertions - // will run too late (i.e., after copying things into vectors above). - // But since those fields are const I'm not sure there's any clean way - // to assert things before copying... assert(dimSizes && "Got nullptr for dimension sizes"); assert(lvlSizes && "Got nullptr for level sizes"); assert(lvlTypes && "Got nullptr for level types"); @@ -44,18 +33,15 @@ SparseTensorStorageBase::SparseTensorStorageBase( // NOLINT assert(dimRank > 0 && "Trivial shape is unsupported"); for (uint64_t d = 0; d < dimRank; ++d) assert(dimSizes[d] > 0 && "Dimension size zero has trivial storage"); - // Validate level-indexed parameters. + // Validate lvl-indexed parameters. assert(lvlRank > 0 && "Trivial shape is unsupported"); for (uint64_t l = 0; l < lvlRank; ++l) { assert(lvlSizes[l] > 0 && "Level size zero has trivial storage"); - const auto dlt = lvlTypes[l]; // Avoid redundant bounds checking. - // We use `MLIR_SPARSETENSOR_FATAL` here instead of `assert` so that - // when this ctor is successful then all the methods can rely on the - // fact that each level-type satisfies one of these options (even - // when `NDEBUG` is true), thereby reducing the need to re-assert things. - if (!(isDenseDLT(dlt) || isCompressedDLT(dlt) || isSingletonDLT(dlt))) + const auto dlt = lvlTypes[l]; + if (!(isDenseDLT(dlt) || isCompressedDLT(dlt) || isSingletonDLT(dlt))) { MLIR_SPARSETENSOR_FATAL("unsupported level type: %d\n", static_cast(dlt)); + } } }