From c875416dd5a1119df4ba3f31ba6bd75452cf96c6 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 14 Aug 2025 17:27:31 +0800 Subject: [PATCH 01/17] fix: fix TF version parse in TF 2.20 Signed-off-by: Jinzhe Zeng --- backend/find_tensorflow.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/backend/find_tensorflow.py b/backend/find_tensorflow.py index 8b055f9f4f..404973fce2 100644 --- a/backend/find_tensorflow.py +++ b/backend/find_tensorflow.py @@ -1,5 +1,6 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import os +import re import site from functools import ( lru_cache, @@ -228,6 +229,22 @@ def get_tf_version(tf_path: Optional[Union[str, Path]]) -> str: patch = line.split()[-1] elif line.startswith("#define TF_VERSION_SUFFIX"): suffix = line.split()[-1].strip('"') + if None in (major, minor, patch): + # since TF 2.20.0, version information is no more contained in version.h + # try to read version from tools/pip_package/setup.py + # _VERSION = '2.20.0' + setup_file = Path(tf_path) / "tools" / "pip_package" / "setup.py" + if setup_file.exists(): + with open(setup_file) as f: + for line in f: + # parse with regex + match = re.search( + r"_VERSION[ \t]*=[ \t]*'(\d+)\.(\d+)\.(\d+)([a-zA-Z0-9]*)?'", + line, + ) + if match: + major, minor, patch, suffix = match.groups() + break if None in (major, minor, patch): raise RuntimeError("Failed to read TF version") return ".".join((major, minor, patch)) + suffix From 97fbe5152859f704bcdc6c54398c3c022844c444 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 14 Aug 2025 17:43:18 +0800 Subject: [PATCH 02/17] fix TENSORFLOW_ROOT Signed-off-by: Jinzhe Zeng --- .github/workflows/test_python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_python.yml b/.github/workflows/test_python.yml index 8274337e65..4441cca564 100644 --- a/.github/workflows/test_python.yml +++ b/.github/workflows/test_python.yml @@ -27,7 +27,7 @@ jobs: - run: | source/install/uv_with_retry.sh pip install --system openmpi tensorflow-cpu~=2.18.0 source/install/uv_with_retry.sh pip install --system torch -i https://download.pytorch.org/whl/cpu - export TENSORFLOW_ROOT=$(python -c 'import tensorflow;print(tensorflow.__path__[0])') + export TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') export PYTORCH_ROOT=$(python -c 'import torch;print(torch.__path__[0])') source/install/uv_with_retry.sh pip install --system -e .[test,jax] mpi4py "jax==0.5.0;python_version>='3.10'" source/install/uv_with_retry.sh pip install --system -U setuptools From 3846b158fbd172ac887ec2dbf2faacefc47692fa Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 14 Aug 2025 17:52:27 +0800 Subject: [PATCH 03/17] detect TF version in cmake Signed-off-by: Jinzhe Zeng --- source/cmake/Findtensorflow.cmake | 4 +++- source/cmake/tf_version.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/source/cmake/Findtensorflow.cmake b/source/cmake/Findtensorflow.cmake index d579af7679..1f36bd2aff 100644 --- a/source/cmake/Findtensorflow.cmake +++ b/source/cmake/Findtensorflow.cmake @@ -291,7 +291,9 @@ if(NOT DEFINED TENSORFLOW_VERSION) TENSORFLOW_VERSION_RUN_RESULT_VAR TENSORFLOW_VERSION_COMPILE_RESULT_VAR ${CMAKE_CURRENT_BINARY_DIR}/tf_version "${CMAKE_CURRENT_LIST_DIR}/tf_version.cpp" - CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${TensorFlow_INCLUDE_DIRS}" + CMAKE_FLAGS + "-DINCLUDE_DIRECTORIES:STRING=${TensorFlow_INCLUDE_DIRS}" LINK_LIBRARIES + ${TensorFlowFramework_LIBRARY} ${TensorFlow_LIBRARY} RUN_OUTPUT_VARIABLE TENSORFLOW_VERSION COMPILE_OUTPUT_VARIABLE TENSORFLOW_VERSION_COMPILE_OUTPUT_VAR) if(NOT ${TENSORFLOW_VERSION_COMPILE_RESULT_VAR}) diff --git a/source/cmake/tf_version.cpp b/source/cmake/tf_version.cpp index 6d09e33493..2ad2125291 100644 --- a/source/cmake/tf_version.cpp +++ b/source/cmake/tf_version.cpp @@ -1,12 +1,14 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include -#include "tensorflow/core/public/version.h" +#include "tensorflow/c/c_api.h" int main(int argc, char* argv[]) { // See // https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/public/version.h // TF_VERSION_STRING has been available since TensorFlow v0.6 - std::cout << TF_VERSION_STRING; + // Aug 2025: since TF 2.20, TF_VERSION_STRING is no more available; + // try to use the C API TF_Version + std::cout << TF_Version(); return 0; } From 772d19d4ff8c040cf46fad68a3f3eda738dc2de2 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 14 Aug 2025 18:29:21 +0800 Subject: [PATCH 04/17] ignore stderr Signed-off-by: Jinzhe Zeng --- source/cmake/Findtensorflow.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/cmake/Findtensorflow.cmake b/source/cmake/Findtensorflow.cmake index 1f36bd2aff..880b9be3f3 100644 --- a/source/cmake/Findtensorflow.cmake +++ b/source/cmake/Findtensorflow.cmake @@ -294,7 +294,7 @@ if(NOT DEFINED TENSORFLOW_VERSION) CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${TensorFlow_INCLUDE_DIRS}" LINK_LIBRARIES ${TensorFlowFramework_LIBRARY} ${TensorFlow_LIBRARY} - RUN_OUTPUT_VARIABLE TENSORFLOW_VERSION + RUN_OUTPUT_STDOUT_VARIABLE TENSORFLOW_VERSION COMPILE_OUTPUT_VARIABLE TENSORFLOW_VERSION_COMPILE_OUTPUT_VAR) if(NOT ${TENSORFLOW_VERSION_COMPILE_RESULT_VAR}) message( From c49269613041f901a612cedccd90c6406a4bcf1a Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 14 Aug 2025 18:32:52 +0800 Subject: [PATCH 05/17] fix deprecation Signed-off-by: Jinzhe Zeng --- source/op/tf/descrpt.cc | 38 +++--- source/op/tf/descrpt_se_a_ef.cc | 48 +++---- source/op/tf/descrpt_se_a_ef_para.cc | 48 +++---- source/op/tf/descrpt_se_a_ef_vert.cc | 48 +++---- source/op/tf/descrpt_se_a_mask.cc | 18 +-- source/op/tf/ewald_recp.cc | 14 +-- source/op/tf/map_aparam.cc | 12 +- source/op/tf/neighbor_stat.cc | 22 ++-- source/op/tf/pair_tab.cc | 32 ++--- source/op/tf/pairwise.cc | 10 +- source/op/tf/prod_env_mat_multi_device.cc | 118 +++++++++--------- .../op/tf/prod_env_mat_multi_device_nvnmd.cc | 80 ++++++------ source/op/tf/prod_force.cc | 31 ++--- source/op/tf/prod_force_grad.cc | 37 +++--- source/op/tf/prod_force_grad_multi_device.cc | 54 ++++---- source/op/tf/prod_force_multi_device.cc | 39 +++--- source/op/tf/prod_force_se_a_grad.cc | 31 ++--- source/op/tf/prod_force_se_a_mask.cc | 21 ++-- source/op/tf/prod_force_se_a_mask_grad.cc | 29 ++--- source/op/tf/prod_force_se_r_grad.cc | 29 ++--- source/op/tf/prod_virial.cc | 37 +++--- source/op/tf/prod_virial_grad.cc | 43 +++---- source/op/tf/prod_virial_grad_multi_device.cc | 66 +++++----- source/op/tf/prod_virial_multi_device.cc | 44 +++---- source/op/tf/prod_virial_se_a_grad.cc | 37 +++--- source/op/tf/prod_virial_se_r_grad.cc | 35 +++--- source/op/tf/soft_min.cc | 22 ++-- source/op/tf/soft_min_force.cc | 27 ++-- source/op/tf/soft_min_force_grad.cc | 26 ++-- source/op/tf/soft_min_virial.cc | 26 ++-- source/op/tf/soft_min_virial_grad.cc | 32 ++--- source/op/tf/tabulate_multi_device.cc | 54 ++++---- source/op/tf/unaggregated_grad.cc | 32 ++--- 33 files changed, 626 insertions(+), 614 deletions(-) diff --git a/source/op/tf/descrpt.cc b/source/op/tf/descrpt.cc index db3b0ca8e5..1a63b45157 100644 --- a/source/op/tf/descrpt.cc +++ b/source/op/tf/descrpt.cc @@ -67,22 +67,22 @@ class DescrptOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of coord should be 2")); + absl::InvalidArgumentError("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of type should be 2")); + absl::InvalidArgumentError("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of box should be 2")); + absl::InvalidArgumentError("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of mesh should be 1")); + absl::InvalidArgumentError("Dim of mesh should be 1")); OP_REQUIRES(context, (avg_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of avg should be 2")); + absl::InvalidArgumentError("Dim of avg should be 2")); OP_REQUIRES(context, (std_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of std should be 2")); + absl::InvalidArgumentError("Dim of std should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); int nloc = natoms(0); @@ -92,24 +92,24 @@ class DescrptOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (ntypes == avg_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of avg should be ntype")); + absl::InvalidArgumentError("number of avg should be ntype")); OP_REQUIRES(context, (ntypes == std_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of std should be ntype")); + absl::InvalidArgumentError("number of std should be ntype")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of box should be 9")); + absl::InvalidArgumentError("number of box should be 9")); OP_REQUIRES(context, (ndescrpt == avg_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of avg should be ndescrpt")); + absl::InvalidArgumentError("number of avg should be ndescrpt")); OP_REQUIRES(context, (ndescrpt == std_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of std should be ndescrpt")); + absl::InvalidArgumentError("number of std should be ndescrpt")); int nei_mode = 0; if (mesh_tensor.shape().dim_size(0) == 16) { @@ -201,10 +201,10 @@ class DescrptOp : public OpKernel { // } // int ntypes = max_type_v + 1; OP_REQUIRES(context, (ntypes == int(sel_a.size())), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of types should match the length of sel array")); OP_REQUIRES(context, (ntypes == int(sel_r.size())), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of types should match the length of sel array")); for (int kk = 0; kk < nsamples; ++kk) { diff --git a/source/op/tf/descrpt_se_a_ef.cc b/source/op/tf/descrpt_se_a_ef.cc index 18dda3d8b0..32d26e5b4a 100644 --- a/source/op/tf/descrpt_se_a_ef.cc +++ b/source/op/tf/descrpt_se_a_ef.cc @@ -69,32 +69,32 @@ class DescrptSeAEfOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of coord should be 2")); + absl::InvalidArgumentError("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of type should be 2")); + absl::InvalidArgumentError("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of box should be 2")); + absl::InvalidArgumentError("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of mesh should be 1")); + absl::InvalidArgumentError("Dim of mesh should be 1")); OP_REQUIRES(context, (ef_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of ef should be 2")); + absl::InvalidArgumentError("Dim of ef should be 2")); OP_REQUIRES(context, (avg_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of avg should be 2")); + absl::InvalidArgumentError("Dim of avg should be 2")); OP_REQUIRES(context, (std_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of std should be 2")); + absl::InvalidArgumentError("Dim of std should be 2")); OP_REQUIRES( context, (fill_nei_a), - errors::InvalidArgument( + absl::InvalidArgumentError( "Rotational free descriptor only support the case rcut_a < 0")); OP_REQUIRES(context, (sec_r.back() == 0), - errors::InvalidArgument( + absl::InvalidArgumentError( "Rotational free descriptor only support all-angular " "information: sel_r should be all zero.")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); int nloc = natoms(0); @@ -104,28 +104,28 @@ class DescrptSeAEfOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nsamples == ef_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (ntypes == avg_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of avg should be ntype")); + absl::InvalidArgumentError("number of avg should be ntype")); OP_REQUIRES(context, (ntypes == std_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of std should be ntype")); + absl::InvalidArgumentError("number of std should be ntype")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of box should be 9")); + absl::InvalidArgumentError("number of box should be 9")); OP_REQUIRES(context, (nloc * 3 == ef_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of ef should be 3")); + absl::InvalidArgumentError("number of ef should be 3")); OP_REQUIRES(context, (ndescrpt == avg_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of avg should be ndescrpt")); + absl::InvalidArgumentError("number of avg should be ndescrpt")); OP_REQUIRES(context, (ndescrpt == std_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of std should be ndescrpt")); + absl::InvalidArgumentError("number of std should be ndescrpt")); int nei_mode = 0; if (mesh_tensor.shape().dim_size(0) == 16) { @@ -208,10 +208,10 @@ class DescrptSeAEfOp : public OpKernel { // } // int ntypes = max_type_v + 1; OP_REQUIRES(context, (ntypes == int(sel_a.size())), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of types should match the length of sel array")); OP_REQUIRES(context, (ntypes == int(sel_r.size())), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of types should match the length of sel array")); for (int kk = 0; kk < nsamples; ++kk) { diff --git a/source/op/tf/descrpt_se_a_ef_para.cc b/source/op/tf/descrpt_se_a_ef_para.cc index 0f34de3f4f..9808457165 100644 --- a/source/op/tf/descrpt_se_a_ef_para.cc +++ b/source/op/tf/descrpt_se_a_ef_para.cc @@ -69,32 +69,32 @@ class DescrptSeAEfParaOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of coord should be 2")); + absl::InvalidArgumentError("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of type should be 2")); + absl::InvalidArgumentError("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of box should be 2")); + absl::InvalidArgumentError("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of mesh should be 1")); + absl::InvalidArgumentError("Dim of mesh should be 1")); OP_REQUIRES(context, (ef_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of ef should be 2")); + absl::InvalidArgumentError("Dim of ef should be 2")); OP_REQUIRES(context, (avg_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of avg should be 2")); + absl::InvalidArgumentError("Dim of avg should be 2")); OP_REQUIRES(context, (std_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of std should be 2")); + absl::InvalidArgumentError("Dim of std should be 2")); OP_REQUIRES( context, (fill_nei_a), - errors::InvalidArgument( + absl::InvalidArgumentError( "Rotational free descriptor only support the case rcut_a < 0")); OP_REQUIRES(context, (sec_r.back() == 0), - errors::InvalidArgument( + absl::InvalidArgumentError( "Rotational free descriptor only support all-angular " "information: sel_r should be all zero.")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); int nloc = natoms(0); @@ -104,28 +104,28 @@ class DescrptSeAEfParaOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nsamples == ef_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (ntypes == avg_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of avg should be ntype")); + absl::InvalidArgumentError("number of avg should be ntype")); OP_REQUIRES(context, (ntypes == std_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of std should be ntype")); + absl::InvalidArgumentError("number of std should be ntype")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of box should be 9")); + absl::InvalidArgumentError("number of box should be 9")); OP_REQUIRES(context, (nloc * 3 == ef_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of ef should be 3")); + absl::InvalidArgumentError("number of ef should be 3")); OP_REQUIRES(context, (ndescrpt == avg_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of avg should be ndescrpt")); + absl::InvalidArgumentError("number of avg should be ndescrpt")); OP_REQUIRES(context, (ndescrpt == std_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of std should be ndescrpt")); + absl::InvalidArgumentError("number of std should be ndescrpt")); int nei_mode = 0; if (mesh_tensor.shape().dim_size(0) == 16) { @@ -208,10 +208,10 @@ class DescrptSeAEfParaOp : public OpKernel { // } // int ntypes = max_type_v + 1; OP_REQUIRES(context, (ntypes == int(sel_a.size())), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of types should match the length of sel array")); OP_REQUIRES(context, (ntypes == int(sel_r.size())), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of types should match the length of sel array")); for (int kk = 0; kk < nsamples; ++kk) { diff --git a/source/op/tf/descrpt_se_a_ef_vert.cc b/source/op/tf/descrpt_se_a_ef_vert.cc index b4eb30d9ee..89526904ba 100644 --- a/source/op/tf/descrpt_se_a_ef_vert.cc +++ b/source/op/tf/descrpt_se_a_ef_vert.cc @@ -69,32 +69,32 @@ class DescrptSeAEfVertOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of coord should be 2")); + absl::InvalidArgumentError("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of type should be 2")); + absl::InvalidArgumentError("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of box should be 2")); + absl::InvalidArgumentError("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of mesh should be 1")); + absl::InvalidArgumentError("Dim of mesh should be 1")); OP_REQUIRES(context, (ef_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of ef should be 2")); + absl::InvalidArgumentError("Dim of ef should be 2")); OP_REQUIRES(context, (avg_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of avg should be 2")); + absl::InvalidArgumentError("Dim of avg should be 2")); OP_REQUIRES(context, (std_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of std should be 2")); + absl::InvalidArgumentError("Dim of std should be 2")); OP_REQUIRES( context, (fill_nei_a), - errors::InvalidArgument( + absl::InvalidArgumentError( "Rotational free descriptor only support the case rcut_a < 0")); OP_REQUIRES(context, (sec_r.back() == 0), - errors::InvalidArgument( + absl::InvalidArgumentError( "Rotational free descriptor only support all-angular " "information: sel_r should be all zero.")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); int nloc = natoms(0); @@ -104,28 +104,28 @@ class DescrptSeAEfVertOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nsamples == ef_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (ntypes == avg_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of avg should be ntype")); + absl::InvalidArgumentError("number of avg should be ntype")); OP_REQUIRES(context, (ntypes == std_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of std should be ntype")); + absl::InvalidArgumentError("number of std should be ntype")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of box should be 9")); + absl::InvalidArgumentError("number of box should be 9")); OP_REQUIRES(context, (nloc * 3 == ef_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of ef should be 3")); + absl::InvalidArgumentError("number of ef should be 3")); OP_REQUIRES(context, (ndescrpt == avg_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of avg should be ndescrpt")); + absl::InvalidArgumentError("number of avg should be ndescrpt")); OP_REQUIRES(context, (ndescrpt == std_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of std should be ndescrpt")); + absl::InvalidArgumentError("number of std should be ndescrpt")); int nei_mode = 0; if (mesh_tensor.shape().dim_size(0) == 16) { @@ -208,10 +208,10 @@ class DescrptSeAEfVertOp : public OpKernel { // } // int ntypes = max_type_v + 1; OP_REQUIRES(context, (ntypes == int(sel_a.size())), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of types should match the length of sel array")); OP_REQUIRES(context, (ntypes == int(sel_r.size())), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of types should match the length of sel array")); for (int kk = 0; kk < nsamples; ++kk) { diff --git a/source/op/tf/descrpt_se_a_mask.cc b/source/op/tf/descrpt_se_a_mask.cc index 28e4a575db..599a6ac044 100644 --- a/source/op/tf/descrpt_se_a_mask.cc +++ b/source/op/tf/descrpt_se_a_mask.cc @@ -63,20 +63,20 @@ class DescrptSeAMaskOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of coord should be 2")); - OP_REQUIRES( - context, (type_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of type for se_e2_a_mask op should be 2")); + absl::InvalidArgumentError("Dim of coord should be 2")); + OP_REQUIRES(context, (type_tensor.shape().dims() == 2), + absl::InvalidArgumentError( + "Dim of type for se_e2_a_mask op should be 2")); OP_REQUIRES(context, (mask_matrix_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of mask matrix should be 2")); + absl::InvalidArgumentError("Dim of mask matrix should be 2")); int nsamples = coord_tensor.shape().dim_size(0); // check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nsamples == mask_matrix_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); // Set n_descrpt for each atom. Include 1/rr, cos(theta), cos(phi), sin(phi) int n_descrpt = 4; @@ -87,10 +87,10 @@ class DescrptSeAMaskOp : public OpKernel { // check the sizes OP_REQUIRES(context, (total_atom_num * 3 == coord_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (total_atom_num == mask_matrix_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); // Create an output tensor TensorShape descrpt_shape; diff --git a/source/op/tf/ewald_recp.cc b/source/op/tf/ewald_recp.cc index dcad204467..16dbd6b56b 100644 --- a/source/op/tf/ewald_recp.cc +++ b/source/op/tf/ewald_recp.cc @@ -43,13 +43,13 @@ class EwaldRecpOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (coord_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of coord should be 1")); + absl::InvalidArgumentError("Dim of coord should be 1")); OP_REQUIRES(context, (charge_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of charge should be 1")); + absl::InvalidArgumentError("Dim of charge should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) == 1), - errors::InvalidArgument("size of natoms should be 1")); + absl::InvalidArgumentError("size of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of box should be 1")); + absl::InvalidArgumentError("Dim of box should be 1")); auto natoms = natoms_tensor.flat(); int nloc = natoms(0); int nsamples = coord_tensor.shape().dim_size(0) / (nloc * 3); @@ -59,15 +59,15 @@ class EwaldRecpOp : public OpKernel { context, (static_cast(nsamples) * nloc * 3 == coord_tensor.shape().dim_size(0)), - errors::InvalidArgument("coord number of samples should match")); + absl::InvalidArgumentError("coord number of samples should match")); OP_REQUIRES( context, (static_cast(nsamples) * nloc * 1 == charge_tensor.shape().dim_size(0)), - errors::InvalidArgument("charge number of samples should match")); + absl::InvalidArgumentError("charge number of samples should match")); OP_REQUIRES( context, (nsamples * 9 == box_tensor.shape().dim_size(0)), - errors::InvalidArgument("box number of samples should match")); + absl::InvalidArgumentError("box number of samples should match")); // Create an output tensor TensorShape energy_shape; diff --git a/source/op/tf/map_aparam.cc b/source/op/tf/map_aparam.cc index 7ac3b48a4f..c952b95160 100644 --- a/source/op/tf/map_aparam.cc +++ b/source/op/tf/map_aparam.cc @@ -35,14 +35,14 @@ class MapAparamOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (aparam_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of aparam should be 2")); + absl::InvalidArgumentError("Dim of aparam should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -54,9 +54,9 @@ class MapAparamOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - errors::InvalidArgument("number of neighbors should match")); + absl::InvalidArgumentError("number of neighbors should match")); // Create an output tensor TensorShape output_shape; diff --git a/source/op/tf/neighbor_stat.cc b/source/op/tf/neighbor_stat.cc index 26f13b0c84..21ff1b78f4 100644 --- a/source/op/tf/neighbor_stat.cc +++ b/source/op/tf/neighbor_stat.cc @@ -46,17 +46,17 @@ class NeighborStatOp : public OpKernel { const Tensor& mesh_tensor = context->input(context_input_index++); OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of coord should be 2")); + absl::InvalidArgumentError("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of type should be 2")); + absl::InvalidArgumentError("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of box should be 2")); + absl::InvalidArgumentError("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of mesh should be 1")); + absl::InvalidArgumentError("Dim of mesh should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); int nloc = natoms_tensor.flat().data()[0]; int nall = natoms_tensor.flat().data()[1]; @@ -64,15 +64,15 @@ class NeighborStatOp : public OpKernel { int ntypes = natoms_tensor.shape().dim_size(0) - 2; // check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of box should be 9")); + absl::InvalidArgumentError("number of box should be 9")); DeviceFunctor()(device, context->eigen_device()); int nei_mode = 0; if (mesh_tensor.shape().dim_size(0) == 6 || diff --git a/source/op/tf/pair_tab.cc b/source/op/tf/pair_tab.cc index 0b04390d5f..1050b715ff 100644 --- a/source/op/tf/pair_tab.cc +++ b/source/op/tf/pair_tab.cc @@ -53,22 +53,22 @@ class PairTabOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (table_info_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of table_info should be 1")); + absl::InvalidArgumentError("Dim of table_info should be 1")); OP_REQUIRES(context, (table_data_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of table_data should be 1")); + absl::InvalidArgumentError("Dim of table_data should be 1")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of type should be 2")); + absl::InvalidArgumentError("Dim of type should be 2")); OP_REQUIRES(context, (rij_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of rij should be 2")); + absl::InvalidArgumentError("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (scale_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of scale should be 2")); + absl::InvalidArgumentError("Dim of scale should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -81,24 +81,24 @@ class PairTabOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == type_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == rij_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - errors::InvalidArgument("shape of type should be nall")); + absl::InvalidArgumentError("shape of type should be nall")); OP_REQUIRES( context, (3 * static_cast(nnei) * nloc == rij_tensor.shape().dim_size(1)), - errors::InvalidArgument("shape of rij should be 3 * nloc * nnei")); + absl::InvalidArgumentError("shape of rij should be 3 * nloc * nnei")); OP_REQUIRES( context, (static_cast(nnei) * nloc == nlist_tensor.shape().dim_size(1)), - errors::InvalidArgument("shape of nlist should be nloc * nnei")); + absl::InvalidArgumentError("shape of nlist should be nloc * nnei")); OP_REQUIRES(context, (nloc == scale_tensor.shape().dim_size(1)), - errors::InvalidArgument("shape of scale should be nloc")); + absl::InvalidArgumentError("shape of scale should be nloc")); // Create an output tensor TensorShape energy_shape; @@ -133,7 +133,7 @@ class PairTabOp : public OpKernel { auto virial = virial_tensor->matrix(); OP_REQUIRES(context, (ntypes == int(table_info(3) + 0.1)), - errors::InvalidArgument( + absl::InvalidArgumentError( "ntypes provided in table does not match deeppot")); int nspline = table_info(2) + 0.1; int tab_stride = 4 * nspline; diff --git a/source/op/tf/pairwise.cc b/source/op/tf/pairwise.cc index ba1e5e6475..0d986a1f25 100644 --- a/source/op/tf/pairwise.cc +++ b/source/op/tf/pairwise.cc @@ -45,9 +45,9 @@ class PairwiseIdxOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (idxs_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of idxs should be 2")); + absl::InvalidArgumentError("Dim of idxs should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); auto idxs = idxs_tensor.matrix(); int nframes = idxs_tensor.shape().dim_size(0); @@ -55,7 +55,7 @@ class PairwiseIdxOp : public OpKernel { int nloc = natoms(0); int nall = natoms(1); OP_REQUIRES(context, nframes > 0, - errors::InvalidArgument("nframes should be > 0")); + absl::InvalidArgumentError("nframes should be > 0")); std::vector> forward_qm_maps, backward_qm_maps, forward_qmmm_maps, backward_qmmm_maps; @@ -237,9 +237,9 @@ class ConvertForwardMapOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (sub_forward_map_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of idxs should be 2")); + absl::InvalidArgumentError("Dim of idxs should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); auto sub_forward_map = sub_forward_map_tensor.matrix(); int sub_nframes = sub_forward_map_tensor.shape().dim_size(0); diff --git a/source/op/tf/prod_env_mat_multi_device.cc b/source/op/tf/prod_env_mat_multi_device.cc index e374102224..ecc14df0af 100644 --- a/source/op/tf/prod_env_mat_multi_device.cc +++ b/source/op/tf/prod_env_mat_multi_device.cc @@ -364,25 +364,25 @@ class ProdEnvMatAOp : public OpKernel { // set size of the sample. assume 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, // 3], [4, 4, 4]]], then shape(t) ==> [2, 2, 3] OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of coord should be 2")); + absl::InvalidArgumentError("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of type should be 2")); + absl::InvalidArgumentError("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of box should be 2")); + absl::InvalidArgumentError("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of mesh should be 1")); + absl::InvalidArgumentError("Dim of mesh should be 1")); OP_REQUIRES(context, (avg_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of avg should be 2")); + absl::InvalidArgumentError("Dim of avg should be 2")); OP_REQUIRES(context, (std_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of std should be 2")); + absl::InvalidArgumentError("Dim of std should be 2")); OP_REQUIRES(context, (sec_r.back() == 0), - errors::InvalidArgument( + absl::InvalidArgumentError( "Rotational free descriptor only support all-angular " "information: sel_r should be all zero.")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); DeviceFunctor()(device, context->eigen_device()); const int* natoms = natoms_tensor.flat().data(); @@ -393,30 +393,30 @@ class ProdEnvMatAOp : public OpKernel { int nsamples = coord_tensor.shape().dim_size(0); //// check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (ntypes == avg_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of avg should be ntype")); + absl::InvalidArgumentError("number of avg should be ntype")); OP_REQUIRES(context, (ntypes == std_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of std should be ntype")); + absl::InvalidArgumentError("number of std should be ntype")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of box should be 9")); + absl::InvalidArgumentError("number of box should be 9")); OP_REQUIRES(context, (ndescrpt == avg_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of avg should be ndescrpt")); + absl::InvalidArgumentError("number of avg should be ndescrpt")); OP_REQUIRES(context, (ndescrpt == std_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of std should be ndescrpt")); + absl::InvalidArgumentError("number of std should be ndescrpt")); OP_REQUIRES(context, (ntypes == int(sel_a.size())), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of types should match the length of sel array")); OP_REQUIRES(context, (ntypes == int(sel_r.size())), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of types should match the length of sel array")); int nei_mode = 0; @@ -680,21 +680,21 @@ class ProdEnvMatROp : public OpKernel { const Tensor& std_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of coord should be 2")); + absl::InvalidArgumentError("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of type should be 2")); + absl::InvalidArgumentError("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of box should be 2")); + absl::InvalidArgumentError("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of mesh should be 1")); + absl::InvalidArgumentError("Dim of mesh should be 1")); OP_REQUIRES(context, (avg_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of avg should be 2")); + absl::InvalidArgumentError("Dim of avg should be 2")); OP_REQUIRES(context, (std_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of std should be 2")); + absl::InvalidArgumentError("Dim of std should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); DeviceFunctor()(device, context->eigen_device()); const int* natoms = natoms_tensor.flat().data(); @@ -707,23 +707,23 @@ class ProdEnvMatROp : public OpKernel { //// check the sizes // check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (ntypes == avg_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of avg should be ntype")); + absl::InvalidArgumentError("number of avg should be ntype")); OP_REQUIRES(context, (ntypes == std_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of std should be ntype")); + absl::InvalidArgumentError("number of std should be ntype")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of box should be 9")); + absl::InvalidArgumentError("number of box should be 9")); OP_REQUIRES(context, (ndescrpt == avg_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of avg should be ndescrpt")); + absl::InvalidArgumentError("number of avg should be ndescrpt")); OP_REQUIRES(context, (ndescrpt == std_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of std should be ndescrpt")); + absl::InvalidArgumentError("number of std should be ndescrpt")); int nei_mode = 0; bool b_nlist_map = false; @@ -995,25 +995,25 @@ class ProdEnvMatAMixOp : public OpKernel { // set size of the sample. assume 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, // 3], [4, 4, 4]]], then shape(t) ==> [2, 2, 3] OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of coord should be 2")); + absl::InvalidArgumentError("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of type should be 2")); + absl::InvalidArgumentError("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of box should be 2")); + absl::InvalidArgumentError("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of mesh should be 1")); + absl::InvalidArgumentError("Dim of mesh should be 1")); OP_REQUIRES(context, (avg_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of avg should be 2")); + absl::InvalidArgumentError("Dim of avg should be 2")); OP_REQUIRES(context, (std_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of std should be 2")); + absl::InvalidArgumentError("Dim of std should be 2")); OP_REQUIRES(context, (sec_r.back() == 0), - errors::InvalidArgument( + absl::InvalidArgumentError( "Rotational free descriptor only support all-angular " "information: sel_r should be all zero.")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); DeviceFunctor()(device, context->eigen_device()); const int* natoms = natoms_tensor.flat().data(); @@ -1023,30 +1023,30 @@ class ProdEnvMatAMixOp : public OpKernel { int nsamples = coord_tensor.shape().dim_size(0); //// check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (ntypes == avg_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of avg should be ntype")); + absl::InvalidArgumentError("number of avg should be ntype")); OP_REQUIRES(context, (ntypes == std_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of std should be ntype")); + absl::InvalidArgumentError("number of std should be ntype")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of box should be 9")); + absl::InvalidArgumentError("number of box should be 9")); OP_REQUIRES(context, (ndescrpt == avg_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of avg should be ndescrpt")); + absl::InvalidArgumentError("number of avg should be ndescrpt")); OP_REQUIRES(context, (ndescrpt == std_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of std should be ndescrpt")); + absl::InvalidArgumentError("number of std should be ndescrpt")); OP_REQUIRES(context, (1 == int(sel_a.size())), - errors::InvalidArgument( + absl::InvalidArgumentError( "the length of sel array should be 1 in this op")); OP_REQUIRES(context, (1 == int(sel_r.size())), - errors::InvalidArgument( + absl::InvalidArgumentError( "the length of sel array should be 1 in this op")); int nei_mode = 0; @@ -1716,7 +1716,7 @@ void _prepare_coord_nlist_gpu(OpKernelContext* context, deepmd::env_mat_nbor_update(inlist_temp, inlist, max_nbor_size, nbor_list_dev, fake_mesh_dev, 16); OP_REQUIRES(context, (max_numneigh(inlist_temp) <= max_nbor_size), - errors::InvalidArgument( + absl::InvalidArgumentError( "Assert failed, max neighbor size of atom(lammps) " + std::to_string(max_numneigh(inlist_temp)) + " is larger than " + std::to_string(max_nbor_size) + @@ -1730,7 +1730,7 @@ void _prepare_coord_nlist_gpu(OpKernelContext* context, nbor_list_dev, mesh_tensor_data, mesh_tensor_size); OP_REQUIRES(context, (max_numneigh(inlist_temp) <= max_nbor_size), - errors::InvalidArgument( + absl::InvalidArgumentError( "Assert failed, max neighbor size of atom(lammps) " + std::to_string(max_numneigh(inlist_temp)) + " is larger than " + std::to_string(max_nbor_size) + diff --git a/source/op/tf/prod_env_mat_multi_device_nvnmd.cc b/source/op/tf/prod_env_mat_multi_device_nvnmd.cc index 57390077ef..1c8a88b426 100644 --- a/source/op/tf/prod_env_mat_multi_device_nvnmd.cc +++ b/source/op/tf/prod_env_mat_multi_device_nvnmd.cc @@ -342,25 +342,25 @@ class ProdEnvMatANvnmdQuantizeOp : public OpKernel { // set size of the sample. assume 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, // 3], [4, 4, 4]]], then shape(t) ==> [2, 2, 3] OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of coord should be 2")); + absl::InvalidArgumentError("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of type should be 2")); + absl::InvalidArgumentError("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of box should be 2")); + absl::InvalidArgumentError("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of mesh should be 1")); + absl::InvalidArgumentError("Dim of mesh should be 1")); OP_REQUIRES(context, (avg_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of avg should be 2")); + absl::InvalidArgumentError("Dim of avg should be 2")); OP_REQUIRES(context, (std_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of std should be 2")); + absl::InvalidArgumentError("Dim of std should be 2")); OP_REQUIRES(context, (sec_r.back() == 0), - errors::InvalidArgument( + absl::InvalidArgumentError( "Rotational free descriptor only support all-angular " "information: sel_r should be all zero.")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); DeviceFunctor()(device, context->eigen_device()); const int* natoms = natoms_tensor.flat().data(); @@ -371,30 +371,30 @@ class ProdEnvMatANvnmdQuantizeOp : public OpKernel { int nsamples = coord_tensor.shape().dim_size(0); //// check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (ntypes == avg_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of avg should be ntype")); + absl::InvalidArgumentError("number of avg should be ntype")); OP_REQUIRES(context, (ntypes == std_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of std should be ntype")); + absl::InvalidArgumentError("number of std should be ntype")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of box should be 9")); + absl::InvalidArgumentError("number of box should be 9")); OP_REQUIRES(context, (ndescrpt == avg_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of avg should be ndescrpt")); + absl::InvalidArgumentError("number of avg should be ndescrpt")); OP_REQUIRES(context, (ndescrpt == std_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of std should be ndescrpt")); + absl::InvalidArgumentError("number of std should be ndescrpt")); OP_REQUIRES(context, (ntypes == int(sel_a.size())), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of types should match the length of sel array")); OP_REQUIRES(context, (ntypes == int(sel_r.size())), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of types should match the length of sel array")); int nei_mode = 0; @@ -585,25 +585,25 @@ class ProdEnvMatAMixNvnmdQuantizeOp : public OpKernel { // set size of the sample. assume 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, // 3], [4, 4, 4]]], then shape(t) ==> [2, 2, 3] OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of coord should be 2")); + absl::InvalidArgumentError("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of type should be 2")); + absl::InvalidArgumentError("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of box should be 2")); + absl::InvalidArgumentError("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of mesh should be 1")); + absl::InvalidArgumentError("Dim of mesh should be 1")); OP_REQUIRES(context, (avg_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of avg should be 2")); + absl::InvalidArgumentError("Dim of avg should be 2")); OP_REQUIRES(context, (std_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of std should be 2")); + absl::InvalidArgumentError("Dim of std should be 2")); OP_REQUIRES(context, (sec_r.back() == 0), - errors::InvalidArgument( + absl::InvalidArgumentError( "Rotational free descriptor only support all-angular " "information: sel_r should be all zero.")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); DeviceFunctor()(device, context->eigen_device()); const int* natoms = natoms_tensor.flat().data(); @@ -613,30 +613,30 @@ class ProdEnvMatAMixNvnmdQuantizeOp : public OpKernel { int nsamples = coord_tensor.shape().dim_size(0); //// check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (ntypes == avg_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of avg should be ntype")); + absl::InvalidArgumentError("number of avg should be ntype")); OP_REQUIRES(context, (ntypes == std_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of std should be ntype")); + absl::InvalidArgumentError("number of std should be ntype")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of atoms should match")); + absl::InvalidArgumentError("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of box should be 9")); + absl::InvalidArgumentError("number of box should be 9")); OP_REQUIRES(context, (ndescrpt == avg_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of avg should be ndescrpt")); + absl::InvalidArgumentError("number of avg should be ndescrpt")); OP_REQUIRES(context, (ndescrpt == std_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of std should be ndescrpt")); + absl::InvalidArgumentError("number of std should be ndescrpt")); OP_REQUIRES(context, (1 == int(sel_a.size())), - errors::InvalidArgument( + absl::InvalidArgumentError( "the length of sel array should be 1 in this op")); OP_REQUIRES(context, (1 == int(sel_r.size())), - errors::InvalidArgument( + absl::InvalidArgumentError( "the length of sel array should be 1 in this op")); int nei_mode = 0; diff --git a/source/op/tf/prod_force.cc b/source/op/tf/prod_force.cc index 20269ebef3..b411122f36 100644 --- a/source/op/tf/prod_force.cc +++ b/source/op/tf/prod_force.cc @@ -40,18 +40,18 @@ class ProdForceOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (net_deriv_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (axis_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of axis should be 2")); + absl::InvalidArgumentError("Dim of axis should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -63,21 +63,22 @@ class ProdForceOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == in_deriv_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == axis_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); - OP_REQUIRES(context, - (static_cast(nloc) * ndescrpt * 12 == - in_deriv_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + OP_REQUIRES( + context, + (static_cast(nloc) * ndescrpt * 12 == + in_deriv_tensor.shape().dim_size(1)), + absl::InvalidArgumentError("number of descriptors should match")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - errors::InvalidArgument("number of neighbors should match")); + absl::InvalidArgumentError("number of neighbors should match")); OP_REQUIRES( context, (nloc * 4 == axis_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of axis type+id should match 2+2")); + absl::InvalidArgumentError("number of axis type+id should match 2+2")); // Create an output tensor TensorShape force_shape; diff --git a/source/op/tf/prod_force_grad.cc b/source/op/tf/prod_force_grad.cc index acfe9145fe..bdc134e694 100644 --- a/source/op/tf/prod_force_grad.cc +++ b/source/op/tf/prod_force_grad.cc @@ -46,20 +46,20 @@ class ProdForceGradOp : public OpKernel { TensorShape axis_shape = axis_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - errors::InvalidArgument("Dim of grad should be 2")); + absl::InvalidArgumentError("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (axis_shape.dims() == 2), - errors::InvalidArgument("Dim of axis should be 2")); + absl::InvalidArgumentError("Dim of axis should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -70,26 +70,27 @@ class ProdForceGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == axis_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES( context, (nloc * 3 == grad_shape.dim_size(1)), - errors::InvalidArgument("input grad shape should be 3 x natoms")); - OP_REQUIRES(context, - (static_cast(nloc) * ndescrpt * 12 == - in_deriv_shape.dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + absl::InvalidArgumentError("input grad shape should be 3 x natoms")); + OP_REQUIRES( + context, + (static_cast(nloc) * ndescrpt * 12 == + in_deriv_shape.dim_size(1)), + absl::InvalidArgumentError("number of descriptors should match")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - errors::InvalidArgument("number of neighbors should match")); + absl::InvalidArgumentError("number of neighbors should match")); OP_REQUIRES( context, (nloc * 4 == axis_shape.dim_size(1)), - errors::InvalidArgument("number of axis type+id should be 2+2")); + absl::InvalidArgumentError("number of axis type+id should be 2+2")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/prod_force_grad_multi_device.cc b/source/op/tf/prod_force_grad_multi_device.cc index ee8a29732d..5bd5cce766 100644 --- a/source/op/tf/prod_force_grad_multi_device.cc +++ b/source/op/tf/prod_force_grad_multi_device.cc @@ -53,18 +53,18 @@ class ProdForceSeAGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - errors::InvalidArgument("Dim of grad should be 2")); + absl::InvalidArgumentError("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -75,20 +75,20 @@ class ProdForceSeAGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES( context, (nloc * 3 == grad_shape.dim_size(1)), - errors::InvalidArgument("input grad shape should be 3 x natoms")); - OP_REQUIRES(context, - (int_64(nloc) * ndescrpt * 3 == in_deriv_shape.dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + absl::InvalidArgumentError("input grad shape should be 3 x natoms")); + OP_REQUIRES( + context, (int_64(nloc) * ndescrpt * 3 == in_deriv_shape.dim_size(1)), + absl::InvalidArgumentError("number of descriptors should match")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - errors::InvalidArgument("number of neighbors should match")); + absl::InvalidArgumentError("number of neighbors should match")); // Create an output tensor TensorShape grad_net_shape; @@ -166,18 +166,18 @@ class ProdForceSeRGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - errors::InvalidArgument("Dim of grad should be 2")); + absl::InvalidArgumentError("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -188,18 +188,18 @@ class ProdForceSeRGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES( context, (nloc * 3 == grad_shape.dim_size(1)), - errors::InvalidArgument("input grad shape should be 3 x natoms")); - OP_REQUIRES(context, - (int_64(nloc) * ndescrpt * 3 == in_deriv_shape.dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + absl::InvalidArgumentError("input grad shape should be 3 x natoms")); + OP_REQUIRES( + context, (int_64(nloc) * ndescrpt * 3 == in_deriv_shape.dim_size(1)), + absl::InvalidArgumentError("number of descriptors should match")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/prod_force_multi_device.cc b/source/op/tf/prod_force_multi_device.cc index d48749faa5..404fd1ce84 100644 --- a/source/op/tf/prod_force_multi_device.cc +++ b/source/op/tf/prod_force_multi_device.cc @@ -75,15 +75,15 @@ class ProdForceSeAOp : public OpKernel { const Tensor& natoms_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (net_deriv_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); const int* natoms = natoms_tensor.flat().data(); int nloc = natoms[0]; @@ -93,13 +93,13 @@ class ProdForceSeAOp : public OpKernel { int nnei = nloc > 0 ? nlist_tensor.shape().dim_size(1) / nloc : 0; // check the sizes OP_REQUIRES(context, (nframes == in_deriv_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES( context, (int_64(nloc) * ndescrpt * 3 == in_deriv_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + absl::InvalidArgumentError("number of descriptors should match")); // Create an output tensor TensorShape force_shape; force_shape.AddDim(nframes); @@ -176,15 +176,15 @@ class ProdForceSeROp : public OpKernel { const Tensor& natoms_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (net_deriv_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); const int* natoms = natoms_tensor.flat().data(); int nloc = natoms[0]; @@ -194,13 +194,14 @@ class ProdForceSeROp : public OpKernel { int nnei = nloc > 0 ? nlist_tensor.shape().dim_size(1) / nloc : 0; // check the sizes OP_REQUIRES(context, (nframes == in_deriv_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); - OP_REQUIRES(context, - (static_cast(nloc) * ndescrpt * 3 == - in_deriv_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + absl::InvalidArgumentError("number of samples should match")); + OP_REQUIRES( + context, + (static_cast(nloc) * ndescrpt * 3 == + in_deriv_tensor.shape().dim_size(1)), + absl::InvalidArgumentError("number of descriptors should match")); // Create an output tensor TensorShape force_shape; force_shape.AddDim(nframes); diff --git a/source/op/tf/prod_force_se_a_grad.cc b/source/op/tf/prod_force_se_a_grad.cc index 05e26b5058..2b45ba1bc0 100644 --- a/source/op/tf/prod_force_se_a_grad.cc +++ b/source/op/tf/prod_force_se_a_grad.cc @@ -46,18 +46,18 @@ class ProdForceSeAGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - errors::InvalidArgument("Dim of grad should be 2")); + absl::InvalidArgumentError("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -68,21 +68,22 @@ class ProdForceSeAGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES( context, (nloc * 3 == grad_shape.dim_size(1)), - errors::InvalidArgument("input grad shape should be 3 x natoms")); - OP_REQUIRES(context, - (static_cast(nloc) * ndescrpt * 3 == - in_deriv_shape.dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + absl::InvalidArgumentError("input grad shape should be 3 x natoms")); + OP_REQUIRES( + context, + (static_cast(nloc) * ndescrpt * 3 == + in_deriv_shape.dim_size(1)), + absl::InvalidArgumentError("number of descriptors should match")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - errors::InvalidArgument("number of neighbors should match")); + absl::InvalidArgumentError("number of neighbors should match")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/prod_force_se_a_mask.cc b/source/op/tf/prod_force_se_a_mask.cc index a7b08ae664..edea3ed397 100644 --- a/source/op/tf/prod_force_se_a_mask.cc +++ b/source/op/tf/prod_force_se_a_mask.cc @@ -37,13 +37,13 @@ class ProdForceSeAMaskOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (net_deriv_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (mask_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of mask matrix should be 2")); + absl::InvalidArgumentError("Dim of mask matrix should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); int nframes = net_deriv_tensor.shape().dim_size(0); int nloc = total_atom_num; @@ -53,13 +53,14 @@ class ProdForceSeAMaskOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == in_deriv_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); - OP_REQUIRES(context, - (static_cast(nloc) * ndescrpt * 3 == - in_deriv_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + absl::InvalidArgumentError("number of samples should match")); + OP_REQUIRES( + context, + (static_cast(nloc) * ndescrpt * 3 == + in_deriv_tensor.shape().dim_size(1)), + absl::InvalidArgumentError("number of descriptors should match")); // Create an output tensor TensorShape force_shape; diff --git a/source/op/tf/prod_force_se_a_mask_grad.cc b/source/op/tf/prod_force_se_a_mask_grad.cc index a01919199f..c4e7b8a2cc 100644 --- a/source/op/tf/prod_force_se_a_mask_grad.cc +++ b/source/op/tf/prod_force_se_a_mask_grad.cc @@ -43,15 +43,15 @@ class ProdForceSeAMaskGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - errors::InvalidArgument("Dim of grad should be 2")); + absl::InvalidArgumentError("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (mask_shape.dims() == 2), - errors::InvalidArgument("Dim of mask should be 2")); + absl::InvalidArgumentError("Dim of mask should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); int nframes = net_deriv_tensor.shape().dim_size(0); int nloc = total_atom_num; @@ -60,21 +60,22 @@ class ProdForceSeAMaskGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == mask_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES( context, (nloc * 3 == grad_shape.dim_size(1)), - errors::InvalidArgument("input grad shape should be 3 x natoms")); - OP_REQUIRES(context, - (static_cast(nloc) * ndescrpt * 3 == - in_deriv_shape.dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + absl::InvalidArgumentError("input grad shape should be 3 x natoms")); + OP_REQUIRES( + context, + (static_cast(nloc) * ndescrpt * 3 == + in_deriv_shape.dim_size(1)), + absl::InvalidArgumentError("number of descriptors should match")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/prod_force_se_r_grad.cc b/source/op/tf/prod_force_se_r_grad.cc index 44741d20fb..4f7cdb60e0 100644 --- a/source/op/tf/prod_force_se_r_grad.cc +++ b/source/op/tf/prod_force_se_r_grad.cc @@ -40,18 +40,18 @@ class ProdForceSeRGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - errors::InvalidArgument("Dim of grad should be 2")); + absl::InvalidArgumentError("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -62,19 +62,20 @@ class ProdForceSeRGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES( context, (nloc * 3 == grad_shape.dim_size(1)), - errors::InvalidArgument("input grad shape should be 3 x natoms")); - OP_REQUIRES(context, - (static_cast(nloc) * ndescrpt * 3 == - in_deriv_shape.dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + absl::InvalidArgumentError("input grad shape should be 3 x natoms")); + OP_REQUIRES( + context, + (static_cast(nloc) * ndescrpt * 3 == + in_deriv_shape.dim_size(1)), + absl::InvalidArgumentError("number of descriptors should match")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/prod_virial.cc b/source/op/tf/prod_virial.cc index 42e7be669d..288d78941f 100644 --- a/source/op/tf/prod_virial.cc +++ b/source/op/tf/prod_virial.cc @@ -43,20 +43,20 @@ class ProdVirialOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (net_deriv_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of rij should be 2")); + absl::InvalidArgumentError("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (axis_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of axis should be 2")); + absl::InvalidArgumentError("Dim of axis should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -68,27 +68,28 @@ class ProdVirialOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == in_deriv_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == rij_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == axis_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); - OP_REQUIRES(context, - (static_cast(nloc) * ndescrpt * 12 == - in_deriv_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + OP_REQUIRES( + context, + (static_cast(nloc) * ndescrpt * 12 == + in_deriv_tensor.shape().dim_size(1)), + absl::InvalidArgumentError("number of descriptors should match")); OP_REQUIRES(context, (static_cast(nloc) * nnei * 3 == rij_tensor.shape().dim_size(1)), - errors::InvalidArgument("dim of rij should be nnei * 3")); + absl::InvalidArgumentError("dim of rij should be nnei * 3")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - errors::InvalidArgument("number of neighbors should match")); + absl::InvalidArgumentError("number of neighbors should match")); OP_REQUIRES( context, (nloc * 4 == axis_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of axis type+id should be 2+2")); + absl::InvalidArgumentError("number of axis type+id should be 2+2")); // Create an output tensor TensorShape virial_shape; diff --git a/source/op/tf/prod_virial_grad.cc b/source/op/tf/prod_virial_grad.cc index a764e524a6..cd670dd2f4 100644 --- a/source/op/tf/prod_virial_grad.cc +++ b/source/op/tf/prod_virial_grad.cc @@ -49,22 +49,22 @@ class ProdVirialGradOp : public OpKernel { TensorShape axis_shape = axis_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - errors::InvalidArgument("Dim of grad should be 2")); + absl::InvalidArgumentError("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_shape.dims() == 2), - errors::InvalidArgument("Dim of rij should be 2")); + absl::InvalidArgumentError("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (axis_shape.dims() == 2), - errors::InvalidArgument("Dim of axis should be 2")); + absl::InvalidArgumentError("Dim of axis should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -75,32 +75,33 @@ class ProdVirialGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == rij_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == axis_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES( context, (9 == grad_shape.dim_size(1)), - errors::InvalidArgument("input grad shape should be 3 x natoms")); - OP_REQUIRES(context, - (static_cast(nloc) * ndescrpt * 12 == - in_deriv_shape.dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + absl::InvalidArgumentError("input grad shape should be 3 x natoms")); + OP_REQUIRES( + context, + (static_cast(nloc) * ndescrpt * 12 == + in_deriv_shape.dim_size(1)), + absl::InvalidArgumentError("number of descriptors should match")); OP_REQUIRES( context, (static_cast(nloc) * nnei * 3 == rij_shape.dim_size(1)), - errors::InvalidArgument("dim of rij should be nnei * 3")); + absl::InvalidArgumentError("dim of rij should be nnei * 3")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - errors::InvalidArgument("number of neighbors should match")); + absl::InvalidArgumentError("number of neighbors should match")); OP_REQUIRES( context, (nloc * 4 == axis_shape.dim_size(1)), - errors::InvalidArgument("number of axis type+id should be 2+2")); + absl::InvalidArgumentError("number of axis type+id should be 2+2")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/prod_virial_grad_multi_device.cc b/source/op/tf/prod_virial_grad_multi_device.cc index 3d8d2a96b3..490f47c2c2 100644 --- a/source/op/tf/prod_virial_grad_multi_device.cc +++ b/source/op/tf/prod_virial_grad_multi_device.cc @@ -57,20 +57,20 @@ class ProdVirialSeAGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - errors::InvalidArgument("Dim of grad should be 2")); + absl::InvalidArgumentError("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_shape.dims() == 2), - errors::InvalidArgument("Dim of rij should be 2")); + absl::InvalidArgumentError("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -81,24 +81,24 @@ class ProdVirialSeAGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == rij_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES( context, (9 == grad_shape.dim_size(1)), - errors::InvalidArgument("input grad shape should be 3 x natoms")); - OP_REQUIRES(context, - (int_64(nloc) * ndescrpt * 3 == in_deriv_shape.dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + absl::InvalidArgumentError("input grad shape should be 3 x natoms")); + OP_REQUIRES( + context, (int_64(nloc) * ndescrpt * 3 == in_deriv_shape.dim_size(1)), + absl::InvalidArgumentError("number of descriptors should match")); OP_REQUIRES(context, (int_64(nloc) * nnei * 3 == rij_shape.dim_size(1)), - errors::InvalidArgument("dim of rij should be nnei * 3")); + absl::InvalidArgumentError("dim of rij should be nnei * 3")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - errors::InvalidArgument("number of neighbors should match")); + absl::InvalidArgumentError("number of neighbors should match")); // Create an output tensor TensorShape grad_net_shape; @@ -191,20 +191,20 @@ class ProdVirialSeRGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - errors::InvalidArgument("Dim of grad should be 2")); + absl::InvalidArgumentError("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_shape.dims() == 2), - errors::InvalidArgument("Dim of rij should be 2")); + absl::InvalidArgumentError("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -215,22 +215,22 @@ class ProdVirialSeRGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == rij_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES( context, (9 == grad_shape.dim_size(1)), - errors::InvalidArgument("input grad shape should be 3 x natoms")); - OP_REQUIRES(context, - (int_64(nloc) * ndescrpt * 3 == in_deriv_shape.dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + absl::InvalidArgumentError("input grad shape should be 3 x natoms")); + OP_REQUIRES( + context, (int_64(nloc) * ndescrpt * 3 == in_deriv_shape.dim_size(1)), + absl::InvalidArgumentError("number of descriptors should match")); OP_REQUIRES(context, (int_64(nloc) * nnei * 3 == rij_shape.dim_size(1)), - errors::InvalidArgument("dim of rij should be nnei * 3")); + absl::InvalidArgumentError("dim of rij should be nnei * 3")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/prod_virial_multi_device.cc b/source/op/tf/prod_virial_multi_device.cc index a544b010c5..99f8d6c93d 100644 --- a/source/op/tf/prod_virial_multi_device.cc +++ b/source/op/tf/prod_virial_multi_device.cc @@ -55,17 +55,17 @@ class ProdVirialSeAOp : public OpKernel { const Tensor& natoms_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (net_deriv_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of rij should be 2")); + absl::InvalidArgumentError("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); const int* natoms = natoms_tensor.flat().data(); int nloc = natoms[0]; @@ -75,18 +75,18 @@ class ProdVirialSeAOp : public OpKernel { int ndescrpt = nloc > 0 ? net_deriv_tensor.shape().dim_size(1) / nloc : 0; // check the sizes OP_REQUIRES(context, (nframes == in_deriv_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == rij_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES( context, (int_64(nloc) * ndescrpt * 3 == in_deriv_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + absl::InvalidArgumentError("number of descriptors should match")); OP_REQUIRES(context, (int_64(nloc) * nnei * 3 == rij_tensor.shape().dim_size(1)), - errors::InvalidArgument("dim of rij should be nnei * 3")); + absl::InvalidArgumentError("dim of rij should be nnei * 3")); // Create an output tensor TensorShape virial_shape; virial_shape.AddDim(nframes); @@ -154,17 +154,17 @@ class ProdVirialSeROp : public OpKernel { const Tensor& natoms_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (net_deriv_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of rij should be 2")); + absl::InvalidArgumentError("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); const int* natoms = natoms_tensor.flat().data(); int nloc = natoms[0]; @@ -174,18 +174,18 @@ class ProdVirialSeROp : public OpKernel { int ndescrpt = nloc > 0 ? net_deriv_tensor.shape().dim_size(1) / nloc : 0; // check the sizes OP_REQUIRES(context, (nframes == in_deriv_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == rij_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES( context, (int_64(nloc) * ndescrpt * 3 == in_deriv_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + absl::InvalidArgumentError("number of descriptors should match")); OP_REQUIRES(context, (int_64(nloc) * nnei * 3 == rij_tensor.shape().dim_size(1)), - errors::InvalidArgument("dim of rij should be nnei * 3")); + absl::InvalidArgumentError("dim of rij should be nnei * 3")); // Create an output tensor TensorShape virial_shape; virial_shape.AddDim(nframes); diff --git a/source/op/tf/prod_virial_se_a_grad.cc b/source/op/tf/prod_virial_se_a_grad.cc index e3a9374b8f..3494dbbc63 100644 --- a/source/op/tf/prod_virial_se_a_grad.cc +++ b/source/op/tf/prod_virial_se_a_grad.cc @@ -49,20 +49,20 @@ class ProdVirialSeAGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - errors::InvalidArgument("Dim of grad should be 2")); + absl::InvalidArgumentError("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_shape.dims() == 2), - errors::InvalidArgument("Dim of rij should be 2")); + absl::InvalidArgumentError("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -73,27 +73,28 @@ class ProdVirialSeAGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == rij_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES( context, (9 == grad_shape.dim_size(1)), - errors::InvalidArgument("input grad shape should be 3 x natoms")); - OP_REQUIRES(context, - (static_cast(nloc) * ndescrpt * 3 == - in_deriv_shape.dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + absl::InvalidArgumentError("input grad shape should be 3 x natoms")); + OP_REQUIRES( + context, + (static_cast(nloc) * ndescrpt * 3 == + in_deriv_shape.dim_size(1)), + absl::InvalidArgumentError("number of descriptors should match")); OP_REQUIRES( context, (static_cast(nloc) * nnei * 3 == rij_shape.dim_size(1)), - errors::InvalidArgument("dim of rij should be nnei * 3")); + absl::InvalidArgumentError("dim of rij should be nnei * 3")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - errors::InvalidArgument("number of neighbors should match")); + absl::InvalidArgumentError("number of neighbors should match")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/prod_virial_se_r_grad.cc b/source/op/tf/prod_virial_se_r_grad.cc index 8e9b2c25b0..3cdd3f7382 100644 --- a/source/op/tf/prod_virial_se_r_grad.cc +++ b/source/op/tf/prod_virial_se_r_grad.cc @@ -43,20 +43,20 @@ class ProdVirialSeRGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - errors::InvalidArgument("Dim of grad should be 2")); + absl::InvalidArgumentError("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_shape.dims() == 2), - errors::InvalidArgument("Dim of rij should be 2")); + absl::InvalidArgumentError("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -67,25 +67,26 @@ class ProdVirialSeRGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == rij_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES( context, (9 == grad_shape.dim_size(1)), - errors::InvalidArgument("input grad shape should be 3 x natoms")); - OP_REQUIRES(context, - (static_cast(nloc) * ndescrpt * 3 == - in_deriv_shape.dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + absl::InvalidArgumentError("input grad shape should be 3 x natoms")); + OP_REQUIRES( + context, + (static_cast(nloc) * ndescrpt * 3 == + in_deriv_shape.dim_size(1)), + absl::InvalidArgumentError("number of descriptors should match")); OP_REQUIRES( context, (static_cast(nloc) * nnei * 3 == rij_shape.dim_size(1)), - errors::InvalidArgument("dim of rij should be nnei * 3")); + absl::InvalidArgumentError("dim of rij should be nnei * 3")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/soft_min.cc b/source/op/tf/soft_min.cc index 07c7404bbf..0ec4787d7d 100644 --- a/source/op/tf/soft_min.cc +++ b/source/op/tf/soft_min.cc @@ -52,16 +52,16 @@ class SoftMinSwitchOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of type should be 2")); + absl::InvalidArgumentError("Dim of type should be 2")); OP_REQUIRES(context, (rij_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of rij should be 2")); + absl::InvalidArgumentError("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -74,22 +74,22 @@ class SoftMinSwitchOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == type_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == rij_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - errors::InvalidArgument("shape of type should be nall")); + absl::InvalidArgumentError("shape of type should be nall")); OP_REQUIRES( context, (3 * static_cast(nnei) * nloc == rij_tensor.shape().dim_size(1)), - errors::InvalidArgument("shape of rij should be 3 * nloc * nnei")); + absl::InvalidArgumentError("shape of rij should be 3 * nloc * nnei")); OP_REQUIRES( context, (static_cast(nnei) * nloc == nlist_tensor.shape().dim_size(1)), - errors::InvalidArgument("shape of nlist should be nloc * nnei")); + absl::InvalidArgumentError("shape of nlist should be nloc * nnei")); // Create an output tensor TensorShape sw_value_shape; diff --git a/source/op/tf/soft_min_force.cc b/source/op/tf/soft_min_force.cc index 14cb42b993..89c3dc09d4 100644 --- a/source/op/tf/soft_min_force.cc +++ b/source/op/tf/soft_min_force.cc @@ -38,16 +38,16 @@ class SoftMinForceOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (du_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of du should be 2")); + absl::InvalidArgumentError("Dim of du should be 2")); OP_REQUIRES(context, (sw_deriv_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of switch deriv should be 2")); + absl::InvalidArgumentError("Dim of switch deriv should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -58,18 +58,19 @@ class SoftMinForceOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == sw_deriv_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nloc == du_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of du should match")); - OP_REQUIRES(context, - (static_cast(nloc) * nnei * 3 == - sw_deriv_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of switch deriv should match")); + absl::InvalidArgumentError("number of du should match")); + OP_REQUIRES( + context, + (static_cast(nloc) * nnei * 3 == + sw_deriv_tensor.shape().dim_size(1)), + absl::InvalidArgumentError("number of switch deriv should match")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - errors::InvalidArgument("number of neighbors should match")); + absl::InvalidArgumentError("number of neighbors should match")); // Create an output tensor TensorShape force_shape; diff --git a/source/op/tf/soft_min_force_grad.cc b/source/op/tf/soft_min_force_grad.cc index e173586d22..a79e5a51d6 100644 --- a/source/op/tf/soft_min_force_grad.cc +++ b/source/op/tf/soft_min_force_grad.cc @@ -45,18 +45,18 @@ class SoftMinForceGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - errors::InvalidArgument("Dim of grad should be 2")); + absl::InvalidArgumentError("Dim of grad should be 2")); OP_REQUIRES(context, (du_shape.dims() == 2), - errors::InvalidArgument("Dim of du should be 2")); + absl::InvalidArgumentError("Dim of du should be 2")); OP_REQUIRES(context, (sw_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of sw deriv should be 2")); + absl::InvalidArgumentError("Dim of sw deriv should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -66,23 +66,23 @@ class SoftMinForceGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == sw_deriv_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nloc == du_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of du should match")); + absl::InvalidArgumentError("number of du should match")); OP_REQUIRES( context, (nloc * 3 == grad_shape.dim_size(1)), - errors::InvalidArgument("input grad shape should be 3 x natoms")); + absl::InvalidArgumentError("input grad shape should be 3 x natoms")); OP_REQUIRES( context, (static_cast(nloc) * nnei * 3 == sw_deriv_shape.dim_size(1)), - errors::InvalidArgument("number of sw deriv should match")); + absl::InvalidArgumentError("number of sw deriv should match")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - errors::InvalidArgument("number of neighbors should match")); + absl::InvalidArgumentError("number of neighbors should match")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/soft_min_virial.cc b/source/op/tf/soft_min_virial.cc index 6c0e1f72f3..d9b17c3d5f 100644 --- a/source/op/tf/soft_min_virial.cc +++ b/source/op/tf/soft_min_virial.cc @@ -42,18 +42,18 @@ class SoftMinVirialOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (du_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (sw_deriv_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of rij should be 2")); + absl::InvalidArgumentError("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -64,24 +64,24 @@ class SoftMinVirialOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == sw_deriv_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == rij_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - errors::InvalidArgument("number of samples should match")); + absl::InvalidArgumentError("number of samples should match")); OP_REQUIRES(context, (nloc == du_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of du should match")); + absl::InvalidArgumentError("number of du should match")); OP_REQUIRES(context, (static_cast(nloc) * nnei * 3 == sw_deriv_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of sw_deriv should match")); + absl::InvalidArgumentError("number of sw_deriv should match")); OP_REQUIRES(context, (static_cast(nloc) * nnei * 3 == rij_tensor.shape().dim_size(1)), - errors::InvalidArgument("dim of rij should be nnei * 3")); + absl::InvalidArgumentError("dim of rij should be nnei * 3")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - errors::InvalidArgument("number of neighbors should match")); + absl::InvalidArgumentError("number of neighbors should match")); // Create an output tensor TensorShape virial_shape; diff --git a/source/op/tf/soft_min_virial_grad.cc b/source/op/tf/soft_min_virial_grad.cc index ac129b29af..adfc281236 100644 --- a/source/op/tf/soft_min_virial_grad.cc +++ b/source/op/tf/soft_min_virial_grad.cc @@ -48,20 +48,20 @@ class SoftMinVirialGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - errors::InvalidArgument("Dim of grad should be 2")); + absl::InvalidArgumentError("Dim of grad should be 2")); OP_REQUIRES(context, (du_shape.dims() == 2), - errors::InvalidArgument("Dim of net deriv should be 2")); + absl::InvalidArgumentError("Dim of net deriv should be 2")); OP_REQUIRES(context, (sw_deriv_shape.dims() == 2), - errors::InvalidArgument("Dim of input deriv should be 2")); + absl::InvalidArgumentError("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_shape.dims() == 2), - errors::InvalidArgument("Dim of rij should be 2")); + absl::InvalidArgumentError("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - errors::InvalidArgument("Dim of nlist should be 2")); + absl::InvalidArgumentError("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - errors::InvalidArgument("Dim of natoms should be 1")); + absl::InvalidArgumentError("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - errors::InvalidArgument( + absl::InvalidArgumentError( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -71,29 +71,29 @@ class SoftMinVirialGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == sw_deriv_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == rij_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - errors::InvalidArgument("number of frames should match")); + absl::InvalidArgumentError("number of frames should match")); OP_REQUIRES( context, (9 == grad_shape.dim_size(1)), - errors::InvalidArgument("input grad shape should be 3 x natoms")); + absl::InvalidArgumentError("input grad shape should be 3 x natoms")); OP_REQUIRES(context, (nloc == du_tensor.shape().dim_size(1)), - errors::InvalidArgument("number of du should match")); + absl::InvalidArgumentError("number of du should match")); OP_REQUIRES( context, (static_cast(nloc) * nnei * 3 == sw_deriv_shape.dim_size(1)), - errors::InvalidArgument("number of descriptors should match")); + absl::InvalidArgumentError("number of descriptors should match")); OP_REQUIRES( context, (static_cast(nloc) * nnei * 3 == rij_shape.dim_size(1)), - errors::InvalidArgument("dim of rij should be nnei * 3")); + absl::InvalidArgumentError("dim of rij should be nnei * 3")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - errors::InvalidArgument("number of neighbors should match")); + absl::InvalidArgumentError("number of neighbors should match")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/tabulate_multi_device.cc b/source/op/tf/tabulate_multi_device.cc index 50267df556..7b6b336f99 100644 --- a/source/op/tf/tabulate_multi_device.cc +++ b/source/op/tf/tabulate_multi_device.cc @@ -184,11 +184,11 @@ class TabulateFusionSeAOp : public OpKernel { const Tensor& em_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (table_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of table should be 2")); + absl::InvalidArgumentError("Dim of table should be 2")); OP_REQUIRES(context, (em_x_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); OP_REQUIRES(context, (em_tensor.shape().dims() == 3), - errors::InvalidArgument("Dim of input should be 3")); + absl::InvalidArgumentError("Dim of input should be 3")); TensorShape descriptor_shape; descriptor_shape.AddDim(em_tensor.shape().dim_size(0)); descriptor_shape.AddDim(4); // be careful here; @@ -247,7 +247,7 @@ class TabulateFusionSeAGradOp : public OpKernel { const Tensor& descriptor_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (dy_tensor.shape().dims() == 3), - errors::InvalidArgument("Dim of table should be 3")); + absl::InvalidArgumentError("Dim of table should be 3")); int context_output_index = 0; Tensor* dy_dem_x_tensor = NULL; OP_REQUIRES_OK(context, context->allocate_output(context_output_index++, @@ -311,9 +311,9 @@ class TabulateFusionSeAGradGradOp : public OpKernel { const Tensor& descriptor_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (dz_dy_dem_x_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); OP_REQUIRES(context, (dz_dy_dem_tensor.shape().dims() == 3), - errors::InvalidArgument("Dim of input should be 3")); + absl::InvalidArgumentError("Dim of input should be 3")); int context_output_index = 0; Tensor* dz_dy_tensor = NULL; OP_REQUIRES_OK(context, context->allocate_output(context_output_index++, @@ -342,7 +342,7 @@ class TabulateFusionSeAGradGradOp : public OpKernel { dz_dy_dtwo, nloc, nnei, last_layer_size, is_sorted); #endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM OP_REQUIRES(context, (last_layer_size <= 1024), - errors::InvalidArgument( + absl::InvalidArgumentError( "In the process of model compression, the size of the " "last layer of embedding net must be less than 1024!")); } else if (device == "CPU") { @@ -381,13 +381,13 @@ class TabulateFusionSeAttenOp : public OpKernel { const Tensor& two_embed_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (table_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of table should be 2")); + absl::InvalidArgumentError("Dim of table should be 2")); OP_REQUIRES(context, (em_x_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); OP_REQUIRES(context, (em_tensor.shape().dims() == 3), - errors::InvalidArgument("Dim of input should be 3")); + absl::InvalidArgumentError("Dim of input should be 3")); OP_REQUIRES(context, (two_embed_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); TensorShape descriptor_shape; descriptor_shape.AddDim(em_tensor.shape().dim_size(0)); descriptor_shape.AddDim(4); // be careful here; @@ -452,7 +452,7 @@ class TabulateFusionSeAttenGradOp : public OpKernel { const Tensor& descriptor_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (dy_tensor.shape().dims() == 3), - errors::InvalidArgument("Dim of table should be 3")); + absl::InvalidArgumentError("Dim of table should be 3")); int context_output_index = 0; Tensor* dy_dem_x_tensor = NULL; OP_REQUIRES_OK(context, context->allocate_output(context_output_index++, @@ -528,9 +528,9 @@ class TabulateFusionSeAttenGradGradOp : public OpKernel { const Tensor& descriptor_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (dz_dy_dem_x_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); OP_REQUIRES(context, (dz_dy_dem_tensor.shape().dims() == 3), - errors::InvalidArgument("Dim of input should be 3")); + absl::InvalidArgumentError("Dim of input should be 3")); int context_output_index = 0; Tensor* dz_dy_tensor = NULL; OP_REQUIRES_OK(context, context->allocate_output(context_output_index++, @@ -559,7 +559,7 @@ class TabulateFusionSeAttenGradGradOp : public OpKernel { dz_dy_dtwo, nloc, nnei, last_layer_size, is_sorted); #endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM OP_REQUIRES(context, (last_layer_size <= 1024), - errors::InvalidArgument( + absl::InvalidArgumentError( "In the process of model compression, the size of the " "last layer of embedding net must be less than 1024!")); } else if (device == "CPU") { @@ -596,11 +596,11 @@ class TabulateFusionSeTOp : public OpKernel { const Tensor& em_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (table_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of table should be 2")); + absl::InvalidArgumentError("Dim of table should be 2")); OP_REQUIRES(context, (em_x_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of em_x_tensor should be 2")); + absl::InvalidArgumentError("Dim of em_x_tensor should be 2")); OP_REQUIRES(context, (em_tensor.shape().dims() == 3), - errors::InvalidArgument("Dim of em_tensor should be 3")); + absl::InvalidArgumentError("Dim of em_tensor should be 3")); TensorShape descriptor_shape; descriptor_shape.AddDim(em_tensor.shape().dim_size(0)); descriptor_shape.AddDim(last_layer_size); @@ -657,7 +657,7 @@ class TabulateFusionSeTGradOp : public OpKernel { const Tensor& descriptor_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (dy_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of dy_tensor should be 2")); + absl::InvalidArgumentError("Dim of dy_tensor should be 2")); int context_output_index = 0; Tensor* dy_dem_x_tensor = NULL; OP_REQUIRES_OK(context, context->allocate_output(context_output_index++, @@ -717,9 +717,9 @@ class TabulateFusionSeTGradGradOp : public OpKernel { const Tensor& descriptor_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (dz_dy_dem_x_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); OP_REQUIRES(context, (dz_dy_dem_tensor.shape().dims() == 3), - errors::InvalidArgument("Dim of input should be 3")); + absl::InvalidArgumentError("Dim of input should be 3")); int context_output_index = 0; Tensor* dz_dy_tensor = NULL; OP_REQUIRES_OK(context, context->allocate_output(context_output_index++, @@ -747,7 +747,7 @@ class TabulateFusionSeTGradGradOp : public OpKernel { nnei_i, nnei_j, last_layer_size); #endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM OP_REQUIRES(context, (last_layer_size <= 1024), - errors::InvalidArgument( + absl::InvalidArgumentError( "In the process of model compression, the size of the " "last layer of embedding net must be less than 1024!")); } else if (device == "CPU") { @@ -781,9 +781,9 @@ class TabulateFusionSeROp : public OpKernel { const Tensor& em_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (table_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of table should be 2")); + absl::InvalidArgumentError("Dim of table should be 2")); OP_REQUIRES(context, (em_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); TensorShape descriptor_shape; descriptor_shape.AddDim(em_tensor.shape().dim_size(0)); descriptor_shape.AddDim(em_tensor.shape().dim_size(1)); // be careful here; @@ -838,7 +838,7 @@ class TabulateFusionSeRGradOp : public OpKernel { const Tensor& descriptor_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (dy_tensor.shape().dims() == 3), - errors::InvalidArgument("Dim of table should be 3")); + absl::InvalidArgumentError("Dim of table should be 3")); int context_output_index = 0; Tensor* dy_dem_tensor = NULL; OP_REQUIRES_OK(context, @@ -887,7 +887,7 @@ class TabulateFusionSeRGradGradOp : public OpKernel { const Tensor& descriptor_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (dz_dy_dem_tensor.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); int context_output_index = 0; Tensor* dz_dy_tensor = NULL; OP_REQUIRES_OK(context, context->allocate_output(context_output_index++, @@ -911,7 +911,7 @@ class TabulateFusionSeRGradGradOp : public OpKernel { dz_dy, table, table_info, em, dz_dy_dem, nloc, nnei, last_layer_size); #endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM OP_REQUIRES(context, (last_layer_size <= 1024), - errors::InvalidArgument( + absl::InvalidArgumentError( "In the process of model compression, the size of the " "last layer of embedding net must be less than 1024!")); } else if (device == "CPU") { diff --git a/source/op/tf/unaggregated_grad.cc b/source/op/tf/unaggregated_grad.cc index cf645f6c21..d0bd3c1dfd 100644 --- a/source/op/tf/unaggregated_grad.cc +++ b/source/op/tf/unaggregated_grad.cc @@ -305,11 +305,11 @@ class UnaggregatedDyDxSOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (y.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); OP_REQUIRES(context, (w.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); OP_REQUIRES(context, (xbar.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); // check functype int context_output_index = 0; @@ -351,13 +351,13 @@ class UnaggregatedDy2DxSOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (y.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); OP_REQUIRES(context, (dy.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); OP_REQUIRES(context, (w.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); OP_REQUIRES(context, (xbar.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); int context_output_index = 0; Tensor* dy2_dx = NULL; @@ -398,13 +398,13 @@ class UnaggregatedDyDxOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (z.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); OP_REQUIRES(context, (w.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); OP_REQUIRES(context, (dy_dx.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); OP_REQUIRES(context, (ybar.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); int context_output_index = 0; Tensor* dz_dx = NULL; @@ -448,15 +448,15 @@ class UnaggregatedDy2DxOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (z.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); OP_REQUIRES(context, (w.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); OP_REQUIRES(context, (dy_dx.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); OP_REQUIRES(context, (dy2_dx.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); OP_REQUIRES(context, (ybar.shape().dims() == 2), - errors::InvalidArgument("Dim of input should be 2")); + absl::InvalidArgumentError("Dim of input should be 2")); int context_output_index = 0; Tensor* dz2_dx = NULL; From fb2e34dc3cfc9d27393b699900f19e9996f7abcb Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 14 Aug 2025 18:39:23 +0800 Subject: [PATCH 06/17] raise error if not found Signed-off-by: Jinzhe Zeng --- backend/find_tensorflow.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/find_tensorflow.py b/backend/find_tensorflow.py index 404973fce2..782302a495 100644 --- a/backend/find_tensorflow.py +++ b/backend/find_tensorflow.py @@ -57,6 +57,10 @@ def find_tensorflow() -> tuple[Optional[str], list[str]]: ) is not None: site_packages = Path(os.environ.get("TENSORFLOW_ROOT")).parent.absolute() tf_spec = FileFinder(str(site_packages)).find_spec("tensorflow") + if tf_spec is None: + raise RuntimeError( + f"cannot find TensorFlow under TENSORFLOW_ROOT {os.environ.get('TENSORFLOW_ROOT')}" + ) # get tensorflow spec # note: isolated build will not work for backend From 0c1b5e72afa53b6dc092910e41fc276e3170e8d5 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 14 Aug 2025 18:43:50 +0800 Subject: [PATCH 07/17] fix import importlib.util Signed-off-by: Jinzhe Zeng --- .devcontainer/build_cxx.sh | 2 +- .devcontainer/gdb_lmp | 2 +- .devcontainer/gdb_pytest_lmp | 2 +- .devcontainer/lmp | 2 +- .devcontainer/pytest_lmp | 2 +- .github/workflows/test_cc.yml | 2 +- .github/workflows/test_cuda.yml | 2 +- .github/workflows/test_python.yml | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.devcontainer/build_cxx.sh b/.devcontainer/build_cxx.sh index 432d7d32db..109d2d7d21 100755 --- a/.devcontainer/build_cxx.sh +++ b/.devcontainer/build_cxx.sh @@ -5,7 +5,7 @@ NPROC=$(nproc --all) SCRIPT_PATH=$(dirname $(realpath -s $0)) export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch -TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') +TENSORFLOW_ROOT=$(python -c 'import importlib.util,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') mkdir -p ${SCRIPT_PATH}/../buildcxx/ cd ${SCRIPT_PATH}/../buildcxx/ diff --git a/.devcontainer/gdb_lmp b/.devcontainer/gdb_lmp index 33e883780b..fc1c8b90fe 100755 --- a/.devcontainer/gdb_lmp +++ b/.devcontainer/gdb_lmp @@ -2,7 +2,7 @@ SCRIPT_PATH=$(dirname $(realpath -s $0)) export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch -TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') +TENSORFLOW_ROOT=$(python -c 'import importlib.util,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') env LAMMPS_PLUGIN_PATH=${SCRIPT_PATH}/../dp/lib/deepmd_lmp \ LD_LIBRARY_PATH=${SCRIPT_PATH}/../dp/lib:${CMAKE_PREFIX_PATH}/lib:${TENSORFLOW_ROOT} \ diff --git a/.devcontainer/gdb_pytest_lmp b/.devcontainer/gdb_pytest_lmp index e27e40d4b0..d27587ec43 100755 --- a/.devcontainer/gdb_pytest_lmp +++ b/.devcontainer/gdb_pytest_lmp @@ -2,7 +2,7 @@ SCRIPT_PATH=$(dirname $(realpath -s $0))/../.. export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch -TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') +TENSORFLOW_ROOT=$(python -c 'import importlib.util,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') env LAMMPS_PLUGIN_PATH=${SCRIPT_PATH}/../dp/lib/deepmd_lmp \ LD_LIBRARY_PATH=${SCRIPT_PATH}/../dp/lib:${CMAKE_PREFIX_PATH}/lib:${TENSORFLOW_ROOT} \ diff --git a/.devcontainer/lmp b/.devcontainer/lmp index c8e781aa57..524f99b326 100755 --- a/.devcontainer/lmp +++ b/.devcontainer/lmp @@ -2,7 +2,7 @@ SCRIPT_PATH=$(dirname $(realpath -s $0)) export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch -TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') +TENSORFLOW_ROOT=$(python -c 'import importlib.util,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') env LAMMPS_PLUGIN_PATH=${SCRIPT_PATH}/../dp/lib/deepmd_lmp \ LD_LIBRARY_PATH=${SCRIPT_PATH}/../dp/lib:${CMAKE_PREFIX_PATH}/lib:${TENSORFLOW_ROOT} \ diff --git a/.devcontainer/pytest_lmp b/.devcontainer/pytest_lmp index 9371ba72d5..bb88da883f 100755 --- a/.devcontainer/pytest_lmp +++ b/.devcontainer/pytest_lmp @@ -2,7 +2,7 @@ SCRIPT_PATH=$(dirname $(realpath -s $0))/../.. export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch -TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') +TENSORFLOW_ROOT=$(python -c 'import importlib.util,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') env LAMMPS_PLUGIN_PATH=${SCRIPT_PATH}/../dp/lib/deepmd_lmp \ LD_LIBRARY_PATH=${SCRIPT_PATH}/../dp/lib:${CMAKE_PREFIX_PATH}/lib:${TENSORFLOW_ROOT} \ diff --git a/.github/workflows/test_cc.yml b/.github/workflows/test_cc.yml index 7d76e60ba1..e2c446a64d 100644 --- a/.github/workflows/test_cc.yml +++ b/.github/workflows/test_cc.yml @@ -26,7 +26,7 @@ jobs: - name: Install Python dependencies run: | source/install/uv_with_retry.sh pip install --system tensorflow-cpu~=2.18.0 jax==0.5.0 - export TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') + export TENSORFLOW_ROOT=$(python -c 'import importlib.util,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') source/install/uv_with_retry.sh pip install --system -e .[cpu,test,lmp,jax] mpi4py mpich source/install/uv_with_retry.sh pip install --system 'torch==2.7' --index-url https://download.pytorch.org/whl/cpu - name: Convert models diff --git a/.github/workflows/test_cuda.yml b/.github/workflows/test_cuda.yml index 14c051123c..b527a5481f 100644 --- a/.github/workflows/test_cuda.yml +++ b/.github/workflows/test_cuda.yml @@ -46,7 +46,7 @@ jobs: - run: source/install/uv_with_retry.sh pip install --system "tensorflow~=2.18.0rc2" "torch~=2.7.0" "jax[cuda12]==0.5.0" - run: | export PYTORCH_ROOT=$(python -c 'import torch;print(torch.__path__[0])') - export TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') + export TENSORFLOW_ROOT=$(python -c 'import importlib.util,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') pip install "paddlepaddle-gpu==3.0.0" -i https://www.paddlepaddle.org.cn/packages/stable/cu126/ source/install/uv_with_retry.sh pip install --system -v -e .[gpu,test,lmp,cu12,torch,jax] mpi4py --reinstall-package deepmd-kit env: diff --git a/.github/workflows/test_python.yml b/.github/workflows/test_python.yml index 4441cca564..ec21fbc669 100644 --- a/.github/workflows/test_python.yml +++ b/.github/workflows/test_python.yml @@ -27,7 +27,7 @@ jobs: - run: | source/install/uv_with_retry.sh pip install --system openmpi tensorflow-cpu~=2.18.0 source/install/uv_with_retry.sh pip install --system torch -i https://download.pytorch.org/whl/cpu - export TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') + export TENSORFLOW_ROOT=$(python -c 'import importlib.util,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)') export PYTORCH_ROOT=$(python -c 'import torch;print(torch.__path__[0])') source/install/uv_with_retry.sh pip install --system -e .[test,jax] mpi4py "jax==0.5.0;python_version>='3.10'" source/install/uv_with_retry.sh pip install --system -U setuptools From dc757b7fec6c2e54b9b16620f6bf2e484451d820 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 14 Aug 2025 19:08:00 +0800 Subject: [PATCH 08/17] add_definitions Signed-off-by: Jinzhe Zeng --- source/cmake/Findtensorflow.cmake | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/source/cmake/Findtensorflow.cmake b/source/cmake/Findtensorflow.cmake index 880b9be3f3..f4d13e1a75 100644 --- a/source/cmake/Findtensorflow.cmake +++ b/source/cmake/Findtensorflow.cmake @@ -306,6 +306,23 @@ if(NOT DEFINED TENSORFLOW_VERSION) endif() endif() +if(TENSORFLOW_VERSION VERSION_GREATER_EQUAL 2.20) + # since TF 2.20, macros like TF_MAJOR_VERSION, TF_MINOR_VERSION, and + # TF_PATCH_VERSION are not defined We manuanlly define them in our CMake files + # firstly, split TENSORFLOW_VERSION (e.g. 2.20.0rc0) to 2 20 0 rc0 + string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)$" _match + ${TENSORFLOW_VERSION}) + if(_match) + set(TF_MAJOR_VERSION ${CMAKE_MATCH_1}) + set(TF_MINOR_VERSION ${CMAKE_MATCH_2}) + set(TF_PATCH_VERSION ${CMAKE_MATCH_3}) + # add defines + add_definitions(-DTF_MAJOR_VERSION=${TF_MAJOR_VERSION}) + add_definitions(-DTF_MINOR_VERSION=${TF_MINOR_VERSION}) + add_definitions(-DTF_PATCH_VERSION=${TF_PATCH_VERSION}) + endif() +endif() + # print message if(NOT TensorFlow_FIND_QUIETLY) message( From 5752d676c76f232df2701748400be5a79ad705b4 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 14 Aug 2025 19:33:44 +0800 Subject: [PATCH 09/17] try to fix win Signed-off-by: Jinzhe Zeng --- source/cmake/Findtensorflow.cmake | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/cmake/Findtensorflow.cmake b/source/cmake/Findtensorflow.cmake index f4d13e1a75..e852cea117 100644 --- a/source/cmake/Findtensorflow.cmake +++ b/source/cmake/Findtensorflow.cmake @@ -144,7 +144,13 @@ endif(BUILD_CPP_IF) # tensorflow_framework if(NOT TensorFlowFramework_FIND_COMPONENTS) if(WIN32) - set(TensorFlowFramework_FIND_COMPONENTS _pywrap_tensorflow_internal) + if(TENSORFLOW_VERSION VERSION_GREATER_EQUAL 2.20) + # in TF 2.20, _pywrap_tensorflow_internal.lib is missing, but + # tensorflow_framework.2.dll is given + set(TensorFlowFramework_FIND_COMPONENTS tensorflow_framework) + else() + set(TensorFlowFramework_FIND_COMPONENTS _pywrap_tensorflow_internal) + endif() set(TF_SUFFIX "") else() set(TensorFlowFramework_FIND_COMPONENTS tensorflow_framework) @@ -154,6 +160,8 @@ endif() # the lib if(WIN32) list(APPEND TensorFlow_search_PATHS ${TENSORFLOW_ROOT}/python) + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .2.dll) + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .2.dll.if.lib) elseif(APPLE) list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .2.dylib) else() From 4862beb79b0e5403891d8dfc0ec77e77645f86ab Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 14 Aug 2025 19:45:44 +0800 Subject: [PATCH 10/17] link lib Signed-off-by: Jinzhe Zeng --- source/cmake/Findtensorflow.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/cmake/Findtensorflow.cmake b/source/cmake/Findtensorflow.cmake index e852cea117..9102b42b61 100644 --- a/source/cmake/Findtensorflow.cmake +++ b/source/cmake/Findtensorflow.cmake @@ -146,7 +146,7 @@ if(NOT TensorFlowFramework_FIND_COMPONENTS) if(WIN32) if(TENSORFLOW_VERSION VERSION_GREATER_EQUAL 2.20) # in TF 2.20, _pywrap_tensorflow_internal.lib is missing, but - # tensorflow_framework.2.dll is given + # tensorflow_framework.2.dll.if.lib is given set(TensorFlowFramework_FIND_COMPONENTS tensorflow_framework) else() set(TensorFlowFramework_FIND_COMPONENTS _pywrap_tensorflow_internal) @@ -160,7 +160,6 @@ endif() # the lib if(WIN32) list(APPEND TensorFlow_search_PATHS ${TENSORFLOW_ROOT}/python) - list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .2.dll) list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .2.dll.if.lib) elseif(APPLE) list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .2.dylib) From 335ed72a3008a1c72e805dcabf2b351da74a038b Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 14 Aug 2025 19:54:18 +0800 Subject: [PATCH 11/17] try _pywrap_tensorflow_common Signed-off-by: Jinzhe Zeng --- source/cmake/Findtensorflow.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/cmake/Findtensorflow.cmake b/source/cmake/Findtensorflow.cmake index 9102b42b61..9b8a0b2a1b 100644 --- a/source/cmake/Findtensorflow.cmake +++ b/source/cmake/Findtensorflow.cmake @@ -146,8 +146,8 @@ if(NOT TensorFlowFramework_FIND_COMPONENTS) if(WIN32) if(TENSORFLOW_VERSION VERSION_GREATER_EQUAL 2.20) # in TF 2.20, _pywrap_tensorflow_internal.lib is missing, but - # tensorflow_framework.2.dll.if.lib is given - set(TensorFlowFramework_FIND_COMPONENTS tensorflow_framework) + # _pywrap_tensorflow_common.dll.if.lib is given + set(TensorFlowFramework_FIND_COMPONENTS _pywrap_tensorflow_common) else() set(TensorFlowFramework_FIND_COMPONENTS _pywrap_tensorflow_internal) endif() @@ -160,7 +160,7 @@ endif() # the lib if(WIN32) list(APPEND TensorFlow_search_PATHS ${TENSORFLOW_ROOT}/python) - list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .2.dll.if.lib) + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .dll.if.lib) elseif(APPLE) list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .2.dylib) else() From be4b24717fcea7226598f420718f84b121afe394 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 14 Aug 2025 23:10:07 +0800 Subject: [PATCH 12/17] Revert "try _pywrap_tensorflow_common" This reverts commit 335ed72a3008a1c72e805dcabf2b351da74a038b. --- source/cmake/Findtensorflow.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/cmake/Findtensorflow.cmake b/source/cmake/Findtensorflow.cmake index 9b8a0b2a1b..9102b42b61 100644 --- a/source/cmake/Findtensorflow.cmake +++ b/source/cmake/Findtensorflow.cmake @@ -146,8 +146,8 @@ if(NOT TensorFlowFramework_FIND_COMPONENTS) if(WIN32) if(TENSORFLOW_VERSION VERSION_GREATER_EQUAL 2.20) # in TF 2.20, _pywrap_tensorflow_internal.lib is missing, but - # _pywrap_tensorflow_common.dll.if.lib is given - set(TensorFlowFramework_FIND_COMPONENTS _pywrap_tensorflow_common) + # tensorflow_framework.2.dll.if.lib is given + set(TensorFlowFramework_FIND_COMPONENTS tensorflow_framework) else() set(TensorFlowFramework_FIND_COMPONENTS _pywrap_tensorflow_internal) endif() @@ -160,7 +160,7 @@ endif() # the lib if(WIN32) list(APPEND TensorFlow_search_PATHS ${TENSORFLOW_ROOT}/python) - list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .dll.if.lib) + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .2.dll.if.lib) elseif(APPLE) list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .2.dylib) else() From 1eeac362d96c9d6d9886a3f10cb2a0f13858f2dc Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 14 Aug 2025 23:10:11 +0800 Subject: [PATCH 13/17] Revert "link lib" This reverts commit 4862beb79b0e5403891d8dfc0ec77e77645f86ab. --- source/cmake/Findtensorflow.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/cmake/Findtensorflow.cmake b/source/cmake/Findtensorflow.cmake index 9102b42b61..e852cea117 100644 --- a/source/cmake/Findtensorflow.cmake +++ b/source/cmake/Findtensorflow.cmake @@ -146,7 +146,7 @@ if(NOT TensorFlowFramework_FIND_COMPONENTS) if(WIN32) if(TENSORFLOW_VERSION VERSION_GREATER_EQUAL 2.20) # in TF 2.20, _pywrap_tensorflow_internal.lib is missing, but - # tensorflow_framework.2.dll.if.lib is given + # tensorflow_framework.2.dll is given set(TensorFlowFramework_FIND_COMPONENTS tensorflow_framework) else() set(TensorFlowFramework_FIND_COMPONENTS _pywrap_tensorflow_internal) @@ -160,6 +160,7 @@ endif() # the lib if(WIN32) list(APPEND TensorFlow_search_PATHS ${TENSORFLOW_ROOT}/python) + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .2.dll) list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .2.dll.if.lib) elseif(APPLE) list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .2.dylib) From 1d9d4031ce770741243ac07309e63bcb860aaa6b Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 14 Aug 2025 23:10:12 +0800 Subject: [PATCH 14/17] Revert "try to fix win" This reverts commit 5752d676c76f232df2701748400be5a79ad705b4. --- source/cmake/Findtensorflow.cmake | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/source/cmake/Findtensorflow.cmake b/source/cmake/Findtensorflow.cmake index e852cea117..f4d13e1a75 100644 --- a/source/cmake/Findtensorflow.cmake +++ b/source/cmake/Findtensorflow.cmake @@ -144,13 +144,7 @@ endif(BUILD_CPP_IF) # tensorflow_framework if(NOT TensorFlowFramework_FIND_COMPONENTS) if(WIN32) - if(TENSORFLOW_VERSION VERSION_GREATER_EQUAL 2.20) - # in TF 2.20, _pywrap_tensorflow_internal.lib is missing, but - # tensorflow_framework.2.dll is given - set(TensorFlowFramework_FIND_COMPONENTS tensorflow_framework) - else() - set(TensorFlowFramework_FIND_COMPONENTS _pywrap_tensorflow_internal) - endif() + set(TensorFlowFramework_FIND_COMPONENTS _pywrap_tensorflow_internal) set(TF_SUFFIX "") else() set(TensorFlowFramework_FIND_COMPONENTS tensorflow_framework) @@ -160,8 +154,6 @@ endif() # the lib if(WIN32) list(APPEND TensorFlow_search_PATHS ${TENSORFLOW_ROOT}/python) - list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .2.dll) - list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .2.dll.if.lib) elseif(APPLE) list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .2.dylib) else() From 3093aaef037e8f39f761d7a5398c5ec15ce2a25a Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 14 Aug 2025 23:13:16 +0800 Subject: [PATCH 15/17] pin tf<2.20 for win --- backend/find_tensorflow.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/find_tensorflow.py b/backend/find_tensorflow.py index 782302a495..a0a1e65aca 100644 --- a/backend/find_tensorflow.py +++ b/backend/find_tensorflow.py @@ -158,7 +158,8 @@ def get_tf_requirement(tf_version: str = "") -> dict: "tensorflow-cpu; platform_machine!='aarch64' and (platform_machine!='arm64' or platform_system != 'Darwin')", "tensorflow; platform_machine=='aarch64' or (platform_machine=='arm64' and platform_system == 'Darwin')", # https://github.com/tensorflow/tensorflow/issues/61830 - "tensorflow-cpu!=2.15.*; platform_system=='Windows'", + # Since TF 2.20, not all symbols are exported to the public API. + "tensorflow-cpu!=2.15.*,<2.20; platform_system=='Windows'", # https://github.com/h5py/h5py/issues/2408 "h5py>=3.6.0,!=3.11.0; platform_system=='Linux' and platform_machine=='aarch64'", *extra_requires, From 1da209e75d0e07a82151c5fe48fbcf2d9d906ff8 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 14 Aug 2025 23:21:07 +0800 Subject: [PATCH 16/17] Revert "fix deprecation" This reverts commit c49269613041f901a612cedccd90c6406a4bcf1a. --- source/op/tf/descrpt.cc | 38 +++--- source/op/tf/descrpt_se_a_ef.cc | 48 +++---- source/op/tf/descrpt_se_a_ef_para.cc | 48 +++---- source/op/tf/descrpt_se_a_ef_vert.cc | 48 +++---- source/op/tf/descrpt_se_a_mask.cc | 18 +-- source/op/tf/ewald_recp.cc | 14 +-- source/op/tf/map_aparam.cc | 12 +- source/op/tf/neighbor_stat.cc | 22 ++-- source/op/tf/pair_tab.cc | 32 ++--- source/op/tf/pairwise.cc | 10 +- source/op/tf/prod_env_mat_multi_device.cc | 118 +++++++++--------- .../op/tf/prod_env_mat_multi_device_nvnmd.cc | 80 ++++++------ source/op/tf/prod_force.cc | 31 +++-- source/op/tf/prod_force_grad.cc | 37 +++--- source/op/tf/prod_force_grad_multi_device.cc | 54 ++++---- source/op/tf/prod_force_multi_device.cc | 39 +++--- source/op/tf/prod_force_se_a_grad.cc | 31 +++-- source/op/tf/prod_force_se_a_mask.cc | 21 ++-- source/op/tf/prod_force_se_a_mask_grad.cc | 29 +++-- source/op/tf/prod_force_se_r_grad.cc | 29 +++-- source/op/tf/prod_virial.cc | 37 +++--- source/op/tf/prod_virial_grad.cc | 43 ++++--- source/op/tf/prod_virial_grad_multi_device.cc | 66 +++++----- source/op/tf/prod_virial_multi_device.cc | 44 +++---- source/op/tf/prod_virial_se_a_grad.cc | 37 +++--- source/op/tf/prod_virial_se_r_grad.cc | 35 +++--- source/op/tf/soft_min.cc | 22 ++-- source/op/tf/soft_min_force.cc | 27 ++-- source/op/tf/soft_min_force_grad.cc | 26 ++-- source/op/tf/soft_min_virial.cc | 26 ++-- source/op/tf/soft_min_virial_grad.cc | 32 ++--- source/op/tf/tabulate_multi_device.cc | 54 ++++---- source/op/tf/unaggregated_grad.cc | 32 ++--- 33 files changed, 614 insertions(+), 626 deletions(-) diff --git a/source/op/tf/descrpt.cc b/source/op/tf/descrpt.cc index 1a63b45157..db3b0ca8e5 100644 --- a/source/op/tf/descrpt.cc +++ b/source/op/tf/descrpt.cc @@ -67,22 +67,22 @@ class DescrptOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of coord should be 2")); + errors::InvalidArgument("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of type should be 2")); + errors::InvalidArgument("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of box should be 2")); + errors::InvalidArgument("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of mesh should be 1")); + errors::InvalidArgument("Dim of mesh should be 1")); OP_REQUIRES(context, (avg_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of avg should be 2")); + errors::InvalidArgument("Dim of avg should be 2")); OP_REQUIRES(context, (std_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of std should be 2")); + errors::InvalidArgument("Dim of std should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); int nloc = natoms(0); @@ -92,24 +92,24 @@ class DescrptOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (ntypes == avg_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of avg should be ntype")); + errors::InvalidArgument("number of avg should be ntype")); OP_REQUIRES(context, (ntypes == std_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of std should be ntype")); + errors::InvalidArgument("number of std should be ntype")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of box should be 9")); + errors::InvalidArgument("number of box should be 9")); OP_REQUIRES(context, (ndescrpt == avg_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of avg should be ndescrpt")); + errors::InvalidArgument("number of avg should be ndescrpt")); OP_REQUIRES(context, (ndescrpt == std_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of std should be ndescrpt")); + errors::InvalidArgument("number of std should be ndescrpt")); int nei_mode = 0; if (mesh_tensor.shape().dim_size(0) == 16) { @@ -201,10 +201,10 @@ class DescrptOp : public OpKernel { // } // int ntypes = max_type_v + 1; OP_REQUIRES(context, (ntypes == int(sel_a.size())), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of types should match the length of sel array")); OP_REQUIRES(context, (ntypes == int(sel_r.size())), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of types should match the length of sel array")); for (int kk = 0; kk < nsamples; ++kk) { diff --git a/source/op/tf/descrpt_se_a_ef.cc b/source/op/tf/descrpt_se_a_ef.cc index 32d26e5b4a..18dda3d8b0 100644 --- a/source/op/tf/descrpt_se_a_ef.cc +++ b/source/op/tf/descrpt_se_a_ef.cc @@ -69,32 +69,32 @@ class DescrptSeAEfOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of coord should be 2")); + errors::InvalidArgument("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of type should be 2")); + errors::InvalidArgument("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of box should be 2")); + errors::InvalidArgument("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of mesh should be 1")); + errors::InvalidArgument("Dim of mesh should be 1")); OP_REQUIRES(context, (ef_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of ef should be 2")); + errors::InvalidArgument("Dim of ef should be 2")); OP_REQUIRES(context, (avg_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of avg should be 2")); + errors::InvalidArgument("Dim of avg should be 2")); OP_REQUIRES(context, (std_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of std should be 2")); + errors::InvalidArgument("Dim of std should be 2")); OP_REQUIRES( context, (fill_nei_a), - absl::InvalidArgumentError( + errors::InvalidArgument( "Rotational free descriptor only support the case rcut_a < 0")); OP_REQUIRES(context, (sec_r.back() == 0), - absl::InvalidArgumentError( + errors::InvalidArgument( "Rotational free descriptor only support all-angular " "information: sel_r should be all zero.")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); int nloc = natoms(0); @@ -104,28 +104,28 @@ class DescrptSeAEfOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nsamples == ef_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (ntypes == avg_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of avg should be ntype")); + errors::InvalidArgument("number of avg should be ntype")); OP_REQUIRES(context, (ntypes == std_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of std should be ntype")); + errors::InvalidArgument("number of std should be ntype")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of box should be 9")); + errors::InvalidArgument("number of box should be 9")); OP_REQUIRES(context, (nloc * 3 == ef_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of ef should be 3")); + errors::InvalidArgument("number of ef should be 3")); OP_REQUIRES(context, (ndescrpt == avg_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of avg should be ndescrpt")); + errors::InvalidArgument("number of avg should be ndescrpt")); OP_REQUIRES(context, (ndescrpt == std_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of std should be ndescrpt")); + errors::InvalidArgument("number of std should be ndescrpt")); int nei_mode = 0; if (mesh_tensor.shape().dim_size(0) == 16) { @@ -208,10 +208,10 @@ class DescrptSeAEfOp : public OpKernel { // } // int ntypes = max_type_v + 1; OP_REQUIRES(context, (ntypes == int(sel_a.size())), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of types should match the length of sel array")); OP_REQUIRES(context, (ntypes == int(sel_r.size())), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of types should match the length of sel array")); for (int kk = 0; kk < nsamples; ++kk) { diff --git a/source/op/tf/descrpt_se_a_ef_para.cc b/source/op/tf/descrpt_se_a_ef_para.cc index 9808457165..0f34de3f4f 100644 --- a/source/op/tf/descrpt_se_a_ef_para.cc +++ b/source/op/tf/descrpt_se_a_ef_para.cc @@ -69,32 +69,32 @@ class DescrptSeAEfParaOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of coord should be 2")); + errors::InvalidArgument("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of type should be 2")); + errors::InvalidArgument("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of box should be 2")); + errors::InvalidArgument("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of mesh should be 1")); + errors::InvalidArgument("Dim of mesh should be 1")); OP_REQUIRES(context, (ef_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of ef should be 2")); + errors::InvalidArgument("Dim of ef should be 2")); OP_REQUIRES(context, (avg_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of avg should be 2")); + errors::InvalidArgument("Dim of avg should be 2")); OP_REQUIRES(context, (std_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of std should be 2")); + errors::InvalidArgument("Dim of std should be 2")); OP_REQUIRES( context, (fill_nei_a), - absl::InvalidArgumentError( + errors::InvalidArgument( "Rotational free descriptor only support the case rcut_a < 0")); OP_REQUIRES(context, (sec_r.back() == 0), - absl::InvalidArgumentError( + errors::InvalidArgument( "Rotational free descriptor only support all-angular " "information: sel_r should be all zero.")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); int nloc = natoms(0); @@ -104,28 +104,28 @@ class DescrptSeAEfParaOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nsamples == ef_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (ntypes == avg_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of avg should be ntype")); + errors::InvalidArgument("number of avg should be ntype")); OP_REQUIRES(context, (ntypes == std_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of std should be ntype")); + errors::InvalidArgument("number of std should be ntype")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of box should be 9")); + errors::InvalidArgument("number of box should be 9")); OP_REQUIRES(context, (nloc * 3 == ef_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of ef should be 3")); + errors::InvalidArgument("number of ef should be 3")); OP_REQUIRES(context, (ndescrpt == avg_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of avg should be ndescrpt")); + errors::InvalidArgument("number of avg should be ndescrpt")); OP_REQUIRES(context, (ndescrpt == std_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of std should be ndescrpt")); + errors::InvalidArgument("number of std should be ndescrpt")); int nei_mode = 0; if (mesh_tensor.shape().dim_size(0) == 16) { @@ -208,10 +208,10 @@ class DescrptSeAEfParaOp : public OpKernel { // } // int ntypes = max_type_v + 1; OP_REQUIRES(context, (ntypes == int(sel_a.size())), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of types should match the length of sel array")); OP_REQUIRES(context, (ntypes == int(sel_r.size())), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of types should match the length of sel array")); for (int kk = 0; kk < nsamples; ++kk) { diff --git a/source/op/tf/descrpt_se_a_ef_vert.cc b/source/op/tf/descrpt_se_a_ef_vert.cc index 89526904ba..b4eb30d9ee 100644 --- a/source/op/tf/descrpt_se_a_ef_vert.cc +++ b/source/op/tf/descrpt_se_a_ef_vert.cc @@ -69,32 +69,32 @@ class DescrptSeAEfVertOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of coord should be 2")); + errors::InvalidArgument("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of type should be 2")); + errors::InvalidArgument("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of box should be 2")); + errors::InvalidArgument("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of mesh should be 1")); + errors::InvalidArgument("Dim of mesh should be 1")); OP_REQUIRES(context, (ef_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of ef should be 2")); + errors::InvalidArgument("Dim of ef should be 2")); OP_REQUIRES(context, (avg_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of avg should be 2")); + errors::InvalidArgument("Dim of avg should be 2")); OP_REQUIRES(context, (std_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of std should be 2")); + errors::InvalidArgument("Dim of std should be 2")); OP_REQUIRES( context, (fill_nei_a), - absl::InvalidArgumentError( + errors::InvalidArgument( "Rotational free descriptor only support the case rcut_a < 0")); OP_REQUIRES(context, (sec_r.back() == 0), - absl::InvalidArgumentError( + errors::InvalidArgument( "Rotational free descriptor only support all-angular " "information: sel_r should be all zero.")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); int nloc = natoms(0); @@ -104,28 +104,28 @@ class DescrptSeAEfVertOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nsamples == ef_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (ntypes == avg_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of avg should be ntype")); + errors::InvalidArgument("number of avg should be ntype")); OP_REQUIRES(context, (ntypes == std_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of std should be ntype")); + errors::InvalidArgument("number of std should be ntype")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of box should be 9")); + errors::InvalidArgument("number of box should be 9")); OP_REQUIRES(context, (nloc * 3 == ef_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of ef should be 3")); + errors::InvalidArgument("number of ef should be 3")); OP_REQUIRES(context, (ndescrpt == avg_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of avg should be ndescrpt")); + errors::InvalidArgument("number of avg should be ndescrpt")); OP_REQUIRES(context, (ndescrpt == std_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of std should be ndescrpt")); + errors::InvalidArgument("number of std should be ndescrpt")); int nei_mode = 0; if (mesh_tensor.shape().dim_size(0) == 16) { @@ -208,10 +208,10 @@ class DescrptSeAEfVertOp : public OpKernel { // } // int ntypes = max_type_v + 1; OP_REQUIRES(context, (ntypes == int(sel_a.size())), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of types should match the length of sel array")); OP_REQUIRES(context, (ntypes == int(sel_r.size())), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of types should match the length of sel array")); for (int kk = 0; kk < nsamples; ++kk) { diff --git a/source/op/tf/descrpt_se_a_mask.cc b/source/op/tf/descrpt_se_a_mask.cc index 599a6ac044..28e4a575db 100644 --- a/source/op/tf/descrpt_se_a_mask.cc +++ b/source/op/tf/descrpt_se_a_mask.cc @@ -63,20 +63,20 @@ class DescrptSeAMaskOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of coord should be 2")); - OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - absl::InvalidArgumentError( - "Dim of type for se_e2_a_mask op should be 2")); + errors::InvalidArgument("Dim of coord should be 2")); + OP_REQUIRES( + context, (type_tensor.shape().dims() == 2), + errors::InvalidArgument("Dim of type for se_e2_a_mask op should be 2")); OP_REQUIRES(context, (mask_matrix_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of mask matrix should be 2")); + errors::InvalidArgument("Dim of mask matrix should be 2")); int nsamples = coord_tensor.shape().dim_size(0); // check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nsamples == mask_matrix_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); // Set n_descrpt for each atom. Include 1/rr, cos(theta), cos(phi), sin(phi) int n_descrpt = 4; @@ -87,10 +87,10 @@ class DescrptSeAMaskOp : public OpKernel { // check the sizes OP_REQUIRES(context, (total_atom_num * 3 == coord_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (total_atom_num == mask_matrix_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); // Create an output tensor TensorShape descrpt_shape; diff --git a/source/op/tf/ewald_recp.cc b/source/op/tf/ewald_recp.cc index 16dbd6b56b..dcad204467 100644 --- a/source/op/tf/ewald_recp.cc +++ b/source/op/tf/ewald_recp.cc @@ -43,13 +43,13 @@ class EwaldRecpOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (coord_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of coord should be 1")); + errors::InvalidArgument("Dim of coord should be 1")); OP_REQUIRES(context, (charge_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of charge should be 1")); + errors::InvalidArgument("Dim of charge should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) == 1), - absl::InvalidArgumentError("size of natoms should be 1")); + errors::InvalidArgument("size of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of box should be 1")); + errors::InvalidArgument("Dim of box should be 1")); auto natoms = natoms_tensor.flat(); int nloc = natoms(0); int nsamples = coord_tensor.shape().dim_size(0) / (nloc * 3); @@ -59,15 +59,15 @@ class EwaldRecpOp : public OpKernel { context, (static_cast(nsamples) * nloc * 3 == coord_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("coord number of samples should match")); + errors::InvalidArgument("coord number of samples should match")); OP_REQUIRES( context, (static_cast(nsamples) * nloc * 1 == charge_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("charge number of samples should match")); + errors::InvalidArgument("charge number of samples should match")); OP_REQUIRES( context, (nsamples * 9 == box_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("box number of samples should match")); + errors::InvalidArgument("box number of samples should match")); // Create an output tensor TensorShape energy_shape; diff --git a/source/op/tf/map_aparam.cc b/source/op/tf/map_aparam.cc index c952b95160..7ac3b48a4f 100644 --- a/source/op/tf/map_aparam.cc +++ b/source/op/tf/map_aparam.cc @@ -35,14 +35,14 @@ class MapAparamOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (aparam_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of aparam should be 2")); + errors::InvalidArgument("Dim of aparam should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -54,9 +54,9 @@ class MapAparamOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - absl::InvalidArgumentError("number of neighbors should match")); + errors::InvalidArgument("number of neighbors should match")); // Create an output tensor TensorShape output_shape; diff --git a/source/op/tf/neighbor_stat.cc b/source/op/tf/neighbor_stat.cc index 21ff1b78f4..26f13b0c84 100644 --- a/source/op/tf/neighbor_stat.cc +++ b/source/op/tf/neighbor_stat.cc @@ -46,17 +46,17 @@ class NeighborStatOp : public OpKernel { const Tensor& mesh_tensor = context->input(context_input_index++); OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of coord should be 2")); + errors::InvalidArgument("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of type should be 2")); + errors::InvalidArgument("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of box should be 2")); + errors::InvalidArgument("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of mesh should be 1")); + errors::InvalidArgument("Dim of mesh should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); int nloc = natoms_tensor.flat().data()[0]; int nall = natoms_tensor.flat().data()[1]; @@ -64,15 +64,15 @@ class NeighborStatOp : public OpKernel { int ntypes = natoms_tensor.shape().dim_size(0) - 2; // check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of box should be 9")); + errors::InvalidArgument("number of box should be 9")); DeviceFunctor()(device, context->eigen_device()); int nei_mode = 0; if (mesh_tensor.shape().dim_size(0) == 6 || diff --git a/source/op/tf/pair_tab.cc b/source/op/tf/pair_tab.cc index 1050b715ff..0b04390d5f 100644 --- a/source/op/tf/pair_tab.cc +++ b/source/op/tf/pair_tab.cc @@ -53,22 +53,22 @@ class PairTabOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (table_info_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of table_info should be 1")); + errors::InvalidArgument("Dim of table_info should be 1")); OP_REQUIRES(context, (table_data_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of table_data should be 1")); + errors::InvalidArgument("Dim of table_data should be 1")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of type should be 2")); + errors::InvalidArgument("Dim of type should be 2")); OP_REQUIRES(context, (rij_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of rij should be 2")); + errors::InvalidArgument("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (scale_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of scale should be 2")); + errors::InvalidArgument("Dim of scale should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -81,24 +81,24 @@ class PairTabOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == type_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == rij_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("shape of type should be nall")); + errors::InvalidArgument("shape of type should be nall")); OP_REQUIRES( context, (3 * static_cast(nnei) * nloc == rij_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("shape of rij should be 3 * nloc * nnei")); + errors::InvalidArgument("shape of rij should be 3 * nloc * nnei")); OP_REQUIRES( context, (static_cast(nnei) * nloc == nlist_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("shape of nlist should be nloc * nnei")); + errors::InvalidArgument("shape of nlist should be nloc * nnei")); OP_REQUIRES(context, (nloc == scale_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("shape of scale should be nloc")); + errors::InvalidArgument("shape of scale should be nloc")); // Create an output tensor TensorShape energy_shape; @@ -133,7 +133,7 @@ class PairTabOp : public OpKernel { auto virial = virial_tensor->matrix(); OP_REQUIRES(context, (ntypes == int(table_info(3) + 0.1)), - absl::InvalidArgumentError( + errors::InvalidArgument( "ntypes provided in table does not match deeppot")); int nspline = table_info(2) + 0.1; int tab_stride = 4 * nspline; diff --git a/source/op/tf/pairwise.cc b/source/op/tf/pairwise.cc index 0d986a1f25..ba1e5e6475 100644 --- a/source/op/tf/pairwise.cc +++ b/source/op/tf/pairwise.cc @@ -45,9 +45,9 @@ class PairwiseIdxOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (idxs_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of idxs should be 2")); + errors::InvalidArgument("Dim of idxs should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); auto idxs = idxs_tensor.matrix(); int nframes = idxs_tensor.shape().dim_size(0); @@ -55,7 +55,7 @@ class PairwiseIdxOp : public OpKernel { int nloc = natoms(0); int nall = natoms(1); OP_REQUIRES(context, nframes > 0, - absl::InvalidArgumentError("nframes should be > 0")); + errors::InvalidArgument("nframes should be > 0")); std::vector> forward_qm_maps, backward_qm_maps, forward_qmmm_maps, backward_qmmm_maps; @@ -237,9 +237,9 @@ class ConvertForwardMapOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (sub_forward_map_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of idxs should be 2")); + errors::InvalidArgument("Dim of idxs should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); auto sub_forward_map = sub_forward_map_tensor.matrix(); int sub_nframes = sub_forward_map_tensor.shape().dim_size(0); diff --git a/source/op/tf/prod_env_mat_multi_device.cc b/source/op/tf/prod_env_mat_multi_device.cc index ecc14df0af..e374102224 100644 --- a/source/op/tf/prod_env_mat_multi_device.cc +++ b/source/op/tf/prod_env_mat_multi_device.cc @@ -364,25 +364,25 @@ class ProdEnvMatAOp : public OpKernel { // set size of the sample. assume 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, // 3], [4, 4, 4]]], then shape(t) ==> [2, 2, 3] OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of coord should be 2")); + errors::InvalidArgument("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of type should be 2")); + errors::InvalidArgument("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of box should be 2")); + errors::InvalidArgument("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of mesh should be 1")); + errors::InvalidArgument("Dim of mesh should be 1")); OP_REQUIRES(context, (avg_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of avg should be 2")); + errors::InvalidArgument("Dim of avg should be 2")); OP_REQUIRES(context, (std_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of std should be 2")); + errors::InvalidArgument("Dim of std should be 2")); OP_REQUIRES(context, (sec_r.back() == 0), - absl::InvalidArgumentError( + errors::InvalidArgument( "Rotational free descriptor only support all-angular " "information: sel_r should be all zero.")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); DeviceFunctor()(device, context->eigen_device()); const int* natoms = natoms_tensor.flat().data(); @@ -393,30 +393,30 @@ class ProdEnvMatAOp : public OpKernel { int nsamples = coord_tensor.shape().dim_size(0); //// check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (ntypes == avg_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of avg should be ntype")); + errors::InvalidArgument("number of avg should be ntype")); OP_REQUIRES(context, (ntypes == std_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of std should be ntype")); + errors::InvalidArgument("number of std should be ntype")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of box should be 9")); + errors::InvalidArgument("number of box should be 9")); OP_REQUIRES(context, (ndescrpt == avg_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of avg should be ndescrpt")); + errors::InvalidArgument("number of avg should be ndescrpt")); OP_REQUIRES(context, (ndescrpt == std_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of std should be ndescrpt")); + errors::InvalidArgument("number of std should be ndescrpt")); OP_REQUIRES(context, (ntypes == int(sel_a.size())), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of types should match the length of sel array")); OP_REQUIRES(context, (ntypes == int(sel_r.size())), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of types should match the length of sel array")); int nei_mode = 0; @@ -680,21 +680,21 @@ class ProdEnvMatROp : public OpKernel { const Tensor& std_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of coord should be 2")); + errors::InvalidArgument("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of type should be 2")); + errors::InvalidArgument("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of box should be 2")); + errors::InvalidArgument("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of mesh should be 1")); + errors::InvalidArgument("Dim of mesh should be 1")); OP_REQUIRES(context, (avg_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of avg should be 2")); + errors::InvalidArgument("Dim of avg should be 2")); OP_REQUIRES(context, (std_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of std should be 2")); + errors::InvalidArgument("Dim of std should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); DeviceFunctor()(device, context->eigen_device()); const int* natoms = natoms_tensor.flat().data(); @@ -707,23 +707,23 @@ class ProdEnvMatROp : public OpKernel { //// check the sizes // check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (ntypes == avg_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of avg should be ntype")); + errors::InvalidArgument("number of avg should be ntype")); OP_REQUIRES(context, (ntypes == std_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of std should be ntype")); + errors::InvalidArgument("number of std should be ntype")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of box should be 9")); + errors::InvalidArgument("number of box should be 9")); OP_REQUIRES(context, (ndescrpt == avg_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of avg should be ndescrpt")); + errors::InvalidArgument("number of avg should be ndescrpt")); OP_REQUIRES(context, (ndescrpt == std_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of std should be ndescrpt")); + errors::InvalidArgument("number of std should be ndescrpt")); int nei_mode = 0; bool b_nlist_map = false; @@ -995,25 +995,25 @@ class ProdEnvMatAMixOp : public OpKernel { // set size of the sample. assume 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, // 3], [4, 4, 4]]], then shape(t) ==> [2, 2, 3] OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of coord should be 2")); + errors::InvalidArgument("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of type should be 2")); + errors::InvalidArgument("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of box should be 2")); + errors::InvalidArgument("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of mesh should be 1")); + errors::InvalidArgument("Dim of mesh should be 1")); OP_REQUIRES(context, (avg_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of avg should be 2")); + errors::InvalidArgument("Dim of avg should be 2")); OP_REQUIRES(context, (std_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of std should be 2")); + errors::InvalidArgument("Dim of std should be 2")); OP_REQUIRES(context, (sec_r.back() == 0), - absl::InvalidArgumentError( + errors::InvalidArgument( "Rotational free descriptor only support all-angular " "information: sel_r should be all zero.")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); DeviceFunctor()(device, context->eigen_device()); const int* natoms = natoms_tensor.flat().data(); @@ -1023,30 +1023,30 @@ class ProdEnvMatAMixOp : public OpKernel { int nsamples = coord_tensor.shape().dim_size(0); //// check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (ntypes == avg_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of avg should be ntype")); + errors::InvalidArgument("number of avg should be ntype")); OP_REQUIRES(context, (ntypes == std_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of std should be ntype")); + errors::InvalidArgument("number of std should be ntype")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of box should be 9")); + errors::InvalidArgument("number of box should be 9")); OP_REQUIRES(context, (ndescrpt == avg_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of avg should be ndescrpt")); + errors::InvalidArgument("number of avg should be ndescrpt")); OP_REQUIRES(context, (ndescrpt == std_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of std should be ndescrpt")); + errors::InvalidArgument("number of std should be ndescrpt")); OP_REQUIRES(context, (1 == int(sel_a.size())), - absl::InvalidArgumentError( + errors::InvalidArgument( "the length of sel array should be 1 in this op")); OP_REQUIRES(context, (1 == int(sel_r.size())), - absl::InvalidArgumentError( + errors::InvalidArgument( "the length of sel array should be 1 in this op")); int nei_mode = 0; @@ -1716,7 +1716,7 @@ void _prepare_coord_nlist_gpu(OpKernelContext* context, deepmd::env_mat_nbor_update(inlist_temp, inlist, max_nbor_size, nbor_list_dev, fake_mesh_dev, 16); OP_REQUIRES(context, (max_numneigh(inlist_temp) <= max_nbor_size), - absl::InvalidArgumentError( + errors::InvalidArgument( "Assert failed, max neighbor size of atom(lammps) " + std::to_string(max_numneigh(inlist_temp)) + " is larger than " + std::to_string(max_nbor_size) + @@ -1730,7 +1730,7 @@ void _prepare_coord_nlist_gpu(OpKernelContext* context, nbor_list_dev, mesh_tensor_data, mesh_tensor_size); OP_REQUIRES(context, (max_numneigh(inlist_temp) <= max_nbor_size), - absl::InvalidArgumentError( + errors::InvalidArgument( "Assert failed, max neighbor size of atom(lammps) " + std::to_string(max_numneigh(inlist_temp)) + " is larger than " + std::to_string(max_nbor_size) + diff --git a/source/op/tf/prod_env_mat_multi_device_nvnmd.cc b/source/op/tf/prod_env_mat_multi_device_nvnmd.cc index 1c8a88b426..57390077ef 100644 --- a/source/op/tf/prod_env_mat_multi_device_nvnmd.cc +++ b/source/op/tf/prod_env_mat_multi_device_nvnmd.cc @@ -342,25 +342,25 @@ class ProdEnvMatANvnmdQuantizeOp : public OpKernel { // set size of the sample. assume 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, // 3], [4, 4, 4]]], then shape(t) ==> [2, 2, 3] OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of coord should be 2")); + errors::InvalidArgument("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of type should be 2")); + errors::InvalidArgument("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of box should be 2")); + errors::InvalidArgument("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of mesh should be 1")); + errors::InvalidArgument("Dim of mesh should be 1")); OP_REQUIRES(context, (avg_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of avg should be 2")); + errors::InvalidArgument("Dim of avg should be 2")); OP_REQUIRES(context, (std_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of std should be 2")); + errors::InvalidArgument("Dim of std should be 2")); OP_REQUIRES(context, (sec_r.back() == 0), - absl::InvalidArgumentError( + errors::InvalidArgument( "Rotational free descriptor only support all-angular " "information: sel_r should be all zero.")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); DeviceFunctor()(device, context->eigen_device()); const int* natoms = natoms_tensor.flat().data(); @@ -371,30 +371,30 @@ class ProdEnvMatANvnmdQuantizeOp : public OpKernel { int nsamples = coord_tensor.shape().dim_size(0); //// check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (ntypes == avg_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of avg should be ntype")); + errors::InvalidArgument("number of avg should be ntype")); OP_REQUIRES(context, (ntypes == std_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of std should be ntype")); + errors::InvalidArgument("number of std should be ntype")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of box should be 9")); + errors::InvalidArgument("number of box should be 9")); OP_REQUIRES(context, (ndescrpt == avg_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of avg should be ndescrpt")); + errors::InvalidArgument("number of avg should be ndescrpt")); OP_REQUIRES(context, (ndescrpt == std_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of std should be ndescrpt")); + errors::InvalidArgument("number of std should be ndescrpt")); OP_REQUIRES(context, (ntypes == int(sel_a.size())), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of types should match the length of sel array")); OP_REQUIRES(context, (ntypes == int(sel_r.size())), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of types should match the length of sel array")); int nei_mode = 0; @@ -585,25 +585,25 @@ class ProdEnvMatAMixNvnmdQuantizeOp : public OpKernel { // set size of the sample. assume 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, // 3], [4, 4, 4]]], then shape(t) ==> [2, 2, 3] OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of coord should be 2")); + errors::InvalidArgument("Dim of coord should be 2")); OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of type should be 2")); + errors::InvalidArgument("Dim of type should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (box_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of box should be 2")); + errors::InvalidArgument("Dim of box should be 2")); OP_REQUIRES(context, (mesh_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of mesh should be 1")); + errors::InvalidArgument("Dim of mesh should be 1")); OP_REQUIRES(context, (avg_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of avg should be 2")); + errors::InvalidArgument("Dim of avg should be 2")); OP_REQUIRES(context, (std_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of std should be 2")); + errors::InvalidArgument("Dim of std should be 2")); OP_REQUIRES(context, (sec_r.back() == 0), - absl::InvalidArgumentError( + errors::InvalidArgument( "Rotational free descriptor only support all-angular " "information: sel_r should be all zero.")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); DeviceFunctor()(device, context->eigen_device()); const int* natoms = natoms_tensor.flat().data(); @@ -613,30 +613,30 @@ class ProdEnvMatAMixNvnmdQuantizeOp : public OpKernel { int nsamples = coord_tensor.shape().dim_size(0); //// check the sizes OP_REQUIRES(context, (nsamples == type_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nsamples == box_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (ntypes == avg_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of avg should be ntype")); + errors::InvalidArgument("number of avg should be ntype")); OP_REQUIRES(context, (ntypes == std_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of std should be ntype")); + errors::InvalidArgument("number of std should be ntype")); OP_REQUIRES(context, (nall * 3 == coord_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of atoms should match")); + errors::InvalidArgument("number of atoms should match")); OP_REQUIRES(context, (9 == box_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of box should be 9")); + errors::InvalidArgument("number of box should be 9")); OP_REQUIRES(context, (ndescrpt == avg_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of avg should be ndescrpt")); + errors::InvalidArgument("number of avg should be ndescrpt")); OP_REQUIRES(context, (ndescrpt == std_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of std should be ndescrpt")); + errors::InvalidArgument("number of std should be ndescrpt")); OP_REQUIRES(context, (1 == int(sel_a.size())), - absl::InvalidArgumentError( + errors::InvalidArgument( "the length of sel array should be 1 in this op")); OP_REQUIRES(context, (1 == int(sel_r.size())), - absl::InvalidArgumentError( + errors::InvalidArgument( "the length of sel array should be 1 in this op")); int nei_mode = 0; diff --git a/source/op/tf/prod_force.cc b/source/op/tf/prod_force.cc index b411122f36..20269ebef3 100644 --- a/source/op/tf/prod_force.cc +++ b/source/op/tf/prod_force.cc @@ -40,18 +40,18 @@ class ProdForceOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (net_deriv_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (axis_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of axis should be 2")); + errors::InvalidArgument("Dim of axis should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -63,22 +63,21 @@ class ProdForceOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == in_deriv_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == axis_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); - OP_REQUIRES( - context, - (static_cast(nloc) * ndescrpt * 12 == - in_deriv_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + OP_REQUIRES(context, + (static_cast(nloc) * ndescrpt * 12 == + in_deriv_tensor.shape().dim_size(1)), + errors::InvalidArgument("number of descriptors should match")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - absl::InvalidArgumentError("number of neighbors should match")); + errors::InvalidArgument("number of neighbors should match")); OP_REQUIRES( context, (nloc * 4 == axis_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of axis type+id should match 2+2")); + errors::InvalidArgument("number of axis type+id should match 2+2")); // Create an output tensor TensorShape force_shape; diff --git a/source/op/tf/prod_force_grad.cc b/source/op/tf/prod_force_grad.cc index bdc134e694..acfe9145fe 100644 --- a/source/op/tf/prod_force_grad.cc +++ b/source/op/tf/prod_force_grad.cc @@ -46,20 +46,20 @@ class ProdForceGradOp : public OpKernel { TensorShape axis_shape = axis_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - absl::InvalidArgumentError("Dim of grad should be 2")); + errors::InvalidArgument("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (axis_shape.dims() == 2), - absl::InvalidArgumentError("Dim of axis should be 2")); + errors::InvalidArgument("Dim of axis should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -70,27 +70,26 @@ class ProdForceGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == axis_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES( context, (nloc * 3 == grad_shape.dim_size(1)), - absl::InvalidArgumentError("input grad shape should be 3 x natoms")); - OP_REQUIRES( - context, - (static_cast(nloc) * ndescrpt * 12 == - in_deriv_shape.dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + errors::InvalidArgument("input grad shape should be 3 x natoms")); + OP_REQUIRES(context, + (static_cast(nloc) * ndescrpt * 12 == + in_deriv_shape.dim_size(1)), + errors::InvalidArgument("number of descriptors should match")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - absl::InvalidArgumentError("number of neighbors should match")); + errors::InvalidArgument("number of neighbors should match")); OP_REQUIRES( context, (nloc * 4 == axis_shape.dim_size(1)), - absl::InvalidArgumentError("number of axis type+id should be 2+2")); + errors::InvalidArgument("number of axis type+id should be 2+2")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/prod_force_grad_multi_device.cc b/source/op/tf/prod_force_grad_multi_device.cc index 5bd5cce766..ee8a29732d 100644 --- a/source/op/tf/prod_force_grad_multi_device.cc +++ b/source/op/tf/prod_force_grad_multi_device.cc @@ -53,18 +53,18 @@ class ProdForceSeAGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - absl::InvalidArgumentError("Dim of grad should be 2")); + errors::InvalidArgument("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -75,20 +75,20 @@ class ProdForceSeAGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES( context, (nloc * 3 == grad_shape.dim_size(1)), - absl::InvalidArgumentError("input grad shape should be 3 x natoms")); - OP_REQUIRES( - context, (int_64(nloc) * ndescrpt * 3 == in_deriv_shape.dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + errors::InvalidArgument("input grad shape should be 3 x natoms")); + OP_REQUIRES(context, + (int_64(nloc) * ndescrpt * 3 == in_deriv_shape.dim_size(1)), + errors::InvalidArgument("number of descriptors should match")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - absl::InvalidArgumentError("number of neighbors should match")); + errors::InvalidArgument("number of neighbors should match")); // Create an output tensor TensorShape grad_net_shape; @@ -166,18 +166,18 @@ class ProdForceSeRGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - absl::InvalidArgumentError("Dim of grad should be 2")); + errors::InvalidArgument("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -188,18 +188,18 @@ class ProdForceSeRGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES( context, (nloc * 3 == grad_shape.dim_size(1)), - absl::InvalidArgumentError("input grad shape should be 3 x natoms")); - OP_REQUIRES( - context, (int_64(nloc) * ndescrpt * 3 == in_deriv_shape.dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + errors::InvalidArgument("input grad shape should be 3 x natoms")); + OP_REQUIRES(context, + (int_64(nloc) * ndescrpt * 3 == in_deriv_shape.dim_size(1)), + errors::InvalidArgument("number of descriptors should match")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/prod_force_multi_device.cc b/source/op/tf/prod_force_multi_device.cc index 404fd1ce84..d48749faa5 100644 --- a/source/op/tf/prod_force_multi_device.cc +++ b/source/op/tf/prod_force_multi_device.cc @@ -75,15 +75,15 @@ class ProdForceSeAOp : public OpKernel { const Tensor& natoms_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (net_deriv_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); const int* natoms = natoms_tensor.flat().data(); int nloc = natoms[0]; @@ -93,13 +93,13 @@ class ProdForceSeAOp : public OpKernel { int nnei = nloc > 0 ? nlist_tensor.shape().dim_size(1) / nloc : 0; // check the sizes OP_REQUIRES(context, (nframes == in_deriv_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES( context, (int_64(nloc) * ndescrpt * 3 == in_deriv_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + errors::InvalidArgument("number of descriptors should match")); // Create an output tensor TensorShape force_shape; force_shape.AddDim(nframes); @@ -176,15 +176,15 @@ class ProdForceSeROp : public OpKernel { const Tensor& natoms_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (net_deriv_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); const int* natoms = natoms_tensor.flat().data(); int nloc = natoms[0]; @@ -194,14 +194,13 @@ class ProdForceSeROp : public OpKernel { int nnei = nloc > 0 ? nlist_tensor.shape().dim_size(1) / nloc : 0; // check the sizes OP_REQUIRES(context, (nframes == in_deriv_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); - OP_REQUIRES( - context, - (static_cast(nloc) * ndescrpt * 3 == - in_deriv_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + errors::InvalidArgument("number of samples should match")); + OP_REQUIRES(context, + (static_cast(nloc) * ndescrpt * 3 == + in_deriv_tensor.shape().dim_size(1)), + errors::InvalidArgument("number of descriptors should match")); // Create an output tensor TensorShape force_shape; force_shape.AddDim(nframes); diff --git a/source/op/tf/prod_force_se_a_grad.cc b/source/op/tf/prod_force_se_a_grad.cc index 2b45ba1bc0..05e26b5058 100644 --- a/source/op/tf/prod_force_se_a_grad.cc +++ b/source/op/tf/prod_force_se_a_grad.cc @@ -46,18 +46,18 @@ class ProdForceSeAGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - absl::InvalidArgumentError("Dim of grad should be 2")); + errors::InvalidArgument("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -68,22 +68,21 @@ class ProdForceSeAGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES( context, (nloc * 3 == grad_shape.dim_size(1)), - absl::InvalidArgumentError("input grad shape should be 3 x natoms")); - OP_REQUIRES( - context, - (static_cast(nloc) * ndescrpt * 3 == - in_deriv_shape.dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + errors::InvalidArgument("input grad shape should be 3 x natoms")); + OP_REQUIRES(context, + (static_cast(nloc) * ndescrpt * 3 == + in_deriv_shape.dim_size(1)), + errors::InvalidArgument("number of descriptors should match")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - absl::InvalidArgumentError("number of neighbors should match")); + errors::InvalidArgument("number of neighbors should match")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/prod_force_se_a_mask.cc b/source/op/tf/prod_force_se_a_mask.cc index edea3ed397..a7b08ae664 100644 --- a/source/op/tf/prod_force_se_a_mask.cc +++ b/source/op/tf/prod_force_se_a_mask.cc @@ -37,13 +37,13 @@ class ProdForceSeAMaskOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (net_deriv_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (mask_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of mask matrix should be 2")); + errors::InvalidArgument("Dim of mask matrix should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); int nframes = net_deriv_tensor.shape().dim_size(0); int nloc = total_atom_num; @@ -53,14 +53,13 @@ class ProdForceSeAMaskOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == in_deriv_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); - OP_REQUIRES( - context, - (static_cast(nloc) * ndescrpt * 3 == - in_deriv_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + errors::InvalidArgument("number of samples should match")); + OP_REQUIRES(context, + (static_cast(nloc) * ndescrpt * 3 == + in_deriv_tensor.shape().dim_size(1)), + errors::InvalidArgument("number of descriptors should match")); // Create an output tensor TensorShape force_shape; diff --git a/source/op/tf/prod_force_se_a_mask_grad.cc b/source/op/tf/prod_force_se_a_mask_grad.cc index c4e7b8a2cc..a01919199f 100644 --- a/source/op/tf/prod_force_se_a_mask_grad.cc +++ b/source/op/tf/prod_force_se_a_mask_grad.cc @@ -43,15 +43,15 @@ class ProdForceSeAMaskGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - absl::InvalidArgumentError("Dim of grad should be 2")); + errors::InvalidArgument("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (mask_shape.dims() == 2), - absl::InvalidArgumentError("Dim of mask should be 2")); + errors::InvalidArgument("Dim of mask should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); int nframes = net_deriv_tensor.shape().dim_size(0); int nloc = total_atom_num; @@ -60,22 +60,21 @@ class ProdForceSeAMaskGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == mask_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES( context, (nloc * 3 == grad_shape.dim_size(1)), - absl::InvalidArgumentError("input grad shape should be 3 x natoms")); - OP_REQUIRES( - context, - (static_cast(nloc) * ndescrpt * 3 == - in_deriv_shape.dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + errors::InvalidArgument("input grad shape should be 3 x natoms")); + OP_REQUIRES(context, + (static_cast(nloc) * ndescrpt * 3 == + in_deriv_shape.dim_size(1)), + errors::InvalidArgument("number of descriptors should match")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/prod_force_se_r_grad.cc b/source/op/tf/prod_force_se_r_grad.cc index 4f7cdb60e0..44741d20fb 100644 --- a/source/op/tf/prod_force_se_r_grad.cc +++ b/source/op/tf/prod_force_se_r_grad.cc @@ -40,18 +40,18 @@ class ProdForceSeRGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - absl::InvalidArgumentError("Dim of grad should be 2")); + errors::InvalidArgument("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -62,20 +62,19 @@ class ProdForceSeRGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES( context, (nloc * 3 == grad_shape.dim_size(1)), - absl::InvalidArgumentError("input grad shape should be 3 x natoms")); - OP_REQUIRES( - context, - (static_cast(nloc) * ndescrpt * 3 == - in_deriv_shape.dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + errors::InvalidArgument("input grad shape should be 3 x natoms")); + OP_REQUIRES(context, + (static_cast(nloc) * ndescrpt * 3 == + in_deriv_shape.dim_size(1)), + errors::InvalidArgument("number of descriptors should match")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/prod_virial.cc b/source/op/tf/prod_virial.cc index 288d78941f..42e7be669d 100644 --- a/source/op/tf/prod_virial.cc +++ b/source/op/tf/prod_virial.cc @@ -43,20 +43,20 @@ class ProdVirialOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (net_deriv_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of rij should be 2")); + errors::InvalidArgument("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (axis_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of axis should be 2")); + errors::InvalidArgument("Dim of axis should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -68,28 +68,27 @@ class ProdVirialOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == in_deriv_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == rij_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == axis_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); - OP_REQUIRES( - context, - (static_cast(nloc) * ndescrpt * 12 == - in_deriv_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + OP_REQUIRES(context, + (static_cast(nloc) * ndescrpt * 12 == + in_deriv_tensor.shape().dim_size(1)), + errors::InvalidArgument("number of descriptors should match")); OP_REQUIRES(context, (static_cast(nloc) * nnei * 3 == rij_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("dim of rij should be nnei * 3")); + errors::InvalidArgument("dim of rij should be nnei * 3")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - absl::InvalidArgumentError("number of neighbors should match")); + errors::InvalidArgument("number of neighbors should match")); OP_REQUIRES( context, (nloc * 4 == axis_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of axis type+id should be 2+2")); + errors::InvalidArgument("number of axis type+id should be 2+2")); // Create an output tensor TensorShape virial_shape; diff --git a/source/op/tf/prod_virial_grad.cc b/source/op/tf/prod_virial_grad.cc index cd670dd2f4..a764e524a6 100644 --- a/source/op/tf/prod_virial_grad.cc +++ b/source/op/tf/prod_virial_grad.cc @@ -49,22 +49,22 @@ class ProdVirialGradOp : public OpKernel { TensorShape axis_shape = axis_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - absl::InvalidArgumentError("Dim of grad should be 2")); + errors::InvalidArgument("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_shape.dims() == 2), - absl::InvalidArgumentError("Dim of rij should be 2")); + errors::InvalidArgument("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (axis_shape.dims() == 2), - absl::InvalidArgumentError("Dim of axis should be 2")); + errors::InvalidArgument("Dim of axis should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -75,33 +75,32 @@ class ProdVirialGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == rij_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == axis_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES( context, (9 == grad_shape.dim_size(1)), - absl::InvalidArgumentError("input grad shape should be 3 x natoms")); - OP_REQUIRES( - context, - (static_cast(nloc) * ndescrpt * 12 == - in_deriv_shape.dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + errors::InvalidArgument("input grad shape should be 3 x natoms")); + OP_REQUIRES(context, + (static_cast(nloc) * ndescrpt * 12 == + in_deriv_shape.dim_size(1)), + errors::InvalidArgument("number of descriptors should match")); OP_REQUIRES( context, (static_cast(nloc) * nnei * 3 == rij_shape.dim_size(1)), - absl::InvalidArgumentError("dim of rij should be nnei * 3")); + errors::InvalidArgument("dim of rij should be nnei * 3")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - absl::InvalidArgumentError("number of neighbors should match")); + errors::InvalidArgument("number of neighbors should match")); OP_REQUIRES( context, (nloc * 4 == axis_shape.dim_size(1)), - absl::InvalidArgumentError("number of axis type+id should be 2+2")); + errors::InvalidArgument("number of axis type+id should be 2+2")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/prod_virial_grad_multi_device.cc b/source/op/tf/prod_virial_grad_multi_device.cc index 490f47c2c2..3d8d2a96b3 100644 --- a/source/op/tf/prod_virial_grad_multi_device.cc +++ b/source/op/tf/prod_virial_grad_multi_device.cc @@ -57,20 +57,20 @@ class ProdVirialSeAGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - absl::InvalidArgumentError("Dim of grad should be 2")); + errors::InvalidArgument("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_shape.dims() == 2), - absl::InvalidArgumentError("Dim of rij should be 2")); + errors::InvalidArgument("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -81,24 +81,24 @@ class ProdVirialSeAGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == rij_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES( context, (9 == grad_shape.dim_size(1)), - absl::InvalidArgumentError("input grad shape should be 3 x natoms")); - OP_REQUIRES( - context, (int_64(nloc) * ndescrpt * 3 == in_deriv_shape.dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + errors::InvalidArgument("input grad shape should be 3 x natoms")); + OP_REQUIRES(context, + (int_64(nloc) * ndescrpt * 3 == in_deriv_shape.dim_size(1)), + errors::InvalidArgument("number of descriptors should match")); OP_REQUIRES(context, (int_64(nloc) * nnei * 3 == rij_shape.dim_size(1)), - absl::InvalidArgumentError("dim of rij should be nnei * 3")); + errors::InvalidArgument("dim of rij should be nnei * 3")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - absl::InvalidArgumentError("number of neighbors should match")); + errors::InvalidArgument("number of neighbors should match")); // Create an output tensor TensorShape grad_net_shape; @@ -191,20 +191,20 @@ class ProdVirialSeRGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - absl::InvalidArgumentError("Dim of grad should be 2")); + errors::InvalidArgument("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_shape.dims() == 2), - absl::InvalidArgumentError("Dim of rij should be 2")); + errors::InvalidArgument("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -215,22 +215,22 @@ class ProdVirialSeRGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == rij_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES( context, (9 == grad_shape.dim_size(1)), - absl::InvalidArgumentError("input grad shape should be 3 x natoms")); - OP_REQUIRES( - context, (int_64(nloc) * ndescrpt * 3 == in_deriv_shape.dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + errors::InvalidArgument("input grad shape should be 3 x natoms")); + OP_REQUIRES(context, + (int_64(nloc) * ndescrpt * 3 == in_deriv_shape.dim_size(1)), + errors::InvalidArgument("number of descriptors should match")); OP_REQUIRES(context, (int_64(nloc) * nnei * 3 == rij_shape.dim_size(1)), - absl::InvalidArgumentError("dim of rij should be nnei * 3")); + errors::InvalidArgument("dim of rij should be nnei * 3")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/prod_virial_multi_device.cc b/source/op/tf/prod_virial_multi_device.cc index 99f8d6c93d..a544b010c5 100644 --- a/source/op/tf/prod_virial_multi_device.cc +++ b/source/op/tf/prod_virial_multi_device.cc @@ -55,17 +55,17 @@ class ProdVirialSeAOp : public OpKernel { const Tensor& natoms_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (net_deriv_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of rij should be 2")); + errors::InvalidArgument("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); const int* natoms = natoms_tensor.flat().data(); int nloc = natoms[0]; @@ -75,18 +75,18 @@ class ProdVirialSeAOp : public OpKernel { int ndescrpt = nloc > 0 ? net_deriv_tensor.shape().dim_size(1) / nloc : 0; // check the sizes OP_REQUIRES(context, (nframes == in_deriv_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == rij_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES( context, (int_64(nloc) * ndescrpt * 3 == in_deriv_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + errors::InvalidArgument("number of descriptors should match")); OP_REQUIRES(context, (int_64(nloc) * nnei * 3 == rij_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("dim of rij should be nnei * 3")); + errors::InvalidArgument("dim of rij should be nnei * 3")); // Create an output tensor TensorShape virial_shape; virial_shape.AddDim(nframes); @@ -154,17 +154,17 @@ class ProdVirialSeROp : public OpKernel { const Tensor& natoms_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (net_deriv_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of rij should be 2")); + errors::InvalidArgument("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); const int* natoms = natoms_tensor.flat().data(); int nloc = natoms[0]; @@ -174,18 +174,18 @@ class ProdVirialSeROp : public OpKernel { int ndescrpt = nloc > 0 ? net_deriv_tensor.shape().dim_size(1) / nloc : 0; // check the sizes OP_REQUIRES(context, (nframes == in_deriv_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == rij_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES( context, (int_64(nloc) * ndescrpt * 3 == in_deriv_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + errors::InvalidArgument("number of descriptors should match")); OP_REQUIRES(context, (int_64(nloc) * nnei * 3 == rij_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("dim of rij should be nnei * 3")); + errors::InvalidArgument("dim of rij should be nnei * 3")); // Create an output tensor TensorShape virial_shape; virial_shape.AddDim(nframes); diff --git a/source/op/tf/prod_virial_se_a_grad.cc b/source/op/tf/prod_virial_se_a_grad.cc index 3494dbbc63..e3a9374b8f 100644 --- a/source/op/tf/prod_virial_se_a_grad.cc +++ b/source/op/tf/prod_virial_se_a_grad.cc @@ -49,20 +49,20 @@ class ProdVirialSeAGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - absl::InvalidArgumentError("Dim of grad should be 2")); + errors::InvalidArgument("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_shape.dims() == 2), - absl::InvalidArgumentError("Dim of rij should be 2")); + errors::InvalidArgument("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -73,28 +73,27 @@ class ProdVirialSeAGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == rij_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES( context, (9 == grad_shape.dim_size(1)), - absl::InvalidArgumentError("input grad shape should be 3 x natoms")); - OP_REQUIRES( - context, - (static_cast(nloc) * ndescrpt * 3 == - in_deriv_shape.dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + errors::InvalidArgument("input grad shape should be 3 x natoms")); + OP_REQUIRES(context, + (static_cast(nloc) * ndescrpt * 3 == + in_deriv_shape.dim_size(1)), + errors::InvalidArgument("number of descriptors should match")); OP_REQUIRES( context, (static_cast(nloc) * nnei * 3 == rij_shape.dim_size(1)), - absl::InvalidArgumentError("dim of rij should be nnei * 3")); + errors::InvalidArgument("dim of rij should be nnei * 3")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - absl::InvalidArgumentError("number of neighbors should match")); + errors::InvalidArgument("number of neighbors should match")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/prod_virial_se_r_grad.cc b/source/op/tf/prod_virial_se_r_grad.cc index 3cdd3f7382..8e9b2c25b0 100644 --- a/source/op/tf/prod_virial_se_r_grad.cc +++ b/source/op/tf/prod_virial_se_r_grad.cc @@ -43,20 +43,20 @@ class ProdVirialSeRGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - absl::InvalidArgumentError("Dim of grad should be 2")); + errors::InvalidArgument("Dim of grad should be 2")); OP_REQUIRES(context, (net_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (in_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_shape.dims() == 2), - absl::InvalidArgumentError("Dim of rij should be 2")); + errors::InvalidArgument("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -67,26 +67,25 @@ class ProdVirialSeRGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == in_deriv_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == rij_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES( context, (9 == grad_shape.dim_size(1)), - absl::InvalidArgumentError("input grad shape should be 3 x natoms")); - OP_REQUIRES( - context, - (static_cast(nloc) * ndescrpt * 3 == - in_deriv_shape.dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + errors::InvalidArgument("input grad shape should be 3 x natoms")); + OP_REQUIRES(context, + (static_cast(nloc) * ndescrpt * 3 == + in_deriv_shape.dim_size(1)), + errors::InvalidArgument("number of descriptors should match")); OP_REQUIRES( context, (static_cast(nloc) * nnei * 3 == rij_shape.dim_size(1)), - absl::InvalidArgumentError("dim of rij should be nnei * 3")); + errors::InvalidArgument("dim of rij should be nnei * 3")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/soft_min.cc b/source/op/tf/soft_min.cc index 0ec4787d7d..07c7404bbf 100644 --- a/source/op/tf/soft_min.cc +++ b/source/op/tf/soft_min.cc @@ -52,16 +52,16 @@ class SoftMinSwitchOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (type_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of type should be 2")); + errors::InvalidArgument("Dim of type should be 2")); OP_REQUIRES(context, (rij_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of rij should be 2")); + errors::InvalidArgument("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -74,22 +74,22 @@ class SoftMinSwitchOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == type_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == rij_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nall == type_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("shape of type should be nall")); + errors::InvalidArgument("shape of type should be nall")); OP_REQUIRES( context, (3 * static_cast(nnei) * nloc == rij_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("shape of rij should be 3 * nloc * nnei")); + errors::InvalidArgument("shape of rij should be 3 * nloc * nnei")); OP_REQUIRES( context, (static_cast(nnei) * nloc == nlist_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("shape of nlist should be nloc * nnei")); + errors::InvalidArgument("shape of nlist should be nloc * nnei")); // Create an output tensor TensorShape sw_value_shape; diff --git a/source/op/tf/soft_min_force.cc b/source/op/tf/soft_min_force.cc index 89c3dc09d4..14cb42b993 100644 --- a/source/op/tf/soft_min_force.cc +++ b/source/op/tf/soft_min_force.cc @@ -38,16 +38,16 @@ class SoftMinForceOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (du_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of du should be 2")); + errors::InvalidArgument("Dim of du should be 2")); OP_REQUIRES(context, (sw_deriv_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of switch deriv should be 2")); + errors::InvalidArgument("Dim of switch deriv should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -58,19 +58,18 @@ class SoftMinForceOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == sw_deriv_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nloc == du_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of du should match")); - OP_REQUIRES( - context, - (static_cast(nloc) * nnei * 3 == - sw_deriv_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of switch deriv should match")); + errors::InvalidArgument("number of du should match")); + OP_REQUIRES(context, + (static_cast(nloc) * nnei * 3 == + sw_deriv_tensor.shape().dim_size(1)), + errors::InvalidArgument("number of switch deriv should match")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - absl::InvalidArgumentError("number of neighbors should match")); + errors::InvalidArgument("number of neighbors should match")); // Create an output tensor TensorShape force_shape; diff --git a/source/op/tf/soft_min_force_grad.cc b/source/op/tf/soft_min_force_grad.cc index a79e5a51d6..e173586d22 100644 --- a/source/op/tf/soft_min_force_grad.cc +++ b/source/op/tf/soft_min_force_grad.cc @@ -45,18 +45,18 @@ class SoftMinForceGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - absl::InvalidArgumentError("Dim of grad should be 2")); + errors::InvalidArgument("Dim of grad should be 2")); OP_REQUIRES(context, (du_shape.dims() == 2), - absl::InvalidArgumentError("Dim of du should be 2")); + errors::InvalidArgument("Dim of du should be 2")); OP_REQUIRES(context, (sw_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of sw deriv should be 2")); + errors::InvalidArgument("Dim of sw deriv should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -66,23 +66,23 @@ class SoftMinForceGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == sw_deriv_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nloc == du_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of du should match")); + errors::InvalidArgument("number of du should match")); OP_REQUIRES( context, (nloc * 3 == grad_shape.dim_size(1)), - absl::InvalidArgumentError("input grad shape should be 3 x natoms")); + errors::InvalidArgument("input grad shape should be 3 x natoms")); OP_REQUIRES( context, (static_cast(nloc) * nnei * 3 == sw_deriv_shape.dim_size(1)), - absl::InvalidArgumentError("number of sw deriv should match")); + errors::InvalidArgument("number of sw deriv should match")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - absl::InvalidArgumentError("number of neighbors should match")); + errors::InvalidArgument("number of neighbors should match")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/soft_min_virial.cc b/source/op/tf/soft_min_virial.cc index d9b17c3d5f..6c0e1f72f3 100644 --- a/source/op/tf/soft_min_virial.cc +++ b/source/op/tf/soft_min_virial.cc @@ -42,18 +42,18 @@ class SoftMinVirialOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (du_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (sw_deriv_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of rij should be 2")); + errors::InvalidArgument("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -64,24 +64,24 @@ class SoftMinVirialOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == sw_deriv_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == rij_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nframes == nlist_tensor.shape().dim_size(0)), - absl::InvalidArgumentError("number of samples should match")); + errors::InvalidArgument("number of samples should match")); OP_REQUIRES(context, (nloc == du_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of du should match")); + errors::InvalidArgument("number of du should match")); OP_REQUIRES(context, (static_cast(nloc) * nnei * 3 == sw_deriv_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of sw_deriv should match")); + errors::InvalidArgument("number of sw_deriv should match")); OP_REQUIRES(context, (static_cast(nloc) * nnei * 3 == rij_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("dim of rij should be nnei * 3")); + errors::InvalidArgument("dim of rij should be nnei * 3")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - absl::InvalidArgumentError("number of neighbors should match")); + errors::InvalidArgument("number of neighbors should match")); // Create an output tensor TensorShape virial_shape; diff --git a/source/op/tf/soft_min_virial_grad.cc b/source/op/tf/soft_min_virial_grad.cc index adfc281236..ac129b29af 100644 --- a/source/op/tf/soft_min_virial_grad.cc +++ b/source/op/tf/soft_min_virial_grad.cc @@ -48,20 +48,20 @@ class SoftMinVirialGradOp : public OpKernel { TensorShape nlist_shape = nlist_tensor.shape(); OP_REQUIRES(context, (grad_shape.dims() == 2), - absl::InvalidArgumentError("Dim of grad should be 2")); + errors::InvalidArgument("Dim of grad should be 2")); OP_REQUIRES(context, (du_shape.dims() == 2), - absl::InvalidArgumentError("Dim of net deriv should be 2")); + errors::InvalidArgument("Dim of net deriv should be 2")); OP_REQUIRES(context, (sw_deriv_shape.dims() == 2), - absl::InvalidArgumentError("Dim of input deriv should be 2")); + errors::InvalidArgument("Dim of input deriv should be 2")); OP_REQUIRES(context, (rij_shape.dims() == 2), - absl::InvalidArgumentError("Dim of rij should be 2")); + errors::InvalidArgument("Dim of rij should be 2")); OP_REQUIRES(context, (nlist_shape.dims() == 2), - absl::InvalidArgumentError("Dim of nlist should be 2")); + errors::InvalidArgument("Dim of nlist should be 2")); OP_REQUIRES(context, (natoms_tensor.shape().dims() == 1), - absl::InvalidArgumentError("Dim of natoms should be 1")); + errors::InvalidArgument("Dim of natoms should be 1")); OP_REQUIRES(context, (natoms_tensor.shape().dim_size(0) >= 3), - absl::InvalidArgumentError( + errors::InvalidArgument( "number of atoms should be larger than (or equal to) 3")); auto natoms = natoms_tensor.flat(); @@ -71,29 +71,29 @@ class SoftMinVirialGradOp : public OpKernel { // check the sizes OP_REQUIRES(context, (nframes == grad_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == sw_deriv_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == rij_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES(context, (nframes == nlist_shape.dim_size(0)), - absl::InvalidArgumentError("number of frames should match")); + errors::InvalidArgument("number of frames should match")); OP_REQUIRES( context, (9 == grad_shape.dim_size(1)), - absl::InvalidArgumentError("input grad shape should be 3 x natoms")); + errors::InvalidArgument("input grad shape should be 3 x natoms")); OP_REQUIRES(context, (nloc == du_tensor.shape().dim_size(1)), - absl::InvalidArgumentError("number of du should match")); + errors::InvalidArgument("number of du should match")); OP_REQUIRES( context, (static_cast(nloc) * nnei * 3 == sw_deriv_shape.dim_size(1)), - absl::InvalidArgumentError("number of descriptors should match")); + errors::InvalidArgument("number of descriptors should match")); OP_REQUIRES( context, (static_cast(nloc) * nnei * 3 == rij_shape.dim_size(1)), - absl::InvalidArgumentError("dim of rij should be nnei * 3")); + errors::InvalidArgument("dim of rij should be nnei * 3")); OP_REQUIRES(context, (nnei == n_a_sel + n_r_sel), - absl::InvalidArgumentError("number of neighbors should match")); + errors::InvalidArgument("number of neighbors should match")); // Create an output tensor TensorShape grad_net_shape; diff --git a/source/op/tf/tabulate_multi_device.cc b/source/op/tf/tabulate_multi_device.cc index 7b6b336f99..50267df556 100644 --- a/source/op/tf/tabulate_multi_device.cc +++ b/source/op/tf/tabulate_multi_device.cc @@ -184,11 +184,11 @@ class TabulateFusionSeAOp : public OpKernel { const Tensor& em_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (table_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of table should be 2")); + errors::InvalidArgument("Dim of table should be 2")); OP_REQUIRES(context, (em_x_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); OP_REQUIRES(context, (em_tensor.shape().dims() == 3), - absl::InvalidArgumentError("Dim of input should be 3")); + errors::InvalidArgument("Dim of input should be 3")); TensorShape descriptor_shape; descriptor_shape.AddDim(em_tensor.shape().dim_size(0)); descriptor_shape.AddDim(4); // be careful here; @@ -247,7 +247,7 @@ class TabulateFusionSeAGradOp : public OpKernel { const Tensor& descriptor_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (dy_tensor.shape().dims() == 3), - absl::InvalidArgumentError("Dim of table should be 3")); + errors::InvalidArgument("Dim of table should be 3")); int context_output_index = 0; Tensor* dy_dem_x_tensor = NULL; OP_REQUIRES_OK(context, context->allocate_output(context_output_index++, @@ -311,9 +311,9 @@ class TabulateFusionSeAGradGradOp : public OpKernel { const Tensor& descriptor_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (dz_dy_dem_x_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); OP_REQUIRES(context, (dz_dy_dem_tensor.shape().dims() == 3), - absl::InvalidArgumentError("Dim of input should be 3")); + errors::InvalidArgument("Dim of input should be 3")); int context_output_index = 0; Tensor* dz_dy_tensor = NULL; OP_REQUIRES_OK(context, context->allocate_output(context_output_index++, @@ -342,7 +342,7 @@ class TabulateFusionSeAGradGradOp : public OpKernel { dz_dy_dtwo, nloc, nnei, last_layer_size, is_sorted); #endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM OP_REQUIRES(context, (last_layer_size <= 1024), - absl::InvalidArgumentError( + errors::InvalidArgument( "In the process of model compression, the size of the " "last layer of embedding net must be less than 1024!")); } else if (device == "CPU") { @@ -381,13 +381,13 @@ class TabulateFusionSeAttenOp : public OpKernel { const Tensor& two_embed_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (table_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of table should be 2")); + errors::InvalidArgument("Dim of table should be 2")); OP_REQUIRES(context, (em_x_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); OP_REQUIRES(context, (em_tensor.shape().dims() == 3), - absl::InvalidArgumentError("Dim of input should be 3")); + errors::InvalidArgument("Dim of input should be 3")); OP_REQUIRES(context, (two_embed_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); TensorShape descriptor_shape; descriptor_shape.AddDim(em_tensor.shape().dim_size(0)); descriptor_shape.AddDim(4); // be careful here; @@ -452,7 +452,7 @@ class TabulateFusionSeAttenGradOp : public OpKernel { const Tensor& descriptor_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (dy_tensor.shape().dims() == 3), - absl::InvalidArgumentError("Dim of table should be 3")); + errors::InvalidArgument("Dim of table should be 3")); int context_output_index = 0; Tensor* dy_dem_x_tensor = NULL; OP_REQUIRES_OK(context, context->allocate_output(context_output_index++, @@ -528,9 +528,9 @@ class TabulateFusionSeAttenGradGradOp : public OpKernel { const Tensor& descriptor_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (dz_dy_dem_x_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); OP_REQUIRES(context, (dz_dy_dem_tensor.shape().dims() == 3), - absl::InvalidArgumentError("Dim of input should be 3")); + errors::InvalidArgument("Dim of input should be 3")); int context_output_index = 0; Tensor* dz_dy_tensor = NULL; OP_REQUIRES_OK(context, context->allocate_output(context_output_index++, @@ -559,7 +559,7 @@ class TabulateFusionSeAttenGradGradOp : public OpKernel { dz_dy_dtwo, nloc, nnei, last_layer_size, is_sorted); #endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM OP_REQUIRES(context, (last_layer_size <= 1024), - absl::InvalidArgumentError( + errors::InvalidArgument( "In the process of model compression, the size of the " "last layer of embedding net must be less than 1024!")); } else if (device == "CPU") { @@ -596,11 +596,11 @@ class TabulateFusionSeTOp : public OpKernel { const Tensor& em_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (table_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of table should be 2")); + errors::InvalidArgument("Dim of table should be 2")); OP_REQUIRES(context, (em_x_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of em_x_tensor should be 2")); + errors::InvalidArgument("Dim of em_x_tensor should be 2")); OP_REQUIRES(context, (em_tensor.shape().dims() == 3), - absl::InvalidArgumentError("Dim of em_tensor should be 3")); + errors::InvalidArgument("Dim of em_tensor should be 3")); TensorShape descriptor_shape; descriptor_shape.AddDim(em_tensor.shape().dim_size(0)); descriptor_shape.AddDim(last_layer_size); @@ -657,7 +657,7 @@ class TabulateFusionSeTGradOp : public OpKernel { const Tensor& descriptor_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (dy_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of dy_tensor should be 2")); + errors::InvalidArgument("Dim of dy_tensor should be 2")); int context_output_index = 0; Tensor* dy_dem_x_tensor = NULL; OP_REQUIRES_OK(context, context->allocate_output(context_output_index++, @@ -717,9 +717,9 @@ class TabulateFusionSeTGradGradOp : public OpKernel { const Tensor& descriptor_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (dz_dy_dem_x_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); OP_REQUIRES(context, (dz_dy_dem_tensor.shape().dims() == 3), - absl::InvalidArgumentError("Dim of input should be 3")); + errors::InvalidArgument("Dim of input should be 3")); int context_output_index = 0; Tensor* dz_dy_tensor = NULL; OP_REQUIRES_OK(context, context->allocate_output(context_output_index++, @@ -747,7 +747,7 @@ class TabulateFusionSeTGradGradOp : public OpKernel { nnei_i, nnei_j, last_layer_size); #endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM OP_REQUIRES(context, (last_layer_size <= 1024), - absl::InvalidArgumentError( + errors::InvalidArgument( "In the process of model compression, the size of the " "last layer of embedding net must be less than 1024!")); } else if (device == "CPU") { @@ -781,9 +781,9 @@ class TabulateFusionSeROp : public OpKernel { const Tensor& em_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (table_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of table should be 2")); + errors::InvalidArgument("Dim of table should be 2")); OP_REQUIRES(context, (em_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); TensorShape descriptor_shape; descriptor_shape.AddDim(em_tensor.shape().dim_size(0)); descriptor_shape.AddDim(em_tensor.shape().dim_size(1)); // be careful here; @@ -838,7 +838,7 @@ class TabulateFusionSeRGradOp : public OpKernel { const Tensor& descriptor_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (dy_tensor.shape().dims() == 3), - absl::InvalidArgumentError("Dim of table should be 3")); + errors::InvalidArgument("Dim of table should be 3")); int context_output_index = 0; Tensor* dy_dem_tensor = NULL; OP_REQUIRES_OK(context, @@ -887,7 +887,7 @@ class TabulateFusionSeRGradGradOp : public OpKernel { const Tensor& descriptor_tensor = context->input(context_input_index++); // set size of the sample OP_REQUIRES(context, (dz_dy_dem_tensor.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); int context_output_index = 0; Tensor* dz_dy_tensor = NULL; OP_REQUIRES_OK(context, context->allocate_output(context_output_index++, @@ -911,7 +911,7 @@ class TabulateFusionSeRGradGradOp : public OpKernel { dz_dy, table, table_info, em, dz_dy_dem, nloc, nnei, last_layer_size); #endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM OP_REQUIRES(context, (last_layer_size <= 1024), - absl::InvalidArgumentError( + errors::InvalidArgument( "In the process of model compression, the size of the " "last layer of embedding net must be less than 1024!")); } else if (device == "CPU") { diff --git a/source/op/tf/unaggregated_grad.cc b/source/op/tf/unaggregated_grad.cc index d0bd3c1dfd..cf645f6c21 100644 --- a/source/op/tf/unaggregated_grad.cc +++ b/source/op/tf/unaggregated_grad.cc @@ -305,11 +305,11 @@ class UnaggregatedDyDxSOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (y.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); OP_REQUIRES(context, (w.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); OP_REQUIRES(context, (xbar.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); // check functype int context_output_index = 0; @@ -351,13 +351,13 @@ class UnaggregatedDy2DxSOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (y.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); OP_REQUIRES(context, (dy.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); OP_REQUIRES(context, (w.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); OP_REQUIRES(context, (xbar.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); int context_output_index = 0; Tensor* dy2_dx = NULL; @@ -398,13 +398,13 @@ class UnaggregatedDyDxOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (z.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); OP_REQUIRES(context, (w.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); OP_REQUIRES(context, (dy_dx.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); OP_REQUIRES(context, (ybar.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); int context_output_index = 0; Tensor* dz_dx = NULL; @@ -448,15 +448,15 @@ class UnaggregatedDy2DxOp : public OpKernel { // set size of the sample OP_REQUIRES(context, (z.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); OP_REQUIRES(context, (w.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); OP_REQUIRES(context, (dy_dx.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); OP_REQUIRES(context, (dy2_dx.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); OP_REQUIRES(context, (ybar.shape().dims() == 2), - absl::InvalidArgumentError("Dim of input should be 2")); + errors::InvalidArgument("Dim of input should be 2")); int context_output_index = 0; Tensor* dz2_dx = NULL; From 7668543a84c2fade1ce87aea1e17507b8b652c0f Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 14 Aug 2025 23:57:43 +0800 Subject: [PATCH 17/17] Update source/cmake/Findtensorflow.cmake Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Jinzhe Zeng --- source/cmake/Findtensorflow.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/cmake/Findtensorflow.cmake b/source/cmake/Findtensorflow.cmake index f4d13e1a75..b5b8c92f3d 100644 --- a/source/cmake/Findtensorflow.cmake +++ b/source/cmake/Findtensorflow.cmake @@ -309,7 +309,7 @@ endif() if(TENSORFLOW_VERSION VERSION_GREATER_EQUAL 2.20) # since TF 2.20, macros like TF_MAJOR_VERSION, TF_MINOR_VERSION, and # TF_PATCH_VERSION are not defined We manuanlly define them in our CMake files - # firstly, split TENSORFLOW_VERSION (e.g. 2.20.0rc0) to 2 20 0 rc0 + # first, split TENSORFLOW_VERSION (e.g. 2.20.0rc0) to 2 20 0 rc0 string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)$" _match ${TENSORFLOW_VERSION}) if(_match)