ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Tensor.cpp File Reference
#include "Tensor.h"
#include <luci/IR/CircleNodeDecl.h>
#include <cassert>

Go to the source code of this file.

Namespaces

namespace  circle_eval_diff
 

Macros

#define THROW_UNLESS(COND, MSG)
 
#define INSTANTIATE(DT)
 

Functions

 circle_eval_diff::INSTANTIATE (loco::DataType::S64)
 
 circle_eval_diff::INSTANTIATE (loco::DataType::S32)
 
 circle_eval_diff::INSTANTIATE (loco::DataType::S16)
 
 circle_eval_diff::INSTANTIATE (loco::DataType::U8)
 
 circle_eval_diff::INSTANTIATE (loco::DataType::FLOAT32)
 
std::shared_ptr< Tensorcircle_eval_diff::createEmptyTensor (const luci::CircleNode *node)
 

Macro Definition Documentation

◆ INSTANTIATE

#define INSTANTIATE (   DT)
Value:
template uint32_t Tensor::size<DT>(void) const; \
template void Tensor::size<DT>(uint32_t); \
template const typename loco::DataTypeImpl<DT>::Type &Tensor::at<DT>(uint32_t) const; \
template typename loco::DataTypeImpl<DT>::Type &Tensor::at<DT>(uint32_t);
C++ scalar type corresponding to each DataType.

Definition at line 74 of file Tensor.cpp.

90{
91 auto tensor = std::make_shared<Tensor>();
92 {
93 tensor->dtype(node->dtype());
94 tensor->rank(node->rank());
95 for (uint32_t i = 0; i < node->rank(); i++)
96 tensor->dim(i) = node->dim(i);
97
98 switch (node->dtype())
99 {
100 case loco::DataType::FLOAT32:
101 tensor->size<loco::DataType::FLOAT32>(numElements(node));
102 break;
103 case loco::DataType::U8:
104 tensor->size<loco::DataType::U8>(numElements(node));
105 break;
106 case loco::DataType::S16:
107 tensor->size<loco::DataType::S16>(numElements(node));
108 break;
109 case loco::DataType::S32:
110 tensor->size<loco::DataType::S32>(numElements(node));
111 break;
112 case loco::DataType::S64:
113 tensor->size<loco::DataType::S64>(numElements(node));
114 break;
115 default:
116 throw std::runtime_error("Unsupported input tensor dtype for " + node->name());
117 }
118 }
119
120 return tensor;
121}
122
123} // namespace circle_eval_diff
uint32_t numElements(const luci::CircleNode *node)
Definition Utils.cpp:41

◆ THROW_UNLESS

#define THROW_UNLESS (   COND,
  MSG 
)
Value:
if (not(COND)) \
throw std::runtime_error(MSG);

Definition at line 40 of file Tensor.cpp.