Skip to content
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
11 changes: 10 additions & 1 deletion test/cpp/cpp_test_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <string>

#include "tensorflow/compiler/xla/xla_client/debug_macros.h"
#include "tensorflow/compiler/xla/xla_client/sys_util.h"
#include "torch_xla/csrc/aten_xla_bridge.h"
#include "torch_xla/csrc/ir_dump_util.h"
#include "torch_xla/csrc/lowering_context.h"
Expand Down Expand Up @@ -82,7 +83,15 @@ bool CloseValues(at::Tensor tensor1, at::Tensor tensor2, double rtol,
tensor2 = ToCpuTensor(tensor2);
bool equal = tensor1.allclose(tensor2, rtol, atol);
if (!equal) {
std::cerr << tensor1 << "\n-vs-\n" << tensor2 << "\n";
static bool dump_tensors =
xla::sys_util::GetEnvBool("XLA_TEST_DUMP_TENSORS", false);
at::Tensor diff = tensor1 - tensor2;
std::cerr << "Difference Tensor:\n" << diff << "\n";
if (dump_tensors) {
std::cerr << "Compared Tensors:\n"
<< tensor1 << "\n-vs-\n"
<< tensor2 << "\n";
}
}
return equal;
}
Expand Down
8 changes: 4 additions & 4 deletions test/cpp/test_tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ TEST_F(TensorTest, TestConv2D) {
/*output_padding=*/{output_padding, output_padding},
/*groups=*/groups);
}
AllClose(output, dev_output);
AllClose(output, dev_output, /*rtol=*/5e-3, /*atol=*/1e-3);
});
};
}
Expand Down Expand Up @@ -567,7 +567,7 @@ TEST_F(TensorTest, TestConv2DNonSquare) {
/*output_padding=*/{output_padding, output_padding + 1},
/*groups=*/groups);
}
AllClose(output, dev_output);
AllClose(output, dev_output, /*rtol=*/5e-3, /*atol=*/1e-3);
});
}
}
Expand Down Expand Up @@ -638,7 +638,7 @@ TEST_F(TensorTest, TestConv3D) {
{output_padding, output_padding, output_padding},
/*groups=*/groups);
}
AllClose(output, dev_output);
AllClose(output, dev_output, /*rtol=*/5e-3, /*atol=*/1e-3);
});
};
}
Expand Down Expand Up @@ -709,7 +709,7 @@ TEST_F(TensorTest, TestConv3DNonSquare) {
{output_padding, output_padding + 1, output_padding},
/*groups=*/groups);
}
AllClose(output, dev_output);
AllClose(output, dev_output, /*rtol=*/5e-3, /*atol=*/1e-3);
});
};
}
Expand Down