ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnfw::cker::detail::GemmImplUsingEigen Struct Reference

#include <eigen_gemm_eigen.h>

Static Public Member Functions

static void Run (const MatrixParams< float > &lhs_params, const float *lhs_data, const MatrixParams< float > &rhs_params, const float *rhs_data, const MatrixParams< float > &dst_params, float *dst_data, const GemmParams< float, float > &params)
 

Detailed Description

Definition at line 45 of file eigen_gemm_eigen.h.

Member Function Documentation

◆ Run()

static void nnfw::cker::detail::GemmImplUsingEigen::Run ( const MatrixParams< float > &  lhs_params,
const float *  lhs_data,
const MatrixParams< float > &  rhs_params,
const float *  rhs_data,
const MatrixParams< float > &  dst_params,
float *  dst_data,
const GemmParams< float, float > &  params 
)
inlinestatic

Definition at line 47 of file eigen_gemm_eigen.h.

51 {
52 // This code assumes specific storage orders, encoded in these Eigen types.
53 // These assumptions have been checked by TF_LITE_ASSERT's in the public
54 // Gemm entry point already, before the implementation gets to this point.
55 using EigenMatrixMapRowMajorConst =
56 Eigen::Map<const Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>;
57 using EigenMatrixMapColMajorConst =
58 Eigen::Map<const Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>>;
59 using EigenMatrixMapColMajorMutable =
60 Eigen::Map<Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>>;
61
62 EigenMatrixMapRowMajorConst eigen_lhs(lhs_data, lhs_params.rows, lhs_params.cols);
63 EigenMatrixMapColMajorConst eigen_rhs(rhs_data, rhs_params.rows, rhs_params.cols);
64 EigenMatrixMapColMajorMutable eigen_dst(dst_data, dst_params.rows, dst_params.cols);
65
66 if (rhs_params.cols == 1)
67 {
68 eigen_dst.col(0).noalias() = eigen_lhs * eigen_rhs.col(0);
69 }
70 else if (lhs_params.rows == 1)
71 {
72 eigen_dst.row(0).noalias() = eigen_lhs.row(0) * eigen_rhs;
73 }
74 else
75 {
76 eigen_dst.noalias() = eigen_lhs * eigen_rhs;
77 }
78
79 if (params.bias)
80 {
81 BiasAndClamp(params.clamp_min, params.clamp_max, dst_params.rows, params.bias,
82 dst_params.rows * dst_params.cols, dst_data);
83 }
84 else
85 {
86 eigen_dst = eigen_dst.cwiseMin(params.clamp_max).cwiseMax(params.clamp_min);
87 }
88 }
void BiasAndClamp(float clamp_min, float clamp_max, int bias_size, const float *bias_data, int array_size, float *array_data)
Definition Common.h:29

References nnfw::cker::GemmParams< AccumScalar, DstScalar, quantization_flavor >::bias, nnfw::cker::BiasAndClamp(), nnfw::cker::GemmParams< AccumScalar, DstScalar, quantization_flavor >::clamp_max, nnfw::cker::GemmParams< AccumScalar, DstScalar, quantization_flavor >::clamp_min, nnfw::cker::MatrixParams< Scalar >::cols, and nnfw::cker::MatrixParams< Scalar >::rows.


The documentation for this struct was generated from the following file: