PyTorch torch.resolve_conj Function
Pytorch torch Reference Manual
torch.resolve_conjIt is a function in PyTorch used to resolve conjugate views. If the input tensor is a view of a conjugate complex number, this function returns the actual tensor data; otherwise, it directly returns the original tensor.
Function Definition
torch.resolve_conj(input)
Usage Example
Example
import torch
# Create a complex tensor
x = torch.randn(3, dtype=torch.complex64)
# Get conjugate view
x_conj = torch.conj(x)
# Resolve conjugate
resolved = torch.resolve_conj(x_conj)
print("Original tensor:", x)
print("Conjugate view:", x_conj)
print("After resolution:", resolved)
# Create a complex tensor
x = torch.randn(3, dtype=torch.complex64)
# Get conjugate view
x_conj = torch.conj(x)
# Resolve conjugate
resolved = torch.resolve_conj(x_conj)
print("Original tensor:", x)
print("Conjugate view:", x_conj)
print("After resolution:", resolved)
The output result is:
原始张量: tensor([ 1.2345+0.5678j, -2.3456+1.2345j, 3.4567-0.9876j]) 共轭视图: tensor([ 1.2345-0.5678j, -2.3456-1.2345j, 3.4567+0.9876j]) 解析后: tensor([ 1.2345-0.5678j, -2.3456-1.2345j, 3.4567+0.9876j])
Other Extensions