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

Function SetOutputToSizedImage

tensorflow/core/ops/image_ops.cc:30–60  ·  view source on GitHub ↗

Sets output[0] to shape [batch_dim,height,width,channel_dim], where height and width come from the size_tensor.

Source from the content-addressed store, hash-verified

28// Sets output[0] to shape [batch_dim,height,width,channel_dim], where
29// height and width come from the size_tensor.
30Status 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
62Status ResizeShapeFn(InferenceContext* c) {
63 ShapeHandle input;

Callers 2

ResizeShapeFnFunction · 0.70
image_ops.ccFile · 0.70

Calls 13

InvalidArgumentFunction · 0.85
WithValueMethod · 0.80
UnknownDimMethod · 0.80
DataTypeStringFunction · 0.50
WithRankMethod · 0.45
inputMethod · 0.45
DimMethod · 0.45
input_tensorMethod · 0.45
dtypeMethod · 0.45
DebugStringMethod · 0.45
MakeDimMethod · 0.45
set_outputMethod · 0.45

Tested by

no test coverage detected