warp.fem.TemporaryStore#

class warp.fem.TemporaryStore[source]#

Shared pool of temporary arrays that will be persisted and reused across invocations of warp.fem functions.

A TemporaryStore instance may either be passed explicitly to warp.fem functions that accept such an argument, for instance integrate.integrate(), or can be set globally as the default store using set_default_temporary_store().

By default, there is no default temporary store, so that temporary allocations are not persisted.

__init__()[source]#

Methods

__init__()

add_temporary_convenience_methods(temporary)

Attach release and detach convenience methods to a temporary.

borrow(shape, dtype[, pinned, device, ...])

Borrow a temporary array from the pool.

clear()

Clear all cached temporary pools.

class Pool(dtype, device, pinned)[source]#
Parameters:

pinned (bool)

class Deleter(pool)[source]#
Parameters:

pool (TemporaryStore.Pool)

detach(temporary)[source]#
Parameters:

temporary (array)

borrow(shape, dtype, requires_grad)[source]#
Parameters:

requires_grad (bool)

redeem(ptr)[source]#
Parameters:

ptr (int)

detach(array)[source]#
Parameters:

array (array)

clear()[source]#

Clear all cached temporary pools.

borrow(
shape,
dtype,
pinned=False,
device=None,
requires_grad=False,
)[source]#

Borrow a temporary array from the pool.

Parameters:
  • shape – Desired shape of the temporary.

  • dtype – Desired data type of the temporary.

  • pinned (bool) – Whether to allocate pinned host memory.

  • device – Device on which to allocate the temporary.

  • requires_grad (bool) – Whether to allocate a gradient array.

Return type:

array

static add_temporary_convenience_methods(temporary)[source]#

Attach release and detach convenience methods to a temporary.

Parameters:

temporary (array)

Return type:

array