| 315 | } |
| 316 | |
| 317 | af_err af_dot(af_array *out, const af_array lhs, const af_array rhs, |
| 318 | const af_mat_prop optLhs, const af_mat_prop optRhs) { |
| 319 | try { |
| 320 | const ArrayInfo &lhsInfo = getInfo(lhs); |
| 321 | const ArrayInfo &rhsInfo = getInfo(rhs); |
| 322 | |
| 323 | if (optLhs != AF_MAT_NONE && optLhs != AF_MAT_CONJ) { |
| 324 | AF_ERROR("Using this property is not yet supported in dot", |
| 325 | AF_ERR_NOT_SUPPORTED); |
| 326 | } |
| 327 | |
| 328 | if (optRhs != AF_MAT_NONE && optRhs != AF_MAT_CONJ) { |
| 329 | AF_ERROR("Using this property is not yet supported in dot", |
| 330 | AF_ERR_NOT_SUPPORTED); |
| 331 | } |
| 332 | |
| 333 | DIM_ASSERT(1, lhsInfo.dims()[0] == rhsInfo.dims()[0]); |
| 334 | af_dtype lhs_type = lhsInfo.getType(); |
| 335 | af_dtype rhs_type = rhsInfo.getType(); |
| 336 | |
| 337 | if (lhsInfo.ndims() == 0) { return af_retain_array(out, lhs); } |
| 338 | if (lhsInfo.ndims() > 1 || rhsInfo.ndims() > 1) { |
| 339 | AF_ERROR("dot can not be used in batch mode", AF_ERR_BATCH); |
| 340 | } |
| 341 | |
| 342 | TYPE_ASSERT(lhs_type == rhs_type); |
| 343 | |
| 344 | af_array output = 0; |
| 345 | |
| 346 | switch (lhs_type) { |
| 347 | case f16: output = dot<half>(lhs, rhs, optLhs, optRhs); break; |
| 348 | case f32: output = dot<float>(lhs, rhs, optLhs, optRhs); break; |
| 349 | case c32: output = dot<cfloat>(lhs, rhs, optLhs, optRhs); break; |
| 350 | case f64: output = dot<double>(lhs, rhs, optLhs, optRhs); break; |
| 351 | case c64: output = dot<cdouble>(lhs, rhs, optLhs, optRhs); break; |
| 352 | default: TYPE_ERROR(1, lhs_type); |
| 353 | } |
| 354 | std::swap(*out, output); |
| 355 | } |
| 356 | CATCHALL; |
| 357 | return AF_SUCCESS; |
| 358 | } |
| 359 | |
| 360 | af_err af_dot_all(double *rval, double *ival, const af_array lhs, |
| 361 | const af_array rhs, const af_mat_prop optLhs, |
no test coverage detected