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

Method Compute

tensorflow/core/kernels/string_strip_op.cc:33–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31 explicit StringStripOp(OpKernelConstruction* context) : OpKernel(context) {}
32
33 void Compute(OpKernelContext* ctx) override {
34 const Tensor* input_tensor;
35 OP_REQUIRES_OK(ctx, ctx->input("input", &input_tensor));
36 Tensor* output_tensor;
37 OP_REQUIRES_OK(
38 ctx, ctx->allocate_output(0, input_tensor->shape(), &output_tensor));
39
40 const auto input = input_tensor->flat<tstring>();
41 auto output = output_tensor->flat<tstring>();
42
43 for (int64 i = 0; i < input.size(); ++i) {
44 StringPiece entry(input(i));
45 str_util::RemoveWhitespaceContext(&entry);
46 output(i) = string(entry);
47 }
48 }
49};
50
51REGISTER_KERNEL_BUILDER(Name("StringStrip").Device(DEVICE_CPU), StringStripOp);

Callers

nothing calls this directly

Calls 5

RemoveWhitespaceContextFunction · 0.85
allocate_outputMethod · 0.80
inputMethod · 0.45
shapeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected