From 6ac19b69e4e4fb3c2dffac6d1ee01860b0a404bf Mon Sep 17 00:00:00 2001 From: Lukasz Wawrzyniak Date: Wed, 9 Oct 2024 17:59:01 -0400 Subject: [PATCH] Fix hashing of static expressions --- CHANGELOG.md | 1 + warp/context.py | 48 ++++++------ warp/tests/test_static.py | 156 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 182 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3302df1d..af7f75c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Fix potential out-of-bounds memory access when a `wp.sparse.BsrMatrix` object is reused for storing matrices of different shapes - Fix robustness to very low desired tolerance in `wp.fem.utils.symmetric_eigenvalues_qr` - Fix invalid code generation error messages when nesting dynamic and static for-loops +- Fix caching of kernels with static expressions ## [1.4.0] - 2024-10-01 diff --git a/warp/context.py b/warp/context.py index fc114417..8a813678 100644 --- a/warp/context.py +++ b/warp/context.py @@ -6,7 +6,6 @@ # license agreement from NVIDIA CORPORATION is strictly prohibited. import ast -import builtins import ctypes import functools import hashlib @@ -22,7 +21,6 @@ import weakref from copy import copy as shallowcopy from pathlib import Path -from struct import pack as struct_pack from typing import Any, Callable, Dict, List, Mapping, Optional, Sequence, Tuple, Union import numpy as np @@ -1488,30 +1486,16 @@ def hash_adjoint(self, adj): # hash referenced constants for name, value in constants.items(): ch.update(bytes(name, "utf-8")) - # hash the referenced object - if isinstance(value, builtins.bool): - # This needs to come before the check for `int` since all boolean - # values are also instances of `int`. - ch.update(struct_pack("?", value)) - elif isinstance(value, int): - ch.update(struct_pack("