1#ifndef TORCH_STATE_ADAPTOR_H
2#define TORCH_STATE_ADAPTOR_H
4#include "bitrl/base/bitrl_config.h"
10#include <torch/torch.h>
29 bool requires_grad =
false);
32 bool requires_grad =
false);
35 bool requires_grad =
false);
37 bool requires_grad =
false);
39 bool requires_grad =
false);
41 bool requires_grad =
false);
45 bool requires_grad =
false);
51 bool requires_grad =
false);
70 std::vector<std::vector<float_t>> values_(values.size());
73 for (
uint_t i = 0; i < values.size(); ++i)
75 values_[i].resize(values[i].size());
76 for (
uint_t j = 0; j < values[i].size(); ++j)
78 values_[i][j] =
static_cast<float>(values[i][j]);
Definition torch_adaptor.h:18
Definition bitrl_concepts.h:22
Various utilities used when working with RL problems.
Definition bitrl_log.h:25
torch::Tensor torch_tensor_t
torch_tensor_t
Definition bitrl_types.h:95
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
double real_t
real_t
Definition bitsim_types.h:20
DeviceType
Enumeration of various device types.
Definition bitsim_types.h:186
The TorchStateAdaptor struct.
Definition torch_adaptor.h:24
static value_type to_torch(const std::vector< float_t > &data, DeviceType dtype=DeviceType::CPU, bool requires_grad=false)
torch_tensor_t operator()(const std::vector< int > &data) const
static value_type to_torch(const std::vector< uint_t > &data, DeviceType dtype=DeviceType::CPU, bool requires_grad=false)
static value_type to_torch(const std::vector< lint_t > &data, DeviceType dtype=DeviceType::CPU, bool requires_grad=false)
torch_tensor_t operator()(const std::vector< float_t > &data) const
static value_type to_torch(const std::vector< real_t > &data, DeviceType dtype=DeviceType::CPU, bool requires_grad=false)
static value_type stack(const std::vector< T > &values, DeviceType type=DeviceType::CPU, bool requires_grad=false)
static std::vector< T > to_vector(torch_tensor_t tensor)
static value_type to_torch(const std::vector< int_t > &data, DeviceType dtype=DeviceType::CPU, bool requires_grad=false)
torch_tensor_t value_type
Definition torch_adaptor.h:26
torch_tensor_t operator()(const std::vector< real_t > &data) const
torch_tensor_t operator()(real_t value) const
static value_type cat(const std::vector< real_t > &values, DeviceType type=DeviceType::CPU, bool requires_grad=false)
static value_type to_torch(const std::vector< bool > &data, DeviceType dtype=DeviceType::CPU, bool requires_grad=false)
static value_type stack_as_float(const std::vector< std::vector< T > > &values, DeviceType type=DeviceType::CPU)
Definition torch_adaptor.h:66