Код: Выделить всё
def non_jitted_setup():
print("This code runs once at the beginning of the program.")
return jnp.array([1.0, 2.0, 3.0])
class A:
@partial(jax.jit, static_argnums=0)
def my_jitted_function(self, x):
print("This code runs once during the first trace.")
y = x * 2
self.temp = y
return y
# Program execution
data = non_jitted_setup()
A = A()
result1 = A.my_jitted_function(data) # Tracing happens here
np.array(result1)
np.array(A.temp)
может быть возвращен в результат1 , результат1
Подробнее здесь: https://stackoverflow.com/questions/797 ... program-an