This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen

Bug 1648

Summary: Slow Tensor gemv vs Matrix
Product: Eigen Reporter: william.tambellini
Component: TensorAssignee: Nobody <eigen.nobody>
Status: NEW ---    
Severity: Optimization CC: benoit.steiner.goog, chtz, gael.guennebaud, rmlarsen
Priority: Normal    
Version: 3.5 (future version)   
Hardware: x86 - 64-bit   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
bench_matrix_vs_tensor.cpp (dec 17) none

Description william.tambellini 2018-12-18 02:25:36 UTC
Created attachment 909 [details]
bench_matrix_vs_tensor.cpp (dec 17)

Unless I did something unfair for Tensors, Tensor gemv is significantly slower than Vector-Matrix gemv:

Example:
$ ./buildrun.sh 
Bench Eigen Matrix vs Tensor
Usage: program numberOfEigenThreads (default to 1)
GCC: 6.1.0
Eigen version: 3.3.90
Simd: SSE, SSE2
Eigen::nbThreads: 1
EIGEN_NO_DEBUG
EIGEN_VECTORIZE
EIGEN_HAS_OPENMP: 201511
omp_get_num_threads: 1

Gemv:
Repeat: 200
               N         EMatrix         ETensor
             256      0.00156261      0.00443656
             512      0.00572028       0.0179982
            1024        0.035893       0.0818175
            2048        0.329064        0.455825
            4096        0.906102         1.96649

That seems to be confirmed by TensorFlow which is today casting tensors to Matrix/VectorMap in order to do faster gemv : 
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/batch_matmul_op_impl.h
Comment 1 Nobody 2019-12-04 18:17:57 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1648.