Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nielstron committed Dec 29, 2024
1 parent 2968732 commit 33e4256
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion uplc/cost_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class LiteralInYOrLinearInZ(CostingFun):
slope: int = 0

def cost(self, *memories: int, values=[]) -> int:
y = values[1]
y = values[1].value
if y == 0:
return self.intercept + self.slope * memories[2]
# "+ 7" for ceil
Expand Down
6 changes: 4 additions & 2 deletions uplc/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ def budget_cost_of_op_on_model(
model: Union[BuiltinCostModel, CekMachineCostModel],
op: Union[BuiltInFun, CekOp],
*args: int,
values=[],
):
if op not in model.cpu or op not in model.memory:
return Budget(0, 0)
return Budget(
cpu=model.cpu[op].cost(*args),
memory=model.memory[op].cost(*args),
cpu=model.cpu[op].cost(*args, values=values),
memory=model.memory[op].cost(*args, values=values),
)


Expand Down Expand Up @@ -269,6 +270,7 @@ def apply_evaluate(self, context, function, argument):
self.builtin_cost_model,
function.builtin,
*(arg.ex_mem() for arg in arguments),
values=arguments,
)
self.spend_budget(cost)
if function.builtin == BuiltInFun.Trace:
Expand Down

0 comments on commit 33e4256

Please sign in to comment.