12 #include "ade/coord.hpp" 13 #include "ade/ileaf.hpp" 15 #include "llo/generated/codes.hpp" 28 GenericData (ade::Shape shape, age::_GENERATED_DTYPE dtype);
32 void copyover (
const char* indata, age::_GENERATED_DTYPE intype);
48 GenericRef (
char* data, ade::Shape shape, age::_GENERATED_DTYPE dtype) :
69 ade::Shape
shape, std::string label) :
106 label_ = std::move(other.label_);
107 data_ = std::move(other.data_);
113 template <
typename T>
123 if (
false ==
data.shape_.compatible_after(
shape(), 0))
125 logs::fatalf(
"cannot assign data of incompatible shaped %s to " 126 "internal data of shape %s",
data.shape_.to_string().c_str(),
127 shape().to_string().c_str());
131 logs::fatalf(
"cannot assign data of incompatible types %s " 132 "(external) and %s (internal)",
133 age::name_type(
data.dtype_).c_str(), age::name_type(
data_.
dtype_).c_str());
140 const ade::Shape&
shape (
void)
const override 158 const void*
data (
void)
const override 184 using VarptrT = std::shared_ptr<llo::Variable>;
189 template <
typename T>
191 std::string label =
"")
193 if (data.size() != shape.n_elems())
195 logs::fatalf(
"cannot create variable with data size %d " 196 "against shape %s", data.size(), shape.to_string().c_str());
199 age::get_type<T>(), shape, label));
204 template <
typename T>
207 return get_variable(std::vector<T>(shape.n_elems(), 0), shape, label);
212 template <
typename T>
217 label = fmts::to_string(scalar);
245 template <
typename T>
263 template <
typename T>
267 (
const T*) arg.
data_.get(),
275 template <
typename T>
278 std::vector<VecRef<T>> out;
279 std::transform(args.begin(), args.end(), std::back_inserter(out),
282 return to_ref<T>(arg);
289 #endif // LLO_DATA_HPP
size_t nbytes(void) const
Return number of bytes in data source.
Definition: data.hpp:170
ade::CoordptrT mapper_
Coordinate mapper.
Definition: data.hpp:233
const void * data(void) const override
Implementation of iLeaf.
Definition: data.hpp:158
Variable(const char *data, age::_GENERATED_DTYPE dtype, ade::Shape shape, std::string label)
Definition: data.hpp:68
const T * data
Raw input data.
Definition: data.hpp:249
Leaf node containing GenericData.
Definition: data.hpp:66
GenericRef(GenericData &generic)
Definition: data.hpp:51
std::vector< DataArg > DataArgsT
Vector of DataArgs to hold arguments.
Definition: data.hpp:241
Variable & operator=(const Variable &other)
Definition: data.hpp:91
VecRef< T > to_ref(DataArg &arg)
Converts DataArgs to VecRef of specific type.
Definition: data.hpp:264
VarptrT get_scalar(T scalar, ade::Shape shape, std::string label="")
Definition: data.hpp:213
std::vector< VecRef< T > > to_refs(DataArgsT &args)
Converts multiple DataArgs to multiple VecRefs of the same type.
Definition: data.hpp:276
void copyover(const char *indata, age::_GENERATED_DTYPE intype)
std::string label_
Label for distinguishing variable nodes.
Definition: data.hpp:176
Data to pass around when evaluating.
Definition: data.hpp:224
ade::Shape shape_
Shape of data_.
Definition: data.hpp:38
size_t type_code(void) const override
Implementation of iLeaf.
Definition: data.hpp:164
ade::Shape shape_
Shape of the generic data.
Definition: data.hpp:230
bool fwd_
Definition: data.hpp:237
std::string to_string(void) const override
Implementation of iTensor.
Definition: data.hpp:146
GenericRef(char *data, ade::Shape shape, age::_GENERATED_DTYPE dtype)
Definition: data.hpp:48
Variable(const Variable &other)
Definition: data.hpp:82
std::shared_ptr< llo::Variable > VarptrT
Smart pointer for variable nodes.
Definition: data.hpp:184
GenericData for holding data when passing up the tensor graph.
Definition: data.hpp:24
age::_GENERATED_DTYPE dtype_
Type encoding of data_.
Definition: data.hpp:41
Variable(Variable &&other)
Definition: data.hpp:88
ade::Shape shape_
Shape of data_.
Definition: data.hpp:59
const ade::Shape & shape(void) const override
Implementation of iTensor.
Definition: data.hpp:140
std::shared_ptr< char > data_
Smart pointer to generic data as bytes.
Definition: data.hpp:227
VarptrT get_variable(std::vector< T > data, ade::Shape shape, std::string label="")
Definition: data.hpp:190
age::_GENERATED_DTYPE dtype_
Data type of data_.
Definition: data.hpp:62
std::shared_ptr< char > data_
Smartpointer to a block of untyped data.
Definition: data.hpp:35
bool push
Definition: data.hpp:259
ade::Shape shape
Shape info of the raw input.
Definition: data.hpp:252
GenericData data_
Generic data source.
Definition: data.hpp:180
GenericData(void)=default
void * data(void) override
Implementation of iLeaf.
Definition: data.hpp:152
ade::CoordptrT mapper
Coordinate mapper of input to output.
Definition: data.hpp:255
char * data_
Raw pointer to a block of untyped data.
Definition: data.hpp:56