Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4fb8d62
[ExecuTorch] Implement BFloat16 and hook it up to scalar_type_util
swolchok Aug 29, 2024
4e8b86b
[ExecuTorch] support BF16 in op_to_copy
swolchok Aug 29, 2024
ff88974
[ExecuTorch] support BF16 in op_mul
swolchok Aug 29, 2024
46579e4
[ExecuTorch] support BF16 in op_mm
swolchok Aug 29, 2024
8388e56
[ExecuTorch] support BF16 in op_copy
swolchok Aug 29, 2024
8e0b9d3
[ExecuTorch] support BF16 in op_slice_scatter
swolchok Aug 29, 2024
741f777
[ExecuTorch] support BF16 in op_scalar_tensor
swolchok Aug 29, 2024
ebdde77
[ExecuTorch] support BF16 in op_where
swolchok Aug 29, 2024
1addb7d
[ExecuTorch] support BF16 in op_add
swolchok Aug 29, 2024
7127237
[ExecuTorch] support BF16 in LLM runner & sampler
swolchok Aug 29, 2024
79021ef
[ExecuTorch] Allow setting dtype to bf16 in export_llama
swolchok Aug 29, 2024
9f13154
Update base for Update on "[ExecuTorch] Allow setting dtype to bf16 i…
swolchok Aug 30, 2024
eac4e38
Update on "[ExecuTorch] Allow setting dtype to bf16 in export_llama"
swolchok Aug 30, 2024
5917de2
Update base for Update on "[ExecuTorch] Allow setting dtype to bf16 i…
swolchok Aug 30, 2024
d67b816
Update on "[ExecuTorch] Allow setting dtype to bf16 in export_llama"
swolchok Aug 30, 2024
4f1d89b
Update base for Update on "[ExecuTorch] Allow setting dtype to bf16 i…
swolchok Sep 3, 2024
8f466a8
Update on "[ExecuTorch] Allow setting dtype to bf16 in export_llama"
swolchok Sep 3, 2024
fc9bf07
Update base for Update on "[ExecuTorch] Allow setting dtype to bf16 i…
swolchok Sep 3, 2024
413a847
Update on "[ExecuTorch] Allow setting dtype to bf16 in export_llama"
swolchok Sep 3, 2024
b88b3f3
Update base for Update on "[ExecuTorch] Allow setting dtype to bf16 i…
swolchok Sep 4, 2024
b8003af
Update on "[ExecuTorch] Allow setting dtype to bf16 in export_llama"
swolchok Sep 4, 2024
862cd85
Update base for Update on "[ExecuTorch] Allow setting dtype to bf16 i…
swolchok Sep 6, 2024
b211c00
Update on "[ExecuTorch] Allow setting dtype to bf16 in export_llama"
swolchok Sep 6, 2024
0e194a5
[ExecuTorch] Support BFloat16 in CPUBlas gemm
swolchok Sep 6, 2024
9c7e8fb
Merge remote-tracking branch 'origin/main' into gh/swolchok/31/head
kirklandsign Sep 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions kernels/optimized/blas/CPUBlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,28 @@ void gemm(
}
// clang-format on

// clang-format off
void gemm(
TransposeType transa, TransposeType transb,
int64_t m, int64_t n, int64_t k,
const BFloat16 alpha,
const BFloat16 *a, int64_t lda,
const BFloat16 *b, int64_t ldb,
const BFloat16 beta,
BFloat16 *c, int64_t ldc) {
normalize_last_dims(transa, transb, m, n, k, &lda, &ldb, &ldc);

using acc_type = utils::compute_dtype<BFloat16>;
gemm_impl(
transa, transb,
m, n, k,
static_cast<const acc_type>(alpha),
a, lda,
b, ldb,
static_cast<const acc_type>(beta),
c, ldc);
}
// clang-format on

} // namespace cpublas
} // namespace executorch
10 changes: 10 additions & 0 deletions kernels/optimized/blas/CPUBlas.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
namespace executorch {
namespace cpublas {

using BFloat16 = torch::executor::BFloat16;
using Half = torch::executor::Half;

enum class TransposeType {
Expand Down Expand Up @@ -104,6 +105,15 @@ void gemm(
const Half *b, int64_t ldb,
const Half beta,
Half *c, int64_t ldc);

void gemm(
TransposeType transa, TransposeType transb,
int64_t m, int64_t n, int64_t k,
const BFloat16 alpha,
const BFloat16 *a, int64_t lda,
const BFloat16 *b, int64_t ldb,
const BFloat16 beta,
BFloat16 *c, int64_t ldc);
// clang-format on

// clang-format off
Expand Down
4 changes: 3 additions & 1 deletion kernels/optimized/test/libblas_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <gtest/gtest.h>

#include <executorch/kernels/optimized/blas/CPUBlas.h>
#include <executorch/runtime/core/exec_aten/exec_aten.h>

#include <vector>

Expand All @@ -17,7 +18,8 @@
_<float, N>(); \
_<int64_t, N>(); \
_<uint8_t, N>(); \
_<int32_t, N>();
_<int32_t, N>(); \
_<exec_aten::BFloat16, N>();

namespace {

Expand Down
Loading