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

Method Compute

tensorflow/core/kernels/dilation_ops.cc:219–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217 }
218
219 void Compute(OpKernelContext* context) override {
220 const Tensor& input = context->input(0);
221 const Tensor& filter = context->input(1);
222 const Tensor& out_backprop = context->input(2);
223
224 // Determine relevant sizes from input and filters.
225 int stride_rows = 0, stride_cols = 0;
226 int rate_rows = 0, rate_cols = 0;
227 int64 pad_top = 0, pad_left = 0;
228 int64 out_rows = 0, out_cols = 0;
229 ParseSizes(context, strides_, rates_, padding_, &stride_rows, &stride_cols,
230 &rate_rows, &rate_cols, &pad_top, &pad_left, &out_rows,
231 &out_cols);
232
233 // Verify that the incoming gradient tensor has the expected size
234 // [ batch, out_rows, out_cols, depth ]
235 const int batch = input.dim_size(0);
236 const int depth = input.dim_size(3);
237 OP_REQUIRES(context,
238 batch == out_backprop.dim_size(0) &&
239 out_rows == out_backprop.dim_size(1) &&
240 out_cols == out_backprop.dim_size(2) &&
241 depth == out_backprop.dim_size(3),
242 errors::InvalidArgument("out_backprop has incompatible size."));
243
244 // The computed in_backprop has the same dimensions as the input:
245 // [ batch, input_rows, input_cols, depth ]
246 Tensor* in_backprop = nullptr;
247 OP_REQUIRES_OK(context,
248 context->allocate_output(0, input.shape(), &in_backprop));
249
250 // If there is nothing to compute, return.
251 if (input.shape().num_elements() == 0) {
252 return;
253 }
254
255 functor::DilationBackpropInput<Device, T>()(
256 context->eigen_device<Device>(), input.tensor<T, 4>(),
257 filter.tensor<T, 3>(), out_backprop.tensor<T, 4>(), stride_rows,
258 stride_cols, rate_rows, rate_cols, pad_top, pad_left,
259 in_backprop->tensor<T, 4>());
260 }
261
262 std::vector<int32> strides_;
263 std::vector<int32> rates_;

Callers

nothing calls this directly

Calls 7

ParseSizesFunction · 0.85
InvalidArgumentFunction · 0.85
allocate_outputMethod · 0.80
inputMethod · 0.45
dim_sizeMethod · 0.45
shapeMethod · 0.45
num_elementsMethod · 0.45

Tested by

no test coverage detected