| 119 | public ::testing::WithParamInterface<TestParam> {}; |
| 120 | |
| 121 | TEST_P(ParameterizedZipDatasetOpTest, GetNext) { |
| 122 | int thread_num = 2, cpu_num = 2; |
| 123 | TF_ASSERT_OK(InitThreadPool(thread_num)); |
| 124 | TF_ASSERT_OK(InitFunctionLibraryRuntime({}, cpu_num)); |
| 125 | |
| 126 | const TestParam &test_case = GetParam(); |
| 127 | std::vector<Tensor> range_dataset_tensors; |
| 128 | range_dataset_tensors.reserve(test_case.input_range_dataset_params.size()); |
| 129 | TF_ASSERT_OK(CreateRangeDatasetTensors(test_case.input_range_dataset_params, |
| 130 | &range_dataset_tensors)); |
| 131 | gtl::InlinedVector<TensorValue, 4> inputs; |
| 132 | inputs.reserve(range_dataset_tensors.size()); |
| 133 | for (auto &tensor : range_dataset_tensors) { |
| 134 | inputs.emplace_back(&tensor); |
| 135 | } |
| 136 | std::unique_ptr<OpKernel> dataset_kernel; |
| 137 | int num_tensors_per_slice = test_case.input_range_dataset_params.size(); |
| 138 | TF_ASSERT_OK(CreateZipDatasetKernel({DT_INT64}, {{num_tensors_per_slice}}, |
| 139 | inputs.size(), &dataset_kernel)); |
| 140 | std::unique_ptr<OpKernelContext> dataset_kernel_ctx; |
| 141 | TF_ASSERT_OK(CreateZipDatasetContext(dataset_kernel.get(), &inputs, |
| 142 | &dataset_kernel_ctx)); |
| 143 | DatasetBase *zip_dataset; |
| 144 | TF_ASSERT_OK(CreateDataset(dataset_kernel.get(), dataset_kernel_ctx.get(), |
| 145 | &zip_dataset)); |
| 146 | core::ScopedUnref scoped_unref(zip_dataset); |
| 147 | std::unique_ptr<IteratorContext> iterator_ctx; |
| 148 | TF_ASSERT_OK(CreateIteratorContext(dataset_kernel_ctx.get(), &iterator_ctx)); |
| 149 | std::unique_ptr<IteratorBase> iterator; |
| 150 | TF_ASSERT_OK( |
| 151 | zip_dataset->MakeIterator(iterator_ctx.get(), "Iterator", &iterator)); |
| 152 | |
| 153 | auto expected_outputs_it = test_case.expected_outputs.begin(); |
| 154 | bool end_of_sequence = false; |
| 155 | std::vector<Tensor> out_tensors; |
| 156 | while (!end_of_sequence) { |
| 157 | TF_EXPECT_OK( |
| 158 | iterator->GetNext(iterator_ctx.get(), &out_tensors, &end_of_sequence)); |
| 159 | if (!end_of_sequence) { |
| 160 | for (const auto &tensor : out_tensors) { |
| 161 | EXPECT_NE(expected_outputs_it, test_case.expected_outputs.end()); |
| 162 | TF_EXPECT_OK(ExpectEqual(tensor, *expected_outputs_it)); |
| 163 | expected_outputs_it++; |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | EXPECT_EQ(expected_outputs_it, test_case.expected_outputs.end()); |
| 168 | } |
| 169 | |
| 170 | TEST_F(ZipDatasetOpTest, DatasetNodeName) { |
| 171 | int thread_num = 2, cpu_num = 2; |
nothing calls this directly
no test coverage detected