| 1240 | } |
| 1241 | |
| 1242 | Tensor SumAll(const Tensor &in) { |
| 1243 | Tensor out({(size_t)1}, in.device(), in.data_type()); |
| 1244 | Tensor one(in.shape(), in.device(), in.data_type()); |
| 1245 | one.SetValue(1.0f); |
| 1246 | TYPE_LANG_SWITCH(in.data_type(), DType, in.device()->lang(), Lang, { |
| 1247 | one.device()->Exec( |
| 1248 | [in, one, out](Context *ctx) mutable { |
| 1249 | Dot<DType, Lang>(in, one, &out, ctx); |
| 1250 | }, |
| 1251 | {in.block(), one.block()}, {out.block()}, "SumAll"); |
| 1252 | }); |
| 1253 | return out; |
| 1254 | } |
| 1255 | |
| 1256 | Tensor RowMax(const Tensor &in) { |
| 1257 | Tensor ret({in.shape(0)}, in.device(), in.data_type()); |