Skip to content
Open
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
4 changes: 2 additions & 2 deletions kernels/portable/cpu/scalar_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ bool extract_scalar(Scalar scalar, FLOAT_T* out_val) {
// be represented when FLOAT_T == float. float can, however, represent
// infinite and NaN values.
if (std::isfinite(val) &&
(val < std::numeric_limits<FLOAT_T>::lowest() ||
val > std::numeric_limits<FLOAT_T>::max())) {
(val < static_cast<double>(std::numeric_limits<FLOAT_T>::lowest()) ||
val > static_cast<double>(std::numeric_limits<FLOAT_T>::max()))) {
// PyTorch's implementation of clamp() raises an exception if the min/max
// values cannot be represented as the dtype, so we should fail too.
return false;
Expand Down
2 changes: 1 addition & 1 deletion kernels/portable/cpu/util/distance_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void pdist(const Tensor& in, Tensor& out, double p) {
pdist<CTYPE, L1<CTYPE>>(in, out, p);
} else if (p == 2.0) {
pdist<CTYPE, L2<CTYPE>>(in, out, p);
} else if (p == INFINITY) {
} else if (p == static_cast<double>(INFINITY)) {
pdist<CTYPE, Linf<CTYPE>>(in, out, p);
} else {
pdist<CTYPE, Lp<CTYPE>>(in, out, p);
Expand Down
3 changes: 2 additions & 1 deletion kernels/portable/cpu/util/math_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ template <
type = true>
FLOAT_T floor_divide(FLOAT_T a, FLOAT_T b) {
if (b == 0) {
return std::signbit(a) ? -INFINITY : INFINITY;
return std::signbit(a) ? static_cast<FLOAT_T>(-INFINITY)
: static_cast<FLOAT_T>(INFINITY);
}
const auto mod = std::fmod(a, b);
auto div = (a - mod) / b;
Expand Down
5 changes: 3 additions & 2 deletions runtime/core/exec_aten/testing_util/tensor_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ bool element_is_close(const T a, const T b, double rtol, double atol) {
return false;
}
} else {
auto allowed_error = atol + std::abs(rtol * b);
auto actual_error = std::abs(a - b);
const double allowed_error =
atol + std::abs(rtol * static_cast<double>(b));
const double actual_error = static_cast<double>(std::abs(a - b));
if (!std::isfinite(actual_error) || actual_error > allowed_error) {
return false;
}
Expand Down