17#ifndef __LOCO_IR_NODES_H__
18#define __LOCO_IR_NODES_H__
58 Node *
from(
void)
const {
return at(0)->node(); }
79 bool indexed(
void)
const {
return _index != -1; }
85void link(GraphOutput *, Push *push);
95 With<NodeTrait::TensorShape>::Mixin>
118 bool indexed(
void)
const {
return _index != -1; }
132 DataType _dtype = DataType::Unknown;
135void link(GraphInput *, Pull *pull);
217 With<NodeTrait::DataType>::Mixin, With<NodeTrait::TensorShape>::Mixin>
227 template <DataType DT> uint32_t
size(
void)
const;
232 template <DataType DT>
void size(uint32_t
size);
248 std::vector<uint8_t> _data;
307 Node *
ifm(
void)
const {
return at(0)->node(); }
349 Node *
ifm(
void)
const {
return at(0)->node(); }
379 :
public CanonicalNodeDef<CanonicalOpcode::FeatureEncode, FixedArity<1>::Mixin>
387 void encoder(std::unique_ptr<FeatureEncoder> &&enc) { _enc = std::move(enc); }
391 std::unique_ptr<FeatureEncoder> _enc{
nullptr};
398 :
public CanonicalNodeDef<CanonicalOpcode::FeatureDecode, FixedArity<1>::Mixin>
406 void decoder(std::unique_ptr<FeatureDecoder> &&dec) { _dec = std::move(dec); }
410 std::unique_ptr<FeatureDecoder> _dec{
nullptr};
417 :
public CanonicalNodeDef<CanonicalOpcode::FilterEncode, FixedArity<1>::Mixin>
425 void encoder(std::unique_ptr<FilterEncoder> &&enc) { _enc = std::move(enc); }
429 std::unique_ptr<FilterEncoder> _enc{
nullptr};
436 :
public CanonicalNodeDef<CanonicalOpcode::FilterDecode, FixedArity<1>::Mixin>
444 void decoder(std::unique_ptr<FilterDecoder> &&dec) { _dec = std::move(dec); }
448 std::unique_ptr<FilterDecoder> _dec{
nullptr};
455 :
public CanonicalNodeDef<CanonicalOpcode::DepthwiseFilterEncode, FixedArity<1>::Mixin>
463 void encoder(std::unique_ptr<DepthwiseFilterEncoder> &&enc) { _enc = std::move(enc); }
467 std::unique_ptr<DepthwiseFilterEncoder> _enc{
nullptr};
474 :
public CanonicalNodeDef<CanonicalOpcode::DepthwiseFilterDecode, FixedArity<1>::Mixin>
482 void decoder(std::unique_ptr<DepthwiseFilterDecoder> &&dec) { _dec = std::move(dec); }
486 std::unique_ptr<DepthwiseFilterDecoder> _dec{
nullptr};
515 :
public CanonicalNodeDef<CanonicalOpcode::FixedReshape, FixedArity<1>::Mixin,
516 With<NodeTrait::TensorShape>::Mixin>
532 :
public CanonicalNodeDef<CanonicalOpcode::TensorConcat, FixedArity<2>::Mixin>
535 Node *
lhs(
void)
const {
return at(0)->node(); }
538 Node *
rhs(
void)
const {
return at(1)->node(); }
542 uint32_t
axis(
void)
const {
return _axis; }
543 void axis(uint32_t val) { _axis = val; }
556 Node *
ifm(
void)
const {
return at(0)->node(); }
559 Node *
ker(
void)
const {
return at(1)->node(); }
581 :
public CanonicalNodeDef<CanonicalOpcode::DepthwiseConv2D, FixedArity<2>::Mixin>
584 Node *
ifm(
void)
const {
return at(0)->node(); }
587 Node *
ker(
void)
const {
return at(1)->node(); }
619 :
public CanonicalNodeDef<CanonicalOpcode::TensorReduce, FixedArity<1>::Mixin>
687 :
public CanonicalNodeDef<CanonicalOpcode::TransposedConv2D, FixedArity<2>::Mixin>
690 Node *
ifm(
void)
const {
return at(0)->node(); }
693 Node *
ker(
void)
const {
return at(1)->node(); }
721 :
public CanonicalNodeDef<CanonicalOpcode::TensorSoftmax, FixedArity<1>::Mixin>
730 uint32_t
axis(
void)
const {
return _axis; }
780 :
public CanonicalNodeDef<CanonicalOpcode::TensorBiasAdd, FixedArity<2>::Mixin>
790 void bias(
Node *node) {
return at(1)->node(node); }
792 uint32_t
axis(
void)
const {
return _axis; }
816 :
public CanonicalNodeDef<CanonicalOpcode::FeatureBiasAdd, FixedArity<2>::Mixin>
826 void bias(
Node *node) {
return at(1)->node(node); }
851 :
public CanonicalNodeDef<CanonicalOpcode::TensorConstantPad, FixedArity<2>::Mixin>
877 Node *
lhs(
void)
const {
return at(0)->node(); }
878 void lhs(
Node *node) {
return at(0)->node(node); }
880 Node *
rhs(
void)
const {
return at(1)->node(); }
881 void rhs(
Node *node) {
return at(1)->node(node); }
895 Node *
lhs(
void)
const {
return at(0)->node(); }
896 void lhs(
Node *node) {
return at(0)->node(node); }
898 Node *
rhs(
void)
const {
return at(1)->node(); }
899 void rhs(
Node *node) {
return at(1)->node(node); }
911 Node *
lhs(
void)
const {
return at(0)->node(); }
912 void lhs(
Node *node) {
return at(0)->node(node); }
914 Node *
rhs(
void)
const {
return at(1)->node(); }
915 void rhs(
Node *node) {
return at(1)->node(node); }
927 Node *
lhs(
void)
const {
return at(0)->node(); }
928 void lhs(
Node *node) {
return at(0)->node(node); }
930 Node *
rhs(
void)
const {
return at(1)->node(); }
931 void rhs(
Node *node) {
return at(1)->node(node); }
943 Node *
lhs(
void)
const {
return at(0)->node(); }
944 void lhs(
Node *node) {
return at(0)->node(node); }
946 Node *
rhs(
void)
const {
return at(1)->node(); }
947 void rhs(
Node *node) {
return at(1)->node(node); }
954 :
public CanonicalNodeDef<CanonicalOpcode::EltwiseSqrt, FixedArity<1>::Mixin>
979 :
public CanonicalNodeDef<CanonicalOpcode::TensorBroadcast, FixedArity<1>::Mixin>
1001 std::map<TensorAxis, Dimension> _content;
1017 :
public CanonicalNodeDef<CanonicalOpcode::MatrixEncode, FixedArity<1>::Mixin>
1028 void encoder(std::unique_ptr<MatrixEncoder> &&enc) { _enc = std::move(enc); }
1032 std::unique_ptr<MatrixEncoder> _enc{
nullptr};
1041 :
public CanonicalNodeDef<CanonicalOpcode::MatrixDecode, FixedArity<1>::Mixin>
1052 void decoder(std::unique_ptr<MatrixDecoder> &&dec) { _dec = std::move(dec); }
1056 std::unique_ptr<MatrixDecoder> _dec{
nullptr};
1071 void lhs(
Node *node) {
return at(0)->node(node); }
1074 void rhs(
Node *node) {
return at(1)->node(node); }
1089 :
public CanonicalNodeDef<CanonicalOpcode::TensorTranspose, FixedArity<1>::Mixin>
1104 uint32_t
size()
const {
return _vals.size(); }
1111 std::vector<TensorAxis> _vals;
Convention convention(void) const
const Stride< 2 > * stride(void) const
const Padding2D * pad(void) const
const Window< 2 > * window(void) const
Window< 2 > * window(void)
Stride< 2 > * stride(void)
void convention(const Convention &convention)
Add Feature and Bias along "depth" axis.
uint32_t axis(void) const
Produce a value of domain D from an input value (of domain D) and a bias.
Create a "Tensor" from a "Bias".
Create a "Bias" from a "Tensor".
Create a value from constant byte array.
uint32_t size(void) const
Return the number of reserved elements.
const DataTypeImpl< DT >::Type & at(uint32_t n) const
Get the element at a given position @require at(n) is valid only when n < size()
const Stride< 2 > * stride(void) const
const Padding2D * pad(void) const
Stride< 2 > * stride(void)
Depthwise 2D Convolution.
const Stride< 2 > * stride(void) const
const Padding2D * pad(void) const
Stride< 2 > * stride(void)
Create a tensor from a depthwise filter.
DepthwiseFilterDecoder * decoder(void) const
void decoder(std::unique_ptr< DepthwiseFilterDecoder > &&dec)
Create a depthwise filter from a tensor.
DepthwiseFilterEncoder * encoder(void) const
void encoder(std::unique_ptr< DepthwiseFilterEncoder > &&enc)
The value of one dimension in a tensor shape.
Elementwise Add lhs and rhs.
Elementwise Div lhs and rhs.
Elementwise Maximum of lhs and rhs.
Elementwise Mul lhs and rhs.
Elementwise Sqrt of input.
Elementwise Sub lhs and rhs.
Create a tensor from a feature map.
void decoder(std::unique_ptr< FeatureDecoder > &&dec)
FeatureDecoder * decoder(void) const
Create a feature map from a tensor.
void encoder(std::unique_ptr< FeatureEncoder > &&enc)
FeatureEncoder * encoder(void) const
Create a tensor from a filter.
void decoder(std::unique_ptr< FilterDecoder > &&dec)
FilterDecoder * decoder(void) const
Create a filter from a tensor.
FilterEncoder * encoder(void) const
void encoder(std::unique_ptr< FilterEncoder > &&enc)
Create a new value identical to its input.
Matrix Multiplication lhs and rhs.
Create Tensor from Matrix.
MatrixDecoder * decoder(void) const
void decoder(std::unique_ptr< MatrixDecoder > &&dec)
Create Matrix from Tensor.
MatrixEncoder * encoder(void) const
void encoder(std::unique_ptr< MatrixEncoder > &&enc)
Window< 2 > * window(void)
const Padding2D * pad(void) const
const Stride< 2 > * stride(void) const
Stride< 2 > * stride(void)
const Window< 2 > * window(void) const
Logical unit of computation.
Create a value from user data.
GraphInputIndex index(void) const
Get associated input index.
DataType dtype(void) const
bool indexed(void) const
Check whether index is initialized.
Make a value visible to user.
GraphOutputIndex index(void) const
Get associated output index.
bool indexed(void) const
Check whether index is initialized.
Create a new value that rectifies its input capping the units at 6.
Create a new value that rectifies its input.
Reshape a tensor to another tensor whose shape is known at compile time.
Computes softmax activations for Tensor domain.
uint32_t axis(void) const
Computes softmax activations.
Stride configuration for N-dimensional spatial operations.
Create a new value that rectifies its input by tanh.
const Dimension & dim(const TensorAxis &axis) const
bool defined(const TensorAxis &axis) const
Duplicate elements along specified axes.
TensorBroadcast()=default
const Mapping * mapping(void) const
uint32_t axis(void) const
Pads a tensor with constant value.
Node * constant(void) const
const PaddingND * padding(void) const
PaddingND * padding(void)
void constant(Node *node)
Computes ReduceFunc operations for Tensor domain.
TensorAxisSet * axes(void)
ReduceFunc func(void) const
const TensorAxisSet * axes(void) const
void func(ReduceFunc func)
const TensorAxis & axis(TensorAxis n) const
TensorAxis & axis(TensorAxis n)
const Perm * perm(void) const
TensorTranspose()=default
2D Transposed Convolution
Stride< 2 > * stride(void)
const Stride< 2 > * stride(void) const
const Padding2D * pad(void) const
ND Receptive Field Shape.
void link(GraphOutput *, Push *push)
uint32_t GraphOutputIndex
ReduceFunc
Reduce type functions.
Pull * pull_node(Graph *g, const GraphInputIndex &index)
Find a Pull node with a given input index.
DataType
"scalar" value type
Domain
Describe the kind of (N-dimensional) loco values.
Push * push_node(Graph *g, const GraphOutputIndex &index)
Find a Push node with a given output index.
C++ scalar type corresponding to each DataType.
Describe how to build a tensor from a depthwise convolution filter.
Describe how to build a depthwise convolution filter from a tensor.
Describe how to build a tensor from a (convolution) feature map.
Decribe how to build a (convolution) feature map from a tensor.
Decribe how to build a a tensor from a filter.
Decribe how to build a (convolution) filter from a tensor.
Describe how to build a tensor from a matrix.
Decribe how to build a matrix from a tensor.