| 360 | template <typename LhsScalar, typename RhsScalar, typename AccumScalar, |
| 361 | typename DstScalar> |
| 362 | void TestSomeGemm(int rows, int depth, int cols, |
| 363 | const std::vector<DstScalar>& golden) { |
| 364 | CpuBackendContext cpu_backend_context; |
| 365 | std::default_random_engine random_engine; |
| 366 | cpu_backend_context.SetMaxNumThreads(1 + (random_engine() % 8)); |
| 367 | |
| 368 | const bool use_golden = !golden.empty(); |
| 369 | |
| 370 | std::vector<LhsScalar> lhs_data; |
| 371 | std::vector<RhsScalar> rhs_data; |
| 372 | std::vector<AccumScalar> bias_data; |
| 373 | std::vector<DstScalar> dst_data; |
| 374 | if (use_golden) { |
| 375 | MakeVectorFilledWithConsecutiveInts(rows * depth, &lhs_data); |
| 376 | MakeVectorFilledWithConsecutiveInts(depth * cols, &rhs_data); |
| 377 | MakeVectorFilledWithConsecutiveInts(rows, &bias_data); |
| 378 | } else { |
| 379 | MakeDeterministicPseudoRandomVector(rows * depth, &lhs_data); |
| 380 | MakeDeterministicPseudoRandomVector(depth * cols, &rhs_data); |
| 381 | MakeDeterministicPseudoRandomVector(rows, &bias_data); |
| 382 | } |
| 383 | MakeDeterministicPseudoRandomVector(rows * cols, &dst_data); |
| 384 | |
| 385 | MatrixParams<LhsScalar> lhs_params; |
| 386 | lhs_params.order = cpu_backend_gemm::Order::kRowMajor; |
| 387 | lhs_params.rows = rows; |
| 388 | lhs_params.cols = depth; |
| 389 | if (!std::is_floating_point<LhsScalar>::value) { |
| 390 | lhs_params.zero_point = 1; |
| 391 | if (!use_golden) { |
| 392 | lhs_params.zero_point += random_engine() % 8; |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | MatrixParams<RhsScalar> rhs_params; |
| 397 | rhs_params.order = cpu_backend_gemm::Order::kColMajor; |
| 398 | rhs_params.rows = depth; |
| 399 | rhs_params.cols = cols; |
| 400 | if (!std::is_floating_point<RhsScalar>::value) { |
| 401 | rhs_params.zero_point = 1; |
| 402 | if (!use_golden) { |
| 403 | rhs_params.zero_point += random_engine() % 8; |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | MatrixParams<DstScalar> dst_params; |
| 408 | dst_params.order = cpu_backend_gemm::Order::kColMajor; |
| 409 | dst_params.rows = rows; |
| 410 | dst_params.cols = cols; |
| 411 | if (!std::is_floating_point<DstScalar>::value) { |
| 412 | dst_params.zero_point = 1; |
| 413 | if (!use_golden) { |
| 414 | dst_params.zero_point += random_engine() % 8; |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | GemmParams<AccumScalar, DstScalar> params; |
| 419 | if (use_golden || (random_engine() % 2)) { |
nothing calls this directly
no test coverage detected