Skip to content

Commit

Permalink
[Lang] Move real function out of the experimental module (#8399)
Browse files Browse the repository at this point in the history
Issue: #

### Brief Summary

<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 8c46960</samp>

This pull request updates the `real_func` examples and tests to use the
stable `ti.real_func` decorator and the new vector, matrix, and field
APIs. It also refactors some code for readability, performance, and
consistency, and removes the deprecated `experimental` module.

### Walkthrough

<!--
copilot:walkthrough
-->
### <samp>🤖 Generated by Copilot at 8c46960</samp>

* Remove `experimental` module and move `real_func` decorator to
top-level `taichi` module
([link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-e0e39c57bc92c0e1da4c831f8820a4082a3cc26a9b88962bee72964dfa26a74aL13-R13),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-a157043b38542c8145447ff342fda65fe4d54fb777fe514daa70007e83e20dc1L1235-R1235))
* Update all examples and tests that use `real_func` decorator to import
it from `taichi` module instead of `experimental` module
([link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-9cbae292e39bc9b37e4cfab4bfef6f363788d06ecb7757753ee5c0ba7ad0afcdL51-R51),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-9cbae292e39bc9b37e4cfab4bfef6f363788d06ecb7757753ee5c0ba7ad0afcdL58-R58),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-9cbae292e39bc9b37e4cfab4bfef6f363788d06ecb7757753ee5c0ba7ad0afcdL72-R82),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-9cbae292e39bc9b37e4cfab4bfef6f363788d06ecb7757753ee5c0ba7ad0afcdL136-R136),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-f6098eab3d43899f2146cafc8454b2d9bae86064709eb2eeb43e0edbf459f22fL33-R33),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-f6098eab3d43899f2146cafc8454b2d9bae86064709eb2eeb43e0edbf459f22fL55-R55),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-f6098eab3d43899f2146cafc8454b2d9bae86064709eb2eeb43e0edbf459f22fL93-R98),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-86667a5be06e5995f4b15199aa3d4b655e64cceed6d108185d5cc71e03f0bb1fL43-R53),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-86667a5be06e5995f4b15199aa3d4b655e64cceed6d108185d5cc71e03f0bb1fL89-R94),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-86667a5be06e5995f4b15199aa3d4b655e64cceed6d108185d5cc71e03f0bb1fL108-R108),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-f9f9a26653afb587b73d90d08c099a8236820fc72b4d247e001954d620073ebcL51-R51),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-f9f9a26653afb587b73d90d08c099a8236820fc72b4d247e001954d620073ebcL61-R61),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-f9f9a26653afb587b73d90d08c099a8236820fc72b4d247e001954d620073ebcL68-R68),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-f9f9a26653afb587b73d90d08c099a8236820fc72b4d247e001954d620073ebcL78-R78),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-f9f9a26653afb587b73d90d08c099a8236820fc72b4d247e001954d620073ebcL89-R89),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-f9f9a26653afb587b73d90d08c099a8236820fc72b4d247e001954d620073ebcL116-R116),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-f9f9a26653afb587b73d90d08c099a8236820fc72b4d247e001954d620073ebcL124-R124),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-52ca6a00561cb88b076a00d2ae2a30dca3d46713e52f0f5ca6b52ecfd95545daL66-R71),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-52ca6a00561cb88b076a00d2ae2a30dca3d46713e52f0f5ca6b52ecfd95545daL80-R80),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-52ca6a00561cb88b076a00d2ae2a30dca3d46713e52f0f5ca6b52ecfd95545daL86-R86),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-52ca6a00561cb88b076a00d2ae2a30dca3d46713e52f0f5ca6b52ecfd95545daL95-R95),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-52ca6a00561cb88b076a00d2ae2a30dca3d46713e52f0f5ca6b52ecfd95545daL105-R105),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-52ca6a00561cb88b076a00d2ae2a30dca3d46713e52f0f5ca6b52ecfd95545daL119-R119),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-52ca6a00561cb88b076a00d2ae2a30dca3d46713e52f0f5ca6b52ecfd95545daL125-R125),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-52ca6a00561cb88b076a00d2ae2a30dca3d46713e52f0f5ca6b52ecfd95545daL132-R132),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-52ca6a00561cb88b076a00d2ae2a30dca3d46713e52f0f5ca6b52ecfd95545daL344-R344),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-f2d9c4a8c504d2073549cde99b31a733a2f39bba4ce9f062cbaa09e1be17aa87L243-R243),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L11-R11),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L29-R29),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L49-R49),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L153-R153),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L185-R185),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L194-R194),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L207-R207),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L221-R221),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L242-R242),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L259-R259),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L281-R281),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L295-R295),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L310-R310),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L329-R329),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L352-R352),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L451-R451),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L469-R469),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L484-R484),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L501-R501),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L515-R515),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-d6f5c74e17462c8ff96d5bba06ebf81d16c015ca667fa945513a80be17bef017L533-R533),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-ca3c8d1edb25b6a7f4affbb79b2e3e74f73b3757e5d465258ce42ea9eb09fbc0L1035-R1035),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-ca3c8d1edb25b6a7f4affbb79b2e3e74f73b3757e5d465258ce42ea9eb09fbc0L1052-R1052),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-ca3c8d1edb25b6a7f4affbb79b2e3e74f73b3757e5d465258ce42ea9eb09fbc0L1134-R1134),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-ca3c8d1edb25b6a7f4affbb79b2e3e74f73b3757e5d465258ce42ea9eb09fbc0L1149-R1149),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-85fb062b09589d588166180e3c7954753018dc39474d3846346f2a8bb3faac32L480-R480),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-85fb062b09589d588166180e3c7954753018dc39474d3846346f2a8bb3faac32L494-R494),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-8641463ffef94529453efd945e02d056e4339417cc65aad074d4e6b3ef093244L49-R53),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-e206c19691b4678b401a5e2787000e93ab0b0060cbf4ac2625b51f87599d98d8L218-R218),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-e206c19691b4678b401a5e2787000e93ab0b0060cbf4ac2625b51f87599d98d8L238-R238),
[link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-e206c19691b4678b401a5e2787000e93ab0b0060cbf4ac2625b51f87599d98d8L258-R258))
* Delete `python/taichi/experimental.py` file as it is no longer needed
([link](https://github.com/taichi-dev/taichi/pull/8399/files?diff=unified&w=0#diff-60267f25c1e1dfada9487235a4a793b63a49aa3d33c93b8449e24ac821a33174))
  • Loading branch information
lin-hitonami authored Oct 31, 2023
1 parent b2d553f commit c72897e
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 72 deletions.
2 changes: 1 addition & 1 deletion python/taichi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from taichi.types.primitive_types import *


from taichi import ad, algorithms, experimental, graph, linalg, math, sparse, tools, types
from taichi import ad, algorithms, graph, linalg, math, sparse, tools, types
from taichi.ui import GUI, hex_to_rgb, rgb_to_hex, ui

# Issue#2223: Do not reorder, or we're busted with partially initialized module
Expand Down
12 changes: 6 additions & 6 deletions python/taichi/examples/real_func/algorithm/marching_squares.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@
iTime = ti.field(float, shape=())


@ti.experimental.real_func
@ti.real_func
def hash22(p_: tm.vec2) -> tm.vec2:
n = tm.sin(tm.dot(p_, tm.vec2(41, 289)))
p = tm.fract(tm.vec2(262144, 32768) * n)
return tm.sin(p * 6.28 + iTime[None])


@ti.experimental.real_func
@ti.real_func
def noise(p_: tm.vec2) -> float:
ip = tm.floor(p_)
p = p_ - ip
Expand All @@ -69,17 +69,17 @@ def noise(p_: tm.vec2) -> float:
return tm.mix(tm.mix(v.x, v.y, p.x), tm.mix(v.z, v.w, p.x), p.y)


@ti.experimental.real_func
@ti.real_func
def isofunc(p: tm.vec2) -> float:
return noise(p / 4 + 1)


@ti.experimental.real_func
@ti.real_func
def interp(p1: tm.vec2, p2: tm.vec2, v1: float, v2: float, isovalue: float) -> tm.vec2:
return tm.mix(p1, p2, (isovalue - v1) / (v2 - v1))


@ti.experimental.real_func
@ti.real_func
def get_vertex(vertex_id: int, values: tm.vec4, isovalue: float) -> tm.vec2:
v = tm.vec2(0)
square = [tm.vec2(0), tm.vec2(1, 0), tm.vec2(1, 1), tm.vec2(0, 1)]
Expand Down Expand Up @@ -133,7 +133,7 @@ def march_squares() -> int:
return edges.length()


@ti.experimental.real_func
@ti.real_func
def dseg(p_: tm.vec2, a: tm.vec2, b_: tm.vec2) -> ti.f32:
p = p_ - a
b = b_ - a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
sample_count = ti.field(int, shape=())


@ti.experimental.real_func
@ti.real_func
def coord_to_index(p: tm.vec2) -> tm.ivec2:
return (p * tm.vec2(grid_n)).cast(int)

Expand All @@ -52,7 +52,7 @@ def refresh_scene():
img[i, j] = tm.vec3(1)


@ti.experimental.real_func
@ti.real_func
def find_nearest_point(p: tm.vec2) -> typing.Tuple[float, tm.vec2]:
x, y = coord_to_index(p)
dmin = 1e5
Expand Down Expand Up @@ -90,12 +90,12 @@ def poisson_disk_sample(num_samples: int) -> int:
return tail[None]


@ti.experimental.real_func
@ti.real_func
def hash21(p: tm.vec2) -> float:
return tm.fract(tm.sin(tm.dot(p, tm.vec2(127.619, 157.583))) * 43758.5453)


@ti.experimental.real_func
@ti.real_func
def sample_dist(uv_: tm.vec2) -> tm.vec4:
uv = uv_ * iResolution
x, y = tm.clamp(0, iResolution - 1, uv).cast(int)
Expand Down
12 changes: 6 additions & 6 deletions python/taichi/examples/real_func/graph/stable_fluid_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ def sample_impl(qf: ti.template(), u: int, v: int):
return qf[I]


@ti.experimental.real_func
@ti.real_func
def sample2(qf: ti.types.ndarray(ndim=2), u: int, v: int) -> vec2:
return sample_impl(qf, u, v)


@ti.experimental.real_func
@ti.real_func
def sample3(qf: ti.types.ndarray(ndim=2), u: int, v: int) -> vec3:
return sample_impl(qf, u, v)


@ti.experimental.real_func
@ti.real_func
def sample0(qf: ti.types.ndarray(ndim=2), u: int, v: int) -> float:
return sample_impl(qf, u, v)

Expand Down Expand Up @@ -86,12 +86,12 @@ def bilerp_impl(vf: ti.template(), p):
return lerp(lerp(a, b, fu), lerp(c, d, fu), fv)


@ti.experimental.real_func
@ti.real_func
def bilerp2(vf: ti.types.ndarray(ndim=2), p: vec2) -> vec2:
return bilerp_impl(vf, p)


@ti.experimental.real_func
@ti.real_func
def bilerp3(vf: ti.types.ndarray(ndim=2), p: vec2) -> vec3:
return bilerp_impl(vf, p)

Expand All @@ -105,7 +105,7 @@ def bilerp(vf: ti.template(), p):


# 3rd order Runge-Kutta
@ti.experimental.real_func
@ti.real_func
def backtrace(vf: ti.types.ndarray(ndim=2), p: vec2, dt_: float) -> vec2:
v1 = bilerp(vf, p)
p1 = p - 0.5 * dt_ * v1
Expand Down
14 changes: 7 additions & 7 deletions python/taichi/examples/real_func/rendering/cornell_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
)


@ti.experimental.real_func
@ti.real_func
def rotate(a: vec3) -> mat3:
s, c = sin(a), cos(a)
return (
Expand All @@ -58,14 +58,14 @@ def rotate(a: vec3) -> mat3:
)


@ti.experimental.real_func
@ti.real_func
def signed_distance(obj: SDFObject, pos: vec3) -> float:
p = obj.transform.matrix @ (pos - obj.transform.position)
q = abs(p) - obj.transform.scale
return length(max(q, 0)) + min(max(q.x, max(q.y, q.z)), 0)


@ti.experimental.real_func
@ti.real_func
def nearest_object(p: vec3) -> (int, float):
index, min_dis = 0, 1e32
for i in ti.static(range(8)):
Expand All @@ -75,7 +75,7 @@ def nearest_object(p: vec3) -> (int, float):
return index, min_dis


@ti.experimental.real_func
@ti.real_func
def calc_normal(obj: SDFObject, p: vec3) -> vec3:
e = vec2(1, -1) * 0.5773 * 0.005
return normalize(
Expand All @@ -86,7 +86,7 @@ def calc_normal(obj: SDFObject, p: vec3) -> vec3:
)


@ti.experimental.real_func
@ti.real_func
def raycast(ray: Ray) -> (SDFObject, vec3, bool):
w, s, d, cerr = 1.6, 0.0, 0.0, 1e32
index, t, position, hit = 0, 0.005, vec3(0), False
Expand All @@ -113,15 +113,15 @@ def raycast(ray: Ray) -> (SDFObject, vec3, bool):
return objects[index], position, hit


@ti.experimental.real_func
@ti.real_func
def hemispheric_sampling(normal: vec3) -> vec3:
z = 2.0 * ti.random() - 1.0
a = ti.random() * 2.0 * pi
xy = sqrt(1.0 - z * z) * vec2(sin(a), cos(a))
return normalize(normal + vec3(xy, z))


@ti.experimental.real_func
@ti.real_func
def raytrace(ray: Ray) -> Ray:
for _ in range(3):
object, position, hit = raycast(ray)
Expand Down
20 changes: 10 additions & 10 deletions python/taichi/examples/real_func/rendering/taichi_ngp.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ def depth2img(depth):


# <----------------- hash table util code ----------------->
@ti.experimental.real_func
@ti.real_func
def calc_dt(t: data_type, exp_step_factor: data_type, grid_size: int, scale: data_type) -> data_type:
return ti.math.clamp(t * exp_step_factor, SQRT3_MAX_SAMPLES, SQRT3_2 * scale / grid_size)


@ti.experimental.real_func
@ti.real_func
def __expand_bits(v_: uvec3) -> uvec3:
v = (v_ * ti.uint32(0x00010001)) & ti.uint32(0xFF0000FF)
v = (v * ti.uint32(0x00000101)) & ti.uint32(0x0F00F00F)
Expand All @@ -77,13 +77,13 @@ def __expand_bits(v_: uvec3) -> uvec3:
return v


@ti.experimental.real_func
@ti.real_func
def __morton3D(xyz_: uvec3) -> ti.u32:
xyz = __expand_bits(xyz_)
return xyz[0] | (xyz[1] << 1) | (xyz[2] << 2)


@ti.experimental.real_func
@ti.real_func
def fast_hash(pos_grid_local: uvec3) -> ti.u32:
result = ti.uint32(0)
primes = uvec3(ti.uint32(1), ti.uint32(2654435761), ti.uint32(805459861))
Expand All @@ -92,7 +92,7 @@ def fast_hash(pos_grid_local: uvec3) -> ti.u32:
return result


@ti.experimental.real_func
@ti.real_func
def under_hash(pos_grid_local: uvec3, resolution: ti.u32) -> ti.u32:
result = ti.uint32(0)
stride = ti.uint32(1)
Expand All @@ -102,7 +102,7 @@ def under_hash(pos_grid_local: uvec3, resolution: ti.u32) -> ti.u32:
return result


@ti.experimental.real_func
@ti.real_func
def grid_pos2hash_index(indicator: ti.i32, pos_grid_local: uvec3, resolution: ti.u32, map_size: ti.u32) -> ti.u32:
hash_result = ti.uint32(0)
if indicator == 1:
Expand All @@ -116,20 +116,20 @@ def grid_pos2hash_index(indicator: ti.i32, pos_grid_local: uvec3, resolution: ti
# <----------------- hash table util code ----------------->


@ti.experimental.real_func
@ti.real_func
def random_in_unit_disk() -> tf_vec2:
theta = 2.0 * np.pi * ti.random()
return ti.Vector([ti.sin(theta), ti.cos(theta)])


@ti.experimental.real_func
@ti.real_func
def random_normal() -> tf_vec2:
x = ti.random() * 2.0 - 1.0
y = ti.random() * 2.0 - 1.0
return tf_vec2(x, y)


@ti.experimental.real_func
@ti.real_func
def dir_encode_func(dir_: tf_vec3) -> tf_vec32:
out_feat = tf_vec32(0.0)
dir_n = dir_ / dir_.norm()
Expand Down Expand Up @@ -341,7 +341,7 @@ def reset(self):
for i, j in ti.ndrange(self.N_rays, 2):
self.alive_indices[i * 2 + j] = i

@ti.experimental.real_func
@ti.real_func
def _ray_aabb_intersec(self, ray_o: tf_vec3, ray_d: tf_vec3) -> tf_vec2:
inv_d = 1.0 / ray_d

Expand Down
3 changes: 0 additions & 3 deletions python/taichi/experimental.py

This file was deleted.

2 changes: 1 addition & 1 deletion python/taichi/lang/kernel_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1232,4 +1232,4 @@ def _getattr(self, item):
return cls


__all__ = ["data_oriented", "func", "kernel", "pyfunc"]
__all__ = ["data_oriented", "func", "kernel", "pyfunc", "real_func"]
2 changes: 1 addition & 1 deletion tests/python/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def _get_expected_matrix_apis():
"dx12",
"eig",
"exp",
"experimental",
"extension",
"f16",
"f32",
Expand Down Expand Up @@ -199,6 +198,7 @@ def _get_expected_matrix_apis():
"random",
"raw_div",
"raw_mod",
"real_func",
"ref",
"rescale_index",
"reset",
Expand Down
2 changes: 1 addition & 1 deletion tests/python/test_argument.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def test_struct_arg_with_matrix_real_func():
s0 = ti.types.struct(a=mat, b=ti.f32)
s1 = ti.types.struct(a=ti.i32, b=s0)

@ti.experimental.real_func
@ti.real_func
def foo(a: s1) -> ti.i32:
ret = a.a + a.b.b
for i in range(3):
Expand Down
Loading

0 comments on commit c72897e

Please sign in to comment.