tensorized_relative_state
TensorizedRelativeState
Bases: TensorizedState, RelativeObjectState
Tensorized state-mixin for RELATIVE (pairwise) values.
All pairwise values across all object state instances of this type are updated at once via _update_values(), rather than per individual instance update() call.
Multi-scene layout
VALUES (S, N, N, *value_shape) — [scene, self_obj, other_obj, ...] OBJ_IDXS {relative_prim_path: int} — shared N index across both pairwise dims IDX_OBJS list[list[obj|None]] — IDX_OBJS[scene_idx][obj_idx] = object instance
Conventions
- Diagonal cells
VALUES[s, i, i, ...]should be False / zero by convention; subclasses enforce this in their_update_valueskernel. - Cross-scene cells (object
aexists in scene s butbdoes not) should be False / zero; subclasses enforce via existence-mask checks in their kernel.
Subclasses are derived states (computed from simulator state each step). The default
_dump_state / _load_state / serialize / deserialize / state_size are no-ops
because pairwise values are recomputed and don't need to round-trip through saves.
Subclasses may override if persistence is needed.
_set_value(self, other, new_value) raises NotImplementedError by default. Subclasses
that need a setter should override it (typically by copying the original non-tensorized
setter logic and writing into the (s, idx_self, idx_other) cell).
Source code in OmniGibson/omnigibson/object_states/tensorized_relative_state.py
11 12 13 14 15 16 17 18 19 20 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 | |
global_initialize()
classmethod
Initialize the global class-level tensors and indices for the (S, N, N, ...) shape.
Source code in OmniGibson/omnigibson/object_states/tensorized_relative_state.py
initialize_view()
classmethod
Rebuild all class-level tensors by scanning current objects across all scenes.
Called from simulator.py after scene changes.
Two-pass to avoid the O(N^3) grow-by-cat pattern the naive implementation has: pass 1 only touches Python dicts/lists to settle OBJ_IDXS / IDX_OBJS at their final size; pass 2 allocates VALUES once at (S, N, N, value_shape) and fills carry-over values directly. For a scene with N objects across S scenes this is O(SN^2) instead of O(N^3).
Carry-over: for each (a, b) pair where both relative_prim_paths still exist, the previous VALUES[s, a, b] is preserved. New rows/columns are zero-initialized.
Source code in OmniGibson/omnigibson/object_states/tensorized_relative_state.py
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 | |