[all-commits] [llvm/llvm-project] 84cd51: [mlir][sparse] Renaming "pointer/index" to "positi...

wren romano via All-commits all-commits at lists.llvm.org
Mon Mar 6 12:23:59 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 84cd51bb97d5014195e50d9358478d1e450338b6
      https://github.com/llvm/llvm-project/commit/84cd51bb97d5014195e50d9358478d1e450338b6
  Author: wren romano <2998727+wrengr at users.noreply.github.com>
  Date:   2023-03-06 (Mon, 06 Mar 2023)

  Changed paths:
    M mlir/include/mlir-c/Dialect/SparseTensor.h
    M mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h
    M mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td
    M mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorBase.td
    M mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td
    M mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorType.h
    M mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorTypes.td
    M mlir/include/mlir/ExecutionEngine/SparseTensor/COO.h
    M mlir/include/mlir/ExecutionEngine/SparseTensor/File.h
    M mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h
    M mlir/include/mlir/ExecutionEngine/SparseTensorRuntime.h
    M mlir/lib/Bindings/Python/DialectSparseTensor.cpp
    M mlir/lib/CAPI/Dialect/SparseTensor.cpp
    M mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/BufferizableOpInterfaceImpl.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.h
    M mlir/lib/Dialect/SparseTensor/Transforms/LoopEmitter.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/LoopEmitter.h
    M mlir/lib/Dialect/SparseTensor/Transforms/SparseStorageSpecifierToLLVM.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorStorageLayout.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorStorageLayout.h
    M mlir/lib/Dialect/SparseTensor/Transforms/SparseVectorization.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
    M mlir/lib/ExecutionEngine/SparseTensor/NNZ.cpp
    M mlir/lib/ExecutionEngine/SparseTensor/Storage.cpp
    M mlir/lib/ExecutionEngine/SparseTensorRuntime.cpp
    M mlir/test/CAPI/sparse_tensor.c
    M mlir/test/Dialect/SparseTensor/codegen.mlir
    M mlir/test/Dialect/SparseTensor/codegen_buffer_initialization.mlir
    M mlir/test/Dialect/SparseTensor/conversion.mlir
    M mlir/test/Dialect/SparseTensor/convert_dense2sparse.mlir
    M mlir/test/Dialect/SparseTensor/convert_sparse2sparse.mlir
    M mlir/test/Dialect/SparseTensor/convert_sparse2sparse_element.mlir
    M mlir/test/Dialect/SparseTensor/fold.mlir
    M mlir/test/Dialect/SparseTensor/invalid.mlir
    M mlir/test/Dialect/SparseTensor/invalid_encoding.mlir
    M mlir/test/Dialect/SparseTensor/roundtrip.mlir
    M mlir/test/Dialect/SparseTensor/roundtrip_encoding.mlir
    M mlir/test/Dialect/SparseTensor/sorted_coo.mlir
    M mlir/test/Dialect/SparseTensor/sparse_1d.mlir
    M mlir/test/Dialect/SparseTensor/sparse_2d.mlir
    M mlir/test/Dialect/SparseTensor/sparse_3d.mlir
    M mlir/test/Dialect/SparseTensor/sparse_affine.mlir
    M mlir/test/Dialect/SparseTensor/sparse_broadcast.mlir
    M mlir/test/Dialect/SparseTensor/sparse_concat_codegen.mlir
    M mlir/test/Dialect/SparseTensor/sparse_fill_zero.mlir
    M mlir/test/Dialect/SparseTensor/sparse_fp_ops.mlir
    M mlir/test/Dialect/SparseTensor/sparse_index.mlir
    M mlir/test/Dialect/SparseTensor/sparse_int_ops.mlir
    M mlir/test/Dialect/SparseTensor/sparse_kernels.mlir
    M mlir/test/Dialect/SparseTensor/sparse_lower.mlir
    M mlir/test/Dialect/SparseTensor/sparse_lower_col.mlir
    M mlir/test/Dialect/SparseTensor/sparse_lower_inplace.mlir
    M mlir/test/Dialect/SparseTensor/sparse_matmul_codegen.mlir
    M mlir/test/Dialect/SparseTensor/sparse_nd.mlir
    M mlir/test/Dialect/SparseTensor/sparse_out.mlir
    M mlir/test/Dialect/SparseTensor/sparse_outbuf.mlir
    M mlir/test/Dialect/SparseTensor/sparse_pack.mlir
    M mlir/test/Dialect/SparseTensor/sparse_parallel_reduce.mlir
    M mlir/test/Dialect/SparseTensor/sparse_reshape.mlir
    M mlir/test/Dialect/SparseTensor/sparse_reshape_dot.mlir
    M mlir/test/Dialect/SparseTensor/sparse_scalars.mlir
    M mlir/test/Dialect/SparseTensor/sparse_sddmm.mlir
    M mlir/test/Dialect/SparseTensor/sparse_sddmm_org.mlir
    M mlir/test/Dialect/SparseTensor/sparse_storage.mlir
    M mlir/test/Dialect/SparseTensor/sparse_transpose.mlir
    M mlir/test/Dialect/SparseTensor/sparse_vector.mlir
    M mlir/test/Dialect/SparseTensor/sparse_vector_chain.mlir
    M mlir/test/Dialect/SparseTensor/sparse_vector_index.mlir
    M mlir/test/Dialect/SparseTensor/sparse_vector_peeled.mlir
    M mlir/test/Dialect/SparseTensor/specifier_to_llvm.mlir
    M mlir/test/Dialect/SparseTensor/vectorize_reduction.mlir
    M mlir/test/Integration/Dialect/SparseTensor/CPU/reshape_dot.mlir
    M mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_constant_to_sparse_tensor.mlir
    M mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion.mlir
    M mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_conversion_ptr.mlir
    M mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_file_io.mlir
    M mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_insert_1d.mlir
    M mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_insert_2d.mlir
    M mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_insert_3d.mlir
    M mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matvec.mlir
    M mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_pack.mlir
    M mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_re_im.mlir
    M mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sampled_matmul.mlir
    M mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sorted_coo.mlir
    M mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_storage.mlir
    M mlir/test/Integration/Dialect/SparseTensor/taco/tools/mlir_pytaco.py
    M mlir/test/python/dialects/sparse_tensor/dialect.py

  Log Message:
  -----------
  [mlir][sparse] Renaming "pointer/index" to "position/coordinate"

