NEML2 2.0.0
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
TensorCache Struct Reference

#include <TensorCache.h>

Public Member Functions

 TensorCache (std::function< Tensor(const TensorOptions &)> &&)
 Construct a new Tensor Cache object.
 
const Tensoroperator() (const TensorOptions &)
 Get the tensor with the given tensor options. If the tensor does not exist in the cache, it is created.
 

Constructor & Destructor Documentation

◆ TensorCache()

TensorCache ( std::function< Tensor(const TensorOptions &)> && creator)

Construct a new Tensor Cache object.

The constructor takes a lambda that creates a tensor given a set of tensor options. The lambda is invoked upon a cache miss.

Member Function Documentation

◆ operator()()

const Tensor & operator() ( const TensorOptions & opt)

Get the tensor with the given tensor options. If the tensor does not exist in the cache, it is created.