121 [[nodiscard]] int64_t
size()
const {
return size_; }
124 [[nodiscard]] int64_t
capacity()
const {
return capacity_; }
130 [[nodiscard]] int64_t
action_dim()
const {
return action_dim_; }
134 [[nodiscard]] int64_t next_index(int64_t bound);
137 int64_t observation_dim_;
143 int64_t write_index_ = 0;
146 std::vector<float> observations_;
147 std::vector<float> actions_;
148 std::vector<float> rewards_;
149 std::vector<float> next_observations_;
150 std::vector<float> dones_;
Vendor-agnostic compute/memory backend. CPUBackend, CUDABackend (Phase 1.5), and HIPBackend (Phase 1....
Definition device_backend.hpp:219
Fixed-capacity circular replay buffer of (observation, action, reward, next_observation,...
Definition replay_buffer.hpp:69
int64_t capacity() const
Maximum transitions retained before the oldest starts being overwritten.
Definition replay_buffer.hpp:124
int64_t size() const
Transitions currently stored – rises to capacity(), then stays there.
Definition replay_buffer.hpp:121
int64_t observation_dim() const
Width of an observation row, as passed to the constructor.
Definition replay_buffer.hpp:127
ReplayBuffer(int64_t capacity, int64_t observation_dim, int64_t action_dim, DeviceBackend *backend, uint32_t seed=42)
Constructs an empty buffer with all storage pre-allocated and zero-filled.
ReplayBatch sample(int64_t batch_size)
Draws batch_size transitions uniformly at random, with replacement.
int64_t action_dim() const
Width of an action row, as passed to the constructor.
Definition replay_buffer.hpp:130
void add(const Tensor &observation, const Tensor &action, float reward, const Tensor &next_observation, bool done)
Stores one transition at the current circular write index, overwriting the oldest transition once the...
N-dimensional tensor. Owns its data buffer exclusively; a DeviceBackend* is injected (not owned) – th...
Definition tensor.hpp:29
Abstract interface isolating vendor-specific memory/compute operations from Tensor/ComputationGraph.
Definition acquisition_functions.hpp:16
One uniformly-sampled minibatch of transitions, one Tensor per transition field.
Definition replay_buffer.hpp:30
Tensor actions
Definition replay_buffer.hpp:32
Tensor next_observations
Definition replay_buffer.hpp:34
Tensor rewards
Definition replay_buffer.hpp:33
Tensor observations
Definition replay_buffer.hpp:31
Tensor dones
Definition replay_buffer.hpp:35
N-dimensional tensor – owns a buffer via DeviceBackend*, RAII (Rule of Five).