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

Function GatherNdShape

tensorflow/core/framework/common_shape_fns.cc:1975–2009  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1973}
1974
1975Status GatherNdShape(InferenceContext* c) {
1976 ShapeHandle params;
1977 std::vector<ShapeAndType> handle_shape_and_type;
1978 if (c->input_handle_shapes_and_types(0) != nullptr) {
1979 TF_RETURN_IF_ERROR(
1980 ValidateVariableResourceHandle(c, &handle_shape_and_type));
1981 params = handle_shape_and_type[0].shape;
1982 } else {
1983 params = c->input(0);
1984 }
1985 ShapeHandle indices;
1986 TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(1), 1, &indices));
1987 DimensionHandle r_dim = c->Dim(indices, -1);
1988
1989 if (!c->RankKnown(params) || !c->ValueKnown(r_dim)) {
1990 c->set_output(0, c->UnknownShape());
1991 return Status::OK();
1992 }
1993
1994 if (c->Value(r_dim) > c->Rank(params)) {
1995 return errors::InvalidArgument(
1996 "indices.shape[-1] must be <= params.rank, but saw indices shape: ",
1997 c->DebugString(indices), " and params shape: ", c->DebugString(params));
1998 }
1999
2000 // Remove r_dim from indices to get output.
2001 ShapeHandle indices_slice;
2002 ShapeHandle params_slice;
2003 TF_RETURN_IF_ERROR(c->Subshape(indices, 0, -1, &indices_slice));
2004 TF_RETURN_IF_ERROR(c->Subshape(params, c->Value(r_dim), &params_slice));
2005 ShapeHandle out;
2006 TF_RETURN_IF_ERROR(c->Concatenate(indices_slice, params_slice, &out));
2007 c->set_output(0, out);
2008 return Status::OK();
2009}
2010
2011Status ScatterNdUpdateShape(InferenceContext* c) {
2012 ShapeHandle input_shape = c->input(0);

Callers

nothing calls this directly

Calls 15

InvalidArgumentFunction · 0.85
WithRankAtLeastMethod · 0.80
RankKnownMethod · 0.80
ValueKnownMethod · 0.80
UnknownShapeMethod · 0.80
SubshapeMethod · 0.80
inputMethod · 0.45
DimMethod · 0.45
set_outputMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected