tensorized_state
TensorizedState
Mixin holding the shared lifecycle and class-level tensors for tensorized states.
Concrete tensorized states should inherit through one of two front-ends
TensorizedAbsoluteStatefor single-object values, VALUES shape (S, N, *value_shape)TensorizedRelativeStatefor pairwise values, VALUES shape (S, N, N, *value_shape)
Both front-ends provide their own global_initialize / initialize_view to allocate
their respective VALUES tensor; everything else (pre/post update, change detection,
wp.array wrapping, graph_dirty flag) lives here and is shared.
Subclasses MUST implement _update_values.
Source code in OmniGibson/omnigibson/object_states/tensorized_state.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
global_update()
classmethod
Globally update all values via _update_values() and async-copy to VALUES_CPU. Change detection and post_update() are called separately by the simulator after synchronize(). Skips if there are no tracked objects.
Should be capturable inside wp.graph: only emits CUDA work via Warp kernel launches and Warp memcpy.
Source code in OmniGibson/omnigibson/object_states/tensorized_state.py
initialize_view()
classmethod
Δt-tracking setup shared across tensorized states. Subclasses' initialize_view should
call super().initialize_view() after they finish allocating VALUES.
Allocates the 1-element wp.array that pre_update fills with the per-step dt each step.
Source code in OmniGibson/omnigibson/object_states/tensorized_state.py
maybe_refresh_caches()
classmethod
Helper for get_value: if caches are dirty (and we're not already
mid-refresh), run the lazy refresh so the upcoming read sees fresh values.
Source code in OmniGibson/omnigibson/object_states/tensorized_state.py
post_update()
classmethod
Called by the simulator after th.cuda.synchronize(). Compares VALUES_CPU with PREV_VALUES (both CPU) to detect changes, fires state_updated() for affected objects, then updates PREV_VALUES.
Reduce semantics: - Absolute (S, N, value_shape): reduces over value_shape dims to get per-(scene, obj) row mask. - Relative (S, N, N, value_shape): reduces over (other-obj, *value_shape) dims to get per-(scene, self-obj) row mask. A pairwise-cell change fires state_updated() once on the row's self-object.
Source code in OmniGibson/omnigibson/object_states/tensorized_state.py
pre_update(dt=0.0)
classmethod
CPU-side prep run BEFORE global_update each step. Snapshots VALUES_CPU into
PREV_VALUES so post_update() can detect changes after the warp work completes,
and stores the caller-provided dt (seconds elapsed for this logical step) into
cls._dt for time-dependent kernels to read inside the captured graph.
Lives outside the captured wp.graph.
Subclasses may override to add per-state CPU prep (e.g. ToggledOn refreshing marker world poses).
Source code in OmniGibson/omnigibson/object_states/tensorized_state.py
value_name()
Returns:
| Type | Description |
|---|---|
str
|
Name of the value key to assign when dumping / loading the state. Should be implemented by subclass |
value_shape()
Returns:
| Type | Description |
|---|---|
tuple
|
Expected shape of the per-object state instance value. Default is () (scalar). |
value_type()
Returns:
| Type | Description |
|---|---|
type
|
Type of the internal value array, e.g., bool, th.uint, th.float32, etc. Default is th.float32 |