
# Autogenerated by mlir-tblgen; don't manually edit.

from enum import IntEnum, auto, IntFlag
from ._ods_common import _cext as _ods_cext
from ..ir import register_attribute_builder
_ods_ir = _ods_cext.ir

class ReductionKind(IntEnum):
    """Reduction of an iterator/grid dimension."""

    Sum = 1
    Max = 2
    Min = 3
    Product = 4
    Average = 5
    BitwiseAnd = 6
    BitwiseOr = 7
    BitwiseXor = 8
    Generic = 100

    def __str__(self):
        if self is ReductionKind.Sum:
            return "sum"
        if self is ReductionKind.Max:
            return "max"
        if self is ReductionKind.Min:
            return "min"
        if self is ReductionKind.Product:
            return "product"
        if self is ReductionKind.Average:
            return "average"
        if self is ReductionKind.BitwiseAnd:
            return "bitwise_and"
        if self is ReductionKind.BitwiseOr:
            return "bitwise_or"
        if self is ReductionKind.BitwiseXor:
            return "bitwise_xor"
        if self is ReductionKind.Generic:
            return "generic"
        raise ValueError("Unknown ReductionKind enum entry.")



@register_attribute_builder("Shard_ReductionKind", allow_existing=True)
def _shard_reductionkind(x, context):
    return _ods_ir.IntegerAttr.get(_ods_ir.IntegerType.get_signless(32, context=context), int(x))

@register_attribute_builder("shard.Shard_ReductionKindAttr")
def _shard_reductionkindattr(x, context):
    return _ods_ir.Attribute.parse(f'#shard<partial {str(x)}>', context=context)

