TODO(mrry): If these checks become a bottleneck, find a way to reduce the number of times that they are called.
| 159 | // TODO(mrry): If these checks become a bottleneck, find a way to |
| 160 | // reduce the number of times that they are called. |
| 161 | Status QueueBase::ValidateManyTuple(const Tuple& tuple) { |
| 162 | TF_RETURN_IF_ERROR(ValidateTupleCommon(tuple)); |
| 163 | const int64 batch_size = tuple[0].dim_size(0); |
| 164 | if (specified_shapes()) { |
| 165 | for (size_t i = 0; i < tuple.size(); ++i) { |
| 166 | // Expected shape is [batch_size] + component_shapes_[i] |
| 167 | const TensorShape expected_shape = ManyOutShape(i, batch_size); |
| 168 | if (!expected_shape.IsSameSize(tuple[i].shape())) { |
| 169 | return errors::InvalidArgument("Shape mismatch in tuple component ", i, |
| 170 | ". Expected ", |
| 171 | expected_shape.DebugString(), ", got ", |
| 172 | tuple[i].shape().DebugString()); |
| 173 | } |
| 174 | } |
| 175 | } else { |
| 176 | for (size_t i = 1; i < tuple.size(); ++i) { |
| 177 | if (tuple[i].dim_size(0) != batch_size) { |
| 178 | return errors::InvalidArgument( |
| 179 | "All input tensors must have the same size in the 0th ", |
| 180 | "dimension. Component ", i, " has ", tuple[i].dim_size(0), |
| 181 | ", and should have ", batch_size); |
| 182 | } |
| 183 | } |
| 184 | } |
| 185 | return Status::OK(); |
| 186 | } |
| 187 | |
| 188 | void QueueBase::Cancel(Action action, CancellationManager* cancellation_manager, |
| 189 | CancellationToken token) { |
no test coverage detected