17#ifndef __ONERT_IR_OPERAND_H__
18#define __ONERT_IR_OPERAND_H__
26#include "ir/DataType.h"
66 _data = std::move(
data);
69 const Data *
data(
void)
const {
return _data.get(); }
73 std::shared_ptr<Data>
shareData(
void)
const {
return _data; }
82 template <
typename T,
typename... Args>
void data(Args &&...args)
84 data(std::make_unique<T>(std::forward<Args>(args)...));
90 assert((
shape().rank() == 0) || ((
shape().rank() == 1) && (
shape().dim(0) == 1)));
91 assert(_data !=
nullptr);
92 assert((_data->base() !=
nullptr) && (_data->size() ==
sizeof(T)));
94 return *(
reinterpret_cast<const T *
>(_data->base()));
97 template <
typename T> std::vector<T>
asVector()
const
99 assert(_data !=
nullptr);
100 assert(_data->size() %
sizeof(T) == 0);
102 const auto *base =
reinterpret_cast<const T *
>(_data->base());
103 const std::size_t
size = _data->size() /
sizeof(T);
104 return std::vector<T>(base, base +
size);
112 std::shared_ptr<Data> _data;
This file contains OperandInfo class.
const OperationIndexSet & getUses() const
const OperandInfo & info(void) const
OriginIndex originIndex() const
OperationIndex getDef() const
const TypeInfo & typeInfo(void) const
void data(Args &&...args)
Operand(const Operand &)=default
const Data * data(void) const
const Shape & shape(void) const
void data(std::shared_ptr< Data > &&data)
void setDef(const OperationIndex &idx)
std::vector< T > asVector() const
void insertUse(const OperationIndex &idx)
Operand(const Shape &shape, const TypeInfo &type)
void setOriginIndex(OriginIndex origin)
size_t operandSize(void) const
void removeUse(const OperationIndex &idx)
bool isConstant(void) const
Get true if Operand is const, otherwise false a.
void type(const DataType type)
std::shared_ptr< Data > shareData(void) const
Class to save tensor's shape and type.
void setOriginIndex(OriginIndex origin)
const TypeInfo & typeInfo() const
Return tensor data type info.
void type(const DataType type)
Set tensor data type.
const Shape & shape() const
Return tensor shape.
OriginIndex originIndex() const
MemAllocType
enum class indicating when the memory for a tensor is allocated
@ STATIC
At compile time, shape for a tensor is known, thus requried memory capacity can be calculated.