Sums all elements in the window specified by 'kernel_size' and 'stride'.
| 71 | |
| 72 | // Sums all elements in the window specified by 'kernel_size' and 'stride'. |
| 73 | XlaOp ComputeSums(XlaOp operand, XlaOp init_value, |
| 74 | absl::Span<const int64> kernel_size, |
| 75 | absl::Span<const int64> stride, |
| 76 | const TensorFormat& data_format) { |
| 77 | XlaBuilder* b = operand.builder(); |
| 78 | return b->ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { |
| 79 | TF_ASSIGN_OR_RETURN(Shape operand_shape, b->GetShape(operand)); |
| 80 | TF_ASSIGN_OR_RETURN(Shape init_shape, b->GetShape(init_value)); |
| 81 | PrimitiveType accumulation_type = init_shape.element_type(); |
| 82 | auto add_computation = CreateScalarAddComputation(accumulation_type, b); |
| 83 | return ReduceWindow(operand, init_value, add_computation, kernel_size, |
| 84 | stride, Padding::kValid); |
| 85 | }); |
| 86 | } |
| 87 | |
| 88 | // Creates a padding configuration out of spatial padding values. |
| 89 | PaddingConfig MakeSpatialPaddingConfig( |
no test coverage detected