-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ARM gemm #41
Merged
ARM gemm #41
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// Copyright (c) 2019-2020 Mikhail Katliar All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
#pragma once | ||
|
||
#include <blast/math/TypeTraits.hpp> | ||
#include <blast/math/algorithm/Tile.hpp> | ||
#include <blast/math/register_matrix/Gemm.hpp> | ||
#include <blast/math/Matrix.hpp> | ||
#include <blast/util/Exception.hpp> | ||
|
||
|
||
namespace blast :: reference | ||
{ | ||
/** | ||
* @brief Constant times matrix plus matrix, matrix pointer arguments | ||
* | ||
* C := alpha*A + B | ||
* | ||
* where alpha is a scalar, and A, B and C are M by N matrices | ||
* | ||
* @tparam ST scalar type for @a alpha | ||
* @tparam MPA matrix pointer type for @a A | ||
* @tparam MPB matrix pointer type for @a B | ||
* @tparam MPC matrix pointer type for @a C | ||
* | ||
* @param M the number of rows of the matrices A, B, and C. | ||
* @param N the number of columns of the matrices A, B and C. | ||
* @param alpha the scalar alpha | ||
* @param A pointer to the top left element of matrix A | ||
* @param B pointer to the top left element of matrix B | ||
* @param C pointer to the top left element of matrix C | ||
*/ | ||
template <typename ST, MatrixPointer MPA, MatrixPointer MPB, MatrixPointer MPC> | ||
inline void axpy(size_t M, size_t N, ST alpha, MPA A, MPB B, MPC C) | ||
{ | ||
for (size_t i = 0; i < M; ++i) | ||
for (size_t j = 0; j < N; ++j) | ||
*(~C)(i, j) = alpha * *(~A)(i, j) + *(~B)(i, j); | ||
} | ||
|
||
|
||
/** | ||
* @brief Constant times matrix plus matrix, matrix arguments | ||
* | ||
* C := alpha*A + B | ||
* | ||
* where alpha is a scalar, and A, B and C are M by N matrices | ||
* | ||
* @tparam ST scalar type for @a alpha | ||
* @tparam MTA matrix type for @a A | ||
* @tparam MTB matrix type for @a B | ||
* @tparam MTC matrix type for @a C | ||
* | ||
* @param alpha the scalar alpha | ||
* @param A matrix A | ||
* @param B matrix B | ||
* @param C matrix C | ||
* | ||
* @throw @a std::invalid_argument if matrix sizes are not consistent | ||
*/ | ||
template <typename ST, Matrix MTA, Matrix MTB, Matrix MTC> | ||
inline void axpy(ST alpha, MTA const& A, MTB const& B, MTC& C) | ||
{ | ||
size_t const M = rows(C); | ||
size_t const N = columns(C); | ||
|
||
if (rows(A) != M || columns(A) != N || | ||
rows(B) != M || columns(B) != N) | ||
BLAST_THROW_EXCEPTION(std::invalid_argument {"Inconsistent matrix sizes"}); | ||
|
||
reference::axpy(M, N, alpha, ptr(A), ptr(B), ptr(C)); | ||
} | ||
|
||
|
||
/** | ||
* @brief Constant times matrix plus matrix, matrix arguments, rvalue reference output argument | ||
* | ||
* C := alpha*A + B | ||
* | ||
* where alpha is a scalar, and A, B and C are M by N matrices | ||
* | ||
* @tparam ST scalar type for @a alpha | ||
* @tparam MTA matrix type for @a A | ||
* @tparam MTB matrix type for @a B | ||
* @tparam MTC matrix view type for @a C | ||
* | ||
* @param alpha the scalar alpha | ||
* @param A matrix A | ||
* @param B matrix B | ||
* @param C matrix view C | ||
* | ||
* @throw @a std::invalid_argument if matrix sizes are not consistent | ||
*/ | ||
template <typename ST, Matrix MTA, Matrix MTB, Matrix MTC> | ||
requires IsView_v<MTC> | ||
inline void axpy(ST alpha, MTA const& A, MTB const& B, MTC&& C) | ||
{ | ||
reference::axpy(alpha, A, B, C); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Superfluous comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed