| 169 | } |
| 170 | |
| 171 | void Compute(OpKernelContext* context) override { |
| 172 | const Tensor& tensor_in = context->input(0); |
| 173 | |
| 174 | OP_REQUIRES(context, tensor_in.dims() == 5, |
| 175 | errors::InvalidArgument("tensor_in must be 5-dimensional")); |
| 176 | const int64 depth = GetTensorDim(tensor_in, data_format_, 'C'); |
| 177 | const int64 in_batch = GetTensorDim(tensor_in, data_format_, 'N'); |
| 178 | |
| 179 | // Dimension order for these arrays is: x, y, z. |
| 180 | std::array<int64, 3> input_size{ |
| 181 | {GetTensorDim(tensor_in, data_format_, '2'), |
| 182 | GetTensorDim(tensor_in, data_format_, '1'), |
| 183 | GetTensorDim(tensor_in, data_format_, '0')}}; |
| 184 | std::array<int64, 3> window{{GetTensorDim(ksize_, data_format_, '2'), |
| 185 | GetTensorDim(ksize_, data_format_, '1'), |
| 186 | GetTensorDim(ksize_, data_format_, '0')}}; |
| 187 | std::array<int64, 3> stride{{GetTensorDim(stride_, data_format_, '2'), |
| 188 | GetTensorDim(stride_, data_format_, '1'), |
| 189 | GetTensorDim(stride_, data_format_, '0')}}; |
| 190 | std::array<int64, 3> padding, out; |
| 191 | |
| 192 | OP_REQUIRES_OK(context, Get3dOutputSize(input_size, window, stride, |
| 193 | padding_, &out, &padding)); |
| 194 | |
| 195 | TensorShape out_shape = ShapeFromFormat(data_format_, in_batch, |
| 196 | {{out[2], out[1], out[0]}}, depth); |
| 197 | Tensor* output; |
| 198 | OP_REQUIRES_OK(context, context->allocate_output(0, out_shape, &output)); |
| 199 | LaunchPoolingOp<Device, T, Type>::launch(context, tensor_in, window, stride, |
| 200 | padding, data_format_, padding_, |
| 201 | output); |
| 202 | } |
| 203 | |
| 204 | private: |
| 205 | std::vector<int32> ksize_; |
nothing calls this directly
no test coverage detected