Function deepmd::buildPairExcludeTable#
Defined in File common.h
Function Documentation#
- inline std::vector<int> deepmd::buildPairExcludeTable(const int ntypes, const std::vector<std::pair<int, int>> &exclude_types)#
Build the flat
(ntypes+1)^2pair-type keep table.Inference-path mirror of the Python
PairExcludeMaskconstructor (deepmd/dpmodel/utils/exclude_mask.py). The table is row-major over[tj][ti](flat indextj * (ntypes+1) + ti); an entry is0when the ordered pair(ti, tj)is excluded and1otherwise. Both(ti, tj)and(tj, ti)are inserted into the exclude set, so the table is symmetric. Typentypesis the reserved virtual-atom row/column.Returns an empty vector when
exclude_typesis empty, so callers can treat an empty table as “no exclusion” (identity) just like the Pythonpair_excl is Noneearly-exit.This lives in the backend-agnostic
common.h(notcommonPT.h) so both the libtorch apply-helpers (applyPairExclusion*incommonPT.h) and the torch-free TF-C-APIDeepPotJAXingestion seam share one canonical table builder.- Parameters:
ntypes – Number of real atom types.
exclude_types – List of excluded
(ti, tj)type pairs.