MLX
Loading...
Searching...
No Matches
mlx
backend
accelerate
utils.h
Go to the documentation of this file.
1
// Copyright © 2023 Apple Inc.
2
3
#pragma once
4
5
#include <vecLib/BNNS/bnns.h>
6
#include "
mlx/dtype.h
"
7
8
namespace
mlx::core
{
9
10
BNNSDataType
to_bnns_dtype
(
Dtype
mlx_dtype) {
11
uint32_t size_bits =
size_of
(mlx_dtype) * 8;
12
switch
(
kindof
(mlx_dtype)) {
13
case
Dtype::Kind::b
:
14
return
BNNSDataTypeBoolean;
15
case
Dtype::Kind::u
:
16
return
BNNSDataType(BNNSDataTypeUIntBit | size_bits);
17
case
Dtype::Kind::i
:
18
return
BNNSDataType(BNNSDataTypeIntBit | size_bits);
19
case
Dtype::Kind::f
:
20
return
BNNSDataType(BNNSDataTypeFloatBit | size_bits);
21
case
Dtype::Kind::V
:
22
return
BNNSDataTypeBFloat16;
23
case
Dtype::Kind::c
:
24
throw
std::invalid_argument(
"BNNS does not support complex types"
);
25
}
26
}
27
28
}
// namespace mlx::core
dtype.h
mlx::core
Definition
allocator.h:7
mlx::core::to_bnns_dtype
BNNSDataType to_bnns_dtype(Dtype mlx_dtype)
Definition
utils.h:10
mlx::core::kindof
Dtype::Kind kindof(const Dtype &t)
mlx::core::size_of
uint8_t size_of(const Dtype &t)
Definition
dtype.h:95
mlx::core::Dtype
Definition
dtype.h:15
mlx::core::Dtype::Kind::c
@ c
mlx::core::Dtype::Kind::V
@ V
mlx::core::Dtype::Kind::u
@ u
mlx::core::Dtype::Kind::i
@ i
mlx::core::Dtype::Kind::f
@ f
mlx::core::Dtype::Kind::b
@ b
Generated by
1.10.0