| 342 | } |
| 343 | |
| 344 | void Compute(OpKernelContext* context) override { |
| 345 | const Tensor& tensor_in = context->input(0); |
| 346 | const Tensor& tensor_out = context->input(1); |
| 347 | const Tensor& out_backprop = context->input(2); |
| 348 | OP_REQUIRES(context, tensor_in.dims() == 5, |
| 349 | errors::InvalidArgument("tensor_in must be 5-dimensional")); |
| 350 | OP_REQUIRES(context, tensor_out.dims() == 5, |
| 351 | errors::InvalidArgument("tensor_out must be 5-dimensional")); |
| 352 | OP_REQUIRES(context, out_backprop.dims() == 5, |
| 353 | errors::InvalidArgument("out_backprop must be 5-dimensional")); |
| 354 | |
| 355 | const TensorShape& output_shape = tensor_in.shape(); |
| 356 | Tensor* input_backprop; |
| 357 | OP_REQUIRES_OK(context, |
| 358 | context->allocate_output(0, output_shape, &input_backprop)); |
| 359 | std::array<int64, 3> input_size{ |
| 360 | {GetTensorDim(output_shape, data_format_, '2'), |
| 361 | GetTensorDim(output_shape, data_format_, '1'), |
| 362 | GetTensorDim(output_shape, data_format_, '0')}}; |
| 363 | std::array<int64, 3> window{{GetTensorDim(ksize_, data_format_, '2'), |
| 364 | GetTensorDim(ksize_, data_format_, '1'), |
| 365 | GetTensorDim(ksize_, data_format_, '0')}}; |
| 366 | std::array<int64, 3> stride{{GetTensorDim(stride_, data_format_, '2'), |
| 367 | GetTensorDim(stride_, data_format_, '1'), |
| 368 | GetTensorDim(stride_, data_format_, '0')}}; |
| 369 | std::array<int64, 3> out, padding; |
| 370 | |
| 371 | OP_REQUIRES_OK(context, Get3dOutputSize(input_size, window, stride, |
| 372 | padding_, &out, &padding)); |
| 373 | |
| 374 | const int64_t depth = GetTensorDim(tensor_in, data_format_, 'C'); |
| 375 | const int64_t in_batch = GetTensorDim(tensor_in, data_format_, 'N'); |
| 376 | TensorShape out_shape = ShapeFromFormat(data_format_, in_batch, |
| 377 | {{out[2], out[1], out[0]}}, depth); |
| 378 | OP_REQUIRES( |
| 379 | context, tensor_out.shape() == out_shape, |
| 380 | errors::InvalidArgument("Expected orig_output shape to be ", out_shape, |
| 381 | ", but got ", tensor_out.shape())); |
| 382 | OP_REQUIRES(context, out_backprop.shape() == out_shape, |
| 383 | errors::InvalidArgument("Expected grad shape to be ", out_shape, |
| 384 | ", but got ", out_backprop.shape())); |
| 385 | |
| 386 | LaunchMaxPooling3dGradOp<Device, T>::launch( |
| 387 | context, tensor_in, tensor_out, out_backprop, window, stride, out, |
| 388 | padding, data_format_, input_backprop); |
| 389 | } |
| 390 | |
| 391 | private: |
| 392 | std::vector<int32> ksize_; |
nothing calls this directly
no test coverage detected