10 #include <initializer_list>
17 namespace tensor_init {
24 template <
typename T,
size_t D>
26 using type = std::initializer_list<
35 template <
typename T,
size_t D>
40 static constexpr
size_t value = 0;
51 static constexpr
size_t value(
const L& list) {
52 if (list.size() == 0) {
56 for (
const auto&
value : list) {
59 "Input contains ragged nested sequences"
60 "(nested lists with unequal sizes or shapes).");
70 static constexpr
size_t value(
const L& list) {
75 template <
typename L,
size_t... D>
87 while (shape.
size() > (last_dim + 1) && shape[last_dim] != 0) {
90 shape.
resize(last_dim + 1);
94 template <
typename T,
typename L>
99 template <
typename T,
typename L>
100 void NestedCopy(T&& iter,
const std::initializer_list<L>& list) {
101 for (
const auto& value : list) {
106 template <
typename T,
size_t D>
#define LogError(...)
Definition: Logging.h:51
Definition: SizeVector.h:69
int64_t NumElements() const
Definition: SizeVector.cpp:108
size_t size() const
Definition: SmallVector.h:119
void resize(size_type N)
Definition: SmallVector.h:678
void NestedCopy(T &&iter, const L &list)
Definition: TensorInit.h:95
SizeVector InferShape(const L &list)
Definition: TensorInit.h:82
typename NestedInitializerImpl< T, D >::type NestedInitializerList
Definition: TensorInit.h:36
std::vector< T > ToFlatVector(const SizeVector &shape, const tensor_init::NestedInitializerList< T, D > &nested_list)
Definition: TensorInit.h:107
SizeVector InitializerShape(const L &list, std::index_sequence< D... >)
Definition: TensorInit.h:76
Definition: PinholeCameraIntrinsic.cpp:16
Definition: TensorInit.h:39
static constexpr size_t value
Definition: TensorInit.h:40
static constexpr size_t value(const L &list)
Definition: TensorInit.h:70
Definition: TensorInit.h:49
static constexpr size_t value(const L &list)
Definition: TensorInit.h:51
T type
Definition: TensorInit.h:32
Definition: TensorInit.h:25
std::initializer_list< typename NestedInitializerImpl< T, D - 1 >::type > type
Definition: TensorInit.h:27