Skip to content

Commit 2f0252d

Browse files
committed
[ET-Ext] Enable operator<< for Half tensor
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 Differential Revision: [D57977366](https://our.internmc.facebook.com/intern/diff/D57977366/)
1 parent e650dd9 commit 2f0252d

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)