MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Compute

Method Compute

tensorflow/core/kernels/string_split_op.cc:606–642  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

604 }
605
606 void Compute(OpKernelContext* ctx) override {
607 const Tensor* input_tensor;
608 OP_REQUIRES_OK(ctx, ctx->input("input", &input_tensor));
609 OP_REQUIRES(ctx, TensorShapeUtils::IsVector(input_tensor->shape()),
610 errors::InvalidArgument("input must be a vector, got shape: ",
611 input_tensor->shape().DebugString()));
612
613 const auto input_vec = input_tensor->vec<string>();
614 const int64 batch_size = input_vec.dimension(0);
615
616 const Tensor* sep_tensor;
617 OP_REQUIRES_OK(ctx, ctx->input("sep", &sep_tensor));
618 OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(sep_tensor->shape()),
619 errors::InvalidArgument("sep must be a scalar, got shape: ",
620 sep_tensor->shape().DebugString()));
621 const auto sep_vec = sep_tensor->flat<string>();
622 StringPiece sep(sep_vec(0));
623
624 uint64 start = 0;
625 uint64 end = 0;
626
627 if (element_cost_ == 0 && batch_size) {
628 size_t sample_id = rand() % batch_size;
629 std::vector<StringPiece> temp_for_warm_up =
630 SplitV2(input_vec(sample_id), sep, maxsplit_);
631 start = Env::Default()->NowNanos();
632 temp_for_warm_up = SplitV2(input_vec(sample_id), sep, maxsplit_);
633 end = Env::Default()->NowNanos();
634 element_cost_ = end -start;
635 }
636 uint64 element_cost = element_cost_;
637 if (element_cost * batch_size >= parallel_limit_) {
638 ParallelSplitV2(ctx, input_vec, batch_size, sep);
639 } else {
640 SequentialSplitV2(ctx, input_vec, batch_size, sep);
641 }
642 }
643
644 private:
645 int maxsplit_;

Callers

nothing calls this directly

Calls 9

InvalidArgumentFunction · 0.85
SplitV2Function · 0.85
DefaultFunction · 0.85
IsScalarFunction · 0.50
inputMethod · 0.45
shapeMethod · 0.45
DebugStringMethod · 0.45
dimensionMethod · 0.45
NowNanosMethod · 0.45

Tested by

no test coverage detected