Slow Tensor gemv vs Matrix
Submitted by wil..@..il.com
Assigned to Nobody
Link to original bugzilla bug (#1648)
Version: 3.5 (future version)
Operating system: Linux
Description
Created attachment 909
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
Attachment 909, "bench_matrix_vs_tensor.cpp (dec 17)":
bench_matrix_vs_tensor.cpp