Opschietto
Opschietto
MModular
Created by Opschietto on 9/15/2024 in #questions
Conditional parameter evaluation
Hello, I was wondering if there was a way to write conditional parameter evaluation, something like @parameter(condition) to apply the @parameter only if condition is true. Practial example of unrolling loop:
# Current:
@parameter
if nchunks <= 4:
@parameter
for chunk in range(nchunks):
var idx = ...
dest.store(idx, src.load[width=32](idx))
else:
for chunk in range(nchunks):
var idx = ...
dest.store(idx, src.load[width=32](idx))

# Ideal:
@parameter(nchunks <= 4)
for chunk in range(nchunks):
var idx = ...
dest.store(idx, src.load[width=32](idx))
# Current:
@parameter
if nchunks <= 4:
@parameter
for chunk in range(nchunks):
var idx = ...
dest.store(idx, src.load[width=32](idx))
else:
for chunk in range(nchunks):
var idx = ...
dest.store(idx, src.load[width=32](idx))

# Ideal:
@parameter(nchunks <= 4)
for chunk in range(nchunks):
var idx = ...
dest.store(idx, src.load[width=32](idx))
2 replies