Skip to content

Commit

Permalink
update some ade docs
Browse files Browse the repository at this point in the history
  • Loading branch information
raggledodo committed May 5, 2019
1 parent fcdcc35 commit aa615de
Show file tree
Hide file tree
Showing 79 changed files with 243 additions and 109 deletions.
1 change: 1 addition & 0 deletions ade/coord.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ using CoordptrT = std::shared_ptr<iCoordMap>;
/// Identity matrix instance
extern CoordptrT identity;

/// Checks if the coord mapper is an identity mapper
bool is_identity (iCoordMap* coorder);

/// Return coordinate mapper dividing dimensions after rank
Expand Down
16 changes: 16 additions & 0 deletions ade/edge.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
///
/// ead.hpp
/// ade
///
/// Purpose:
/// Define non-operating edges between tensor nodes
///

#include "ade/ifunctor.hpp"

#ifndef ADE_EDGE_HPP
Expand All @@ -6,22 +14,29 @@
namespace ade
{

/// Edge between parent and child tensor references and labelled with edge code
struct Edge final
{
/// Return true if either parent or child are expired, otherwise false
bool expired (void) const
{
return parent_.expired() || child_.expired();
}

/// Parent reference
TensrefT parent_;

/// Child refence
TensrefT child_;

/// Edge label and enumeration
Opcode edge_code_;
};

/// Vector of edges
using EdgesT = std::vector<Edge>;

/// Edge hasher
struct EdgeHash final
{
size_t operator() (const Edge& edge) const
Expand All @@ -38,6 +53,7 @@ struct EdgeHash final
}
};

/// Edge equality comparator
inline bool operator == (const Edge& lhs, const Edge& rhs)
{
EdgeHash hasher;
Expand Down
3 changes: 3 additions & 0 deletions ade/functor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ struct Functor final : public iFunctor
ArgsT args_;
};

/// Functor smart pointer
using FuncptrT = std::shared_ptr<iFunctor>;

}

#endif // ADE_FUNCTOR_HPP
1 change: 1 addition & 0 deletions ade/ileaf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct iLeaf : public iTensor
virtual size_t type_code (void) const = 0;
};

/// Leaf smart pointer
using LeafptrT = std::shared_ptr<iLeaf>;

}
Expand Down
2 changes: 2 additions & 0 deletions ade/itensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ struct iTensor
virtual std::string to_string (void) const = 0;
};

/// Tensor smart pointer
using TensptrT = std::shared_ptr<iTensor>;

/// Tensor weak pointers
using TensrefT = std::weak_ptr<iTensor>;

}
Expand Down
13 changes: 12 additions & 1 deletion ade/opfunc.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
///
/// opfunc.hpp
/// ade
///
/// Purpose:
/// Define functor nodes directly hold/manipulate data
/// This differs from Functor which should not directly manipulate data
///

#include "ade/ifunctor.hpp"

#ifndef ADE_OPFUNC_HPP
Expand All @@ -7,12 +16,14 @@ namespace ade
{

/// A functor node with direct access to evaluated data
struct iOperableFunc : public ade::iFunctor
struct iOperableFunc : public iFunctor
{
virtual ~iOperableFunc (void) = default;

/// Update local data-cache using this functor's operation
virtual void update (void) = 0;

/// Return data-cache raw pointer
virtual void* raw_data (void) = 0;
};

Expand Down
17 changes: 16 additions & 1 deletion ade/test/test_edge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@ TEST(EDGE, Equality)
ade::Edge edge3{parent2, child2, mock_code};
ade::Edge edge4{parent, child, mock_code2};

ade::Edge expired_edge;
ASSERT_TRUE(expired_edge.expired());

ade::Edge edge_eq{parent, child, mock_code};

EXPECT_FALSE(orig_edge == edge);
EXPECT_FALSE(orig_edge == edge2);
EXPECT_FALSE(orig_edge == edge3);
EXPECT_FALSE(orig_edge == edge4);
EXPECT_FALSE(orig_edge == expired_edge);
EXPECT_TRUE(orig_edge == edge_eq);
}

