ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::exec::IPermuteFunction Class Referenceabstract

#include <IPermuteFunction.h>

Collaboration diagram for onert::exec::IPermuteFunction:

Public Member Functions

virtual void run () override
 
virtual void prepare () override
 
virtual void optimize ()=0
 
- Public Member Functions inherited from onert::exec::IFunction
virtual ~IFunction ()=default
 

Protected Member Functions

void permute (backend::ITensor *src_tensor, backend::ITensor *dst_tensor, size_t rank, std::vector< size_t > &src_offsets, std::vector< size_t > &dst_offsets, const ir::PermuteType &permute_type)
 
const std::type_info & underlying_type (ir::DataType type) const
 

Protected Attributes

std::vector< backend::ITensor * > _src_tensors
 
std::vector< backend::ITensor * > _dst_tensors
 
std::vector< std::vector< size_t > > _src_tensors_offsets
 
std::vector< std::vector< size_t > > _dst_tensors_offsets
 
std::vector< ir::PermuteType_permute_types
 
std::unordered_map< const backend::ITensor *, std::vector< uint8_t > > _buffers_map
 

Detailed Description

Definition at line 67 of file IPermuteFunction.h.

Member Function Documentation

◆ optimize()

virtual void onert::exec::IPermuteFunction::optimize ( )
pure virtual

◆ permute()

void onert::exec::IPermuteFunction::permute ( backend::ITensor src_tensor,
backend::ITensor dst_tensor,
size_t  rank,
std::vector< size_t > &  src_offsets,
std::vector< size_t > &  dst_offsets,
const ir::PermuteType permute_type 
)
protected

Definition at line 240 of file IPermuteFunction.cc.

244{
245 if (src_tensor->total_size() == 0)
246 {
247 assert(dst_tensor->total_size() == 0);
248 return;
249 }
250
251 assert(src_tensor != dst_tensor);
252 if (underlying_type(src_tensor->data_type()) != underlying_type(dst_tensor->data_type()))
253 {
254 typeAwareQuantize(src_tensor, dst_tensor, permute_type);
255 return;
256 }
257
258 switch (src_tensor->data_type())
259 {
260 case ir::DataType::FLOAT32:
261 permute<float>(src_tensor, dst_tensor, rank, src_offsets, dst_offsets, permute_type);
262 break;
263 case ir::DataType::INT32:
264 permute<int32_t>(src_tensor, dst_tensor, rank, src_offsets, dst_offsets, permute_type);
265 break;
266 case ir::DataType::UINT32:
267 permute<uint32_t>(src_tensor, dst_tensor, rank, src_offsets, dst_offsets, permute_type);
268 break;
269 case ir::DataType::BOOL8:
270 case ir::DataType::QUANT_UINT8_ASYMM:
271 case ir::DataType::UINT8:
272 permute<uint8_t>(src_tensor, dst_tensor, rank, src_offsets, dst_offsets, permute_type);
273 break;
274 case ir::DataType::QUANT_INT8_ASYMM:
275 case ir::DataType::QUANT_INT8_SYMM:
276 permute<int8_t>(src_tensor, dst_tensor, rank, src_offsets, dst_offsets, permute_type);
277 break;
278 case ir::DataType::INT64:
279 permute<int64_t>(src_tensor, dst_tensor, rank, src_offsets, dst_offsets, permute_type);
280 break;
281 case ir::DataType::QUANT_INT16_SYMM:
282 permute<int16_t>(src_tensor, dst_tensor, rank, src_offsets, dst_offsets, permute_type);
283 break;
284 default:
285 throw std::runtime_error("IPermuteFunction: Not supported data type");
286 break;
287 }
288}
const std::type_info & underlying_type(ir::DataType type) const

References onert::backend::ITensor::data_type(), onert::backend::ITensor::total_size(), and underlying_type().

Referenced by onert::backend::builtin::train::kernel::PermuteLayer::backward(), and onert::backend::builtin::kernel::PermuteLayer::run().

◆ prepare()

virtual void onert::exec::IPermuteFunction::prepare ( )
inlineoverridevirtual

Reimplemented from onert::exec::IFunction.

Definition at line 72 of file IPermuteFunction.h.

72{ optimize(); }

References optimize().

◆ run()

virtual void onert::exec::IPermuteFunction::run ( )
overridevirtual

◆ underlying_type()

const std::type_info & onert::exec::IPermuteFunction::underlying_type ( ir::DataType  type) const
protected

Definition at line 290 of file IPermuteFunction.cc.

291{
292 switch (type)
293 {
294 case ir::DataType::FLOAT32:
295 return typeid(float);
296 case ir::DataType::INT32:
297 return typeid(int32_t);
298 case ir::DataType::UINT32:
299 return typeid(uint32_t);
300 case ir::DataType::INT64:
301 return typeid(int64_t);
302 case ir::DataType::BOOL8:
303 case ir::DataType::QUANT_UINT8_ASYMM:
304 case ir::DataType::UINT8:
305 return typeid(uint8_t);
306 case ir::DataType::QUANT_INT8_ASYMM:
307 case ir::DataType::QUANT_INT8_SYMM:
308 return typeid(int8_t);
309 case ir::DataType::QUANT_INT16_SYMM:
310 return typeid(int16_t);
311 default:
312 throw std::runtime_error("IPermuteFunction: Not supported data type");
313 }
314}

Referenced by onert::backend::builtin::kernel::PermuteLayer::optimize(), permute(), and onert::backend::builtin::kernel::PermuteLayer::run().

Field Documentation

◆ _buffers_map

std::unordered_map<const backend::ITensor *, std::vector<uint8_t> > onert::exec::IPermuteFunction::_buffers_map
protected

◆ _dst_tensors

◆ _dst_tensors_offsets

◆ _permute_types

◆ _src_tensors

◆ _src_tensors_offsets


The documentation for this class was generated from the following files: