| 98 | } |
| 99 | |
| 100 | xla::StatusOr<std::vector<int64>> GetStride(XlaOpKernelContext* ctx) { |
| 101 | if (ctx->num_inputs() == 1) { |
| 102 | return stride_; |
| 103 | } |
| 104 | const TensorShape stride_shape = ctx->InputShape(2); |
| 105 | // Validate input sizes. |
| 106 | if (!TensorShapeUtils::IsVector(stride_shape)) { |
| 107 | return errors::InvalidArgument("stride must be a vector, not shape ", |
| 108 | stride_shape.DebugString()); |
| 109 | } |
| 110 | if (stride_shape.num_elements() != num_dims()) { |
| 111 | return errors::InvalidArgument( |
| 112 | "Sliding window stride field must " |
| 113 | "specify ", |
| 114 | num_dims(), " dimensions"); |
| 115 | } |
| 116 | std::vector<int64> stride; |
| 117 | auto status = ctx->ConstantInputAsIntVector(2, &stride); |
| 118 | if (!status.ok()) { |
| 119 | return status; |
| 120 | } |
| 121 | return stride; |
| 122 | } |
| 123 | |
| 124 | protected: |
| 125 | const int num_spatial_dims_; |
nothing calls this directly
no test coverage detected