112 void add(
const Tensor& observation,
const Tensor& action,
float reward,
float log_prob,
bool done);
170 [[nodiscard]] int64_t
size()
const {
return size_; }
173 [[nodiscard]] int64_t
max_length()
const {
return max_length_; }
179 [[nodiscard]] int64_t
action_dim()
const {
return action_dim_; }
183 int64_t observation_dim_;
190 std::vector<float> observations_;
191 std::vector<float> actions_;
192 std::vector<float> rewards_;
193 std::vector<float> log_probs_;
194 std::vector<float> dones_;
Vendor-agnostic compute/memory backend. CPUBackend, CUDABackend (Phase 1.5), and HIPBackend (Phase 1....
Definition device_backend.hpp:219
Fixed-length, fill-once on-policy trajectory buffer of (observation, action, reward,...
Definition rollout_buffer.hpp:83
int64_t size() const
Steps currently stored – rises to max_length(), never past it.
Definition rollout_buffer.hpp:170
RolloutBuffer(int64_t max_length, int64_t observation_dim, int64_t action_dim, DeviceBackend *backend)
Constructs an empty buffer with all storage pre-allocated and zero-filled.
int64_t observation_dim() const
Width of an observation row, as passed to the constructor.
Definition rollout_buffer.hpp:176
int64_t action_dim() const
Width of an action row, as passed to the constructor.
Definition rollout_buffer.hpp:179
void clear()
Empties the rollout, making the buffer reusable for the next one.
void add(const Tensor &observation, const Tensor &action, float reward, float log_prob, bool done)
Appends one step to the rollout.
RolloutBatch compute_returns(float gamma) const
Reduces the stored rollout to per-step discounted return-to-go, G_t = sum_{k=t}^{T-1} gamma^(k-t) * r...
Tensor rewards() const
The raw per-step rewards exactly as add()-ed, shape (size(), 1), in stored order.
Tensor dones() const
The raw per-step termination flags as 0.0f/1.0f floats, shape (size(), 1), in stored order – the same...
int64_t max_length() const
Steps one rollout holds, as passed to the constructor.
Definition rollout_buffer.hpp:173
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 whole stored rollout, reduced to what a policy-gradient update consumes: the visited observations...
Definition rollout_buffer.hpp:32
Tensor actions
Definition rollout_buffer.hpp:34
Tensor log_probs
Definition rollout_buffer.hpp:36
Tensor observations
Definition rollout_buffer.hpp:33
Tensor returns
Definition rollout_buffer.hpp:35
N-dimensional tensor – owns a buffer via DeviceBackend*, RAII (Rule of Five).