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

Function GetIsPositive

tensorflow/cc/gradients/math_grad.cc:1262–1275  ·  view source on GitHub ↗

Helper function for unsorted segment ops. Returns a mask of where 'ids' are positive, reshaped so that it will be broadcastable to the result shape of gathering params by ids.

Source from the content-addressed store, hash-verified

1260// Returns a mask of where 'ids' are positive, reshaped so that it will be
1261// broadcastable to the result shape of gathering params by ids.
1262Output GetIsPositive(const Scope& scope, const Output& params,
1263 const Output& ids) {
1264 Output is_positive = GreaterEqual(scope, ids, ZerosLike(scope, ids));
1265 // tf.where(condition, x, y) requires condition to have the same shape as x
1266 // and y.
1267 Output is_positive_shape = Shape(scope, is_positive);
1268 Output ones =
1269 Tile(scope, Const(scope, {1}), Subtract(scope, Rank(scope, params), {1}));
1270 auto broadcastable_shape = Concat(scope, {is_positive_shape, ones},
1271 /*axis=*/0);
1272 is_positive = Reshape(scope, is_positive, broadcastable_shape);
1273 is_positive = LogicalAnd(scope, is_positive, OnesLike(scope, is_positive));
1274 return is_positive;
1275}
1276
1277// Helper function for unsorted segment ops.
1278// Gathers params for positive segment ids and gathers 0 for inputs with

Callers 2

UnsortedSegmentSumGradFunction · 0.85

Calls 11

OnesLikeFunction · 0.85
GreaterEqualFunction · 0.50
ZerosLikeFunction · 0.50
ShapeClass · 0.50
TileClass · 0.50
ConstFunction · 0.50
SubtractClass · 0.50
RankFunction · 0.50
ConcatFunction · 0.50
ReshapeFunction · 0.50
LogicalAndClass · 0.50

Tested by

no test coverage detected