17#ifndef __LOCO_IR_NODE_MIXINS_H__
18#define __LOCO_IR_NODE_MIXINS_H__
25#include <initializer_list>
64 uint32_t
rank(
void)
const {
return _dims.size(); }
65 void rank(uint32_t value) { _dims.resize(value); }
67 const Dimension &
dim(uint32_t axis)
const {
return _dims.at(axis); }
70 void shape(std::initializer_list<uint32_t> dims)
83 std::vector<Dimension> _dims;
88 template <
typename Base>
class Mixin :
public virtual Base
93 for (uint32_t n = 0; n < N; ++n)
95 _args[n] = std::unique_ptr<Use>{
new Use{
this}};
102 uint32_t
arity(
void)
const final {
return N; }
104 Node *
arg(uint32_t n)
const final {
return _args.at(n)->node(); }
108 for (uint32_t n = 0; n < N; ++n)
110 _args.at(n)->node(
nullptr);
116 Use *
at(uint32_t n)
const {
return _args.at(n).get(); }
119 std::array<std::unique_ptr<Use>, N> _args{};
123template <NodeTrait Trait>
struct With
125 template <
typename Base>
struct Mixin :
public virtual Base,
public NodeMixin<Trait>
The value of one dimension in a tensor shape.
Use * at(uint32_t n) const
uint32_t arity(void) const final
Node * arg(uint32_t n) const final
Logical unit of computation.
const DataType & dtype(void) const
void dtype(const DataType &dtype)
void rank(uint32_t value)
const Dimension & dim(uint32_t axis) const
void shape(std::initializer_list< uint32_t > dims)
uint32_t rank(void) const
Dimension & dim(uint32_t axis)
The edge between a node definition and its user.
DataType
"scalar" value type