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

Method Compute

tensorflow/core/kernels/regex_replace_op.cc:67–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65 }
66
67 void Compute(OpKernelContext* ctx) override {
68 const Tensor* pattern_tensor;
69 OP_REQUIRES_OK(ctx, ctx->input("pattern", &pattern_tensor));
70 OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(pattern_tensor->shape()),
71 errors::InvalidArgument("Pattern must be scalar, but received ",
72 pattern_tensor->shape().DebugString()));
73 const string& pattern = pattern_tensor->scalar<tstring>()();
74 const RE2 match(pattern);
75 OP_REQUIRES(ctx, match.ok(),
76 errors::InvalidArgument("Invalid pattern: ", pattern,
77 ", error: ", match.error()));
78
79 const Tensor* rewrite_tensor;
80 OP_REQUIRES_OK(ctx, ctx->input("rewrite", &rewrite_tensor));
81 OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(rewrite_tensor->shape()),
82 errors::InvalidArgument("Rewrite must be scalar, but received ",
83 rewrite_tensor->shape().DebugString()));
84 const string& rewrite = rewrite_tensor->scalar<tstring>()();
85 OP_REQUIRES_OK(ctx, InternalCompute(match, rewrite, replace_global_, ctx));
86 }
87
88 private:
89 bool replace_global_;

Callers

nothing calls this directly

Calls 8

InvalidArgumentFunction · 0.85
InternalComputeFunction · 0.85
errorMethod · 0.80
IsScalarFunction · 0.50
inputMethod · 0.45
shapeMethod · 0.45
DebugStringMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected