CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
65 lines
1.9 KiB
C++
65 lines
1.9 KiB
C++
//===- MapRef.cpp - A dim2lvl/lvl2dim map reference wrapper ---------------===//
|
|
//
|
|
// 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 "mlir/ExecutionEngine/SparseTensor/MapRef.h"
|
|
#include "mlir/Dialect/SparseTensor/IR/Enums.h"
|
|
|
|
mlir::sparse_tensor::MapRef::MapRef(uint64_t d, uint64_t l, const uint64_t *d2l,
|
|
const uint64_t *l2d)
|
|
: dimRank(d), lvlRank(l), dim2lvl(d2l), lvl2dim(l2d),
|
|
isPermutation(isPermutationMap()) {
|
|
if (isPermutation) {
|
|
for (uint64_t l = 0; l < lvlRank; l++)
|
|
assert(lvl2dim[dim2lvl[l]] == l);
|
|
}
|
|
}
|
|
|
|
bool mlir::sparse_tensor::MapRef::isPermutationMap() const {
|
|
if (dimRank != lvlRank)
|
|
return false;
|
|
std::vector<bool> seen(dimRank, false);
|
|
for (uint64_t l = 0; l < lvlRank; l++) {
|
|
const uint64_t d = dim2lvl[l];
|
|
if (d >= dimRank || seen[d])
|
|
return false;
|
|
seen[d] = true;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool mlir::sparse_tensor::MapRef::isFloor(uint64_t l, uint64_t &i,
|
|
uint64_t &c) const {
|
|
if (isEncodedFloor(dim2lvl[l])) {
|
|
i = decodeIndex(dim2lvl[l]);
|
|
c = decodeConst(dim2lvl[l]);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool mlir::sparse_tensor::MapRef::isMod(uint64_t l, uint64_t &i,
|
|
uint64_t &c) const {
|
|
if (isEncodedMod(dim2lvl[l])) {
|
|
i = decodeIndex(dim2lvl[l]);
|
|
c = decodeConst(dim2lvl[l]);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool mlir::sparse_tensor::MapRef::isMul(uint64_t d, uint64_t &i, uint64_t &c,
|
|
uint64_t &ii) const {
|
|
if (isEncodedMul(lvl2dim[d])) {
|
|
i = decodeIndex(lvl2dim[d]);
|
|
c = decodeMulc(lvl2dim[d]);
|
|
ii = decodeMuli(lvl2dim[d]);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|