| 1973 | } |
| 1974 | |
| 1975 | Status 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), ¶ms_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 | |
| 2011 | Status ScatterNdUpdateShape(InferenceContext* c) { |
| 2012 | ShapeHandle input_shape = c->input(0); |
nothing calls this directly
no test coverage detected