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

Method Compute

tensorflow/core/kernels/pooling_ops_3d.cc:171–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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_;

Callers

nothing calls this directly

Calls 8

InvalidArgumentFunction · 0.85
GetTensorDimFunction · 0.85
Get3dOutputSizeFunction · 0.85
ShapeFromFormatFunction · 0.85
launchFunction · 0.85
allocate_outputMethod · 0.80
inputMethod · 0.45
dimsMethod · 0.45

Tested by

no test coverage detected