-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a249057
commit 6d0cf9d
Showing
30 changed files
with
771 additions
and
191 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
|
||
#include "ma_math_scalars.h" | ||
#include "ma_math_vectors.h" | ||
#include "ma_math_matrix.h" | ||
|
||
#endif // _MA_MATH_H |
22 changes: 22 additions & 0 deletions
22
src/components/sscma-micro/sscma/core/math/ma_math_matrix.cpp
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,22 @@ | ||
#include "ma_math_matrix.h" | ||
#include "ma_math_vectors.h" | ||
|
||
#include <cmath> | ||
|
||
namespace ma::math { | ||
|
||
void softmax2D(float* data, size_t rows, size_t cols) { | ||
size_t size = rows * cols; | ||
for (size_t i = 0; i < size; i += cols) { | ||
softmax(&data[i], cols); | ||
} | ||
} | ||
|
||
void fastSoftmax2D(float* data, size_t rows, size_t cols) { | ||
size_t size = rows * cols; | ||
for (size_t i = 0; i < size; i += cols) { | ||
fastSoftmax(&data[i], cols); | ||
} | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
src/components/sscma-micro/sscma/core/math/ma_math_matrix.h
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,32 @@ | ||
#ifndef _MA_MATH_MARTRIX_H_ | ||
#define _MA_MATH_MARTRIX_H_ | ||
|
||
#include <cstddef> | ||
#include <cstdint> | ||
|
||
#if MA_USE_LIB_XTENSOR | ||
#include <xtensor/xarray.hpp> | ||
#include <xtensor/xmath.hpp> | ||
#include <xtensor/xview.hpp> | ||
#endif | ||
|
||
namespace ma::math { | ||
|
||
void softmax2D(float* data, size_t rows, size_t cols); | ||
|
||
void fastSoftmax2D(float* data, size_t rows, size_t cols); | ||
|
||
#if MA_USE_LIB_XTENSOR | ||
template <typename QT> | ||
static void dequantizeValues2D(xt::xarray<float>& dequantized_outputs, int index, const xt::xarray<QT>& quantized_outputs, size_t dim1, size_t dim2, float32_t qp_scale, float32_t qp_zp) { | ||
for (size_t i = 0; i < dim1; i++) { | ||
for (size_t j = 0; j < dim2; j++) { | ||
dequantized_outputs(i, j) = (float(quantized_outputs(index, i, j)) - qp_zp) * qp_scale; | ||
} | ||
} | ||
} | ||
#endif | ||
|
||
} // namespace ma::math | ||
|
||
#endif |
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.