11 #include "eteq/generated/opcode.hpp" 17 #ifndef DBG_CUSTOM_FUNCTOR_HPP 18 #define DBG_CUSTOM_FUNCTOR_HPP 55 return "DBG_CUSTOM_FUNCTOR";
73 logs::fatal(
"cannot modify custom functor");
82 auto tens = arg.get_tensor();
83 auto coorder =
static_cast<eteq::CoordMap*
>(arg.get_coorder().get());
100 const void*
data (
void)
const override 108 return egen::get_type<T>();
114 return egen::name_type(egen::get_type<T>());
140 template <
typename T>
154 return (T*)
func_->data();
177 std::shared_ptr<CustomFunctor<T>>
func_;
180 template <
typename T>
183 static bool registered = eteq::register_builder<CustomFunctor<T>,T>(
186 return std::make_shared<CustomFunctorNode<T>>(
194 logs::fatal(
"cannot create custom functor without args");
198 for (
size_t i = 1, n =
nargs; i < n; ++i)
203 logs::fatalf(
"cannot create custom functor with " 204 "incompatible shapes %s and %s",
211 input_args.reserve(
nargs);
212 std::transform(
args.begin(),
args.end(),
213 std::back_inserter(input_args),
226 template <
typename T>
229 return std::make_shared<CustomFunctorNode<T>>(
236 #endif // DBG_CUSTOM_FUNCTOR_HPP std::string to_string(void) const override
Implementation of iTensor.
Definition: custom_functor.hpp:53
std::string to_string(void) const
Return string representation of shape.
Definition: shape.hpp:148
args
Definition: csv_to_png.py:105
CustomFunctor(const CustomFunctor< T > &other)=default
A functor node with direct access to evaluated data.
Definition: iopfunc.hpp:20
Encoding of operation.
Definition: ifunctor.hpp:18
CustomOpF< T > op_
Definition: custom_functor.hpp:130
const void * data(void) const override
Implementation of iData.
Definition: custom_functor.hpp:100
CustomFunctorNode(std::shared_ptr< CustomFunctor< T >> f)
Definition: custom_functor.hpp:143
eteq::iNode< T > * clone_impl(void) const override
Definition: custom_functor.hpp:170
static CustomFunctor< T > * get(CustomOpF< T > op, eteq::ArgsT< T > args)
Return a CustomFunctor with input function and meta arguments.
Definition: custom_functor.hpp:181
Definition: constant.hpp:17
std::vector< FuncArg > ArgsT
Type of functor arguments.
Definition: funcarg.hpp:101
Definition: custom_functor.hpp:20
nargs
Definition: csv_to_png.py:101
void update(void) override
Implementation of iOperableFunc.
Definition: custom_functor.hpp:77
CustomFunctor's node wrapper.
Definition: custom_functor.hpp:141
Interface node for wrapping typed tensor.
Definition: inode.hpp:23
Eigen node version of teq::FuncArg.
Definition: funcarg.hpp:22
bool compatible_after(const Shape &other, RankT idx) const
Definition: shape.hpp:136
size_t nbytes(void) const override
Implementation of iData.
Definition: custom_functor.hpp:118
teq::Opcode get_opcode(void) const override
Implementation of iFunctor.
Definition: custom_functor.hpp:59
Coordinate mapper and tensor pair.
Definition: funcarg.hpp:21
std::shared_ptr< CustomFunctor< T > > func_
Definition: custom_functor.hpp:177
std::string type_label(void) const override
Implementation of iData.
Definition: custom_functor.hpp:112
Eigen transformation wrapper implementation of iCoordMap.
Definition: coord.hpp:18
void update(void) override
Implementation of iNode<T>
Definition: custom_functor.hpp:158
std::function< void(eteq::TensorT< T > &, const DataMapT< T > &)> CustomOpF
Custom functor to assign DataMap to Eigen tensor output.
Definition: custom_functor.hpp:29
teq::Shape shape_
Shape info built at construction time according to arguments.
Definition: custom_functor.hpp:133
eteq::NodeptrT< T > make_functor(CustomOpF< T > op, eteq::ArgsT< T > args)
Return custom functor node given custom function and arguments.
Definition: custom_functor.hpp:227
teq::TensptrT get_tensor(void) const override
Implementation of iNode<T>
Definition: custom_functor.hpp:164
const teq::ArgsT & get_children(void) const override
Implementation of iFunctor.
Definition: custom_functor.hpp:65
std::vector< eteq::OpArg< T > > DataMapT
Arguments of raw data and shapes.
Definition: custom_functor.hpp:25
std::shared_ptr< iTensor > TensptrT
Tensor smart pointer.
Definition: itensor.hpp:51
std::vector< FuncArg< T > > ArgsT
Type of typed functor arguments.
Definition: funcarg.hpp:84
Raw data, shape, and transformation argument struct.
Definition: operator.hpp:28
void update_child(teq::FuncArg arg, size_t index) override
Implementation of iFunctor.
Definition: custom_functor.hpp:71
T * data(void) override
Implementation of iNode<T>
Definition: custom_functor.hpp:152
void * data(void) override
Implementation of iData.
Definition: custom_functor.hpp:94
Eigen::Tensor< T, 8 > TensorT
Eigen Tensor.
Definition: eigen.hpp:35
Functor that runs a custom functor instead of Eigen operators.
Definition: custom_functor.hpp:33
NElemT index(Shape shape, CoordT coord)
std::shared_ptr< iNode< T > > NodeptrT
Smart pointer of node.
Definition: inode.hpp:63
CustomFunctor(CustomOpF< T > op, teq::Shape shape, teq::ArgsT args)
Definition: custom_functor.hpp:124
eteq::TensorT< T > out_
Definition: custom_functor.hpp:128
teq::ArgsT args_
Tensor arguments (and children)
Definition: custom_functor.hpp:136
const teq::Shape & shape(void) const override
Implementation of iTensor.
Definition: custom_functor.hpp:47
size_t type_code(void) const override
Implementation of iData.
Definition: custom_functor.hpp:106
NElemT n_elems(void) const
Return the total number of elements represented by the shape.
Definition: shape.hpp:118
#define TO_NODE(tens)
Macro for converting tensor to node.
Definition: inode.hpp:106
CustomFunctorNode< T > * clone(void) const
Return deep copy of this instance (with a copied functor)
Definition: custom_functor.hpp:146
DimensionsT shape_convert(teq::Shape shape)
Return Eigen shape of teq Shape.
CustomFunctor< T > & operator=(const CustomFunctor< T > &other)=delete