| 89 | |
| 90 | template <typename ArgType> |
| 91 | struct CumulativeMean { |
| 92 | using OutType = DoubleType; |
| 93 | using ArgValue = typename GetViewType<ArgType>::T; |
| 94 | int64_t count = 0; |
| 95 | double sum = 0; |
| 96 | |
| 97 | CumulativeMean() = default; |
| 98 | |
| 99 | // start value is ignored for CumulativeMean |
| 100 | explicit CumulativeMean(const std::shared_ptr<Scalar> start) {} |
| 101 | |
| 102 | double Call(KernelContext* ctx, ArgValue arg, Status* st) { |
| 103 | sum += static_cast<double>(arg); |
| 104 | ++count; |
| 105 | return sum / count; |
| 106 | } |
| 107 | }; |
| 108 | |
| 109 | // The driver kernel for all cumulative compute functions. |
| 110 | // ArgType and OutType are the input and output types, which will |