11 #include "eteq/generated/opcode.hpp" 17 #ifndef ETEQ_FUNCTOR_HPP 18 #define ETEQ_FUNCTOR_HPP 72 logs::fatalf(
"cannot update child %d to argument with " 73 "incompatible shape %s (requires shape %s)",
89 return out_->assign();
99 return out_->get_ptr();
103 const void*
data (
void)
const override 107 logs::fatal(
"cannot get data of uninitialized functor");
109 return out_->get_ptr();
115 return egen::get_type<T>();
121 return egen::name_type(egen::get_type<T>());
134 return nullptr ==
out_;
146 std::vector<OpArg<T>> datamaps;
149 auto tens = arg.get_tensor();
150 auto coorder =
static_cast<CoordMap*
>(arg.get_coorder().get());
157 egen::typed_exec<T>((egen::_GENERATED_OPCODE)
opcode_.
code_,
180 template <
typename T>
194 return (T*)
func_->data();
214 input_args.reserve(
args.size());
215 std::transform(
args.begin(),
args.end(),
216 std::back_inserter(input_args),
220 TO_NODE(arg.get_tensor()), arg.get_shaper(),
221 std::static_pointer_cast<
CoordMap>(arg.get_coorder()));
231 template <
typename T>
234 static bool registered = register_builder<Functor<T>,T>(
237 return std::make_shared<FunctorNode<T>>(
245 logs::fatalf(
"cannot perform `%s` with no arguments",
246 opcode.
name_.c_str());
250 for (
size_t i = 1, n =
nargs; i < n; ++i)
255 logs::fatalf(
"cannot perform `%s` with incompatible shapes %s " 262 input_args.reserve(
nargs);
263 std::transform(
args.begin(),
args.end(),
264 std::back_inserter(input_args),
273 return new Functor<T>(opcode, shape, input_args);
277 template <
typename T>
280 return std::make_shared<FunctorNode<T>>(
287 #endif // ETEQ_FUNCTOR_HPP std::string to_string(void) const
Return string representation of shape.
Definition: shape.hpp:148
std::string to_string(void) const override
Implementation of iTensor.
Definition: functor.hpp:49
args
Definition: csv_to_png.py:105
void update(void) override
Implementation of iOperableFunc.
Definition: functor.hpp:83
A functor node with direct access to evaluated data.
Definition: iopfunc.hpp:20
Encoding of operation.
Definition: ifunctor.hpp:18
void * data(void) override
Implementation of iData.
Definition: functor.hpp:93
NodeptrT< T > make_functor(teq::Opcode opcode, ArgsT< T > args)
Return functor node given opcode and node arguments.
Definition: functor.hpp:278
Definition: constant.hpp:17
std::vector< FuncArg > ArgsT
Type of functor arguments.
Definition: funcarg.hpp:101
T * data(void) override
Implementation of iNode<T>
Definition: functor.hpp:192
nargs
Definition: csv_to_png.py:101
teq::Shape shape_
Shape info built at construction time according to arguments.
Definition: functor.hpp:173
Shape shape(void) const
Return shape of tensor filtered through coordinate mapper.
Definition: funcarg.hpp:55
Interface node for wrapping typed tensor.
Definition: inode.hpp:23
static Functor< T > * get(teq::Opcode opcode, ArgsT< T > args)
Return Functor given opcodes mapped to Eigen operators in operator.hpp.
Definition: functor.hpp:232
Eigen node version of teq::FuncArg.
Definition: funcarg.hpp:22
const teq::Shape & shape(void) const override
Implementation of iTensor.
Definition: functor.hpp:43
bool compatible_after(const Shape &other, RankT idx) const
Definition: shape.hpp:136
size_t type_code(void) const override
Implementation of iData.
Definition: functor.hpp:113
std::string name_
String representation of operation.
Definition: ifunctor.hpp:21
Functor(teq::Opcode opcode, teq::Shape shape, teq::ArgsT args)
Definition: functor.hpp:162
std::shared_ptr< iEigen< T > > EigenptrT
Smart point of generic Eigen data object.
Definition: eigen.hpp:94
std::string type_label(void) const override
Implementation of iData.
Definition: functor.hpp:119
teq::ArgsT args_
Tensor arguments (and children)
Definition: functor.hpp:176
size_t nbytes(void) const override
Implementation of iData.
Definition: functor.hpp:125
iNode< T > * clone_impl(void) const override
Definition: functor.hpp:210
void uninitialize(void)
Removes internal Eigen data object.
Definition: functor.hpp:138
Coordinate mapper and tensor pair.
Definition: funcarg.hpp:21
const void * data(void) const override
Implementation of iData.
Definition: functor.hpp:103
bool is_uninit(void) const
Definition: functor.hpp:132
Eigen transformation wrapper implementation of iCoordMap.
Definition: coord.hpp:18
std::shared_ptr< Functor< T > > func_
Definition: functor.hpp:228
EigenptrT< T > out_
Definition: functor.hpp:167
void update_child(teq::FuncArg arg, size_t index) override
Implementation of iFunctor.
Definition: functor.hpp:67
size_t code_
Numerical encoding of operation.
Definition: ifunctor.hpp:24
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
void initialize(void)
Populate internal Eigen data object.
Definition: functor.hpp:144
Raw data, shape, and transformation argument struct.
Definition: operator.hpp:28
Functor(const Functor< T > &other)=delete
teq::Opcode opcode_
Operation encoding.
Definition: functor.hpp:170
Functor's node wrapper.
Definition: functor.hpp:181
teq::Opcode get_opcode(void) const override
Implementation of iFunctor.
Definition: functor.hpp:55
Functor implementation of operable functor of Eigen operators.
Definition: functor.hpp:25
NElemT index(Shape shape, CoordT coord)
std::shared_ptr< iNode< T > > NodeptrT
Smart pointer of node.
Definition: inode.hpp:63
void update(void) override
Implementation of iNode<T>
Definition: functor.hpp:198
teq::TensptrT get_tensor(void) const override
Implementation of iNode<T>
Definition: functor.hpp:204
Functor< T > & operator=(const Functor< T > &other)=delete
NElemT n_elems(void) const
Return the total number of elements represented by the shape.
Definition: shape.hpp:118
const teq::ArgsT & get_children(void) const override
Implementation of iFunctor.
Definition: functor.hpp:61
#define TO_NODE(tens)
Macro for converting tensor to node.
Definition: inode.hpp:106
FunctorNode(std::shared_ptr< Functor< T >> f)
Definition: functor.hpp:183
FunctorNode< T > * clone(void) const
Return deep copy of this instance (with a copied functor)
Definition: functor.hpp:186