MCPcopy Create free account
hub / github.com/MAC-VO/MAC-VO / __init__

Method __init__

Utility/Extensions/TensorExtension.py:168–189  ·  view source on GitHub ↗
(self, 
        shape: torch.Size | Sequence[int], 
        grow_dim: int, 
        device: torch.device, dtype: torch.dtype
    )

Source from the content-addressed store, hash-verified

166 A circular buffer tensor.
167 """
168 def __init__(self,
169 shape: torch.Size | Sequence[int],
170 grow_dim: int,
171 device: torch.device, dtype: torch.dtype
172 ):
173 self.device = device
174 self.grow_dim = grow_dim
175 self.buf_size = shape[self.grow_dim]
176
177 self.q_start = 0 # Starting point of circular array
178 self.q_end = 0 # Ending point of circular array
179
180 self._buffer = torch.empty(size=shape, dtype=dtype, device=device)
181 self._empty = True
182
183 # Special Optimization for scalar write demand
184 # Explicitly maintein a scalar write cache. When the buffer is read
185 # or other (non-scalar) write operation is triggered, first write the
186 # cached scalars in batch operation, then perform the following operations.
187 self.scalar_array = len(shape) == 1
188 self.write_batch = []
189 #
190
191 def __repr__(self) -> str:
192 return f"CircularTensor({self.tensor}, buf_size={self.buf_size}, real_size={len(self)})"

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected