| 908 | BM_AvgPoolFwdCPU(32, 14, 14, 576, 3, 3, 2, SAME, 4, "avgpool10_SAME"); |
| 909 | |
| 910 | static void BM_AvgPoolBk(int iters, int batch_size, int rows, int cols, |
| 911 | int depth, int kernel_rows, int kernel_cols, |
| 912 | int stride, Padding padding, int num_threads, |
| 913 | const string& label) { |
| 914 | tensorflow::testing::StopTiming(); |
| 915 | std::unique_ptr<Device> device( |
| 916 | DeviceFactory::NewDevice("CPU", {}, "/job:a/replica:0/task:0")); |
| 917 | |
| 918 | thread::ThreadPool threadpool(Env::Default(), "test", num_threads); |
| 919 | Eigen::ThreadPoolDevice eigen_cpu_device(threadpool.AsEigenThreadPool(), |
| 920 | num_threads); |
| 921 | device->set_eigen_cpu_device(&eigen_cpu_device); |
| 922 | |
| 923 | gtl::InlinedVector<TensorValue, 4> inputs; |
| 924 | |
| 925 | int64 out_height, out_width, pad_rows, pad_cols; |
| 926 | TF_CHECK_OK(GetWindowedOutputSize(rows, kernel_rows, stride, padding, |
| 927 | &out_height, &pad_rows)); |
| 928 | TF_CHECK_OK(GetWindowedOutputSize(cols, kernel_cols, stride, padding, |
| 929 | &out_width, &pad_cols)); |
| 930 | TensorShape output_shape({batch_size, out_height, out_width, depth}); |
| 931 | TensorShape shape2({4}); |
| 932 | Tensor input_shape_tensor(DT_INT32, shape2); |
| 933 | int32 input_dims[] = {batch_size, rows, cols, depth}; |
| 934 | for (int i = 0; i < 4; i++) { |
| 935 | input_shape_tensor.flat<int32>()(i) = input_dims[i]; |
| 936 | } |
| 937 | inputs.push_back({nullptr, &input_shape_tensor}); |
| 938 | |
| 939 | Tensor output_backprop(DT_FLOAT, output_shape); |
| 940 | test::FillIota<float>(&output_backprop, 11.0); |
| 941 | inputs.push_back({nullptr, &output_backprop}); |
| 942 | |
| 943 | // AvgPoolGrad op. |
| 944 | NodeDef avgpool_grad_node_def; |
| 945 | Status status = NodeDefBuilder("avgpool_grad_op", "AvgPoolGrad") |
| 946 | .Input(FakeInput()) |
| 947 | .Input(FakeInput(DT_FLOAT)) |
| 948 | .Attr("ksize", {1, kernel_rows, kernel_cols, 1}) |
| 949 | .Attr("strides", {1, stride, stride, 1}) |
| 950 | .Attr("padding", padding == VALID ? "VALID" : "SAME") |
| 951 | .Finalize(&avgpool_grad_node_def); |
| 952 | TF_CHECK_OK(status); |
| 953 | std::unique_ptr<OpKernel> op( |
| 954 | CreateOpKernel(DEVICE_CPU, nullptr, cpu_allocator(), |
| 955 | avgpool_grad_node_def, TF_GRAPH_DEF_VERSION, &status)); |
| 956 | TF_CHECK_OK(status); |
| 957 | OpKernelContext::Params params; |
| 958 | params.device = device.get(); |
| 959 | params.frame_iter = FrameAndIter(0, 0); |
| 960 | params.inputs = &inputs; |
| 961 | params.op_kernel = op.get(); |
| 962 | std::vector<AllocatorAttributes> attrs; |
| 963 | test::SetOutputAttrs(¶ms, &attrs); |
| 964 | |
| 965 | std::unique_ptr<OpKernelContext> avgpool_context( |
| 966 | new OpKernelContext(¶ms)); |
| 967 |
nothing calls this directly
no test coverage detected