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

Method SetComputeError

tensorflow/core/kernels/cwise_ops_common.cc:34–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34void BinaryOpShared::SetComputeError(OpKernelContext* ctx) {
35 // For speed, errors during compute are caught only via boolean flag, with no
36 // associated information. This is sufficient for now, since the only binary
37 // ops that have compute errors are integer division and mod, and the only
38 // error they produce is zero division.
39 const string& op = ctx->op_kernel().type_string();
40 if ((op == "Div" || op == "Mod" || op == "FloorMod" || op == "FloorDiv") &&
41 DataTypeIsInteger(ctx->op_kernel().input_type(0))) {
42 ctx->CtxFailure(errors::InvalidArgument("Integer division by zero"));
43 } else if ((op == "Pow") &&
44 DataTypeIsInteger(ctx->op_kernel().input_type(0)) &&
45 DataTypeIsSigned(ctx->op_kernel().input_type(1))) {
46 ctx->CtxFailure(errors::InvalidArgument(
47 "Integers to negative integer powers are not allowed"));
48 } else {
49 ctx->CtxFailure(
50 errors::Internal("Unexpected error in binary operator "
51 "(only integer div and mod should have errors)"));
52 }
53}
54
55BinaryOpShared::BinaryOpState::BinaryOpState(OpKernelContext* ctx)
56 : in0(ctx->input(0)),

Callers

nothing calls this directly

Calls 6

DataTypeIsIntegerFunction · 0.85
InvalidArgumentFunction · 0.85
DataTypeIsSignedFunction · 0.85
InternalFunction · 0.85
input_typeMethod · 0.45
CtxFailureMethod · 0.45

Tested by

no test coverage detected