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

Method Compute

tensorflow/core/kernels/maxpooling_op.cc:869–908  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

867 }
868
869 void Compute(OpKernelContext* context) override {
870 const Tensor& tensor_in = context->input(0);
871
872 std::vector<int32> ksize = ksize_;
873 std::vector<int32> stride = stride_;
874
875 if (context->num_inputs() != 1) {
876 const Tensor& tensor_ksize = context->input(1);
877 auto value_ksize = tensor_ksize.flat<int32>();
878 ksize.resize(tensor_ksize.shape().num_elements());
879 std::copy_n(&value_ksize(0), ksize.size(), ksize.begin());
880
881 const Tensor& tensor_stride = context->input(2);
882 auto value_stride = tensor_stride.flat<int32>();
883 stride.resize(tensor_stride.shape().num_elements());
884 std::copy_n(&value_stride(0), stride.size(), stride.begin());
885 }
886 OP_REQUIRES(context, ksize.size() == 4,
887 errors::InvalidArgument("Sliding window ksize field must "
888 "specify 4 dimensions"));
889 OP_REQUIRES(context, stride.size() == 4,
890 errors::InvalidArgument("Sliding window stride field must "
891 "specify 4 dimensions"));
892 OP_REQUIRES(context, ksize[0] == 1 && stride[0] == 1,
893 errors::Unimplemented(
894 "Pooling is not yet supported on the batch dimension."));
895 PoolParameters params{context, ksize, stride,
896 padding_, data_format_, tensor_in.shape()};
897 if (!context->status().ok()) {
898 return;
899 }
900
901 TensorShape out_shape({params.tensor_in_batch, params.out_height,
902 params.out_width, params.depth});
903 Tensor* output = nullptr;
904 OP_REQUIRES_OK(context, context->allocate_output(0, out_shape, &output));
905
906 LaunchMaxPoolingNoMask<Device, T>::launch(context, params, tensor_in,
907 output);
908 }
909
910 private:
911 std::vector<int32> ksize_;

Callers

nothing calls this directly

Calls 13

InvalidArgumentFunction · 0.85
UnimplementedFunction · 0.85
launchFunction · 0.85
allocate_outputMethod · 0.80
inputMethod · 0.45
num_inputsMethod · 0.45
resizeMethod · 0.45
num_elementsMethod · 0.45
shapeMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected