ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::backend::cpu::ExternalContext Class Reference

#include <ExternalContext.h>

Public Member Functions

 ExternalContext ()
 
void setMaxNumThreads (int max_num_threads)
 
int32_t maxNumThreads () const
 
void initGgmlContext ()
 
ruy::Context * ruy_context () const
 

Detailed Description

Definition at line 33 of file ExternalContext.h.

Constructor & Destructor Documentation

◆ ExternalContext()

onert::backend::cpu::ExternalContext::ExternalContext ( )

Definition at line 66 of file ExternalContext.cc.

66 : _ruy_context(new ruy::Context)
67{
68 setMaxNumThreads(onert::util::getConfigInt(onert::util::config::NUM_THREADS));
69}
void setMaxNumThreads(int max_num_threads)
int getConfigInt(const std::string &key)

References onert::util::getConfigInt(), and setMaxNumThreads().

Member Function Documentation

◆ initGgmlContext()

void onert::backend::cpu::ExternalContext::initGgmlContext ( )

Definition at line 77 of file ExternalContext.cc.

78{
79 if (_ggml_context == nullptr)
80 _ggml_context = std::unique_ptr<ggml_context, decltype(&ggml_free)>(
81 ggml_init({.mem_size = 0, .mem_buffer = nullptr, .no_alloc = true}), &ggml_free);
82}

Referenced by onert::backend::cpu::ops::GatherLayer::configure().

◆ maxNumThreads()

int32_t onert::backend::cpu::ExternalContext::maxNumThreads ( ) const
inline

Definition at line 41 of file ExternalContext.h.

41{ return _max_num_threads; }

◆ ruy_context()

ruy::Context * onert::backend::cpu::ExternalContext::ruy_context ( ) const
inline

Definition at line 45 of file ExternalContext.h.

45{ return _ruy_context.get(); }

◆ setMaxNumThreads()

void onert::backend::cpu::ExternalContext::setMaxNumThreads ( int  max_num_threads)

Definition at line 71 of file ExternalContext.cc.

72{
73 _max_num_threads = max_num_threads > -1 ? max_num_threads : countPhysicalCores();
74 _ruy_context->set_max_num_threads(_max_num_threads);
75}

Referenced by ExternalContext().


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