Skip to content

Commit 1ab7d5b

Browse files
arhikmaleadt
authored andcommitted
better name for IdentityOp
The original name `IdentityOp` could be misleading representation for TileIR Op. New name better represent that its rather a value. - IdentityOp -> IdentityVal
1 parent 5524d5c commit 1ab7d5b

5 files changed

Lines changed: 23 additions & 23 deletions

File tree

src/bytecode/encodings.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ function encode_ReduceOp!(body::Function, cb::CodeBuilder,
12911291
result_types::Vector{TypeId},
12921292
operands::Vector{Value},
12931293
dim::Int,
1294-
identities::Vector{<:IdentityOp},
1294+
identities::Vector{<:IdentityVal},
12951295
body_scalar_types::Vector{TypeId})
12961296
encode_varint!(cb.buf, Opcode.ReduceOp)
12971297

src/bytecode/writer.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -234,41 +234,41 @@ end
234234
=============================================================================#
235235

236236
"""
237-
IdentityOp
237+
IdentityVal
238238
239239
Abstract type for binary operation identity attributes (reduce, scan, etc.).
240240
"""
241-
abstract type IdentityOp end
241+
abstract type IdentityVal end
242242

243243
"""
244-
FloatIdentityOp(value, type_id, dtype)
244+
FloatIdentityVal(value, type_id, dtype)
245245
246246
Float identity value for binary operations.
247247
"""
248-
struct FloatIdentityOp <: IdentityOp
248+
struct FloatIdentityVal <: IdentityVal
249249
value::Float64
250250
type_id::TypeId
251251
dtype::Type # Float16, Float32, Float64, etc.
252252
end
253253

254254
"""
255-
IntegerIdentityOp(value, type_id, dtype)
255+
IntegerIdentityVal(value, type_id, dtype)
256256
257257
Integer identity value for binary operations.
258258
"""
259-
struct IntegerIdentityOp <: IdentityOp
259+
struct IntegerIdentityVal <: IdentityVal
260260
value::UInt128 # Store as UInt128 to handle all unsigned values up to 64 bits
261261
type_id::TypeId
262262
dtype::Type # Int8, Int16, Int32, Int64, UInt8, etc. (signedness inferred from dtype)
263263
end
264264

265265
"""
266-
encode_tagged_float!(cb, identity::FloatIdentityOp)
266+
encode_tagged_float!(cb, identity::FloatIdentityVal)
267267
268268
Encode a tagged float attribute for reduce identity.
269269
Format: tag(Float=0x02) + typeid + ap_int(value_bits)
270270
"""
271-
function encode_tagged_float!(cb::CodeBuilder, identity::FloatIdentityOp)
271+
function encode_tagged_float!(cb::CodeBuilder, identity::FloatIdentityVal)
272272
# Tag for Float attribute
273273
push!(cb.buf, 0x02)
274274
# Type ID
@@ -279,12 +279,12 @@ function encode_tagged_float!(cb::CodeBuilder, identity::FloatIdentityOp)
279279
end
280280

281281
"""
282-
encode_tagged_int!(cb, identity::IntegerIdentityOp)
282+
encode_tagged_int!(cb, identity::IntegerIdentityVal)
283283
284284
Encode a tagged integer identity attribute.
285285
Format: tag(Int=0x01) + typeid + ap_int(value)
286286
"""
287-
function encode_tagged_int!(cb::CodeBuilder, identity::IntegerIdentityOp)
287+
function encode_tagged_int!(cb::CodeBuilder, identity::IntegerIdentityVal)
288288
# Tag for Int attribute
289289
push!(cb.buf, 0x01)
290290
# Type ID
@@ -347,7 +347,7 @@ end
347347
Encode an array of binary operation identity attributes.
348348
Dispatches on identity type to encode correctly.
349349
"""
350-
function encode_identity_array!(cb::CodeBuilder, identities::Vector{<:IdentityOp})
350+
function encode_identity_array!(cb::CodeBuilder, identities::Vector{<:IdentityVal})
351351
encode_varint!(cb.buf, length(identities))
352352
for identity in identities
353353
encode_identity!(cb, identity)
@@ -359,8 +359,8 @@ end
359359
360360
Encode a single identity attribute, dispatching on type.
361361
"""
362-
encode_identity!(cb::CodeBuilder, identity::FloatIdentityOp) = encode_tagged_float!(cb, identity)
363-
encode_identity!(cb::CodeBuilder, identity::IntegerIdentityOp) = encode_tagged_int!(cb, identity)
362+
encode_identity!(cb::CodeBuilder, identity::FloatIdentityVal) = encode_tagged_float!(cb, identity)
363+
encode_identity!(cb::CodeBuilder, identity::IntegerIdentityVal) = encode_tagged_int!(cb, identity)
364364

