warp-lang 1.3.3__py3-none-macosx_10_13_universal2.whl → 1.4.1__py3-none-macosx_10_13_universal2.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of warp-lang might be problematic. Click here for more details.
- warp/__init__.py +6 -0
- warp/autograd.py +59 -6
- warp/bin/libwarp.dylib +0 -0
- warp/build_dll.py +8 -10
- warp/builtins.py +103 -3
- warp/codegen.py +447 -53
- warp/config.py +1 -1
- warp/context.py +682 -405
- warp/dlpack.py +2 -0
- warp/examples/benchmarks/benchmark_cloth.py +10 -0
- warp/examples/core/example_render_opengl.py +12 -10
- warp/examples/fem/example_adaptive_grid.py +251 -0
- warp/examples/fem/example_apic_fluid.py +1 -1
- warp/examples/fem/example_diffusion_3d.py +2 -2
- warp/examples/fem/example_magnetostatics.py +1 -1
- warp/examples/fem/example_streamlines.py +1 -0
- warp/examples/fem/utils.py +25 -5
- warp/examples/sim/example_cloth.py +50 -6
- warp/fem/__init__.py +2 -0
- warp/fem/adaptivity.py +493 -0
- warp/fem/field/field.py +2 -1
- warp/fem/field/nodal_field.py +18 -26
- warp/fem/field/test.py +4 -4
- warp/fem/field/trial.py +4 -4
- warp/fem/geometry/__init__.py +1 -0
- warp/fem/geometry/adaptive_nanogrid.py +843 -0
- warp/fem/geometry/nanogrid.py +55 -28
- warp/fem/space/__init__.py +1 -1
- warp/fem/space/nanogrid_function_space.py +69 -35
- warp/fem/utils.py +118 -107
- warp/jax_experimental.py +28 -15
- warp/native/array.h +0 -1
- warp/native/builtin.h +103 -6
- warp/native/bvh.cu +4 -2
- warp/native/cuda_util.cpp +14 -0
- warp/native/cuda_util.h +2 -0
- warp/native/error.cpp +4 -2
- warp/native/exports.h +99 -0
- warp/native/mat.h +97 -0
- warp/native/mesh.cpp +36 -0
- warp/native/mesh.cu +52 -1
- warp/native/mesh.h +1 -0
- warp/native/quat.h +43 -0
- warp/native/range.h +11 -2
- warp/native/spatial.h +6 -0
- warp/native/vec.h +74 -0
- warp/native/warp.cpp +2 -1
- warp/native/warp.cu +10 -3
- warp/native/warp.h +8 -1
- warp/paddle.py +382 -0
- warp/sim/__init__.py +1 -0
- warp/sim/collide.py +519 -0
- warp/sim/integrator_euler.py +18 -5
- warp/sim/integrator_featherstone.py +5 -5
- warp/sim/integrator_vbd.py +1026 -0
- warp/sim/integrator_xpbd.py +2 -6
- warp/sim/model.py +50 -25
- warp/sparse.py +9 -7
- warp/stubs.py +459 -0
- warp/tape.py +2 -0
- warp/tests/aux_test_dependent.py +1 -0
- warp/tests/aux_test_name_clash1.py +32 -0
- warp/tests/aux_test_name_clash2.py +32 -0
- warp/tests/aux_test_square.py +1 -0
- warp/tests/test_array.py +188 -0
- warp/tests/test_async.py +3 -3
- warp/tests/test_atomic.py +6 -0
- warp/tests/test_closest_point_edge_edge.py +93 -1
- warp/tests/test_codegen.py +93 -15
- warp/tests/test_codegen_instancing.py +1457 -0
- warp/tests/test_collision.py +486 -0
- warp/tests/test_compile_consts.py +3 -28
- warp/tests/test_dlpack.py +170 -0
- warp/tests/test_examples.py +22 -8
- warp/tests/test_fast_math.py +10 -4
- warp/tests/test_fem.py +81 -1
- warp/tests/test_func.py +46 -0
- warp/tests/test_implicit_init.py +49 -0
- warp/tests/test_jax.py +58 -0
- warp/tests/test_mat.py +84 -0
- warp/tests/test_mesh_query_point.py +188 -0
- warp/tests/test_model.py +13 -0
- warp/tests/test_module_hashing.py +40 -0
- warp/tests/test_multigpu.py +3 -3
- warp/tests/test_overwrite.py +8 -0
- warp/tests/test_paddle.py +852 -0
- warp/tests/test_print.py +89 -0
- warp/tests/test_quat.py +111 -0
- warp/tests/test_reload.py +31 -1
- warp/tests/test_scalar_ops.py +2 -0
- warp/tests/test_static.py +568 -0
- warp/tests/test_streams.py +64 -3
- warp/tests/test_struct.py +4 -4
- warp/tests/test_torch.py +24 -0
- warp/tests/test_triangle_closest_point.py +137 -0
- warp/tests/test_types.py +1 -1
- warp/tests/test_vbd.py +386 -0
- warp/tests/test_vec.py +143 -0
- warp/tests/test_vec_scalar_ops.py +139 -0
- warp/tests/unittest_suites.py +12 -0
- warp/tests/unittest_utils.py +9 -5
- warp/thirdparty/dlpack.py +3 -1
- warp/types.py +167 -36
- warp/utils.py +37 -14
- {warp_lang-1.3.3.dist-info → warp_lang-1.4.1.dist-info}/METADATA +10 -8
- {warp_lang-1.3.3.dist-info → warp_lang-1.4.1.dist-info}/RECORD +109 -97
- warp/tests/test_point_triangle_closest_point.py +0 -143
- {warp_lang-1.3.3.dist-info → warp_lang-1.4.1.dist-info}/LICENSE.md +0 -0
- {warp_lang-1.3.3.dist-info → warp_lang-1.4.1.dist-info}/WHEEL +0 -0
- {warp_lang-1.3.3.dist-info → warp_lang-1.4.1.dist-info}/top_level.txt +0 -0
warp/tests/test_vec.py
CHANGED
|
@@ -1035,6 +1035,142 @@ def test_casting_constructors(test, device, dtype, register_kernels=False):
|
|
|
1035
1035
|
assert_np_equal(out, a_grad.numpy())
|
|
1036
1036
|
|
|
1037
1037
|
|
|
1038
|
+
def test_vec_assign(test, device, dtype, register_kernels=False):
|
|
1039
|
+
np_type = np.dtype(dtype)
|
|
1040
|
+
wp_type = wp.types.np_dtype_to_warp_type[np_type]
|
|
1041
|
+
|
|
1042
|
+
vec2 = wp.types.vector(length=2, dtype=wp_type)
|
|
1043
|
+
vec3 = wp.types.vector(length=3, dtype=wp_type)
|
|
1044
|
+
vec4 = wp.types.vector(length=4, dtype=wp_type)
|
|
1045
|
+
|
|
1046
|
+
def vectest_read_write_store(
|
|
1047
|
+
x: wp.array(dtype=wp_type), a: wp.array(dtype=vec2), b: wp.array(dtype=vec3), c: wp.array(dtype=vec4)
|
|
1048
|
+
):
|
|
1049
|
+
tid = wp.tid()
|
|
1050
|
+
|
|
1051
|
+
t = a[tid]
|
|
1052
|
+
t[0] = x[tid]
|
|
1053
|
+
a[tid] = t
|
|
1054
|
+
|
|
1055
|
+
u = b[tid]
|
|
1056
|
+
u[1] = x[tid]
|
|
1057
|
+
b[tid] = u
|
|
1058
|
+
|
|
1059
|
+
v = c[tid]
|
|
1060
|
+
v[2] = x[tid]
|
|
1061
|
+
c[tid] = v
|
|
1062
|
+
|
|
1063
|
+
def vectest_in_register(
|
|
1064
|
+
x: wp.array(dtype=wp_type), y: wp.array(dtype=vec3), a: wp.array(dtype=vec2), b: wp.array(dtype=vec3)
|
|
1065
|
+
):
|
|
1066
|
+
tid = wp.tid()
|
|
1067
|
+
|
|
1068
|
+
f = vec3(wp_type(0.0))
|
|
1069
|
+
b_vec = b[tid]
|
|
1070
|
+
f[0] = b_vec[1]
|
|
1071
|
+
f[2] = b_vec[0] * b_vec[1]
|
|
1072
|
+
y[tid] = f
|
|
1073
|
+
|
|
1074
|
+
g = wp_type(0.0)
|
|
1075
|
+
a_vec = a[tid]
|
|
1076
|
+
g = a_vec[0] + a_vec[1]
|
|
1077
|
+
x[tid] = g
|
|
1078
|
+
|
|
1079
|
+
def vectest_in_register_overwrite(x: wp.array(dtype=vec3), a: wp.array(dtype=vec3)):
|
|
1080
|
+
tid = wp.tid()
|
|
1081
|
+
|
|
1082
|
+
f = vec3(wp_type(0.0))
|
|
1083
|
+
a_vec = a[tid]
|
|
1084
|
+
f = a_vec
|
|
1085
|
+
f[1] = wp_type(3.0)
|
|
1086
|
+
|
|
1087
|
+
x[tid] = f
|
|
1088
|
+
|
|
1089
|
+
def vectest_component(x: wp.array(dtype=vec3), y: wp.array(dtype=wp_type)):
|
|
1090
|
+
i = wp.tid()
|
|
1091
|
+
|
|
1092
|
+
a = vec3(wp_type(0.0))
|
|
1093
|
+
a.x = wp_type(1.0) * y[i]
|
|
1094
|
+
a.y = wp_type(2.0) * y[i]
|
|
1095
|
+
a.z = wp_type(3.0) * y[i]
|
|
1096
|
+
x[i] = a
|
|
1097
|
+
|
|
1098
|
+
kernel_read_write_store = getkernel(vectest_read_write_store, suffix=dtype.__name__)
|
|
1099
|
+
kernel_in_register = getkernel(vectest_in_register, suffix=dtype.__name__)
|
|
1100
|
+
kernel_in_register_overwrite = getkernel(vectest_in_register_overwrite, suffix=dtype.__name__)
|
|
1101
|
+
kernel_component = getkernel(vectest_component, suffix=dtype.__name__)
|
|
1102
|
+
|
|
1103
|
+
if register_kernels:
|
|
1104
|
+
return
|
|
1105
|
+
|
|
1106
|
+
a = wp.ones(1, dtype=vec2, device=device, requires_grad=True)
|
|
1107
|
+
b = wp.ones(1, dtype=vec3, device=device, requires_grad=True)
|
|
1108
|
+
c = wp.ones(1, dtype=vec4, device=device, requires_grad=True)
|
|
1109
|
+
x = wp.full(1, value=2.0, dtype=wp_type, device=device, requires_grad=True)
|
|
1110
|
+
|
|
1111
|
+
tape = wp.Tape()
|
|
1112
|
+
with tape:
|
|
1113
|
+
wp.launch(kernel_read_write_store, dim=1, inputs=[x, a, b, c], device=device)
|
|
1114
|
+
|
|
1115
|
+
tape.backward(
|
|
1116
|
+
grads={
|
|
1117
|
+
a: wp.ones_like(a, requires_grad=False),
|
|
1118
|
+
b: wp.ones_like(b, requires_grad=False),
|
|
1119
|
+
c: wp.ones_like(c, requires_grad=False),
|
|
1120
|
+
}
|
|
1121
|
+
)
|
|
1122
|
+
|
|
1123
|
+
assert_np_equal(a.numpy(), np.array([[2.0, 1.0]], dtype=np_type))
|
|
1124
|
+
assert_np_equal(b.numpy(), np.array([[1.0, 2.0, 1.0]], dtype=np_type))
|
|
1125
|
+
assert_np_equal(c.numpy(), np.array([[1.0, 1.0, 2.0, 1.0]], dtype=np_type))
|
|
1126
|
+
assert_np_equal(x.grad.numpy(), np.array([3.0], dtype=np_type))
|
|
1127
|
+
|
|
1128
|
+
tape.reset()
|
|
1129
|
+
|
|
1130
|
+
a = wp.ones(1, dtype=vec2, device=device, requires_grad=True)
|
|
1131
|
+
b = wp.ones(1, dtype=vec3, device=device, requires_grad=True)
|
|
1132
|
+
x = wp.zeros(1, dtype=wp_type, device=device, requires_grad=True)
|
|
1133
|
+
y = wp.zeros(1, dtype=vec3, device=device, requires_grad=True)
|
|
1134
|
+
|
|
1135
|
+
with tape:
|
|
1136
|
+
wp.launch(kernel_in_register, dim=1, inputs=[x, y, a, b], device=device)
|
|
1137
|
+
|
|
1138
|
+
tape.backward(grads={x: wp.ones_like(x, requires_grad=False), y: wp.ones_like(y, requires_grad=False)})
|
|
1139
|
+
|
|
1140
|
+
assert_np_equal(x.numpy(), np.array([2.0], dtype=np_type))
|
|
1141
|
+
assert_np_equal(y.numpy(), np.array([[1.0, 0.0, 1.0]], dtype=np_type))
|
|
1142
|
+
assert_np_equal(a.grad.numpy(), np.array([[1.0, 1.0]], dtype=np_type))
|
|
1143
|
+
assert_np_equal(b.grad.numpy(), np.array([[1.0, 2.0, 0.0]], dtype=np_type))
|
|
1144
|
+
|
|
1145
|
+
tape.reset()
|
|
1146
|
+
|
|
1147
|
+
x = wp.zeros(1, dtype=vec3, device=device, requires_grad=True)
|
|
1148
|
+
y = wp.ones(1, dtype=wp_type, device=device, requires_grad=True)
|
|
1149
|
+
|
|
1150
|
+
tape = wp.Tape()
|
|
1151
|
+
with tape:
|
|
1152
|
+
wp.launch(kernel_component, dim=1, inputs=[x, y], device=device)
|
|
1153
|
+
|
|
1154
|
+
tape.backward(grads={x: wp.ones_like(x, requires_grad=False)})
|
|
1155
|
+
|
|
1156
|
+
assert_np_equal(x.numpy(), np.array([[1.0, 2.0, 3.0]], dtype=np_type))
|
|
1157
|
+
assert_np_equal(y.grad.numpy(), np.array([6.0], dtype=np_type))
|
|
1158
|
+
|
|
1159
|
+
tape.reset()
|
|
1160
|
+
|
|
1161
|
+
x = wp.zeros(1, dtype=vec3, device=device, requires_grad=True)
|
|
1162
|
+
a = wp.ones(1, dtype=vec3, device=device, requires_grad=True)
|
|
1163
|
+
|
|
1164
|
+
tape = wp.Tape()
|
|
1165
|
+
with tape:
|
|
1166
|
+
wp.launch(kernel_in_register_overwrite, dim=1, inputs=[x, a], device=device)
|
|
1167
|
+
|
|
1168
|
+
tape.backward(grads={x: wp.ones_like(x, requires_grad=False)})
|
|
1169
|
+
|
|
1170
|
+
assert_np_equal(x.numpy(), np.array([[1.0, 3.0, 1.0]], dtype=np_type))
|
|
1171
|
+
assert_np_equal(a.grad.numpy(), np.array([[1.0, 0.0, 1.0]], dtype=np_type))
|
|
1172
|
+
|
|
1173
|
+
|
|
1038
1174
|
@wp.kernel
|
|
1039
1175
|
def test_vector_constructor_value_func():
|
|
1040
1176
|
a = wp.vec2()
|
|
@@ -1170,6 +1306,13 @@ for dtype in np_float_types:
|
|
|
1170
1306
|
devices=devices,
|
|
1171
1307
|
dtype=dtype,
|
|
1172
1308
|
)
|
|
1309
|
+
add_function_test_register_kernel(
|
|
1310
|
+
TestVec,
|
|
1311
|
+
f"test_vec_assign_{dtype.__name__}",
|
|
1312
|
+
test_vec_assign,
|
|
1313
|
+
devices=devices,
|
|
1314
|
+
dtype=dtype,
|
|
1315
|
+
)
|
|
1173
1316
|
|
|
1174
1317
|
add_function_test(
|
|
1175
1318
|
TestVec,
|
|
@@ -192,12 +192,14 @@ def test_py_arithmetic_ops(test, device, dtype):
|
|
|
192
192
|
test.assertSequenceEqual(-v, make_vec(-1, 2, -3))
|
|
193
193
|
test.assertSequenceEqual(v + vec_cls(5, 5, 5), make_vec(6, 3, 8))
|
|
194
194
|
test.assertSequenceEqual(v - vec_cls(5, 5, 5), make_vec(-4, -7, -2))
|
|
195
|
+
test.assertSequenceEqual(v % vec_cls(2, 2, 2), make_vec(1, 0, 1))
|
|
195
196
|
|
|
196
197
|
v = vec_cls(2, 4, 6)
|
|
197
198
|
test.assertSequenceEqual(v * wptype(2), make_vec(4, 8, 12))
|
|
198
199
|
test.assertSequenceEqual(wptype(2) * v, make_vec(4, 8, 12))
|
|
199
200
|
test.assertSequenceEqual(v / wptype(2), make_vec(1, 2, 3))
|
|
200
201
|
test.assertSequenceEqual(wptype(24) / v, make_vec(12, 6, 4))
|
|
202
|
+
test.assertSequenceEqual(v % vec_cls(3, 3, 3), make_vec(2, 1, 0))
|
|
201
203
|
|
|
202
204
|
|
|
203
205
|
def test_constructors(test, device, dtype, register_kernels=False):
|
|
@@ -1797,6 +1799,140 @@ def test_dotproduct(test, device, dtype, register_kernels=False):
|
|
|
1797
1799
|
tape.zero()
|
|
1798
1800
|
|
|
1799
1801
|
|
|
1802
|
+
def test_modulo(test, device, dtype, register_kernels=False):
|
|
1803
|
+
rng = np.random.default_rng(123)
|
|
1804
|
+
|
|
1805
|
+
tol = {
|
|
1806
|
+
np.float16: 1.0e-2,
|
|
1807
|
+
np.float32: 1.0e-6,
|
|
1808
|
+
np.float64: 1.0e-8,
|
|
1809
|
+
}.get(dtype, 0)
|
|
1810
|
+
|
|
1811
|
+
wptype = wp.types.np_dtype_to_warp_type[np.dtype(dtype)]
|
|
1812
|
+
vec2 = wp.types.vector(length=2, dtype=wptype)
|
|
1813
|
+
vec3 = wp.types.vector(length=3, dtype=wptype)
|
|
1814
|
+
vec4 = wp.types.vector(length=4, dtype=wptype)
|
|
1815
|
+
vec5 = wp.types.vector(length=5, dtype=wptype)
|
|
1816
|
+
|
|
1817
|
+
def check_mod(
|
|
1818
|
+
s2: wp.array(dtype=vec2),
|
|
1819
|
+
s3: wp.array(dtype=vec3),
|
|
1820
|
+
s4: wp.array(dtype=vec4),
|
|
1821
|
+
s5: wp.array(dtype=vec5),
|
|
1822
|
+
v2: wp.array(dtype=vec2),
|
|
1823
|
+
v3: wp.array(dtype=vec3),
|
|
1824
|
+
v4: wp.array(dtype=vec4),
|
|
1825
|
+
v5: wp.array(dtype=vec5),
|
|
1826
|
+
v20: wp.array(dtype=wptype),
|
|
1827
|
+
v21: wp.array(dtype=wptype),
|
|
1828
|
+
v30: wp.array(dtype=wptype),
|
|
1829
|
+
v31: wp.array(dtype=wptype),
|
|
1830
|
+
v32: wp.array(dtype=wptype),
|
|
1831
|
+
v40: wp.array(dtype=wptype),
|
|
1832
|
+
v41: wp.array(dtype=wptype),
|
|
1833
|
+
v42: wp.array(dtype=wptype),
|
|
1834
|
+
v43: wp.array(dtype=wptype),
|
|
1835
|
+
v50: wp.array(dtype=wptype),
|
|
1836
|
+
v51: wp.array(dtype=wptype),
|
|
1837
|
+
v52: wp.array(dtype=wptype),
|
|
1838
|
+
v53: wp.array(dtype=wptype),
|
|
1839
|
+
v54: wp.array(dtype=wptype),
|
|
1840
|
+
):
|
|
1841
|
+
v20[0] = (wptype(2) * wp.mod(v2[0], s2[0]))[0]
|
|
1842
|
+
v21[0] = (wptype(2) * wp.mod(v2[0], s2[0]))[1]
|
|
1843
|
+
|
|
1844
|
+
v30[0] = (wptype(2) * wp.mod(v3[0], s3[0]))[0]
|
|
1845
|
+
v31[0] = (wptype(2) * wp.mod(v3[0], s3[0]))[1]
|
|
1846
|
+
v32[0] = (wptype(2) * wp.mod(v3[0], s3[0]))[2]
|
|
1847
|
+
|
|
1848
|
+
v40[0] = (wptype(2) * wp.mod(v4[0], s4[0]))[0]
|
|
1849
|
+
v41[0] = (wptype(2) * wp.mod(v4[0], s4[0]))[1]
|
|
1850
|
+
v42[0] = (wptype(2) * wp.mod(v4[0], s4[0]))[2]
|
|
1851
|
+
v43[0] = (wptype(2) * wp.mod(v4[0], s4[0]))[3]
|
|
1852
|
+
|
|
1853
|
+
v50[0] = (wptype(2) * wp.mod(v5[0], s5[0]))[0]
|
|
1854
|
+
v51[0] = (wptype(2) * wp.mod(v5[0], s5[0]))[1]
|
|
1855
|
+
v52[0] = (wptype(2) * wp.mod(v5[0], s5[0]))[2]
|
|
1856
|
+
v53[0] = (wptype(2) * wp.mod(v5[0], s5[0]))[3]
|
|
1857
|
+
v54[0] = (wptype(2) * wp.mod(v5[0], s5[0]))[4]
|
|
1858
|
+
|
|
1859
|
+
kernel = getkernel(check_mod, suffix=dtype.__name__)
|
|
1860
|
+
|
|
1861
|
+
if register_kernels:
|
|
1862
|
+
return
|
|
1863
|
+
|
|
1864
|
+
s2 = wp.array(randvals(rng, (1, 2), dtype), dtype=vec2, requires_grad=True, device=device)
|
|
1865
|
+
s3 = wp.array(randvals(rng, (1, 3), dtype), dtype=vec3, requires_grad=True, device=device)
|
|
1866
|
+
s4 = wp.array(randvals(rng, (1, 4), dtype), dtype=vec4, requires_grad=True, device=device)
|
|
1867
|
+
s5 = wp.array(randvals(rng, (1, 5), dtype), dtype=vec5, requires_grad=True, device=device)
|
|
1868
|
+
v2 = wp.array(randvals(rng, (1, 2), dtype), dtype=vec2, requires_grad=True, device=device)
|
|
1869
|
+
v3 = wp.array(randvals(rng, (1, 3), dtype), dtype=vec3, requires_grad=True, device=device)
|
|
1870
|
+
v4 = wp.array(randvals(rng, (1, 4), dtype), dtype=vec4, requires_grad=True, device=device)
|
|
1871
|
+
v5 = wp.array(randvals(rng, (1, 5), dtype), dtype=vec5, requires_grad=True, device=device)
|
|
1872
|
+
v20 = wp.zeros(1, dtype=wptype, requires_grad=True, device=device)
|
|
1873
|
+
v21 = wp.zeros(1, dtype=wptype, requires_grad=True, device=device)
|
|
1874
|
+
v30 = wp.zeros(1, dtype=wptype, requires_grad=True, device=device)
|
|
1875
|
+
v31 = wp.zeros(1, dtype=wptype, requires_grad=True, device=device)
|
|
1876
|
+
v32 = wp.zeros(1, dtype=wptype, requires_grad=True, device=device)
|
|
1877
|
+
v40 = wp.zeros(1, dtype=wptype, requires_grad=True, device=device)
|
|
1878
|
+
v41 = wp.zeros(1, dtype=wptype, requires_grad=True, device=device)
|
|
1879
|
+
v42 = wp.zeros(1, dtype=wptype, requires_grad=True, device=device)
|
|
1880
|
+
v43 = wp.zeros(1, dtype=wptype, requires_grad=True, device=device)
|
|
1881
|
+
v50 = wp.zeros(1, dtype=wptype, requires_grad=True, device=device)
|
|
1882
|
+
v51 = wp.zeros(1, dtype=wptype, requires_grad=True, device=device)
|
|
1883
|
+
v52 = wp.zeros(1, dtype=wptype, requires_grad=True, device=device)
|
|
1884
|
+
v53 = wp.zeros(1, dtype=wptype, requires_grad=True, device=device)
|
|
1885
|
+
v54 = wp.zeros(1, dtype=wptype, requires_grad=True, device=device)
|
|
1886
|
+
tape = wp.Tape()
|
|
1887
|
+
with tape:
|
|
1888
|
+
wp.launch(
|
|
1889
|
+
kernel,
|
|
1890
|
+
dim=1,
|
|
1891
|
+
inputs=[
|
|
1892
|
+
s2,
|
|
1893
|
+
s3,
|
|
1894
|
+
s4,
|
|
1895
|
+
s5,
|
|
1896
|
+
v2,
|
|
1897
|
+
v3,
|
|
1898
|
+
v4,
|
|
1899
|
+
v5,
|
|
1900
|
+
],
|
|
1901
|
+
outputs=[
|
|
1902
|
+
v20,
|
|
1903
|
+
v21,
|
|
1904
|
+
v30,
|
|
1905
|
+
v31,
|
|
1906
|
+
v32,
|
|
1907
|
+
v40,
|
|
1908
|
+
v41,
|
|
1909
|
+
v42,
|
|
1910
|
+
v43,
|
|
1911
|
+
v50,
|
|
1912
|
+
v51,
|
|
1913
|
+
v52,
|
|
1914
|
+
v53,
|
|
1915
|
+
v54,
|
|
1916
|
+
],
|
|
1917
|
+
device=device,
|
|
1918
|
+
)
|
|
1919
|
+
|
|
1920
|
+
assert_np_equal(v20.numpy()[0], 2.0 * np.fmod(v2.numpy(), s2.numpy())[0, 0], tol=10 * tol)
|
|
1921
|
+
assert_np_equal(v21.numpy()[0], 2.0 * np.fmod(v2.numpy(), s2.numpy())[0, 1], tol=10 * tol)
|
|
1922
|
+
assert_np_equal(v30.numpy()[0], 2.0 * np.fmod(v3.numpy(), s3.numpy())[0, 0], tol=10 * tol)
|
|
1923
|
+
assert_np_equal(v31.numpy()[0], 2.0 * np.fmod(v3.numpy(), s3.numpy())[0, 1], tol=10 * tol)
|
|
1924
|
+
assert_np_equal(v32.numpy()[0], 2.0 * np.fmod(v3.numpy(), s3.numpy())[0, 2], tol=10 * tol)
|
|
1925
|
+
assert_np_equal(v40.numpy()[0], 2.0 * np.fmod(v4.numpy(), s4.numpy())[0, 0], tol=10 * tol)
|
|
1926
|
+
assert_np_equal(v41.numpy()[0], 2.0 * np.fmod(v4.numpy(), s4.numpy())[0, 1], tol=10 * tol)
|
|
1927
|
+
assert_np_equal(v42.numpy()[0], 2.0 * np.fmod(v4.numpy(), s4.numpy())[0, 2], tol=10 * tol)
|
|
1928
|
+
assert_np_equal(v43.numpy()[0], 2.0 * np.fmod(v4.numpy(), s4.numpy())[0, 3], tol=10 * tol)
|
|
1929
|
+
assert_np_equal(v50.numpy()[0], 2.0 * np.fmod(v5.numpy(), s5.numpy())[0, 0], tol=10 * tol)
|
|
1930
|
+
assert_np_equal(v51.numpy()[0], 2.0 * np.fmod(v5.numpy(), s5.numpy())[0, 1], tol=10 * tol)
|
|
1931
|
+
assert_np_equal(v52.numpy()[0], 2.0 * np.fmod(v5.numpy(), s5.numpy())[0, 2], tol=10 * tol)
|
|
1932
|
+
assert_np_equal(v53.numpy()[0], 2.0 * np.fmod(v5.numpy(), s5.numpy())[0, 3], tol=10 * tol)
|
|
1933
|
+
assert_np_equal(v54.numpy()[0], 2.0 * np.fmod(v5.numpy(), s5.numpy())[0, 4], tol=10 * tol)
|
|
1934
|
+
|
|
1935
|
+
|
|
1800
1936
|
def test_equivalent_types(test, device, dtype, register_kernels=False):
|
|
1801
1937
|
wptype = wp.types.np_dtype_to_warp_type[np.dtype(dtype)]
|
|
1802
1938
|
|
|
@@ -2150,6 +2286,9 @@ for dtype in np_scalar_types:
|
|
|
2150
2286
|
add_function_test_register_kernel(
|
|
2151
2287
|
TestVecScalarOps, f"test_addition_{dtype.__name__}", test_addition, devices=devices, dtype=dtype
|
|
2152
2288
|
)
|
|
2289
|
+
add_function_test_register_kernel(
|
|
2290
|
+
TestVecScalarOps, f"test_modulo_{dtype.__name__}", test_modulo, devices=devices, dtype=dtype
|
|
2291
|
+
)
|
|
2153
2292
|
add_function_test_register_kernel(
|
|
2154
2293
|
TestVecScalarOps, f"test_dotproduct_{dtype.__name__}", test_dotproduct, devices=devices, dtype=dtype
|
|
2155
2294
|
)
|
warp/tests/unittest_suites.py
CHANGED
|
@@ -98,6 +98,7 @@ def default_suite(test_loader: unittest.TestLoader = unittest.defaultTestLoader)
|
|
|
98
98
|
from warp.tests.test_bvh import TestBvh
|
|
99
99
|
from warp.tests.test_closest_point_edge_edge import TestClosestPointEdgeEdgeMethods
|
|
100
100
|
from warp.tests.test_codegen import TestCodeGen
|
|
101
|
+
from warp.tests.test_codegen_instancing import TestCodeGenInstancing
|
|
101
102
|
from warp.tests.test_compile_consts import TestConstants
|
|
102
103
|
from warp.tests.test_conditional import TestConditional
|
|
103
104
|
from warp.tests.test_copy import TestCopy
|
|
@@ -117,6 +118,7 @@ def default_suite(test_loader: unittest.TestLoader = unittest.defaultTestLoader)
|
|
|
117
118
|
from warp.tests.test_fem import TestFem, TestFemShapeFunctions
|
|
118
119
|
from warp.tests.test_fp16 import TestFp16
|
|
119
120
|
from warp.tests.test_func import TestFunc
|
|
121
|
+
from warp.tests.test_future_annotations import TestFutureAnnotations
|
|
120
122
|
from warp.tests.test_generics import TestGenerics
|
|
121
123
|
from warp.tests.test_grad import TestGrad
|
|
122
124
|
from warp.tests.test_grad_customs import TestGradCustoms
|
|
@@ -160,6 +162,7 @@ def default_suite(test_loader: unittest.TestLoader = unittest.defaultTestLoader)
|
|
|
160
162
|
from warp.tests.test_reload import TestReload
|
|
161
163
|
from warp.tests.test_rounding import TestRounding
|
|
162
164
|
from warp.tests.test_runlength_encode import TestRunlengthEncode
|
|
165
|
+
from warp.tests.test_scalar_ops import TestScalarOps
|
|
163
166
|
from warp.tests.test_sim_grad import TestSimGradients
|
|
164
167
|
from warp.tests.test_sim_kinematics import TestSimKinematics
|
|
165
168
|
from warp.tests.test_smoothstep import TestSmoothstep
|
|
@@ -172,8 +175,10 @@ def default_suite(test_loader: unittest.TestLoader = unittest.defaultTestLoader)
|
|
|
172
175
|
from warp.tests.test_tape import TestTape
|
|
173
176
|
from warp.tests.test_torch import TestTorch
|
|
174
177
|
from warp.tests.test_transient_module import TestTransientModule
|
|
178
|
+
from warp.tests.test_triangle_closest_point import TestTriangleClosestPoint
|
|
175
179
|
from warp.tests.test_types import TestTypes
|
|
176
180
|
from warp.tests.test_utils import TestUtils
|
|
181
|
+
from warp.tests.test_vbd import TestVBD
|
|
177
182
|
from warp.tests.test_vec import TestVec
|
|
178
183
|
from warp.tests.test_vec_lite import TestVecLite
|
|
179
184
|
from warp.tests.test_vec_scalar_ops import TestVecScalarOps
|
|
@@ -193,6 +198,7 @@ def default_suite(test_loader: unittest.TestLoader = unittest.defaultTestLoader)
|
|
|
193
198
|
TestBvh,
|
|
194
199
|
TestClosestPointEdgeEdgeMethods,
|
|
195
200
|
TestCodeGen,
|
|
201
|
+
TestCodeGenInstancing,
|
|
196
202
|
TestConstants,
|
|
197
203
|
TestConditional,
|
|
198
204
|
TestCopy,
|
|
@@ -211,6 +217,7 @@ def default_suite(test_loader: unittest.TestLoader = unittest.defaultTestLoader)
|
|
|
211
217
|
TestFemShapeFunctions,
|
|
212
218
|
TestFp16,
|
|
213
219
|
TestFunc,
|
|
220
|
+
TestFutureAnnotations,
|
|
214
221
|
TestGenerics,
|
|
215
222
|
TestGrad,
|
|
216
223
|
TestGradCustoms,
|
|
@@ -254,6 +261,7 @@ def default_suite(test_loader: unittest.TestLoader = unittest.defaultTestLoader)
|
|
|
254
261
|
TestReload,
|
|
255
262
|
TestRounding,
|
|
256
263
|
TestRunlengthEncode,
|
|
264
|
+
TestScalarOps,
|
|
257
265
|
TestSimGradients,
|
|
258
266
|
TestSimKinematics,
|
|
259
267
|
TestSmoothstep,
|
|
@@ -266,8 +274,10 @@ def default_suite(test_loader: unittest.TestLoader = unittest.defaultTestLoader)
|
|
|
266
274
|
TestTape,
|
|
267
275
|
TestTorch,
|
|
268
276
|
TestTransientModule,
|
|
277
|
+
TestTriangleClosestPoint,
|
|
269
278
|
TestTypes,
|
|
270
279
|
TestUtils,
|
|
280
|
+
TestVBD,
|
|
271
281
|
TestVec,
|
|
272
282
|
TestVecLite,
|
|
273
283
|
TestVecScalarOps,
|
|
@@ -288,6 +298,7 @@ def kit_suite(test_loader: unittest.TestLoader = unittest.defaultTestLoader):
|
|
|
288
298
|
from warp.tests.test_array_reduce import TestArrayReduce
|
|
289
299
|
from warp.tests.test_bvh import TestBvh
|
|
290
300
|
from warp.tests.test_codegen import TestCodeGen
|
|
301
|
+
from warp.tests.test_codegen_instancing import TestCodeGenInstancing
|
|
291
302
|
from warp.tests.test_compile_consts import TestConstants
|
|
292
303
|
from warp.tests.test_conditional import TestConditional
|
|
293
304
|
from warp.tests.test_ctypes import TestCTypes
|
|
@@ -332,6 +343,7 @@ def kit_suite(test_loader: unittest.TestLoader = unittest.defaultTestLoader):
|
|
|
332
343
|
TestArrayReduce,
|
|
333
344
|
TestBvh,
|
|
334
345
|
TestCodeGen,
|
|
346
|
+
TestCodeGenInstancing,
|
|
335
347
|
TestConstants,
|
|
336
348
|
TestConditional,
|
|
337
349
|
TestCTypes,
|
warp/tests/unittest_utils.py
CHANGED
|
@@ -198,11 +198,15 @@ class CheckOutput:
|
|
|
198
198
|
if s != "":
|
|
199
199
|
print(s.rstrip())
|
|
200
200
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
201
|
+
# fail if test produces unexpected output (e.g.: from wp.expect_eq() builtins)
|
|
202
|
+
# we allow strings starting of the form "Module xxx load on device xxx"
|
|
203
|
+
# for lazy loaded modules
|
|
204
|
+
filtered_s = "\n".join(
|
|
205
|
+
[line for line in s.splitlines() if not (line.startswith("Module") and "load on device" in line)]
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
if filtered_s.strip():
|
|
209
|
+
self.test.fail(f"Unexpected output:\n'{s.rstrip()}'")
|
|
206
210
|
|
|
207
211
|
|
|
208
212
|
def assert_array_equal(result: wp.array, expect: wp.array):
|
warp/thirdparty/dlpack.py
CHANGED
|
@@ -58,6 +58,7 @@ class DLDataTypeCode(ctypes.c_uint8):
|
|
|
58
58
|
kDLOpaquePointer = 3
|
|
59
59
|
kDLBfloat = 4
|
|
60
60
|
kDLComplex = 5
|
|
61
|
+
kDLBool = 6
|
|
61
62
|
|
|
62
63
|
def __str__(self):
|
|
63
64
|
return {
|
|
@@ -66,6 +67,7 @@ class DLDataTypeCode(ctypes.c_uint8):
|
|
|
66
67
|
self.kDLFloat: "float",
|
|
67
68
|
self.kDLBfloat: "bfloat",
|
|
68
69
|
self.kDLComplex: "complex",
|
|
70
|
+
self.kDLBool: "bool",
|
|
69
71
|
self.kDLOpaquePointer: "void_p",
|
|
70
72
|
}[self.value]
|
|
71
73
|
|
|
@@ -85,7 +87,7 @@ class DLDataType(ctypes.Structure):
|
|
|
85
87
|
("lanes", ctypes.c_uint16),
|
|
86
88
|
]
|
|
87
89
|
TYPE_MAP = {
|
|
88
|
-
"bool": (DLDataTypeCode.
|
|
90
|
+
"bool": (DLDataTypeCode.kDLBool, 8, 1),
|
|
89
91
|
"int8": (DLDataTypeCode.kDLInt, 8, 1),
|
|
90
92
|
"int16": (DLDataTypeCode.kDLInt, 16, 1),
|
|
91
93
|
"int32": (DLDataTypeCode.kDLInt, 32, 1),
|