Skip to content

Commit 9d6bf72

Browse files
manuelcandalesfacebook-github-bot
authored andcommitted
Fix operator<< for Half (#2294)
Summary: Pull Request resolved: #2294 bypass-github-export-checks Reviewed By: mergennachin Differential Revision: D54638827 fbshipit-source-id: 98e2c0a3bc2804d677cc3d38561e55d6b54d8f7e
1 parent 49065cc commit 9d6bf72

File tree

3 files changed

+6
-30
lines changed

3 files changed

+6
-30
lines changed

runtime/core/portable_type/half.cpp

Lines changed: 0 additions & 28 deletions
This file was deleted.

runtime/core/portable_type/half.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,12 @@ inline Half operator/(int64_t a, Half b) {
674674
/// NOTE: we do not define comparisons directly and instead rely on the implicit
675675
/// conversion Half to float.
676676

677-
std::ostream& operator<<(std::ostream& out, const Half& value);
677+
static inline std::ostream& operator<<(
678+
std::ostream& out,
679+
const torch::executor::Half& value) {
680+
out << (float)value;
681+
return out;
682+
}
678683

679684
} // namespace executor
680685
} // namespace torch

runtime/core/portable_type/targets.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def define_common_targets():
4040
# Set up a specific exported library for scalar_type to avoid circle dependency in ScalarTypeUtil.h
4141
runtime.cxx_library(
4242
name = "scalar_type",
43-
srcs = ["half.cpp"],
4443
exported_headers = [
4544
"bfloat16.h",
4645
"complex.h",

0 commit comments

Comments
 (0)