365365
"""
366366
BytecodeWriter

src/compiler/intrinsics.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ using Base: compilerbarrier, donotdelete
88
using ..cuTile: Tile, TileArray, Constant, TensorView, PartitionView
99
using ..cuTile: Signedness, SignednessSigned, SignednessUnsigned
1010
using ..cuTile: ComparisonPredicate, CmpLessThan, CmpLessThanOrEqual, CmpGreaterThan, CmpGreaterThanOrEqual, CmpEqual, CmpNotEqual
11-
using ..cuTile: IdentityOp, FloatIdentityOp, IntegerIdentityOp
11+
using ..cuTile: IdentityVal, FloatIdentityVal, IntegerIdentityVal
1212

1313
end
1414

src/compiler/intrinsics/core.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -581,10 +581,10 @@ end
581581
#=============================================================================#
582582

583583
"""
584-
operation_identity(fn, dtype, elem_type) -> IdentityOp
584+
operation_identity(fn, dtype, elem_type) -> IdentityVal
585585
to_uint128(value)
586586
587-
Convert an integer value to UInt128 for storage in IntegerIdentityOp.
587+
Convert an integer value to UInt128 for storage in IntegerIdentityVal.
588588
For signed types, this returns the two's complement bit representation.
589589
"""
590590
# Unsigned types: directly convert
@@ -599,23 +599,23 @@ to_uint128(value::Int16) = UInt128(reinterpret(UInt16, value))
599599
to_uint128(value::Int8) = UInt128(reinterpret(UInt8, value))
600600

601601
"""
602-
operation_identity(fn, dtype, elem_type) -> IdentityOp
602+
operation_identity(fn, dtype, elem_type) -> IdentityVal
603603
604604
Return the identity value for a binary operation (reduce, scan, etc.).
605605
Identity must satisfy: identity ⊕ x = x for the operation.
606606
"""
607607

608608
# Addition identity: 0 + x = x
609609
operation_identity(::Val{:add}, dtype, ::Type{T}) where T <: AbstractFloat =
610-
FloatIdentityOp(zero(T), dtype, T)
610+
FloatIdentityVal(zero(T), dtype, T)
611611
operation_identity(::Val{:add}, dtype, ::Type{T}) where T <: Integer =
612-
IntegerIdentityOp(to_uint128(zero(T)), dtype, T)
612+
IntegerIdentityVal(to_uint128(zero(T)), dtype, T)
613613

614614
# Maximum identity: max(typemin(T), x) = x
615615
operation_identity(::Val{:max}, dtype, ::Type{T}) where T <: AbstractFloat =
616-
FloatIdentityOp(typemin(T), dtype, T)
616+
FloatIdentityVal(typemin(T), dtype, T)
617617
operation_identity(::Val{:max}, dtype, ::Type{T}) where T <: Integer =
618-
IntegerIdentityOp(to_uint128(typemin(T)), dtype, T)
618+
IntegerIdentityVal(to_uint128(typemin(T)), dtype, T)
619619

620620
#=============================================================================#
621621
# Reduce Body Operations

src/cuTile.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ public launch
4242
launch() = error("Please import CUDA.jl before using `cuTile.launch`.")
4343

4444
# Export identity types for reduction operations
45-
public IdentityOp, FloatIdentityOp, IntegerIdentityOp
45+
public IdentityVal, FloatIdentityVal, IntegerIdentityVal
4646

4747
end # module cuTile

0 commit comments

Comments
 (0)