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

Method Add

tensorflow/core/framework/shape_inference.cc:1052–1076  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1050}
1051
1052Status InferenceContext::Add(DimensionHandle first, DimensionOrConstant second,
1053 DimensionHandle* out) {
1054 const int64 first_value = Value(first);
1055 const int64 second_value = Value(second);
1056 // Special cases.
1057 if (first_value == 0) {
1058 *out = MakeDim(second);
1059 } else if (second_value == 0) {
1060 *out = first;
1061 } else if (first_value == kUnknownDim || second_value == kUnknownDim) {
1062 *out = UnknownDim();
1063 } else {
1064 // Invariant: Both values are known and positive. Still in run-time we can
1065 // get pair of values which cannot be store in output. Check below will
1066 // report error. We still need to avoid undefined behavior of signed
1067 // overflow and use unsigned addition.
1068 const int64 sum = static_cast<uint64>(first_value) + second_value;
1069 if (sum < 0) {
1070 return errors::InvalidArgument("Dimension size overflow from adding ",
1071 first_value, " and ", second_value);
1072 }
1073 *out = MakeDim(sum);
1074 }
1075 return Status::OK();
1076}
1077
1078Status InferenceContext::Subtract(DimensionHandle first,
1079 DimensionOrConstant second,

Callers 13

FillMethod · 0.45
FillMethod · 0.45
ConcatShapeHelperFunction · 0.45
AddValueMethod · 0.45
ExportMethod · 0.45
SetTensorProtoShapeFunction · 0.45
RepFunction · 0.45
ToProtoMethod · 0.45
TEST_FFunction · 0.45
LOCKS_EXCLUDEDMethod · 0.45

Calls 2

InvalidArgumentFunction · 0.85
ValueClass · 0.70

Tested by 3

RepFunction · 0.36
TEST_FFunction · 0.36
TESTFunction · 0.36