* Initialize & check a TensorList based on an input shape * Allocate it as float */
| 89 | * Allocate it as float |
| 90 | */ |
| 91 | void SetupTensorList(TensorList<Backend> *tensor_list, const TensorListShape<> &shape, |
| 92 | vector<Index> *offsets) { |
| 93 | const int num_tensor = shape.size(); |
| 94 | |
| 95 | Index offset = 0; |
| 96 | |
| 97 | for (int i = 0; i < shape.size(); i++) { |
| 98 | offsets->push_back(offset); |
| 99 | offset += volume(shape[i]); |
| 100 | } |
| 101 | |
| 102 | // Resize the buffer |
| 103 | tensor_list->Resize(shape, DALI_FLOAT); |
| 104 | |
| 105 | // Check the internals |
| 106 | ASSERT_TRUE(tensor_list->has_data()); |
| 107 | ASSERT_EQ(tensor_list->num_samples(), num_tensor); |
| 108 | for (int i = 0; i < num_tensor; ++i) { |
| 109 | ASSERT_NE(tensor_list->template mutable_tensor<float>(i), nullptr); |
| 110 | ASSERT_EQ(tensor_list->tensor_shape(i), shape[i]); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | BatchContiguity inverse(BatchContiguity contiguity) { |
| 115 | DALI_ENFORCE(contiguity != BatchContiguity::Automatic, |
no test coverage detected