deepmd.backend.backend

Module Contents

Classes

Backend

General backend class.

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
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.

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

The entry point hook of the backend.

Returns:
Callable[[Namespace], None]

The entry point hook of the backend.

abstract property deep_eval: Type[deepmd.infer.deep_eval.DeepEvalBackend][source]

The Deep Eval backend of the backend.

Returns:
type[DeepEvalBackend]

The Deep Eval backend of the backend.

abstract property neighbor_stat: Type[deepmd.utils.neighbor_stat.NeighborStat][source]

The neighbor statistics of the backend.

Returns:
type[NeighborStat]

The neighbor statistics of the backend.

abstract property serialize_hook: Callable[[str], dict][source]

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

Returns:
Callable[[str], dict]

The serialize hook of the backend.

abstract property deserialize_hook: Callable[[str, dict], None][source]

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

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

The deserialize hook of the backend.

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.

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

abstract is_available() bool[source]

Check if the backend is available.

Returns:
bool

Whether the backend is available.