unary_op_impl_with_complex_to_float_out Class — pytorch Architecture
Architecture documentation for the unary_op_impl_with_complex_to_float_out class in UnaryOps.cpp from the pytorch codebase.
Entity Profile
Source Code
aten/src/ATen/native/UnaryOps.cpp lines 431–456
template <typename Stub>
static inline Tensor& unary_op_impl_with_complex_to_float_out(Tensor& result, const Tensor& self, Stub& stub, bool promotes_integer_to_float) {
if (self.is_complex() && !result.is_complex()) {
// Checks if the corresponding float type can be cast to the desired dtype
const auto float_type = c10::toRealValueType(self.scalar_type());
TORCH_CHECK(canCast(float_type, result.scalar_type()),
"result type ", float_type, " can't be cast to the desired output type ",
result.scalar_type());
// Runs the function complex->complex, as TensorIterator expects
Tensor complex_result = at::empty({0}, self.options());
auto iter = TensorIterator::unary_op(complex_result, self);
stub(iter.device_type(), iter);
// Copies the complex result to the actual result and returns it
at::native::resize_output(result, complex_result.sizes());
result.copy_(at::real(complex_result));
return result;
}
if (promotes_integer_to_float) {
return unary_op_impl_float_out(result, self, stub);
}
return unary_op_impl_out(result, self, stub);
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free