Emits an index tensor, which the Unbatch op will use to un-concatenate the tensor and attribute the pieces to the right batch keys. The index tensor contains, for each input: [batch_key, start_offset, end_offset] where start_offset and end_offset represent the range of entries in the concatenated tensors that belong to that input. Emits the result to the output at 'output_index' using 'context'.
| 642 | // |
| 643 | // Emits the result to the output at 'output_index' using 'context'. |
| 644 | static Status EmitIndexTensor(OpKernelContext* context, const Batch& batch, |
| 645 | int output_index) { |
| 646 | const TensorShape index_shape({batch.num_tasks(), 3}); |
| 647 | Tensor* index = nullptr; |
| 648 | TF_RETURN_IF_ERROR( |
| 649 | context->allocate_output(output_index, index_shape, &index)); |
| 650 | auto index_flat = index->shaped<int64, 2>({batch.num_tasks(), 3}); |
| 651 | size_t offset = 0; |
| 652 | for (int task_idx = 0; task_idx < batch.num_tasks(); ++task_idx) { |
| 653 | const BatchTask& task = batch.task(task_idx); |
| 654 | index_flat(task_idx, 0) = task.guid; |
| 655 | index_flat(task_idx, 1) = offset; |
| 656 | index_flat(task_idx, 2) = offset + task.size(); |
| 657 | offset += task.size(); |
| 658 | } |
| 659 | return Status::OK(); |
| 660 | } |
| 661 | |
| 662 | // Looks up the batcher queue for 'queue_name'. If it did't previously exist, |
| 663 | // creates it. |
nothing calls this directly
no test coverage detected