Skip to content

Commit

Permalink
Don't treat external type values as const (HACK)
Browse files Browse the repository at this point in the history
  • Loading branch information
nvlukasz committed Jun 27, 2024
1 parent 1e13956 commit 4466ae2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions warp/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -2719,7 +2719,11 @@ def codegen_func_forward(adj, func_type="kernel", device="cpu"):
if var.constant is None:
lines += [f"{var.ctype()} {var.emit()};\n"]
else:
lines += [f"const {var.ctype()} {var.emit()} = {constant_str(var.constant)};\n"]
# HACK: don't declare custom type values as const so that they are mutable
if warp.types.type_is_external(var.type):
lines += [f"{var.ctype()} {var.emit()} = {constant_str(var.constant)};\n"]
else:
lines += [f"const {var.ctype()} {var.emit()} = {constant_str(var.constant)};\n"]

# forward pass
lines += ["//---------\n"]
Expand Down Expand Up @@ -2754,7 +2758,11 @@ def codegen_func_reverse(adj, func_type="kernel", device="cpu"):
if var.constant is None:
lines += [f"{var.ctype()} {var.emit()};\n"]
else:
lines += [f"const {var.ctype()} {var.emit()} = {constant_str(var.constant)};\n"]
# HACK: don't declare custom type values as const so that they are mutable
if warp.types.type_is_external(var.type):
lines += [f"{var.ctype()} {var.emit()} = {constant_str(var.constant)};\n"]
else:
lines += [f"const {var.ctype()} {var.emit()} = {constant_str(var.constant)};\n"]

# dual vars
lines += ["//---------\n"]
Expand Down

0 comments on commit 4466ae2

Please sign in to comment.