From f41959ccb2d9d4c722fe8fc3351401d53bcf4900 Mon Sep 17 00:00:00 2001 From: Manjunath Kudlur Date: Fri, 6 Nov 2015 16:27:58 -0800 Subject: TensorFlow: Initial commit of TensorFlow library. TensorFlow is an open source software library for numerical computation using data flow graphs. Base CL: 107276108 --- .../Eigen/CXX11/src/FixedPoint/MatVecProduct.h | 123 +++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/MatVecProduct.h (limited to 'third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/MatVecProduct.h') diff --git a/third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/MatVecProduct.h b/third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/MatVecProduct.h new file mode 100644 index 0000000000..18b5085b89 --- /dev/null +++ b/third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/MatVecProduct.h @@ -0,0 +1,123 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2015 Benoit Steiner +// +// This Source Code Form is subject to the terms of the Mozilla +// Public License v. 2.0. If a copy of the MPL was not distributed +// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef EIGEN_CXX11_FIXED_POINT_MAT_VEC_PRODUCT_H +#define EIGEN_CXX11_FIXED_POINT_MAT_VEC_PRODUCT_H + + +namespace Eigen { +namespace internal { + +// Mat-Vec product +// Both lhs and rhs are encoded as 8bit signed integers +template +struct general_matrix_vector_product +{ +EIGEN_DONT_INLINE static void run( + Index rows, Index cols, + const LhsMapper& lhs, + const RhsMapper& rhs, + QInt32* res, Index resIncr, + QInt8 alpha); +}; + +template +EIGEN_DONT_INLINE void general_matrix_vector_product::run( + Index rows, Index cols, + const LhsMapper& lhs, + const RhsMapper& rhs, + QInt32* res, Index resIncr, + QInt8 alpha) +{ + eigen_assert(alpha.value == 1); + eigen_assert(resIncr == 1); + eigen_assert(rows > 0); + eigen_assert(cols > 0); + + for (Index i = 0; i < rows; ++i) { + for (Index j = 0; j < cols; ++j) { + res[i] += lhs(i, j) * rhs(j, 0); + } + } +} + + +// Mat-Vec product +// The lhs is encoded using 8bit signed integers, the rhs using 8bit unsigned integers +template +struct general_matrix_vector_product +{ +EIGEN_DONT_INLINE static void run( + Index rows, Index cols, + const LhsMapper& lhs, + const RhsMapper& rhs, + QInt32* res, Index resIncr, + QUInt8 alpha); +}; + +template +EIGEN_DONT_INLINE void general_matrix_vector_product::run( + Index rows, Index cols, + const LhsMapper& lhs, + const RhsMapper& rhs, + QInt32* res, Index resIncr, + QUInt8 alpha) +{ + eigen_assert(alpha.value == 1); + eigen_assert(resIncr == 1); + eigen_assert(rows > 0); + eigen_assert(cols > 0); + + for (Index i = 0; i < rows; ++i) { + for (Index j = 0; j < cols; ++j) { + res[i] += lhs(i, j) * rhs(j, 0); + } + } +} + + +// Mat-Vec product +// The lhs is encoded using bit unsigned integers, the rhs using 8bit signed integers +template +struct general_matrix_vector_product +{ +EIGEN_DONT_INLINE static void run( + Index rows, Index cols, + const LhsMapper& lhs, + const RhsMapper& rhs, + QInt32* res, Index resIncr, + QInt8 alpha); +}; + +template +EIGEN_DONT_INLINE void general_matrix_vector_product::run( + Index rows, Index cols, + const LhsMapper& lhs, + const RhsMapper& rhs, + QInt32* res, Index resIncr, + QInt8 alpha) +{ + eigen_assert(alpha.value == 1); + eigen_assert(resIncr == 1); + eigen_assert(rows > 0); + eigen_assert(cols > 0); + + for (Index i = 0; i < rows; ++i) { + for (Index j = 0; j < cols; ++j) { + res[i] += lhs(i, j) * rhs(j, 0); + } + } +} + +} // namespace internal +} // namespace Eigen + + + +#endif // EIGEN_CXX11_FIXED_POINT_MAT_VEC_PRODUCT_H -- cgit v1.2.3