Skip to content

Commit 196bcca

Browse files
author
Han Wang
committed
fix(c++): raise error when fparam required but not provided and no default
Consistent with the Python side: throw deepmd_exception instead of passing a shape-mismatched {0} tensor that would crash in AOTInductor.
1 parent b6e7db3 commit 196bcca

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

source/api_cc/src/DeepPotPTExpt.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,11 @@ void DeepPotPTExpt::compute(ENERGYVTYPE& ener,
832832
torch::TensorOptions().dtype(torch::kFloat64))
833833
.clone()
834834
.to(device);
835+
} else if (dfparam > 0) {
836+
throw deepmd::deepmd_exception(
837+
"fparam is required for this model (dim_fparam=" +
838+
std::to_string(dfparam) +
839+
") but was not provided, and no default_fparam is stored.");
835840
} else {
836841
fparam_tensor = torch::zeros({0}, options).to(device);
837842
}
@@ -1082,6 +1087,11 @@ void DeepPotPTExpt::compute(ENERGYVTYPE& ener,
10821087
torch::TensorOptions().dtype(torch::kFloat64))
10831088
.clone()
10841089
.to(device);
1090+
} else if (dfparam > 0) {
1091+
throw deepmd::deepmd_exception(
1092+
"fparam is required for this model (dim_fparam=" +
1093+
std::to_string(dfparam) +
1094+
") but was not provided, and no default_fparam is stored.");
10851095
} else {
10861096
fparam_tensor = torch::zeros({0}, options).to(device);
10871097
}

0 commit comments

Comments
 (0)