Skip to content

Commit 8c8d965

Browse files
jorgep31415facebook-github-bot
authored andcommitted
Enable operator<< for Half tensor (#3779)
Summary: Pull Request resolved: #3779 Useful for debugging `Half` i.e. `fp16` models, when we have `EValue`s that are `Half` dtype and we do the following: ``` std::cout << "===== INPUT =====" << std::endl; for (EValue& v : inputs) { std::cout << v << std::endl; } std::cout << "===== OUTPUT =====" << std::endl; for (EValue& v : outputs) { std::cout << v << std::endl; } ``` ## Before ``` ===== INPUT ===== tensor(sizes=[1, 3, 96, 72], [<unhandled scalar type 5>]) ===== OUTPUT ===== tensor(sizes=[1, 2, 96, 72], [<unhandled scalar type 5>]) ``` ## After ``` ===== INPUT ===== tensor(sizes=[1, 3, 96, 72], [0.279785, 0.271484, 0.364746, ..., 0.150391, 0.836426, 0.019043]) ===== OUTPUT ===== tensor(sizes=[1, 2, 96, 72], [18.2344, -10.0938, 1.35059, ..., -33.6875, 4.07422, -22.5312]) ``` ghstack-source-id: 228461839 Reviewed By: copyrightly Differential Revision: D57977366 fbshipit-source-id: a9ba1c11f75af85dcf7c91b9b06b4ec3333455bc
1 parent 70e3395 commit 8c8d965

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

extension/evalue_util/print_evalue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void print_tensor(std::ostream& os, exec_aten::Tensor tensor) {
158158
break;
159159

160160
switch (tensor.scalar_type()) {
161-
ET_FORALL_REAL_TYPES_AND(Bool, PRINT_TENSOR_DATA)
161+
ET_FORALL_REAL_TYPES_AND2(Bool, Half, PRINT_TENSOR_DATA)
162162
default:
163163
os << "[<unhandled scalar type " << (int)tensor.scalar_type() << ">]";
164164
}

0 commit comments

Comments
 (0)