Sets output[0] to shape [batch_dim,height,width,channel_dim], where height and width come from the size_tensor.
| 28 | // Sets output[0] to shape [batch_dim,height,width,channel_dim], where |
| 29 | // height and width come from the size_tensor. |
| 30 | Status SetOutputToSizedImage(InferenceContext* c, DimensionHandle batch_dim, |
| 31 | int size_input_idx, DimensionHandle channel_dim) { |
| 32 | // Verify shape of size input. |
| 33 | ShapeHandle size; |
| 34 | TF_RETURN_IF_ERROR(c->WithRank(c->input(size_input_idx), 1, &size)); |
| 35 | DimensionHandle unused; |
| 36 | TF_RETURN_IF_ERROR(c->WithValue(c->Dim(size, 0), 2, &unused)); |
| 37 | |
| 38 | // Get size values from the size tensor. |
| 39 | const Tensor* size_tensor = c->input_tensor(size_input_idx); |
| 40 | DimensionHandle width; |
| 41 | DimensionHandle height; |
| 42 | if (size_tensor == nullptr) { |
| 43 | width = c->UnknownDim(); |
| 44 | height = c->UnknownDim(); |
| 45 | } else { |
| 46 | // TODO(petewarden) - Remove once we have constant evaluation in C++ only. |
| 47 | if (size_tensor->dtype() != DT_INT32) { |
| 48 | return errors::InvalidArgument( |
| 49 | "Bad size input type for SetOutputToSizedImage: Expected DT_INT32 " |
| 50 | "but got ", |
| 51 | DataTypeString(size_tensor->dtype()), " for input #", size_input_idx, |
| 52 | " in ", c->DebugString()); |
| 53 | } |
| 54 | auto vec = size_tensor->vec<int32>(); |
| 55 | height = c->MakeDim(vec(0)); |
| 56 | width = c->MakeDim(vec(1)); |
| 57 | } |
| 58 | c->set_output(0, c->MakeShape({batch_dim, height, width, channel_dim})); |
| 59 | return Status::OK(); |
| 60 | } |
| 61 | |
| 62 | Status ResizeShapeFn(InferenceContext* c) { |
| 63 | ShapeHandle input; |
no test coverage detected