mlx/docs/build/html/backend_2accelerate_2utils_8h_source.html

135 lines
12 KiB
HTML
Raw Normal View History

2024-06-07 11:28:06 +08:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.10.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>MLX: mlx/backend/accelerate/utils.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">MLX
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.10.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_938ab0ecf10b8b860ff766c820f665fd.html">mlx</a></li><li class="navelem"><a class="el" href="dir_1d446c9bd3c99228254c9484e0bc5c06.html">backend</a></li><li class="navelem"><a class="el" href="dir_86b95e7b1d0d6e25466bb9213752d32f.html">accelerate</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">utils.h</div></div>
</div><!--header-->
<div class="contents">
2024-07-12 06:32:08 +08:00
<a href="backend_2accelerate_2utils_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span><span class="comment">// Copyright © 2023-2024 Apple Inc.</span></div>
2024-06-07 11:28:06 +08:00
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno"> 2</span> </div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno"> 3</span><span class="preprocessor">#pragma once</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno"> 4</span> </div>
2024-07-12 06:32:08 +08:00
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno"> 5</span><span class="preprocessor">#include &lt;Accelerate/Accelerate.h&gt;</span></div>
2024-06-07 11:28:06 +08:00
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno"> 6</span><span class="preprocessor">#include &quot;<a class="code" href="dtype_8h.html">mlx/dtype.h</a>&quot;</span></div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno"> 7</span> </div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno"> 8</span><span class="keyword">namespace </span><a class="code hl_namespace" href="namespacemlx_1_1core.html">mlx::core</a> {</div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno"> 9</span> </div>
<div class="foldopen" id="foldopen00010" data-start="{" data-end="}">
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno"><a class="line" href="namespacemlx_1_1core.html#a7a4193f37b1de9c33c31d1da09c77edb"> 10</a></span>BNNSDataType <a class="code hl_function" href="namespacemlx_1_1core.html#a7a4193f37b1de9c33c31d1da09c77edb">to_bnns_dtype</a>(<a class="code hl_struct" href="structmlx_1_1core_1_1_dtype.html">Dtype</a> mlx_dtype) {</div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span> uint32_t size_bits = <a class="code hl_function" href="namespacemlx_1_1core.html#add4794cc0ffe5d717fc146084a235d95">size_of</a>(mlx_dtype) * 8;</div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span> <span class="keywordflow">switch</span> (<a class="code hl_function" href="namespacemlx_1_1core.html#ad527b86818823db040195785efd7d724">kindof</a>(mlx_dtype)) {</div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"> 13</span> <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="structmlx_1_1core_1_1_dtype.html#adb1ea8b45a0c53e04a0e73b168702715a92eb5ffee6ae2fec3ad71c777531578f">Dtype::Kind::b</a>:</div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"> 14</span> <span class="keywordflow">return</span> BNNSDataTypeBoolean;</div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"> 15</span> <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="structmlx_1_1core_1_1_dtype.html#adb1ea8b45a0c53e04a0e73b168702715a7b774effe4a349c6dd82ad4f4f21d34c">Dtype::Kind::u</a>:</div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"> 16</span> <span class="keywordflow">return</span> BNNSDataType(BNNSDataTypeUIntBit | size_bits);</div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"> 17</span> <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="structmlx_1_1core_1_1_dtype.html#adb1ea8b45a0c53e04a0e73b168702715a865c0c0b4ab0e063e5caa3387c1a8741">Dtype::Kind::i</a>:</div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno"> 18</span> <span class="keywordflow">return</span> BNNSDataType(BNNSDataTypeIntBit | size_bits);</div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"> 19</span> <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="structmlx_1_1core_1_1_dtype.html#adb1ea8b45a0c53e04a0e73b168702715a8fa14cdd754f91cc6554c9e71929cce7">Dtype::Kind::f</a>:</div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span> <span class="keywordflow">return</span> BNNSDataType(BNNSDataTypeFloatBit | size_bits);</div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span> <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="structmlx_1_1core_1_1_dtype.html#adb1ea8b45a0c53e04a0e73b168702715a5206560a306a2e085a437fd258eb57ce">Dtype::Kind::V</a>:</div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span> <span class="keywordflow">return</span> BNNSDataTypeBFloat16;</div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"> 23</span> <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="structmlx_1_1core_1_1_dtype.html#adb1ea8b45a0c53e04a0e73b168702715a4a8a08f09d37b73795649038408b5f33">Dtype::Kind::c</a>:</div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span> <span class="keywordflow">throw</span> std::invalid_argument(<span class="stringliteral">&quot;BNNS does not support complex types&quot;</span>);</div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</span> }</div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span>}</div>
</div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"> 27</span> </div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span>} <span class="comment">// namespace mlx::core</span></div>
<div class="ttc" id="adtype_8h_html"><div class="ttname"><a href="dtype_8h.html">dtype.h</a></div></div>
<div class="ttc" id="anamespacemlx_1_1core_html"><div class="ttname"><a href="namespacemlx_1_1core.html">mlx::core</a></div><div class="ttdef"><b>Definition</b> allocator.h:7</div></div>
<div class="ttc" id="anamespacemlx_1_1core_html_a7a4193f37b1de9c33c31d1da09c77edb"><div class="ttname"><a href="namespacemlx_1_1core.html#a7a4193f37b1de9c33c31d1da09c77edb">mlx::core::to_bnns_dtype</a></div><div class="ttdeci">BNNSDataType to_bnns_dtype(Dtype mlx_dtype)</div><div class="ttdef"><b>Definition</b> utils.h:10</div></div>
<div class="ttc" id="anamespacemlx_1_1core_html_ad527b86818823db040195785efd7d724"><div class="ttname"><a href="namespacemlx_1_1core.html#ad527b86818823db040195785efd7d724">mlx::core::kindof</a></div><div class="ttdeci">Dtype::Kind kindof(const Dtype &amp;t)</div></div>
<div class="ttc" id="anamespacemlx_1_1core_html_add4794cc0ffe5d717fc146084a235d95"><div class="ttname"><a href="namespacemlx_1_1core.html#add4794cc0ffe5d717fc146084a235d95">mlx::core::size_of</a></div><div class="ttdeci">uint8_t size_of(const Dtype &amp;t)</div><div class="ttdef"><b>Definition</b> dtype.h:95</div></div>
<div class="ttc" id="astructmlx_1_1core_1_1_dtype_html"><div class="ttname"><a href="structmlx_1_1core_1_1_dtype.html">mlx::core::Dtype</a></div><div class="ttdef"><b>Definition</b> dtype.h:15</div></div>
<div class="ttc" id="astructmlx_1_1core_1_1_dtype_html_adb1ea8b45a0c53e04a0e73b168702715a4a8a08f09d37b73795649038408b5f33"><div class="ttname"><a href="structmlx_1_1core_1_1_dtype.html#adb1ea8b45a0c53e04a0e73b168702715a4a8a08f09d37b73795649038408b5f33">mlx::core::Dtype::Kind::c</a></div><div class="ttdeci">@ c</div></div>
<div class="ttc" id="astructmlx_1_1core_1_1_dtype_html_adb1ea8b45a0c53e04a0e73b168702715a5206560a306a2e085a437fd258eb57ce"><div class="ttname"><a href="structmlx_1_1core_1_1_dtype.html#adb1ea8b45a0c53e04a0e73b168702715a5206560a306a2e085a437fd258eb57ce">mlx::core::Dtype::Kind::V</a></div><div class="ttdeci">@ V</div></div>
<div class="ttc" id="astructmlx_1_1core_1_1_dtype_html_adb1ea8b45a0c53e04a0e73b168702715a7b774effe4a349c6dd82ad4f4f21d34c"><div class="ttname"><a href="structmlx_1_1core_1_1_dtype.html#adb1ea8b45a0c53e04a0e73b168702715a7b774effe4a349c6dd82ad4f4f21d34c">mlx::core::Dtype::Kind::u</a></div><div class="ttdeci">@ u</div></div>
<div class="ttc" id="astructmlx_1_1core_1_1_dtype_html_adb1ea8b45a0c53e04a0e73b168702715a865c0c0b4ab0e063e5caa3387c1a8741"><div class="ttname"><a href="structmlx_1_1core_1_1_dtype.html#adb1ea8b45a0c53e04a0e73b168702715a865c0c0b4ab0e063e5caa3387c1a8741">mlx::core::Dtype::Kind::i</a></div><div class="ttdeci">@ i</div></div>
<div class="ttc" id="astructmlx_1_1core_1_1_dtype_html_adb1ea8b45a0c53e04a0e73b168702715a8fa14cdd754f91cc6554c9e71929cce7"><div class="ttname"><a href="structmlx_1_1core_1_1_dtype.html#adb1ea8b45a0c53e04a0e73b168702715a8fa14cdd754f91cc6554c9e71929cce7">mlx::core::Dtype::Kind::f</a></div><div class="ttdeci">@ f</div></div>
<div class="ttc" id="astructmlx_1_1core_1_1_dtype_html_adb1ea8b45a0c53e04a0e73b168702715a92eb5ffee6ae2fec3ad71c777531578f"><div class="ttname"><a href="structmlx_1_1core_1_1_dtype.html#adb1ea8b45a0c53e04a0e73b168702715a92eb5ffee6ae2fec3ad71c777531578f">mlx::core::Dtype::Kind::b</a></div><div class="ttdeci">@ b</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.10.0
</small></address>
</body>
</html>