blob: e58b82219d21d0e78a7d281794ceb221fa6328ec [file] [log] [blame]
<!-- Copyright (c) 2020 ARM Limited. -->
<!-- -->
<!-- SPDX-License-Identifier: MIT -->
<!-- -->
<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="robots" content="NOINDEX, NOFOLLOW" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>ArmNN: ClContextDeserializer Class Reference</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>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</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>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="stylesheet.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 style="height: 56px;">
<img alt="ArmNN" src="Arm_NN_horizontal_blue.png" style="max-width: 10rem; margin-top: .5rem; margin-left 10px"/>
<td style="padding-left: 0.5em;">
<div id="projectname">
&#160;<span id="projectnumber">21.11</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('classarmnn_1_1_cl_context_deserializer.xhtml','');});
</script>
<div id="doc-content">
<!-- 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">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classarmnn_1_1_cl_context_deserializer-members.xhtml">List of all members</a> </div>
<div class="headertitle">
<div class="title">ClContextDeserializer Class Reference</div> </div>
</div><!--header-->
<div class="contents">
<p><code>#include &lt;<a class="el" href="_cl_context_deserializer_8hpp_source.xhtml">ClContextDeserializer.hpp</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a0a887c104225e85c71c39d73359ef786"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classarmnn_1_1_cl_context_deserializer.xhtml#a0a887c104225e85c71c39d73359ef786">ClContextDeserializer</a> ()=default</td></tr>
<tr class="separator:a0a887c104225e85c71c39d73359ef786"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7842471af1a703f47025648fbcad8894"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classarmnn_1_1_cl_context_deserializer.xhtml#a7842471af1a703f47025648fbcad8894">~ClContextDeserializer</a> ()=default</td></tr>
<tr class="separator:a7842471af1a703f47025648fbcad8894"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abc96e506e291bdb238d60bb46fc0d105"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classarmnn_1_1_cl_context_deserializer.xhtml#abc96e506e291bdb238d60bb46fc0d105">Deserialize</a> (arm_compute::CLCompileContext &amp;clCompileContext, cl::Context &amp;context, cl::Device &amp;device, const std::string &amp;filePath)</td></tr>
<tr class="memdesc:abc96e506e291bdb238d60bb46fc0d105"><td class="mdescLeft">&#160;</td><td class="mdescRight">Deserializes the CLCompileContext built-in programs from a binary file. <a href="#abc96e506e291bdb238d60bb46fc0d105">More...</a><br /></td></tr>
<tr class="separator:abc96e506e291bdb238d60bb46fc0d105"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aef8850786daf73d7b0a0215362d8fb99"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classarmnn_1_1_cl_context_deserializer.xhtml#aef8850786daf73d7b0a0215362d8fb99">DeserializeFromBinary</a> (arm_compute::CLCompileContext &amp;clCompileContext, cl::Context &amp;context, cl::Device &amp;device, const std::vector&lt; uint8_t &gt; &amp;binaryContent)</td></tr>
<tr class="memdesc:aef8850786daf73d7b0a0215362d8fb99"><td class="mdescLeft">&#160;</td><td class="mdescRight">Deserializes the CLCompileContext built-in programs from binary file contents. <a href="#aef8850786daf73d7b0a0215362d8fb99">More...</a><br /></td></tr>
<tr class="separator:aef8850786daf73d7b0a0215362d8fb99"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock">
<p class="definition">Definition at line <a class="el" href="_cl_context_deserializer_8hpp_source.xhtml#l00013">13</a> of file <a class="el" href="_cl_context_deserializer_8hpp_source.xhtml">ClContextDeserializer.hpp</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a0a887c104225e85c71c39d73359ef786"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0a887c104225e85c71c39d73359ef786">&#9670;&nbsp;</a></span>ClContextDeserializer()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classarmnn_1_1_cl_context_deserializer.xhtml">ClContextDeserializer</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">default</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="a7842471af1a703f47025648fbcad8894"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7842471af1a703f47025648fbcad8894">&#9670;&nbsp;</a></span>~ClContextDeserializer()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">~<a class="el" href="classarmnn_1_1_cl_context_deserializer.xhtml">ClContextDeserializer</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">default</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="abc96e506e291bdb238d60bb46fc0d105"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abc96e506e291bdb238d60bb46fc0d105">&#9670;&nbsp;</a></span>Deserialize()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void Deserialize </td>
<td>(</td>
<td class="paramtype">arm_compute::CLCompileContext &amp;&#160;</td>
<td class="paramname"><em>clCompileContext</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">cl::Context &amp;&#160;</td>
<td class="paramname"><em>context</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">cl::Device &amp;&#160;</td>
<td class="paramname"><em>device</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::string &amp;&#160;</td>
<td class="paramname"><em>filePath</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Deserializes the CLCompileContext built-in programs from a binary file. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">clCompileContext</td><td>The CLCompileContext to be serialized </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">context</td><td>The CL Kernel context built-in program will be created from </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">device</td><td>The CL Kernel device built-in program will be created from </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">filePath</td><td>The serialized file </td></tr>
</table>
</dd>
</dl>
<p class="definition">Definition at line <a class="el" href="_cl_context_deserializer_8cpp_source.xhtml#l00024">24</a> of file <a class="el" href="_cl_context_deserializer_8cpp_source.xhtml">ClContextDeserializer.cpp</a>.</p>
<p class="reference">References <a class="el" href="_cl_context_deserializer_8cpp_source.xhtml#l00044">ClContextDeserializer::DeserializeFromBinary()</a>.</p>
<p class="reference">Referenced by <a class="el" href="_cl_workload_factory_8cpp_source.xhtml#l00066">ClWorkloadFactory::AfterWorkloadsCreated()</a>.</p>
<div class="fragment"><div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160;{</div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span>&#160; std::ifstream inputFileStream(filePath, std::ios::binary);</div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span>&#160; std::vector&lt;std::uint8_t&gt; binaryContent;</div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span>&#160; <span class="keywordflow">while</span> (inputFileStream)</div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160; {</div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160; <span class="keywordtype">char</span> input;</div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span>&#160; inputFileStream.get(input);</div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160; <span class="keywordflow">if</span> (inputFileStream)</div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span>&#160; {</div><div class="line"><a name="l00037"></a><span class="lineno"> 37</span>&#160; binaryContent.push_back(static_cast&lt;std::uint8_t&gt;(input));</div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160; }</div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160; }</div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160; inputFileStream.close();</div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span>&#160; <a class="code" href="classarmnn_1_1_cl_context_deserializer.xhtml#aef8850786daf73d7b0a0215362d8fb99">DeserializeFromBinary</a>(clCompileContext, context, device, binaryContent);</div><div class="line"><a name="l00042"></a><span class="lineno"> 42</span>&#160;}</div><div class="ttc" id="classarmnn_1_1_cl_context_deserializer_xhtml_aef8850786daf73d7b0a0215362d8fb99"><div class="ttname"><a href="classarmnn_1_1_cl_context_deserializer.xhtml#aef8850786daf73d7b0a0215362d8fb99">armnn::ClContextDeserializer::DeserializeFromBinary</a></div><div class="ttdeci">void DeserializeFromBinary(arm_compute::CLCompileContext &amp;clCompileContext, cl::Context &amp;context, cl::Device &amp;device, const std::vector&lt; uint8_t &gt; &amp;binaryContent)</div><div class="ttdoc">Deserializes the CLCompileContext built-in programs from binary file contents. </div><div class="ttdef"><b>Definition:</b> <a href="_cl_context_deserializer_8cpp_source.xhtml#l00044">ClContextDeserializer.cpp:44</a></div></div>
</div><!-- fragment -->
</div>
</div>
<a id="aef8850786daf73d7b0a0215362d8fb99"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aef8850786daf73d7b0a0215362d8fb99">&#9670;&nbsp;</a></span>DeserializeFromBinary()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void DeserializeFromBinary </td>
<td>(</td>
<td class="paramtype">arm_compute::CLCompileContext &amp;&#160;</td>
<td class="paramname"><em>clCompileContext</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">cl::Context &amp;&#160;</td>
<td class="paramname"><em>context</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">cl::Device &amp;&#160;</td>
<td class="paramname"><em>device</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::vector&lt; uint8_t &gt; &amp;&#160;</td>
<td class="paramname"><em>binaryContent</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Deserializes the CLCompileContext built-in programs from binary file contents. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">clCompileContext</td><td>The CLCompileContext to be serialized </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">context</td><td>The CL Kernel context built-in program will be created from </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">device</td><td>The CL Kernel device built-in program will be created from </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">filePath</td><td>The serialized file </td></tr>
</table>
</dd>
</dl>
<p class="definition">Definition at line <a class="el" href="_cl_context_deserializer_8cpp_source.xhtml#l00044">44</a> of file <a class="el" href="_cl_context_deserializer_8cpp_source.xhtml">ClContextDeserializer.cpp</a>.</p>
<p class="reference">References <a class="el" href="_exceptions_8hpp_source.xhtml#l00209">CHECK_LOCATION</a>, and <a class="el" href="_cl_context_schema__generated_8h_source.xhtml#l00140">armnn::GetClContext()</a>.</p>
<p class="reference">Referenced by <a class="el" href="_cl_workload_factory_8cpp_source.xhtml#l00066">ClWorkloadFactory::AfterWorkloadsCreated()</a>, and <a class="el" href="_cl_context_deserializer_8cpp_source.xhtml#l00024">ClContextDeserializer::Deserialize()</a>.</p>
<div class="fragment"><div class="line"><a name="l00048"></a><span class="lineno"> 48</span>&#160;{</div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>&#160; <span class="keywordflow">if</span> (binaryContent.data() == <span class="keyword">nullptr</span>)</div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>&#160; {</div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160; <span class="keywordflow">throw</span> InvalidArgumentException(fmt::format(<span class="stringliteral">&quot;Invalid (null) binary content {}&quot;</span>,</div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160; <a class="code" href="_exceptions_8hpp.xhtml#aa3be76aec4ce713822a5ea1ecbb7bc61">CHECK_LOCATION</a>().AsString()));</div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span>&#160; }</div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160;</div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160; <span class="keywordtype">size_t</span> binaryContentSize = binaryContent.size();</div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160; flatbuffers::Verifier verifier(binaryContent.data(), binaryContentSize);</div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160; <span class="keywordflow">if</span> (verifier.VerifyBuffer&lt;ClContext&gt;() == <span class="keyword">false</span>)</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span>&#160; {</div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span>&#160; <span class="keywordflow">throw</span> ParseException(fmt::format(<span class="stringliteral">&quot;Buffer doesn&#39;t conform to the expected Armnn &quot;</span></div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span>&#160; <span class="stringliteral">&quot;flatbuffers format. size:{0} {1}&quot;</span>,</div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span>&#160; binaryContentSize,</div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span>&#160; <a class="code" href="_exceptions_8hpp.xhtml#aa3be76aec4ce713822a5ea1ecbb7bc61">CHECK_LOCATION</a>().AsString()));</div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span>&#160; }</div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span>&#160; <span class="keyword">auto</span> clContext = <a class="code" href="namespacearmnn.xhtml#ac3dec65fab0e6a1a6fef52e6321b4993">GetClContext</a>(binaryContent.data());</div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span>&#160;</div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span>&#160; <span class="keywordflow">for</span> (Program <span class="keyword">const</span>* program : *clContext-&gt;programs())</div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span>&#160; {</div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>&#160; <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">volatile</span> programName = program-&gt;name()-&gt;c_str();</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span>&#160; <span class="keyword">auto</span> programBinary = program-&gt;binary();</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span>&#160; std::vector&lt;uint8_t&gt; binary(programBinary-&gt;begin(), programBinary-&gt;begin() + programBinary-&gt;size());</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>&#160;</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>&#160; cl::Program::Binaries binaries{ binary };</div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span>&#160; std::vector&lt;cl::Device&gt; devices {device};</div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span>&#160; cl::Program theProgram(context, devices, binaries);</div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>&#160; theProgram.build();</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160; clCompileContext.add_built_program(programName, theProgram);</div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160; }</div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160;}</div><div class="ttc" id="namespacearmnn_xhtml_ac3dec65fab0e6a1a6fef52e6321b4993"><div class="ttname"><a href="namespacearmnn.xhtml#ac3dec65fab0e6a1a6fef52e6321b4993">armnn::GetClContext</a></div><div class="ttdeci">const armnn::ClContext * GetClContext(const void *buf)</div><div class="ttdef"><b>Definition:</b> <a href="_cl_context_schema__generated_8h_source.xhtml#l00140">ClContextSchema_generated.h:140</a></div></div>
<div class="ttc" id="_exceptions_8hpp_xhtml_aa3be76aec4ce713822a5ea1ecbb7bc61"><div class="ttname"><a href="_exceptions_8hpp.xhtml#aa3be76aec4ce713822a5ea1ecbb7bc61">CHECK_LOCATION</a></div><div class="ttdeci">#define CHECK_LOCATION()</div><div class="ttdef"><b>Definition:</b> <a href="_exceptions_8hpp_source.xhtml#l00209">Exceptions.hpp:209</a></div></div>
</div><!-- fragment -->
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>src/backends/cl/<a class="el" href="_cl_context_deserializer_8hpp_source.xhtml">ClContextDeserializer.hpp</a></li>
<li>src/backends/cl/<a class="el" href="_cl_context_deserializer_8cpp_source.xhtml">ClContextDeserializer.cpp</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="namespacearmnn.xhtml">armnn</a></li><li class="navelem"><a class="el" href="classarmnn_1_1_cl_context_deserializer.xhtml">ClContextDeserializer</a></li>
<li class="footer">Generated on Wed Nov 17 2021 12:59:41 for ArmNN by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
</ul>
</div>
</body>
</html>