io-chess
UCI chess engine
Loading...
Searching...
No Matches
Evaluator Class Reference

Model manager that shares native weights across threads. More...

#include <Evaluator.h>

Public Member Functions

 Evaluator (const std::string &modelPath, int numThreads, bool useGPU=false)
 Constructs an Evaluator manager.
std::unique_ptr< IEvaluatorcreateThreadContext ()
 Creates a lightweight thread context from the shared model.
bool isLoaded () const
bool isMoE () const
bool isMoECache () const

Private Attributes

std::string modelPath_
std::string nativeWeightsPath_
int numThreads_
bool isMoECache_
bool useGPU_
std::shared_ptr< const EvalContextMoECacheSharedModelsharedMoECacheModel_
 Shared native model used by all thread contexts.

Detailed Description

Model manager that shares native weights across threads.

It is responsible for loading the neural network architecture (or falling back to simple evaluation) and instantiating thread-local IEvaluator contexts that share the read-only weights to save memory.

Constructor & Destructor Documentation

◆ Evaluator()

Evaluator::Evaluator ( const std::string & modelPath,
int numThreads,
bool useGPU = false )

Constructs an Evaluator manager.

Parameters
modelPathPath to the network weights file.
numThreadsNumber of threads that will request contexts.
useGPUWhether to accelerate evaluation using the GPU (if supported).
Here is the call graph for this function:

Member Function Documentation

◆ createThreadContext()

std::unique_ptr< IEvaluator > Evaluator::createThreadContext ( )

Creates a lightweight thread context from the shared model.

Returns
A unique pointer to an IEvaluator instance for a specific thread.
Here is the caller graph for this function:

◆ isLoaded()

bool Evaluator::isLoaded ( ) const
inline
Here is the caller graph for this function:

◆ isMoE()

bool Evaluator::isMoE ( ) const
inline

◆ isMoECache()

bool Evaluator::isMoECache ( ) const
inline

Member Data Documentation

◆ isMoECache_

bool Evaluator::isMoECache_
private

◆ modelPath_

std::string Evaluator::modelPath_
private

◆ nativeWeightsPath_

std::string Evaluator::nativeWeightsPath_
private

◆ numThreads_

int Evaluator::numThreads_
private

◆ sharedMoECacheModel_

std::shared_ptr<const EvalContextMoECacheSharedModel> Evaluator::sharedMoECacheModel_
private

Shared native model used by all thread contexts.

◆ useGPU_

bool Evaluator::useGPU_
private

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