Changeset View
Changeset View
Standalone View
Standalone View
mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | #ifndef NDEBUG | ||||
for (uint64_t i = 0; i < rank; ++i) { | for (uint64_t i = 0; i < rank; ++i) { | ||||
const uint64_t j = perm[i]; | const uint64_t j = perm[i]; | ||||
if (j >= rank || seen[j]) | if (j >= rank || seen[j]) | ||||
MLIR_SPARSETENSOR_FATAL("Not a permutation of 0..%" PRIu64 "\n", rank); | MLIR_SPARSETENSOR_FATAL("Not a permutation of 0..%" PRIu64 "\n", rank); | ||||
seen[j] = true; | seen[j] = true; | ||||
} | } | ||||
// Verify that the sparsity values are supported. | // Verify that the sparsity values are supported. | ||||
// TODO: update this check to match what we actually support. | |||||
for (uint64_t i = 0; i < rank; ++i) | for (uint64_t i = 0; i < rank; ++i) | ||||
if (sparsity[i] != DimLevelType::kDense && | if (sparsity[i] != DimLevelType::kDense && | ||||
sparsity[i] != DimLevelType::kCompressed) | sparsity[i] != DimLevelType::kCompressed) | ||||
MLIR_SPARSETENSOR_FATAL("Unsupported sparsity value %d\n", | MLIR_SPARSETENSOR_FATAL("unsupported dimension level type: %d\n", | ||||
static_cast<int>(sparsity[i])); | static_cast<uint8_t>(sparsity[i])); | ||||
#endif | #endif | ||||
// Convert external format to internal COO. | // Convert external format to internal COO. | ||||
auto *coo = SparseTensorCOO<V>::newSparseTensorCOO(rank, shape, perm, nse); | auto *coo = SparseTensorCOO<V>::newSparseTensorCOO(rank, shape, perm, nse); | ||||
std::vector<uint64_t> idx(rank); | std::vector<uint64_t> idx(rank); | ||||
for (uint64_t i = 0, base = 0; i < nse; i++) { | for (uint64_t i = 0, base = 0; i < nse; i++) { | ||||
for (uint64_t r = 0; r < rank; r++) | for (uint64_t r = 0; r < rank; r++) | ||||
idx[perm[r]] = indices[base + r]; | idx[perm[r]] = indices[base + r]; | ||||
▲ Show 20 Lines • Show All 435 Lines • Show Last 20 Lines |