ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
nnsuite::conv::RandomModel Class Referencefinal

#include <RandomModel.h>

Collaboration diagram for nnsuite::conv::RandomModel:

Public Member Functions

 RandomModel (int32_t seed)
 
const nncc::core::ADT::feature::Shapeifm_shape (void) const override
 
const std::string & ifm_name (void) const override
 
const nncc::core::ADT::feature::Shapeofm_shape (void) const override
 
const std::string & ofm_name (void) const override
 
const nncc::core::ADT::kernel::Shapeker_shape (void) const override
 
const nncc::core::ADT::kernel::Reader< float > & ker_data (void) const override
 
- Public Member Functions inherited from nnsuite::conv::Model
virtual ~Model ()=default
 

Detailed Description

Definition at line 31 of file RandomModel.h.

Constructor & Destructor Documentation

◆ RandomModel()

nnsuite::conv::RandomModel::RandomModel ( int32_t  seed)
explicit

Definition at line 30 of file RandomModel.cpp.

31 : _ifm_shape{1, 8, 8}, _ifm_name{"ifm"}, _ofm_name{"ofm"}, _ofm_shape{2, 6, 6},
32 _ker_buffer{kernel::Shape{2, 1, 3, 3}, kernel::NCHWLayout{}}
33{
34 std::default_random_engine gen{static_cast<uint32_t>(seed)};
35 std::normal_distribution<float> dist{0.0f, 1.0f};
36
37 const uint32_t N = _ker_buffer.shape().count();
38 const uint32_t C = _ker_buffer.shape().depth();
39 const uint32_t H = _ker_buffer.shape().height();
40 const uint32_t W = _ker_buffer.shape().width();
41
42 for (uint32_t n = 0; n < N; ++n)
43 {
44 for (uint32_t ch = 0; ch < C; ++ch)
45 {
46 for (uint32_t row = 0; row < H; ++row)
47 {
48 for (uint32_t col = 0; col < W; ++col)
49 {
50 _ker_buffer.at(n, ch, row, col) = dist(gen);
51 }
52 }
53 }
54 }
55}
T at(uint32_t nth, uint32_t ch, uint32_t row, uint32_t col) const override
Definition Buffer.h:43
const Shape & shape(void) const override
Definition Buffer.h:55
uint32_t width(void) const
Definition Shape.h:47
uint32_t height(void) const
Definition Shape.h:46
uint32_t count(void) const
Definition Shape.h:44
uint32_t depth(void) const
Definition Shape.h:45
C
Definition infer.py:52

References nncc::core::ADT::kernel::Buffer< T >::at(), nncc::core::ADT::kernel::Shape::count(), nncc::core::ADT::kernel::Shape::depth(), nncc::core::ADT::kernel::Shape::height(), nncc::core::ADT::kernel::Buffer< T >::shape(), and nncc::core::ADT::kernel::Shape::width().

Member Function Documentation

◆ ifm_name()

const std::string & nnsuite::conv::RandomModel::ifm_name ( void  ) const
inlineoverridevirtual

Implements nnsuite::conv::Model.

Definition at line 38 of file RandomModel.h.

38{ return _ifm_name; }

◆ ifm_shape()

const nncc::core::ADT::feature::Shape & nnsuite::conv::RandomModel::ifm_shape ( void  ) const
inlineoverridevirtual

Implements nnsuite::conv::Model.

Definition at line 37 of file RandomModel.h.

37{ return _ifm_shape; }

◆ ker_data()

const nncc::core::ADT::kernel::Reader< float > & nnsuite::conv::RandomModel::ker_data ( void  ) const
inlineoverridevirtual

Implements nnsuite::conv::Model.

Definition at line 50 of file RandomModel.h.

51 {
52 return _ker_buffer;
53 }

◆ ker_shape()

const nncc::core::ADT::kernel::Shape & nnsuite::conv::RandomModel::ker_shape ( void  ) const
inlineoverridevirtual

Implements nnsuite::conv::Model.

Definition at line 45 of file RandomModel.h.

46 {
47 return _ker_buffer.shape();
48 }

References nncc::core::ADT::kernel::Buffer< T >::shape().

◆ ofm_name()

const std::string & nnsuite::conv::RandomModel::ofm_name ( void  ) const
inlineoverridevirtual

Implements nnsuite::conv::Model.

Definition at line 42 of file RandomModel.h.

42{ return _ofm_name; }

◆ ofm_shape()

const nncc::core::ADT::feature::Shape & nnsuite::conv::RandomModel::ofm_shape ( void  ) const
inlineoverridevirtual

Implements nnsuite::conv::Model.

Definition at line 41 of file RandomModel.h.

41{ return _ofm_shape; }

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