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

feat(//tests): Update rtol and atol based tolerance for test cases #1055

Merged
merged 3 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions tests/util/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ namespace torch_tensorrt {
namespace tests {
namespace util {

bool almostEqual(const at::Tensor& a, const at::Tensor& b, float threshold, float atol = 1e-8, float rtol = 1e-5) {
bool almostEqual(const at::Tensor& a, const at::Tensor& b, float atol = 1e-8, float rtol = 1e-5) {
LOG_GRAPH(a << std::endl << b << std::endl);
auto a_float = a.toType(at::kFloat);
auto b_float = b.toType(at::kFloat);

auto diff = a_float - b_float;
auto result = diff.abs().max().item<float>() - (atol + rtol * b.abs().max().item<float>());
auto result = diff.abs().max().item<float>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This equation is still confusing (see #1052)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the discussion in 1052, is this resolved? Anurag mentioned we need this PR for DLFW release.

auto threshold = atol + (rtol * b.abs().max().item<float>());

std::cout << "Max Difference: " << result << std::endl;
std::cout << "Acceptable Threshold: " << threshold << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion tests/util/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace torch_tensorrt {
namespace tests {
namespace util {

bool almostEqual(const at::Tensor& a, const at::Tensor& b, float threshold, float atol = 1e-8, float rtol = 1e-5);
bool almostEqual(const at::Tensor& a, const at::Tensor& b, float atol = 1e-8, float rtol = 1e-5);

bool exactlyEqual(const at::Tensor& a, const at::Tensor& b);

Expand Down