Expand All @@ -87,16 +91,27 @@ TEST(EDGE, Hash)
ade::TensptrT child(new MockTensor(shape));
ade::TensptrT child2(new MockTensor(shape));

ade::Edge expired_edge;
ade::Edge expired_edge2 = {
ade::TensrefT(),
ade::TensrefT(),
ade::Opcode{"SOMETHING", 123},
};
ASSERT_TRUE(expired_edge.expired());
ASSERT_TRUE(expired_edge2.expired());

std::unordered_set<ade::Edge,ade::EdgeHash> edges = {
ade::Edge{parent, child, mock_code},
ade::Edge{parent2, child, mock_code},
ade::Edge{parent, child2, mock_code},
ade::Edge{parent2, child2, mock_code},
ade::Edge{parent, child, mock_code2},
ade::Edge{parent, child, mock_code},
expired_edge,
expired_edge2,
};

EXPECT_EQ(5, edges.size());
EXPECT_EQ(6, edges.size());
}


Expand Down
3 changes: 2 additions & 1 deletion ade/traveler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ struct PathFinder final : public iTraveler
ParentMapT parents_;
};

/// Map between tensor and its corresponding smart pointer
using OwnerMapT = std::unordered_map<iTensor*,TensrefT>;

/// Travelers will lose smart pointer references,
// this utility function will grab reference maps of root's subtree
/// This utility function will grab reference maps of root's subtree
OwnerMapT track_owners (TensptrT root);

}
Expand Down
1 change: 1 addition & 0 deletions docs/ade_2coord_8hpp.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a6b6c4cd25145a806179fdf02a9402163"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceade.html#a6b6c4cd25145a806179fdf02a9402163">ade::is_identity</a> (iCoordMap *coorder)</td></tr>
<tr class="memdesc:a6b6c4cd25145a806179fdf02a9402163"><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks if the coord mapper is an identity mapper. <a href="namespaceade.html#a6b6c4cd25145a806179fdf02a9402163">More...</a><br /></td></tr>
<tr class="separator:a6b6c4cd25145a806179fdf02a9402163"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aca905a7156b047e9e5e1df3fb4f62763"><td class="memItemLeft" align="right" valign="top">CoordptrT&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceade.html#aca905a7156b047e9e5e1df3fb4f62763">ade::reduce</a> (uint8_t rank, std::vector&lt; DimT &gt; red)</td></tr>
<tr class="separator:aca905a7156b047e9e5e1df3fb4f62763"><td class="memSeparator" colspan="2">&#160;</td></tr>
Expand Down
4 changes: 2 additions & 2 deletions docs/ade_2coord_8hpp_source.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/ade_2funcarg_8hpp_source.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<div class="ttc" id="namespaceade_html_a51de3f8cb4058a56fc0e51a7b7b564c3"><div class="ttname"><a href="namespaceade.html#a51de3f8cb4058a56fc0e51a7b7b564c3">ade::identity</a></div><div class="ttdeci">CoordptrT identity</div><div class="ttdoc">Identity matrix instance. </div></div>
<div class="ttc" id="structade_1_1_func_arg_html_ab5c06f187d8cb2583b518ffda6365dc3"><div class="ttname"><a href="structade_1_1_func_arg.html#ab5c06f187d8cb2583b518ffda6365dc3">ade::FuncArg::get_coorder</a></div><div class="ttdeci">CoordptrT get_coorder(void) const</div><div class="ttdoc">Return coord map for coordinates. </div><div class="ttdef"><b>Definition:</b> funcarg.hpp:80</div></div>
<div class="ttc" id="namespaceade_html_a1c24e679bb276ba3a7db5fe145b4dcb1"><div class="ttname"><a href="namespaceade.html#a1c24e679bb276ba3a7db5fe145b4dcb1">ade::permute_map</a></div><div class="ttdeci">FuncArg permute_map(TensptrT tensor, std::vector&lt; uint8_t &gt; order)</div></div>
<div class="ttc" id="namespaceade_html_aceac6eb9293c8b2001737f3b26667993"><div class="ttname"><a href="namespaceade.html#aceac6eb9293c8b2001737f3b26667993">ade::TensptrT</a></div><div class="ttdeci">std::shared_ptr&lt; iTensor &gt; TensptrT</div><div class="ttdef"><b>Definition:</b> itensor.hpp:48</div></div>
<div class="ttc" id="namespaceade_html_aceac6eb9293c8b2001737f3b26667993"><div class="ttname"><a href="namespaceade.html#aceac6eb9293c8b2001737f3b26667993">ade::TensptrT</a></div><div class="ttdeci">std::shared_ptr&lt; iTensor &gt; TensptrT</div><div class="ttdoc">Tensor smart pointer. </div><div class="ttdef"><b>Definition:</b> itensor.hpp:49</div></div>
<div class="ttc" id="namespaceade_html_acc064bc531d2ee6464f7f5b50d821216"><div class="ttname"><a href="namespaceade.html#acc064bc531d2ee6464f7f5b50d821216">ade::reduce_map</a></div><div class="ttdeci">FuncArg reduce_map(TensptrT tensor, uint8_t rank, std::vector&lt; DimT &gt; red)</div></div>
<div class="ttc" id="namespaceade_html"><div class="ttname"><a href="namespaceade.html">ade</a></div><div class="ttdef"><b>Definition:</b> coord.hpp:16</div></div>
<div class="ttc" id="namespaceade_html_aca8ab70c54a4bdfb4e58b2a3155c7510"><div class="ttname"><a href="namespaceade.html#aca8ab70c54a4bdfb4e58b2a3155c7510">ade::apply_shaper</a></div><div class="ttdeci">Shape apply_shaper(const CoordptrT &amp;shaper, Shape inshape)</div></div>
Expand Down
9 changes: 8 additions & 1 deletion docs/ade_2functor_8hpp.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
<div class="header">
<div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#namespaces">Namespaces</a> </div>
<a href="#namespaces">Namespaces</a> &#124;
<a href="#typedef-members">Typedefs</a> </div>
<div class="headertitle">
<div class="title">functor.hpp File Reference</div> </div>
</div><!--header-->
Expand Down Expand Up @@ -145,6 +146,12 @@
Namespaces</h2></td></tr>
<tr class="memitem:namespaceade"><td class="memItemLeft" align="right" valign="top"> &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceade.html">ade</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:a769e13e66ecc72f0d142a85dc7395591"><td class="memItemLeft" align="right" valign="top">using&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceade.html#a769e13e66ecc72f0d142a85dc7395591">ade::FuncptrT</a> = std::shared_ptr&lt; iFunctor &gt;</td></tr>
<tr class="memdesc:a769e13e66ecc72f0d142a85dc7395591"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="structade_1_1_functor.html" title="Functor of the graph mapping to operators specified by opcode argument. ">Functor</a> smart pointer. <a href="namespaceade.html#a769e13e66ecc72f0d142a85dc7395591">More...</a><br /></td></tr>
<tr class="separator:a769e13e66ecc72f0d142a85dc7395591"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
</div><!-- contents -->
<!-- start footer part -->
Expand Down
3 changes: 2 additions & 1 deletion docs/ade_2functor_8hpp_source.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/ade_2ileaf_8hpp.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:a1bdf3657cc8a95dd974ad6aa36e2230f"><td class="memItemLeft" align="right" valign="top">using&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceade.html#a1bdf3657cc8a95dd974ad6aa36e2230f">ade::LeafptrT</a> = std::shared_ptr&lt; iLeaf &gt;</td></tr>
<tr class="memdesc:a1bdf3657cc8a95dd974ad6aa36e2230f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Leaf smart pointer. <a href="namespaceade.html#a1bdf3657cc8a95dd974ad6aa36e2230f">More...</a><br /></td></tr>
<tr class="separator:a1bdf3657cc8a95dd974ad6aa36e2230f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
</div><!-- contents -->
Expand Down
Loading

0 comments on commit aa615de

Please sign in to comment.