Skip to content
This repository was archived by the owner on Oct 11, 2025. It is now read-only.

Commit 308cd91

Browse files
committed
Revert "[mlir][python] allow DenseIntElementsAttr for index type (#118947)"
This reverts commit e708617.
1 parent e708617 commit 308cd91

File tree

3 files changed

+2
-13
lines changed

3 files changed

+2
-13
lines changed

mlir/include/mlir-c/BuiltinAttributes.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,6 @@ MLIR_CAPI_EXPORTED int64_t
556556
mlirDenseElementsAttrGetInt64Value(MlirAttribute attr, intptr_t pos);
557557
MLIR_CAPI_EXPORTED uint64_t
558558
mlirDenseElementsAttrGetUInt64Value(MlirAttribute attr, intptr_t pos);
559-
MLIR_CAPI_EXPORTED uint64_t
560-
mlirDenseElementsAttrGetIndexValue(MlirAttribute attr, intptr_t pos);
561559
MLIR_CAPI_EXPORTED float mlirDenseElementsAttrGetFloatValue(MlirAttribute attr,
562560
intptr_t pos);
563561
MLIR_CAPI_EXPORTED double

mlir/lib/Bindings/Python/IRAttributes.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,19 +1372,13 @@ class PyDenseIntElementsAttribute
13721372

13731373
MlirType type = mlirAttributeGetType(*this);
13741374
type = mlirShapedTypeGetElementType(type);
1375-
// Index type can also appear as a DenseIntElementsAttr and therefore can be
1376-
// casted to integer.
1377-
assert(mlirTypeIsAInteger(type) ||
1378-
mlirTypeIsAIndex(type) && "expected integer/index element type in "
1379-
"dense int elements attribute");
1375+
assert(mlirTypeIsAInteger(type) &&
1376+
"expected integer element type in dense int elements attribute");
13801377
// Dispatch element extraction to an appropriate C function based on the
13811378
// elemental type of the attribute. nb::int_ is implicitly constructible
13821379
// from any C++ integral type and handles bitwidth correctly.
13831380
// TODO: consider caching the type properties in the constructor to avoid
13841381
// querying them on each element access.
1385-
if (mlirTypeIsAIndex(type)) {
1386-
return mlirDenseElementsAttrGetIndexValue(*this, pos);
1387-
}
13881382
unsigned width = mlirIntegerTypeGetWidth(type);
13891383
bool isUnsigned = mlirIntegerTypeIsUnsigned(type);
13901384
if (isUnsigned) {

mlir/lib/CAPI/IR/BuiltinAttributes.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -758,9 +758,6 @@ int64_t mlirDenseElementsAttrGetInt64Value(MlirAttribute attr, intptr_t pos) {
758758
uint64_t mlirDenseElementsAttrGetUInt64Value(MlirAttribute attr, intptr_t pos) {
759759
return llvm::cast<DenseElementsAttr>(unwrap(attr)).getValues<uint64_t>()[pos];
760760
}
761-
uint64_t mlirDenseElementsAttrGetIndexValue(MlirAttribute attr, intptr_t pos) {
762-
return llvm::cast<DenseElementsAttr>(unwrap(attr)).getValues<uint64_t>()[pos];
763-
}
764761
float mlirDenseElementsAttrGetFloatValue(MlirAttribute attr, intptr_t pos) {
765762
return llvm::cast<DenseElementsAttr>(unwrap(attr)).getValues<float>()[pos];
766763
}

0 commit comments

Comments
 (0)