Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yb/fix autocompare #745

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ def create_call_aten_cpu_cpp_function_code_from_config(fun_config):
opname = re.sub("\.dim_min", "_outf", opname)
opname = re.sub("\.correction", "", opname)
opname = re.sub("\.input", "", opname)
opname = re.sub("\.dim_IntList", "", opname)
opname = opname.replace(".", "_")
opname = opname.split(".")[0]
if opname[-1] == "_" and len(get_function_return_param_from_schema(schema)) > 0:
Expand Down
15 changes: 15 additions & 0 deletions dipu/torch_dipu/csrc_dipu/aten/ops/AutoCompareUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,20 @@ inline std::string allclose_autocompare(
return stream.str();
}

template <typename T,
std::enable_if_t<std::is_arithmetic<T>::value, bool> = true>
inline std::string allclose_autocompare(T val_expected, T val_real,
int indentation = 2) {
std::ostringstream stream;
stream << std::setfill(' ');
if (val_expected != val_real) {
stream << std::setw(indentation) << "not allclose: expected val is "
<< val_expected << " but the real val is " << val_real << std::endl;
} else {
stream << "allclose" << std::endl;
}
return stream.str();
}

} // namespace native
} // namespace dipu