| 167 | } |
| 168 | |
| 169 | void Compile(XlaOpKernelContext* ctx) override { |
| 170 | auto ksize_or_error = GetKernelSize(ctx); |
| 171 | OP_REQUIRES_OK(ctx, ksize_or_error.status()); |
| 172 | std::vector<int64> ksize = ksize_or_error.ValueOrDie(); |
| 173 | |
| 174 | auto stride_or_error = GetStride(ctx); |
| 175 | OP_REQUIRES_OK(ctx, stride_or_error.status()); |
| 176 | std::vector<int64> stride = stride_or_error.ValueOrDie(); |
| 177 | |
| 178 | const TensorShape input_shape = ctx->InputShape(0); |
| 179 | OP_REQUIRES(ctx, input_shape.dims() == num_dims(), |
| 180 | errors::InvalidArgument("Input to ", type_string(), |
| 181 | " operator must have ", num_dims(), |
| 182 | " dimensions")); |
| 183 | |
| 184 | auto pooling = |
| 185 | xla::MaxPool(ctx->Input(0), ksize, stride, padding_, |
| 186 | XlaTensorFormat(data_format_, input_shape.dims() - 2)); |
| 187 | ctx->SetOutput(0, pooling); |
| 188 | } |
| 189 | }; |
| 190 | |
| 191 | class MaxPool2DOp : public MaxPoolOp { |
nothing calls this directly
no test coverage detected