VisionCpp  0.0.1
eval_expr_leaf_node.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 eval_expr_leaf_node.hpp
21 /// \brief This file contains the specialisation of the EvalExpr
22 /// for LeafNode.
23 
24 #ifndef VISIONCPP_INCLUDE_FRAMEWORK_EVALUATOR_EVAL_EXPRESSION_EVAL_EXPR_LEAF_NODE_HPP_
25 #define VISIONCPP_INCLUDE_FRAMEWORK_EVALUATOR_EVAL_EXPRESSION_EVAL_EXPR_LEAF_NODE_HPP_
26 
27 namespace visioncpp {
28 namespace internal {
29 /// \brief Partial specialisation of the EvalExpr when the expression is
30 /// an LeafNode expression and the internal::ops_category is NeighbourOP.
31 template <size_t Memory_Type, size_t N, size_t Cols, size_t Rows, size_t LVL,
32  size_t Sc, typename Loc, typename... Params>
33 struct EvalExpr<LeafNode<PlaceHolder<Memory_Type, N, Cols, Rows, Sc>, LVL>, Loc,
34  Params...> {
36 
38  -> decltype(tools::tuple::get<N>(t)) {
39  return tools::tuple::get<N>(t);
40  }
41  /// \brief evaluate function when the internal::ops_category is PointOP.
42  static inline auto
43  eval_point(Loc &cOffset, const tools::tuple::Tuple<Params...> &t) -> decltype(
44  tools::tuple::get<N>(t)
45  .get_pointer()[cOffset.pointOp_gc + (Cols * cOffset.pointOp_gr)]) {
46  return tools::tuple::get<N>(t).get_pointer()[calculate_index(
47  cOffset.pointOp_gc, cOffset.pointOp_gr, Cols, Rows)];
48  }
49  /// \brief evaluate function when the internal::ops_category is NeighbourOP.
50  template <bool IsRoot, size_t Halo_Top, size_t Halo_Left, size_t Halo_Butt,
51  size_t Halo_Right, size_t Offset, size_t Index, size_t LC,
52  size_t LR>
53  static inline auto eval_neighbour(Loc &cOffset,
55  -> decltype(
58  Trait<typename tools::RemoveAll<decltype(
59  tools::tuple::get<N>(t))>::Type>::scope>::Index>(t)) {
61  Halo_Top, Halo_Left, Halo_Butt, Halo_Right,
62  Index_Finder<N, OutputLocation<IsRoot, Offset + Index - 1>::ID,
63  Memory_Type, Sc>::Index,
64  LC, LR, Expr>(cOffset, t);
65  return tools::tuple::get<
66  Index_Finder<N, OutputLocation<IsRoot, Offset + Index - 1>::ID,
67  Memory_Type, Sc>::Index>(t);
68  }
69  /// \brief evaluate function when the internal::ops_category is
70  /// GlobalNeighbour;
71  template <bool IsRoot, size_t Offset, size_t Index, size_t LC, size_t LR>
72  static inline auto
74  -> decltype(tools::tuple::get<N>(t)) {
75  return tools::tuple::get<N>(t);
76  }
77 };
78 } // namespace internal
79 } // namespace visioncpp
80 #endif // VISIONCPP_INCLUDE_FRAMEWORK_EVALUATOR_EVAL_EXPRESSION_EVAL_EXPR_LEAF_NODE_HPP_
EnableIf< k==0, typename ElemTypeHolder< 0, Tuple< Ts... > >::type & >::type get(Tuple< Ts... > &t)
get
Definition: tuple.hpp:99
static size_t calculate_index(size_t c, size_t r, size_t cols, size_t rows)
function calculate_index
static void fill_local_neighbour(Loc &cOffset, const internal::tools::tuple::Tuple< Params... > &t)
template deduction for Fill struct.
VisionCpp namespace.
Definition: sycl/device.hpp:24
static auto eval_neighbour(Loc &cOffset, const tools::tuple::Tuple< Params... > &t) -> decltype(tools::tuple::get< Index_Finder< N, OutputLocation< IsRoot, Offset+Index - 1 >::ID, Memory_Type, Trait< typename tools::RemoveAll< decltype(tools::tuple::get< N >(t))>::Type >::scope >::Index >(t))
evaluate function when the internal::ops_category is NeighbourOP.
static auto eval_point(Loc &cOffset, const tools::tuple::Tuple< Params... > &t) -> decltype(tools::tuple::get< N >(t) .get_pointer()[cOffset.pointOp_gc+(Cols *cOffset.pointOp_gr)])
evaluate function when the internal::ops_category is PointOP.
static auto eval_global_neighbour(Loc &, const tools::tuple::Tuple< Params... > &t) -> decltype(tools::tuple::get< N >(t))
evaluate function when the internal::ops_category is GlobalNeighbour;
static auto get_accessor(const tools::tuple::Tuple< Params... > &t) -> decltype(tools::tuple::get< N >(t))
eval_global_neighbour function:
Definition: evaluator.hpp:195
is used to find the index required to access the accessor inside the buffer.
Definition: evaluator.hpp:119
the definition is in LeafNode.
Definition: leaf_node.hpp:38
This is used to find whether a node should use a global memory output or a local memory output is cre...
Definition: evaluator.hpp:265
PlaceHolder is used to replace the Vision Memory in the LeafNode containing sycl buffer.
This struct is used to trait the value type inside the accessor.
Definition: evaluator.hpp:89
These methods are used to remove all the & const and * from a type.
The tuple is a fixed-size collection of heterogeneous values.
Definition: tuple.hpp:48