deepmd.backend.backend#

Classes#

Backend

General backend class.

Module Contents#

class deepmd.backend.backend.Backend[source]#

Bases: deepmd.utils.plugin.PluginVariant, make_plugin_registry('backend')

General backend class.

Examples

>>> @Backend.register("tf")
>>> @Backend.register("tensorflow")
>>> class TensorFlowBackend(Backend):
...     pass
static get_backend(key: str) type[Backend][source]#

Get the backend by key.

Parameters:
keystr

the key of a backend

Returns:
Backend

the backend

static get_backends() dict[str, type[Backend]][source]#

Get all the registered backend names.

Returns:
list

all the registered backends

static get_backends_by_feature(feature: Backend) dict[str, type[Backend]][source]#

Get all the registered backend names with a specific feature.

Parameters:
featureBackend.Feature

the feature flag

Returns:
list

all the registered backends with the feature

static detect_backend_by_model(filename: str) type[Backend][source]#

Detect the backend of the given model file.

Parameters:
filenamestr

The model file name

class Feature(*args, **kwds)[source]#

Bases: enum.Flag

Feature flag to indicate whether the backend supports certain features.

ENTRY_POINT[source]#

Support entry point hook.

DEEP_EVAL[source]#

Support Deep Eval backend.

NEIGHBOR_STAT[source]#

Support neighbor statistics.

IO[source]#

Support IO hook.

name: ClassVar[str] = 'Unknown'[source]#

The formal name of the backend.

To be consistent, this name should be also registered in the plugin system.

features: ClassVar[Backend.Feature][source]#

The features of the backend.

suffixes: ClassVar[list[str]] = [][source]#

The supported suffixes of the saved model.

The first element is considered as the default suffix.

abstractmethod is_available() bool[source]#

Check if the backend is available.

Returns:
bool

Whether the backend is available.

property entry_point_hook: Callable[[argparse.Namespace], None][source]#
Abstractmethod:

The entry point hook of the backend.

Returns:
Callable[[Namespace], None]

The entry point hook of the backend.

property deep_eval: type[deepmd.infer.deep_eval.DeepEvalBackend][source]#
Abstractmethod:

The Deep Eval backend of the backend.

Returns:
type[DeepEvalBackend]

The Deep Eval backend of the backend.

property neighbor_stat: type[deepmd.utils.neighbor_stat.NeighborStat][source]#
Abstractmethod:

The neighbor statistics of the backend.

Returns:
type[NeighborStat]

The neighbor statistics of the backend.

property serialize_hook: Callable[[str], dict][source]#
Abstractmethod:

The serialize hook to convert the model file to a dictionary.

Returns:
Callable[[str], dict]

The serialize hook of the backend.

property deserialize_hook: Callable[[str, dict], None][source]#
Abstractmethod:

The deserialize hook to convert the dictionary to a model file.

Returns:
Callable[[str, dict], None]

The deserialize hook of the backend.