VisionCpp  0.0.1
complex_ops.hpp
Go to the documentation of this file.
1 // This file is part of VisionCpp, a lightweight C++ template library
2 // for computer vision and image processing.
3 //
4 // Copyright (C) 2016 Codeplay Software Limited. All Rights Reserved.
5 //
6 // Contact: visioncpp@codeplay.com
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // Unless required by applicable law or agreed to in writing, software
15 // distributed under the License is distributed on an "AS IS" BASIS,
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 // See the License for the specific language governing permissions and
18 // limitations under the License.
19 
20 /// \file complex_ops.hpp
21 /// \brief This file contains a set of includes and forward declaration required
22 /// to build complex operations like pyramid.
23 
24 #ifndef VISIONCPP_INCLUDE_FRAMEWORK_EXPR_TREE_COMPLEX_OPS_COMPLEX_OPS_HPP_
25 #define VISIONCPP_INCLUDE_FRAMEWORK_EXPR_TREE_COMPLEX_OPS_COMPLEX_OPS_HPP_
26 
27 namespace visioncpp {
28 namespace internal {
29 /// \brief CreatePyramidTupleType: This file is used to create each output
30 /// element type for each downsampling output of the pyramid memory. It is used
31 /// when we need the pyramid node auto generate the output node.
32 /// template parameters:
33 /// \tparam SatisfyingConds: a boolean variable is used to determine the end of
34 /// the recursive creation of the pyramid output tuple.
35 /// \tparam Cols: determines the column size of the input pyramid
36 /// \tparam Rows: determines the row size of the input pyramid
37 /// \tparam LeafType: determines the type of the leafNode {Buffer2D, Buffer1D,
38 /// Host, Image}
39 /// \tparam Depth: represents the depth of down sampling
40 /// \tparam CurrentDepth: represents the number of output created so far in the
41 /// recursion
42 /// \tparam LHS is the final output of the pyramid combining all the node
43 /// together
44 /// \tparam ChildType... : is the total number of output type generated so far
45 template <bool SatisfyingConds, size_t Cols, size_t Rows, size_t LeafType,
46  size_t Depth, size_t CurrentDepth, typename LHS,
47  typename... ChildType>
48 struct CreatePyramidTupleType;
49 
50 /// \brief CreatePyramidTuple. Once the type of each output element for the
51 /// output element of the pyramid has been created, The CreatePyramidTuple is
52 /// used to instantiate the output elements of the Tuple.
53 /// \tparam SatisfyingConds: a boolean variable is used to determine the end of
54 /// the recursive creation of the pyramid output tuple.
55 /// \tparam Cols: determines the column size of the input pyramid
56 /// \tparam Rows: determines the row size of the input pyramid
57 /// \tparam LeafType: determines the type of the leafNode {Buffer2D, Buffer1D,
58 /// Host, Image}
59 /// \tparam Depth: represents the depth of down sampling
60 /// \tparam CurrentDepth: represents the number of outputs created so far in the
61 /// recursion
62 /// \tparam LHS is the final output of the pyramid combining all the nodes
63 /// together
64 template <bool SatisfyingConds, size_t Cols, size_t Rows, size_t LeafType,
65  size_t Depth, size_t Current_Depth, typename LHS>
66 struct CreatePyramidTuple;
67 
68 /// \brief create_pyramid_memory template deduction function for
69 /// CreatePyramidTuple struct.
70 /// template parameters:
71 /// the recursive creation of the pyramid output tuple.
72 /// \tparam Cols: determines the column size of the input pyramid
73 /// \tparam Rows: determines the row size of the input pyramid
74 /// \tparam LeafType: determines the type of the leafNode {Buffer2D, Buffer1D,
75 /// Host, Image}
76 /// \tparam Depth: represents the depth of down sampling
77 /// \tparam CurrentDepth: represents the number of outputs created so far in the
78 /// recursion
79 /// \tparam LHS is the final output of the pyramid combining all the node
80 /// together.
81 /// function parameters:
82 /// \return CreatePyramidTupleType
83 template <size_t Cols, size_t Rows, size_t Depth, size_t Current_Depth,
84  typename LHS>
85 typename CreatePyramidTupleType<false, Cols, Rows, LHS::Type::LeafType, Depth,
86  0, LHS>::Type inline create_pyramid_memory();
87 
88 template <typename PyramidT, size_t N>
90  static constexpr bool has_out = false;
91  using OutType = typename PyramidT::OutType;
92  using Type = typename PyramidT::Type;
93  using LHSExpr = typename PyramidT::LHSExpr;
94  static constexpr size_t Level = PyramidT::Level;
95  static constexpr size_t LeafType = PyramidT::LeafType;
96  static constexpr bool SubExpressionEvaluationNeeded = true;
97  static constexpr size_t Operation_type = PyramidT::Operation_type;
98  static constexpr size_t RThread = PyramidT::RThread;
99  static constexpr size_t CThread = PyramidT::CThread;
100  static constexpr size_t ND_Category = PyramidT::ND_Category;
101  static constexpr size_t Depth = PyramidT::Depth;
102  using PyramidMem = typename PyramidT::PyramidMem;
104  // pyramid
105  PyramidT& rhs; // the pyramid
106  PyramidLeafNode(PyramidT& pst) : subexpr_execution_reseter(false), rhs(pst) {}
107 
108  void reset(bool reset) {
109  rhs.subexpr_execution_reseter = reset;
111  }
112  template <bool ForcedToExec, size_t LC, size_t LR, size_t LCT, size_t LRT,
113  typename DeviceT>
114  auto sub_expression_evaluation(const DeviceT& dev)
115  -> decltype(tools::tuple::get<N>(rhs.mem)) {
116  if (rhs.subexpr_execution_reseter) {
117  if (rhs.first_time) {
118  rhs.template sub_expression_evaluation<ForcedToExec, LC, LR, LCT, LRT>(
119  dev);
120  rhs.subexpr_execution_reseter = false;
121  rhs.first_time = false;
122  rhs.node_reseter = N;
123  } else {
124  if (N == rhs.node_reseter) {
125  rhs.template sub_expression_evaluation<ForcedToExec, LC, LR, LRT,
126  LCT>(dev);
127  }
128  }
129  }
130  return tools::tuple::get<N>(rhs.mem);
131  }
132 };
133 } // end internal
134 } // end visioncpp
135 #include "pyramid_mem.hpp"
138 #endif // VISIONCPP_INCLUDE_FRAMEWORK_EXPR_TREE_COMPLEX_OPS_COMPLEX_OPS_HPP_
CreatePyramidTupleType< false, Cols, Rows, LHS::Type::LeafType, Depth, 0, LHS >::Type create_pyramid_memory()
create_pyramid_memory template deduction function for CreatePyramidTuple struct.
VisionCpp namespace.
Definition: sycl/device.hpp:24
This file is used to create a pyramid output memory when the auto generate output memory is selected.
This file contains the construction of the pyramid node where a user can pass general filter2d functo...
This file contains the construction of the pyramid node where a user can pass separable filter2d func...
auto sub_expression_evaluation(const DeviceT &dev) -> decltype(tools::tuple::get< N >(rhs.mem))
typename PyramidT::PyramidMem PyramidMem
static constexpr size_t CThread
Definition: complex_ops.hpp:99
typename PyramidT::LHSExpr LHSExpr
Definition: complex_ops.hpp:93
static constexpr size_t Operation_type
Definition: complex_ops.hpp:97
typename PyramidT::OutType OutType
Definition: complex_ops.hpp:91
static constexpr size_t ND_Category
static constexpr size_t Level
Definition: complex_ops.hpp:94
static constexpr bool SubExpressionEvaluationNeeded
Definition: complex_ops.hpp:96
static constexpr size_t LeafType
Definition: complex_ops.hpp:95
static constexpr size_t RThread
Definition: complex_ops.hpp:98
typename PyramidT::Type Type
Definition: complex_ops.hpp:92