Loading...
Searching...
No Matches
pot::NestedEngineOracle Class Reference

#include <gpr/potentials/NestedEngineOracle.h>

Public Member Functions

 ~NestedEngineOracle ()
 NestedEngineOracle (const NestedEngineOracle &)=delete
NestedEngineOracle & operator= (const NestedEngineOracle &)=delete
ActiveGP::OracleFn asOracle ()
 Ground truth in the shape ActiveGP consumes.
const std::string & library () const noexcept

Static Public Member Functions

static std::unique_ptr< NestedEngineOracle > open (const std::string &library, const std::vector< unsigned char > &config, std::string &err)

Detailed Description

An oracle built by hosting another engine plugin.

The learning engine's config names its ground truth as a nested PotentialSpec rather than receiving it through callbacks, because the host that loads a learning engine may have no way to supply one: eOn's GenericEngineLoader resolves create, destroy and force, and never calls set_callbacks. An engine that waits for a callback is loadable there and unusable.

So this does to its oracle exactly what a host does to it. Backend selection stays "which library gets dlopened", one level down: the spec names a backend, that names a library, and the nested params travel to it as its own capnp message over the same C ABI.

Definition at line 31 of file NestedEngineOracle.h.

Constructor & Destructor Documentation

◆ ~NestedEngineOracle()

pot::NestedEngineOracle::~NestedEngineOracle ( )
default

◆ NestedEngineOracle()

pot::NestedEngineOracle::NestedEngineOracle ( const NestedEngineOracle & )
delete

Member Function Documentation

◆ asOracle()

ActiveGP::OracleFn pot::NestedEngineOracle::asOracle ( )
nodiscard

Ground truth in the shape ActiveGP consumes.

Definition at line 40 of file NestedEngineOracle.cpp.

41{
42 EnginePotential* engine = engine_.get();
43 return
44 [engine](long n_atoms, const double* positions, const int* atomic_nrs,
45 const double* box, double* energy, double* forces) -> int {
46 // Variance is not requested: the surrogate reports its own, and an
47 // oracle's uncertainty is not what the gate is measured in.
48 return engine->force(n_atoms, positions, atomic_nrs, box, forces,
49 energy, nullptr);
50 };
51}

◆ library()

const std::string & pot::NestedEngineOracle::library ( ) const
nodiscardnoexcept

Definition at line 35 of file NestedEngineOracle.cpp.

36{
37 return engine_->library();
38}

◆ open()

std::unique_ptr< NestedEngineOracle > pot::NestedEngineOracle::open ( const std::string & library,
const std::vector< unsigned char > & config,
std::string & err )
static
Parameters
libraryengine library to dlopen, e.g. "libuma_engine.so".
configcapnp message for THAT engine's params arm.
errfailure detail when construction returns nullptr.

Definition at line 22 of file NestedEngineOracle.cpp.

25{
26 auto engine = EnginePotential::open(library, config, err);
27 if (!engine) return nullptr;
28 std::unique_ptr<NestedEngineOracle> self(new NestedEngineOracle());
29 self->engine_ = std::move(engine);
30 return self;
31}
static std::unique_ptr< EnginePotential > open(const std::string &library, const std::vector< unsigned char > &config, std::string &err, bool torch_cuda=false, int oracle_threads=1)
const std::string & library() const noexcept
NestedEngineOracle(const NestedEngineOracle &)=delete

◆ operator=()

NestedEngineOracle & pot::NestedEngineOracle::operator= ( const NestedEngineOracle & )
delete

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