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

Function GetErrorOptions

tensorflow/core/kernels/unicode_ops.cc:206–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204};
205
206Status GetErrorOptions(OpKernelConstruction* ctx, ErrorOptions* out) {
207 *out = ErrorOptions();
208
209 string error_policy;
210 TF_RETURN_IF_ERROR(ctx->GetAttr("errors", &error_policy));
211
212 if (error_policy == "replace") {
213 out->elide_replacement = false;
214 } else if (error_policy == "ignore") {
215 out->elide_replacement = true;
216 } else if (error_policy == "strict") {
217 out->error_on_malformatting = true;
218 } else {
219 return errors::InvalidArgument(
220 "errors policy must be one of 'strict', 'replace', or 'ignore'");
221 }
222
223 int32 replacement_char;
224 TF_RETURN_IF_ERROR(ctx->GetAttr("replacement_char", &replacement_char));
225
226 if (replacement_char >= UCHAR_MIN_VALUE &&
227 replacement_char <= UCHAR_MAX_VALUE) {
228 out->subst = replacement_char;
229 } else {
230 return errors::InvalidArgument(
231 "replacement_char out of unicode codepoint range");
232 }
233
234 if (ctx->HasAttr("replace_control_characters")) {
235 TF_RETURN_IF_ERROR(ctx->GetAttr("replace_control_characters",
236 &(out->replace_control_chars)));
237 }
238
239 return Status::OK();
240}
241
242inline bool ShouldHandleFormatError(const ErrorOptions& error_options,
243 UChar32 ch, bool format_error) {

Callers 3

UnicodeTranscodeOpMethod · 0.85
UnicodeDecodeBaseOpMethod · 0.85
UnicodeEncodeOpMethod · 0.85

Calls 4

ErrorOptionsClass · 0.85
InvalidArgumentFunction · 0.85
GetAttrMethod · 0.45
HasAttrMethod · 0.45

Tested by

no test coverage detected