Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7289 ディスカッション

Combining Hadamard division and matrix multiplication in one procedure

Chris_Mayer
ビギナー
3,064件の閲覧回数

Hey everyone,

 

I am currently optimising code that performs a series of Hadamard (element-wise)  divisions (1 ./ matrix) and matrix multiplications.

 

For example:

 

C = A[1 ⊘ B]
1, B ∈ R^d×d
A ∈ R^d×d

 

 

Currently, I implement the calculation in two steps:

 

vdDiv(d*d, mOnes, B, temp_M);
// mOnes is a matrix with all elements equal 1

cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans,
                    d, d, d, alpha, A, d, temp_M, d, beta, C, d);

 

 

I want to avoid doing d^2+ d^3 operations and do instead just d^3 operations.

In theory, both steps could be performed in one procedure by defining C as:

 

(c_ij) = a_i1 / b_1j + a_2i / b_2j + ... + a_id / b_dj

 

 

Is there a way to implement this in MKL efficiently?

 

Many thanks and best,

Chris

0 件の賞賛
6 返答(返信)
VidyalathaB_Intel
モデレーター
3,033件の閲覧回数
VidyalathaB_Intel
モデレーター
3,015件の閲覧回数

Hi Chris,


As we haven't heard back from you, could you please provide us with an update regarding your issue?


Regards,

Vidya.


Chris_Mayer
ビギナー
3,009件の閲覧回数

Hi Vidya,

 

Thank you for your reply!

 

I could not find any function in the documentation that provides the operation that I am seeking. Could you point me to a specific function that might solve the problem?

 

Many thanks and best,

 

Chris

VidyalathaB_Intel
モデレーター
2,998件の閲覧回数

Hi Chris,

 

The links in the earlier post lists out the routines which are extensions of BLAS that are available in MKL (i guess there is no direct routine available in MKL which combines both the cases hadamard division and gemm operation and as I mentioned you can refer to the extended functionalities of BLAS)

They may not exactly match the use case of yours but might help you for further stages.

Maybe using this function cblas-gemm-batch might help you but not sure https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-c/top/blas-and-sparse-blas-routines/blas-like-extensions/cblas-gemm-batch.html

 

Regards,

Vidya.

 

Chris_Mayer
ビギナー
2,965件の閲覧回数

Hi Vidya,

 

Thank you!

It seems that it is not possible to perform the exact operation that I envisioned. I will try to find a work around. The question is answered for me, thank you.

 

Best,

Chris

VidyalathaB_Intel
モデレーター
2,959件の閲覧回数

Hi Chris,


>>The question is answered for me,

Thanks for the confirmation.

Please post a new question if you need any additional assistance from Intel as this thread will no longer be monitored.


Have a Nice Day!


Regards,

Vidya.


返信