blob: b4b8135701378952b1efc8a3a113046e09852d6c [file] [log] [blame]
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Code Structure &mdash; incubator-singa 0.3.0 documentation</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="top" title="incubator-singa 0.3.0 documentation" href="../index.html"/>
<script src="../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../index.html" class="icon icon-home"> incubator-singa
<img src="../_static/singa.png" class="logo" />
</a>
<div class="version">
0.3.0
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../downloads.html">Download SINGA</a></li>
<li class="toctree-l1"><a class="reference internal" href="index.html">Documentation</a></li>
</ul>
<p class="caption"><span class="caption-text">Development</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../develop/schedule.html">Development Schedule</a></li>
<li class="toctree-l1"><a class="reference internal" href="../develop/how-contribute.html">How to Contribute to SINGA</a></li>
<li class="toctree-l1"><a class="reference internal" href="../develop/contribute-code.html">How to Contribute Code</a></li>
<li class="toctree-l1"><a class="reference internal" href="../develop/contribute-docs.html">How to Contribute Documentation</a></li>
</ul>
<p class="caption"><span class="caption-text">Community</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../community/source-repository.html">Source Repository</a></li>
<li class="toctree-l1"><a class="reference internal" href="../community/mail-lists.html">Project Mailing Lists</a></li>
<li class="toctree-l1"><a class="reference internal" href="../community/issue-tracking.html">Issue Tracking</a></li>
<li class="toctree-l1"><a class="reference internal" href="../community/team-list.html">The SINGA Team</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">incubator-singa</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html">Docs</a> &raquo;</li>
<li>Code Structure</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="code-structure">
<span id="code-structure"></span><h1>Code Structure<a class="headerlink" href="#code-structure" title="Permalink to this headline"></a></h1>
<hr class="docutils" />
<!--<div class="section" id="worker-side">
<span id="worker-side"></span><h2>Worker Side<a class="headerlink" href="#worker-side" title="Permalink to this headline">¶</a></h2>
<div class="section" id="main-classes">
<span id="main-classes"></span><h3>Main Classes<a class="headerlink" href="#main-classes" title="Permalink to this headline">¶</a></h3>
<p><img src="../_static/images/code-structure/main.jpg" style="width: 550px"/></p>
<ul class="simple">
<li><strong>Worker</strong>: start the solver to conduct training or resume from previous training snapshots.</li>
<li><strong>Solver</strong>: construct the neural network and run training algorithms over it. Validation and testing is also done by the solver along the training.</li>
<li><strong>TableDelegate</strong>: delegate for the parameter table physically stored in parameter servers.
it runs a thread to communicate with table servers for parameter transferring.</li>
<li><strong>Net</strong>: the neural network consists of multiple layers constructed from input configuration file.</li>
<li><strong>Layer</strong>: the core abstraction, read data (neurons) from connecting layers, and compute the data
of itself according to layer specific ComputeFeature functions. Data from the bottom layer is forwarded
layer by layer to the top.</li>
</ul>
</div>
<div class="section" id="data-types">
<span id="data-types"></span><h3>Data types<a class="headerlink" href="#data-types" title="Permalink to this headline">¶</a></h3>
<p><img src="../_static/images/code-structure/layer.jpg" style="width: 700px"/></p>
<ul class="simple">
<li><strong>ComputeFeature</strong>: read data (neurons) from in-coming layers, and compute the data
of itself according to layer type. This function can be overrided to implement different
types layers.</li>
<li><strong>ComputeGradient</strong>: read gradients (and data) from in-coming layers and compute
gradients of parameters and data w.r.t the learning objective (loss).</li>
</ul>
<p>We adpat the implementation for <strong>PoolingLayer</strong>, <strong>Im2colLayer</strong> and <strong>LRNLayer</strong> from <a class="reference external" href="http://caffe.berkeleyvision.org/">Caffe</a>.</p>
<p><img src="../_static/images/code-structure/darray.jpg" style="width: 400px"/></p>
<ul class="simple">
<li><strong>DArray</strong>: provide the abstraction of distributed array on multiple nodes,
supporting array/matrix operations and element-wise operations. Users can use it as a local structure.</li>
<li><strong>LArray</strong>: the local part for the DArray. Each LArray is treated as an
independent array, and support all array-related operations.</li>
<li><strong>MemSpace</strong>: manage the memory used by DArray. Distributed memory are allocated
and managed by armci. Multiple DArray can share a same MemSpace, the memory
will be released when no DArray uses it anymore.</li>
<li><strong>Partition</strong>: maintain both global shape and local partition information.
used when two DArray are going to interact.</li>
<li><strong>Shape</strong>: basic class for representing the scope of a DArray/LArray</li>
<li><strong>Range</strong>: basic class for representing the scope of a Partition</li>
</ul>
</div>
</div>
<div class="section" id="parameter-server">
<span id="parameter-server"></span><h2>Parameter Server<a class="headerlink" href="#parameter-server" title="Permalink to this headline">¶</a></h2>
<div class="section" id="main-classes">
<span id="id1"></span><h3>Main classes<a class="headerlink" href="#main-classes" title="Permalink to this headline">¶</a></h3>
<p><img src="../_static/images/code-structure/uml.jpg" style="width: 750px"/></p>
<ul class="simple">
<li><strong>NetworkService</strong>: provide access to the network (sending and receiving messages). It maintains a queue for received messages, implemented by NetworkQueue.</li>
<li><strong>RequestDispatcher</strong>: pick up next message (request) from the queue, and invoked a method (callback) to process them.</li>
<li><strong>TableServer</strong>: provide access to the data table (parameters). Register callbacks for different types of requests to RequestDispatcher.</li>
<li><strong>GlobalTable</strong>: implement the table. Data is partitioned into multiple Shard objects per table. User-defined consistency model supported by extending TableServerHandler for each table.</li>
</ul>
</div>
<div class="section" id="data-types">
<span id="id2"></span><h3>Data types<a class="headerlink" href="#data-types" title="Permalink to this headline">¶</a></h3>
<p><img src="../_static/images/code-structure/type.jpg" style="width: 400px"/></p>
<p>Table related messages are either of type <strong>RequestBase</strong> which contains different types of request, or of type <strong>TableData</strong> containing a key-value tuple.</p>
</div>
<div class="section" id="control-flow-and-thread-model">
<span id="control-flow-and-thread-model"></span><h3>Control flow and thread model<a class="headerlink" href="#control-flow-and-thread-model" title="Permalink to this headline">¶</a></h3>
<p><img src="../_static/images/code-structure/threads.jpg" alt="uml" style="width: 1000px"/></p>
<p>The figure above shows how a GET request sent from a worker is processed by the
table server. The control flow for other types of requests is similar. At
the server side, there are at least 3 threads running at any time: two by
NetworkService for sending and receiving message, and at least one by the
RequestDispatcher for dispatching requests.</p>
<p>&#8211;&gt;</p>
</div>
</div>
</div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2016 The Apache Software Foundation. All rights reserved. Apache Singa, Apache, the Apache feather logo, and the Apache Singa project logos are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners..
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'0.3.0',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
<div class="rst-versions shift-up" data-toggle="rst-versions" role="note" aria-label="versions">
<img src="../_static/apache.jpg">
<span class="rst-current-version" data-toggle="rst-current-version">
<span class="fa fa-book"> incubator-singa </span>
v: 0.3.0
<span class="fa fa-caret-down"></span>
</span>
<div class="rst-other-versions">
<dl>
<dt>Languages</dt>
<dd><a href="../../en/index.html">English</a></dd>
<dd><a href="../../zh/index.html">中文</a></dd>
<dd><a href="../../jp/index.html">日本語</a></dd>
<dd><a href="../../kr/index.html">한국어</a></dd>
</dl>
</div>
</div>
<a href="https://github.com/apache/incubator-singa">
<img style="position: absolute; top: 0; right: 0; border: 0; z-index: 10000;"
src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png"
alt="Fork me on GitHub">
</a>
</body>
</html>