The old "pointer/index" names often cause confusion since these names clash with names of unrelated things in MLIR; so this change rectifies this by changing everything to use "position/coordinate" terminology instead.

In addition to the basic terminology, there have also been various conventions for making certain distinctions like: (1) the overall storage for coordinates in the sparse-tensor, vs the particular collection of coordinates of a given element; and (2) particular coordinates given as a `Value` or `TypedValue<MemRefType>`, vs particular coordinates given as `ValueRange` or similar.  I have striven to maintain these distinctions
as follows:

  * "p/c" are used for individual position/coordinate values, when there is no risk of confusion.  (Just like we use "d/l" to abbreviate "dim/lvl".)

  * "pos/crd" are used for individual position/coordinate values, when a longer name is helpful to avoid ambiguity or to form compound names (e.g., "parentPos").  (Just like we use "dim/lvl" when we need a longer form of "d/l".)

    I have also used these forms for a handful of compound names where the old name had been using a three-letter form previously, even though a longer form would be more appropriate.  I've avoided renaming these to use a longer form purely for expediency sake, since changing them would require a cascade of other renamings.  They should be updated to follow the new naming scheme, but that can be done in future patches.

  * "coords" is used for the complete collection of crd values associated with a single element.  In the runtime library this includes both `std::vector` and raw pointer representations.  In the compiler, this is used specifically for buffer variables with C++ type `Value`, `TypedValue<MemRefType>`, etc.

    The bare form "coords" is discouraged, since it fails to make the dim/lvl distinction; so the compound names "dimCoords/lvlCoords" should be used instead.  (Though there may exist a rare few cases where is is appropriate to be intentionally ambiguous about what coordinate-space the coords live in; in which case the bare "coords" is appropriate.)

    There is seldom the need for the pos variant of this notion.  In most circumstances we use the term "cursor", since the same buffer is reused for a 'moving' pos-collection.

  * "dcvs/lcvs" is used in the compiler as the `ValueRange` analogue of "dimCoords/lvlCoords".  (The "vs" stands for "`Value`s".)  I haven't found the need for it, but "pvs" would be the obvious name for a pos-`ValueRange`.

    The old "ind"-vs-"ivs" naming scheme does not seem to have been sustained in more recent code, which instead prefers other mnemonics (e.g., adding "Buf" to the end of the names for `TypeValue<MemRefType>`).  I have cleaned up a lot of these to follow the "coords"-vs-"cvs" naming scheme, though haven't done an exhaustive cleanup.

  * "positions/coordinates" are used for larger collections of pos/crd values; in particular, these are used when referring to the complete sparse-tensor storage components.

    I also prefer to use these unabbreviated names in the documentation, unless there is some specific reason why using the abbreviated forms helps resolve ambiguity.

In addition to making this terminology change, this change also does some cleanup along the way:
  * correcting the dim/lvl terminology in certain places.
  * adding `const` when it requires no other code changes.
  * miscellaneous cleanup that was entailed in order to make the proper distinctions.  Most of these are in CodegenUtils.{h,cpp}

Reviewed By: aartbik

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




More information about the All-commits mailing list