message: Add parallel implementation of CTC greedy decoder
diff: @@ -27,6 +27,7 @@ limitations under the License.
  #include "tensorflow/core/platform/macros.h"
  #include "tensorflow/core/util/ctc/ctc_beam_search.h"
  #include "tensorflow/core/util/sparse/sparse_tensor.h"
  +#include "tensorflow/core/util/work_sharder.h"
  namespace tensorflow {
  @@ -213,7 +214,8 @@ class CTCGreedyDecoderOp : public OpKernel {
  // Perform best path decoding
  std::vector<std::vector<std::vector<int> > > sequences(batch_size);
  - for (int b = 0; b < batch_size; ++b) {
  + auto decode = [&](const int64 begin, const int64 end) {
  + for (int b = begin; b < end; ++b) {
  sequences[b].resize(1);
  auto &sequence = sequences[b][0];
  int prev_indices = -1;
  @@ -227,6 +229,14 @@ class CTCGreedyDecoderOp : public OpKernel {
  prev_indices = max_class_indices;
  }
  }
  + };
  +
  + const int64 kCostPerUnit = 50 * max_time * num_classes;
  + const int64 total = batch_size;
  + const DeviceBase::CpuWorkerThreads& worker_threads =
  + *ctx->device()->tensorflow_cpu_worker_threads();
  + Shard(worker_threads.num_threads, worker_threads.workers, total,
  + kCostPerUnit, decode);
  OP_REQUIRES_OK(
  ctx, decode_helper_.StoreAllDecodedSequences(
  