5 ms·
Huh. I'd have written TORCH_CHECK like this: TORCH_CHECK(self.dim() == 1) << "Expected dim to be a 1-D tensor " << "but was " << self.dim() <<
by quotemstr 2y ago
Huh. I'd have written TORCH_CHECK like this:
TORCH_CHECK(self.dim() == 1)
<< "Expected dim to be a 1-D tensor "
<< "but was " << self.dim() << "-D tensor";
Turns out it's possible to write TORCH_CHECK() so that it evaluates the streaming operators only if the check fails. (Check out how glog works.)