| 55 | |
| 56 | template<typename inType, typename outType> |
| 57 | static outType varAll(const af_array& in, const af_var_bias bias) { |
| 58 | using weightType = typename baseOutType<outType>::type; |
| 59 | const Array<inType> inArr = getArray<inType>(in); |
| 60 | Array<outType> input = cast<outType>(inArr); |
| 61 | |
| 62 | Array<outType> meanCnst = createValueArray<outType>( |
| 63 | input.dims(), mean<inType, weightType, outType>(inArr)); |
| 64 | |
| 65 | Array<outType> diff = |
| 66 | arithOp<outType, af_sub_t>(input, meanCnst, input.dims()); |
| 67 | |
| 68 | Array<outType> diffSq = arithOp<outType, af_mul_t>(diff, diff, diff.dims()); |
| 69 | |
| 70 | outType result = division( |
| 71 | getScalar<outType>(reduce_all<af_add_t, outType, outType>(diffSq)), |
| 72 | (input.elements() - (bias == AF_VARIANCE_SAMPLE))); |
| 73 | |
| 74 | return result; |
| 75 | } |
| 76 | |
| 77 | template<typename inType, typename outType> |
| 78 | static outType varAll(const af_array& in, const af_array weights) { |