Added a large number of low-level PyTorch wrapper nodes.
This commit is contained in:
@@ -27,7 +27,7 @@ class NumpyFloatCreate:
|
||||
|
||||
RETURN_TYPES: tuple = ("NDARRAY",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Numpy wrapper"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, data: str) -> tuple:
|
||||
"""
|
||||
|
||||
@@ -27,7 +27,7 @@ class NumpyIntCreate:
|
||||
|
||||
RETURN_TYPES: tuple = ("NDARRAY",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Numpy wrapper"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, data: str) -> tuple:
|
||||
"""
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtAbs:
|
||||
"""
|
||||
Computes the absolute value of each element in a PyTorch tensor.
|
||||
|
||||
category: PyTorch wrapper - Math operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Computes the absolute value of a PyTorch tensor element-wise.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of numerical type.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying the absolute function.
|
||||
"""
|
||||
return (torch.abs(tens_a),)
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtAcos:
|
||||
"""
|
||||
Computes the arccosine (inverse cosine) of a PyTorch tensor element-wise.
|
||||
|
||||
category: PyTorch wrapper - Math operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Computes the element-wise arccosine (inverse cosine) of a PyTorch tensor.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of numerical type. Values must be in the range [-1, 1].
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying the arccosine function.
|
||||
"""
|
||||
return (torch.acos(tens_a),)
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtAdd:
|
||||
"""
|
||||
Adds two PyTorch tensors.
|
||||
|
||||
category: PyTorch wrapper - Arithmetic operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Adds two PyTorch tensors.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of any shape.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of shape that supports addition with `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor.
|
||||
"""
|
||||
return (torch.add(tens_a, tens_b),)
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtAsin:
|
||||
"""
|
||||
Computes the arcsine (inverse sine) of a PyTorch tensor element-wise.
|
||||
|
||||
category: PyTorch wrapper - Math operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Computes the element-wise arcsine (inverse sine) of a PyTorch tensor.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of numerical type. Values must be in the range [-1, 1].
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying the arcsine function.
|
||||
"""
|
||||
return (torch.asin(tens_a),)
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtAtan:
|
||||
"""
|
||||
Computes the arc tangent (inverse tangent) of a PyTorch tensor element-wise.
|
||||
|
||||
category: PyTorch wrapper - Math operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Computes the element-wise arc tangent (inverse tangent) of a PyTorch tensor.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of numerical type.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying the arc tangent function.
|
||||
"""
|
||||
return (torch.atan(tens_a),)
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtBitwiseAnd:
|
||||
"""
|
||||
Performs a bitwise AND operation on two PyTorch tensors element-wise.
|
||||
|
||||
category: PyTorch wrapper - Bitwise operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Performs a bitwise AND operation on two PyTorch tensors.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of integer type.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of the same shape and integer type as `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying bitwise AND.
|
||||
"""
|
||||
return (torch.bitwise_and(tens_a, tens_b),)
|
||||
@@ -0,0 +1,42 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtBitwiseLeftShift:
|
||||
"""
|
||||
Performs a bitwise left shift operation on two PyTorch tensors element-wise.
|
||||
|
||||
category: PyTorch wrapper - Bitwise operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Performs a bitwise left shift operation on two PyTorch tensors.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of integer type.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of the same shape and integer type as `tens_a`,
|
||||
representing the number of positions to shift.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying bitwise left shift.
|
||||
"""
|
||||
return (torch.bitwise_left_shift(tens_a, tens_b),)
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtBitwiseNot:
|
||||
"""
|
||||
Performs a bitwise NOT operation on a PyTorch tensor element-wise.
|
||||
|
||||
category: PyTorch wrapper - Bitwise operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Performs a bitwise NOT operation on a PyTorch tensor.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of integer type.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying bitwise NOT.
|
||||
"""
|
||||
return (torch.bitwise_not(tens_a),)
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtBitwiseOr:
|
||||
"""
|
||||
Performs a bitwise OR operation on two PyTorch tensors element-wise.
|
||||
|
||||
category: PyTorch wrapper - Bitwise operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Performs a bitwise OR operation on two PyTorch tensors.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of integer type.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of the same shape and integer type as `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying bitwise OR.
|
||||
"""
|
||||
return (torch.bitwise_or(tens_a, tens_b),)
|
||||
@@ -0,0 +1,42 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtBitwiseRightShift:
|
||||
"""
|
||||
Performs a bitwise right shift operation on two PyTorch tensors element-wise.
|
||||
|
||||
category: PyTorch wrapper - Bitwise operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Performs a bitwise right shift operation on two PyTorch tensors.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of integer type.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of the same shape and integer type as `tens_a`,
|
||||
representing the number of positions to shift.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying bitwise right shift.
|
||||
"""
|
||||
return (torch.bitwise_right_shift(tens_a, tens_b),)
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtBitwiseXor:
|
||||
"""
|
||||
Performs a bitwise XOR operation on two PyTorch tensors element-wise.
|
||||
|
||||
category: PyTorch wrapper - Bitwise operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Performs a bitwise XOR operation on two PyTorch tensors.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of integer type.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of the same shape and integer type as `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying bitwise XOR.
|
||||
"""
|
||||
return (torch.bitwise_xor(tens_a, tens_b),)
|
||||
@@ -0,0 +1,44 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtBmm:
|
||||
"""
|
||||
Performs batched matrix multiplication on two 3D PyTorch tensors.
|
||||
|
||||
category: PyTorch wrapper - Matrix operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Performs batched matrix multiplication on two 3D PyTorch tensors.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A 3D PyTorch tensor (batch, m, n).
|
||||
tens_b (torch.Tensor): A 3D PyTorch tensor (batch, n, p) that supports matrix multiplication with `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant 3D tensor.
|
||||
"""
|
||||
if tens_a.dim() != 3 or tens_b.dim() != 3:
|
||||
raise ValueError("torch.bmm() only supports batch matrix multiplication for 3D tensors.")
|
||||
|
||||
return (torch.bmm(tens_a, tens_b),)
|
||||
@@ -0,0 +1,51 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
import ast
|
||||
|
||||
|
||||
class PtBoolCreate:
|
||||
"""
|
||||
Creates a PyTorch tensor of dtype bool from True or False values entered as a list in the text field.
|
||||
For example, entering:
|
||||
```
|
||||
[True, False, False]
|
||||
```
|
||||
will create a 1D boolean tensor.
|
||||
|
||||
category: PyTorch wrapper - Tensor creation
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"data": ("STRING", {"multiline": True}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, data: str) -> tuple:
|
||||
"""
|
||||
Creates a PyTorch tensor with bool data type using True or False string values entered in the text field.
|
||||
|
||||
Args:
|
||||
data (str): String value in the text field.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the tensor.
|
||||
"""
|
||||
# Convert string to Python list
|
||||
list_data = ast.literal_eval(data)
|
||||
|
||||
# Convert list to PyTorch tensor
|
||||
tensor = torch.tensor(list_data, dtype=torch.bool)
|
||||
return (tensor,)
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtCos:
|
||||
"""
|
||||
Computes the cosine of a PyTorch tensor element-wise.
|
||||
|
||||
category: PyTorch wrapper - Math operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Computes the element-wise cosine of a PyTorch tensor.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of numerical type, representing angles in radians.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying the cosine function.
|
||||
"""
|
||||
return (torch.cos(tens_a),)
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtCosh:
|
||||
"""
|
||||
Computes the hyperbolic cosine of a PyTorch tensor element-wise.
|
||||
|
||||
category: PyTorch wrapper - Math operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Computes the element-wise hyperbolic cosine of a PyTorch tensor.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of numerical type.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying the hyperbolic cosine function.
|
||||
"""
|
||||
return (torch.cosh(tens_a),)
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtDiv:
|
||||
"""
|
||||
Divides one PyTorch tensor by another element-wise.
|
||||
|
||||
category: PyTorch wrapper - Arithmetic operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Divides one PyTorch tensor by another element-wise.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of any shape.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of shape that supports element-wise division with `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor.
|
||||
"""
|
||||
return (torch.div(tens_a, tens_b),)
|
||||
@@ -0,0 +1,67 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
|
||||
class PtEinsum:
|
||||
"""
|
||||
Performs Tensor operations specified in the Einstein summation equation.
|
||||
|
||||
Specify Einstein summation notation in the first socket.
|
||||
Specify two tensors in tens_a, tens_b. If you specify the third tensor, specify in tens_c.
|
||||
Otherwise, leave the socket unconnected.
|
||||
|
||||
Sublist format is not supported.
|
||||
|
||||
category: PyTorch wrapper - Matrix operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"equation": ("STRING", {"default": ""}),
|
||||
"tens_a": ("TENSOR", {})
|
||||
},
|
||||
"optional":{
|
||||
"tens_b": ("TENSOR", {}),
|
||||
"tens_c": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self,
|
||||
equation: str,
|
||||
tens_a: torch.Tensor,
|
||||
tens_b: torch.Tensor = None,
|
||||
tens_c: torch.Tensor = None) -> tuple:
|
||||
"""
|
||||
Performs Tensor operations specified in the Einstein summation equation.
|
||||
|
||||
Args:
|
||||
equation (str): Einstein summation equation.
|
||||
tens_a (torch.Tensor): A PyTorch tensor.
|
||||
tens_b (torch.Tensor): A PyTorch tensor.
|
||||
tens_c (torch.Tensor): A PyTorch tensor.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor.
|
||||
"""
|
||||
if tens_a is None:
|
||||
raise ValueError("tens_a is None")
|
||||
|
||||
if tens_b is None and tens_c is None:
|
||||
tens_ret_val = torch.einsum(equation, tens_a)
|
||||
elif tens_c is None:
|
||||
tens_ret_val = torch.einsum(equation, tens_a, tens_b)
|
||||
else:
|
||||
tens_ret_val = torch.einsum(equation, tens_a, tens_b, tens_c)
|
||||
return (tens_ret_val,)
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtEq:
|
||||
"""
|
||||
Tests whether two PyTorch tensors are equal element-wise.
|
||||
|
||||
category: PyTorch wrapper - Comparison operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Compares two PyTorch tensors for element-wise equality.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of any shape.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of the same shape as `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a boolean tensor indicating element-wise equality.
|
||||
"""
|
||||
return (torch.eq(tens_a, tens_b),)
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtExp:
|
||||
"""
|
||||
Performs an exponential operation on a PyTorch tensor element-wise.
|
||||
|
||||
category: PyTorch wrapper - Math operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Computes the element-wise exponential of a PyTorch tensor.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of numerical type.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying the exponential function.
|
||||
"""
|
||||
return (torch.exp(tens_a),)
|
||||
@@ -25,7 +25,7 @@ class PtFlatten:
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "PyTorch wrapper"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens: torch.Tensor) -> tuple:
|
||||
"""
|
||||
|
||||
@@ -8,7 +8,7 @@ class PtFloatCreate:
|
||||
Creates a PyTorch tensor with 32-bit floating point precision
|
||||
using values entered in the text field.
|
||||
|
||||
category: PyTorch wrapper
|
||||
category: PyTorch wrapper - Tensor creation
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -27,7 +27,7 @@ class PtFloatCreate:
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "PyTorch wrapper"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, data: str) -> tuple:
|
||||
"""
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtFloorDiv:
|
||||
"""
|
||||
Performs element-wise floor division on two PyTorch tensors.
|
||||
|
||||
category: PyTorch wrapper - Arithmetic operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Performs element-wise floor division on two PyTorch tensors.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of any shape.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of shape that supports element-wise floor division with `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor.
|
||||
"""
|
||||
return (torch.floor_divide(tens_a, tens_b),)
|
||||
@@ -6,7 +6,7 @@ class PtFromImage:
|
||||
"""
|
||||
Casts an Image tensor as a PyTorch tensor.
|
||||
|
||||
category: PyTorch wrapper
|
||||
category: PyTorch wrapper - Tensor creation
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -25,7 +25,7 @@ class PtFromImage:
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "PyTorch wrapper"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, image: torch.Tensor) -> tuple:
|
||||
"""
|
||||
|
||||
@@ -6,7 +6,7 @@ class PtFromLatent:
|
||||
"""
|
||||
Casts a latent tensor as a PyTorch tensor.
|
||||
|
||||
category: PyTorch wrapper
|
||||
category: PyTorch wrapper - Tensor creation
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -25,7 +25,7 @@ class PtFromLatent:
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "PyTorch wrapper"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, latent: torch.Tensor) -> tuple:
|
||||
"""
|
||||
|
||||
@@ -7,7 +7,7 @@ class PtFromNumpy:
|
||||
"""
|
||||
Converts a NumPy ndarray to a PyTorch tensor while preserving its data type.
|
||||
|
||||
category: PyTorch wrapper
|
||||
category: PyTorch wrapper - Tensor creation
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -26,7 +26,7 @@ class PtFromNumpy:
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "PyTorch wrapper"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, array: np.ndarray) -> Tuple[torch.Tensor]:
|
||||
"""
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtGe:
|
||||
"""
|
||||
Tests whether elements in the first PyTorch tensor are greater than or equal to the corresponding elements in the second tensor.
|
||||
|
||||
category: PyTorch wrapper - Comparison operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Compares two PyTorch tensors for element-wise greater-than-or-equal-to condition.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of any shape.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of the same shape as `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a boolean tensor indicating where `tens_a >= tens_b`.
|
||||
"""
|
||||
return (torch.ge(tens_a, tens_b),)
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtGt:
|
||||
"""
|
||||
Tests whether elements in the first PyTorch tensor are greater than the corresponding elements in the second tensor.
|
||||
|
||||
category: PyTorch wrapper - Comparison operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Compares two PyTorch tensors for element-wise greater-than condition.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of any shape.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of the same shape as `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a boolean tensor indicating where `tens_a > tens_b`.
|
||||
"""
|
||||
return (torch.gt(tens_a, tens_b),)
|
||||
@@ -8,7 +8,7 @@ class PtIntCreate:
|
||||
Creates a PyTorch tensor with 32-bit integer
|
||||
using values entered in the text field.
|
||||
|
||||
category: PyTorch wrapper
|
||||
category: PyTorch wrapper - Tensor creation
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -27,7 +27,7 @@ class PtIntCreate:
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "PyTorch wrapper"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, data: str) -> tuple:
|
||||
"""
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtLe:
|
||||
"""
|
||||
Tests whether elements in the first PyTorch tensor are less than or equal to the corresponding elements in the second tensor.
|
||||
|
||||
category: PyTorch wrapper - Comparison operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Compares two PyTorch tensors for element-wise less-than-or-equal-to condition.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of any shape.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of the same shape as `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a boolean tensor indicating where `tens_a <= tens_b`.
|
||||
"""
|
||||
return (torch.le(tens_a, tens_b),)
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtLog:
|
||||
"""
|
||||
Computes the natural logarithm (log base e) of a PyTorch tensor element-wise.
|
||||
|
||||
category: PyTorch wrapper - Math operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Computes the element-wise natural logarithm (log base e) of a PyTorch tensor.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of numerical type. Must contain only positive values.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying the natural logarithm.
|
||||
"""
|
||||
return (torch.log(tens_a),)
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtLogicalAnd:
|
||||
"""
|
||||
Performs a logical AND operation on two PyTorch tensors element-wise.
|
||||
|
||||
category: PyTorch wrapper - Logical operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Performs a logical AND operation on two PyTorch tensors.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of boolean or numerical type.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of the same shape and type as `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a boolean tensor where `tens_a AND tens_b` is applied element-wise.
|
||||
"""
|
||||
return (torch.logical_and(tens_a, tens_b),)
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtLogicalNot:
|
||||
"""
|
||||
Performs a logical NOT operation on a PyTorch tensor element-wise.
|
||||
|
||||
category: PyTorch wrapper - Logical operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Performs a logical NOT operation on a PyTorch tensor.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of boolean or numerical type.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying logical NOT.
|
||||
"""
|
||||
return (torch.logical_not(tens_a),)
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtLogicalOr:
|
||||
"""
|
||||
Performs a logical OR operation on two PyTorch tensors element-wise.
|
||||
|
||||
category: PyTorch wrapper - Logical operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Performs a logical OR operation on two PyTorch tensors.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of boolean or numerical type.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of the same shape and type as `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a boolean tensor where `tens_a OR tens_b` is applied element-wise.
|
||||
"""
|
||||
return (torch.logical_or(tens_a, tens_b),)
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtLogicalXor:
|
||||
"""
|
||||
Performs a logical XOR operation on two PyTorch tensors element-wise.
|
||||
|
||||
category: PyTorch wrapper - Logical operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Performs a logical XOR operation on two PyTorch tensors.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of boolean or numerical type.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of the same shape and type as `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a boolean tensor where `tens_a XOR tens_b` is applied element-wise.
|
||||
"""
|
||||
return (torch.logical_xor(tens_a, tens_b),)
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtLt:
|
||||
"""
|
||||
Tests whether elements in the first PyTorch tensor are less than the corresponding elements in the second tensor.
|
||||
|
||||
category: PyTorch wrapper - Comparison operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Compares two PyTorch tensors for element-wise less-than condition.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of any shape.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of the same shape as `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a boolean tensor indicating where `tens_a < tens_b`.
|
||||
"""
|
||||
return (torch.lt(tens_a, tens_b),)
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtMatMul:
|
||||
"""
|
||||
Performs matrix multiplication on two PyTorch tensors.
|
||||
|
||||
category: PyTorch wrapper - Matrix operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Performs matrix multiplication on two PyTorch tensors.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of shape compatible for matrix multiplication.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of shape that supports matrix multiplication with `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor.
|
||||
"""
|
||||
return (torch.matmul(tens_a, tens_b),)
|
||||
@@ -0,0 +1,44 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtMm:
|
||||
"""
|
||||
Performs 2D matrix multiplication on two PyTorch tensors.
|
||||
|
||||
category: PyTorch wrapper - Matrix operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Performs 2D matrix multiplication on two PyTorch tensors.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A 2D PyTorch tensor.
|
||||
tens_b (torch.Tensor): A 2D PyTorch tensor that supports matrix multiplication with `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor.
|
||||
"""
|
||||
if tens_a.dim() != 2 or tens_b.dim() != 2:
|
||||
raise ValueError("torch.mm() only supports 2D tensors.")
|
||||
|
||||
return (torch.mm(tens_a, tens_b),)
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtMul:
|
||||
"""
|
||||
Multiplies two PyTorch tensors element-wise.
|
||||
|
||||
category: PyTorch wrapper - Arithmetic operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Multiplies two PyTorch tensors element-wise.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of any shape.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of shape that supports element-wise multiplication with `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor.
|
||||
"""
|
||||
return (torch.mul(tens_a, tens_b),)
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtNe:
|
||||
"""
|
||||
Tests whether two PyTorch tensors are not equal element-wise.
|
||||
|
||||
category: PyTorch wrapper - Comparison operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Compares two PyTorch tensors for element-wise inequality.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of any shape.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of the same shape as `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a boolean tensor indicating element-wise inequality.
|
||||
"""
|
||||
return (torch.ne(tens_a, tens_b),)
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtNeg:
|
||||
"""
|
||||
Computes the negation of each element in a PyTorch tensor.
|
||||
|
||||
category: PyTorch wrapper - Math operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Computes the negation of a PyTorch tensor element-wise.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of numerical type.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying negation.
|
||||
"""
|
||||
return (torch.neg(tens_a),)
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtPow:
|
||||
"""
|
||||
Raises one PyTorch tensor to the power of another element-wise.
|
||||
|
||||
category: PyTorch wrapper - Arithmetic operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Raises one PyTorch tensor to the power of another element-wise.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of any shape.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of shape that supports element-wise exponentiation with `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor.
|
||||
"""
|
||||
return (torch.pow(tens_a, tens_b),)
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtRemainder:
|
||||
"""
|
||||
Computes the element-wise remainder of division between two PyTorch tensors.
|
||||
|
||||
category: PyTorch wrapper - Arithmetic operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Computes the element-wise remainder of division between two PyTorch tensors.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of any shape.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of shape that supports element-wise remainder computation with `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor.
|
||||
"""
|
||||
return (torch.remainder(tens_a, tens_b),)
|
||||
@@ -0,0 +1,62 @@
|
||||
"""
|
||||
Almost all of this code was taken from
|
||||
https://github.com/pythongosssss/ComfyUI-Custom-Scripts/blob/main/py/show_text.py
|
||||
|
||||
See credit/credit.md for the full license.
|
||||
"""
|
||||
from typing import List
|
||||
import torch
|
||||
|
||||
|
||||
class PtShowText:
|
||||
"""
|
||||
Displays PyTorch tensor as a string. Note that the tensor is partially printed out when
|
||||
the tensor contains more elements than the threshold set internally.
|
||||
|
||||
category: Display data
|
||||
"""
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"tens": ("TENSOR", {}),
|
||||
},
|
||||
"hidden": {
|
||||
"unique_id": "UNIQUE_ID",
|
||||
"extra_pnginfo": "EXTRA_PNGINFO",
|
||||
},
|
||||
}
|
||||
|
||||
INPUT_IS_LIST = True
|
||||
RETURN_TYPES = ("STRING",)
|
||||
FUNCTION = "notify"
|
||||
OUTPUT_NODE = True
|
||||
OUTPUT_IS_LIST = (True,)
|
||||
|
||||
CATEGORY = "Data Analysis"
|
||||
|
||||
MAX_NUM_ELEMENTS_TO_DISPLAY = 100
|
||||
|
||||
def notify(self, tens: torch.Tensor, unique_id=None, extra_pnginfo=None):
|
||||
torch.set_printoptions(threshold=PtShowText.MAX_NUM_ELEMENTS_TO_DISPLAY)
|
||||
text = str(tens[0])
|
||||
|
||||
if unique_id is not None and extra_pnginfo is not None:
|
||||
if not isinstance(extra_pnginfo, list):
|
||||
print("Error: extra_pnginfo is not a list")
|
||||
elif (
|
||||
not isinstance(extra_pnginfo[0], dict)
|
||||
or "workflow" not in extra_pnginfo[0]
|
||||
):
|
||||
print("Error: extra_pnginfo[0] is not a dict or missing 'workflow' key")
|
||||
else:
|
||||
workflow = extra_pnginfo[0]["workflow"]
|
||||
node = next(
|
||||
(x for x in workflow["nodes"] if str(x["id"]) == str(unique_id[0])),
|
||||
None,
|
||||
)
|
||||
if node:
|
||||
node["widgets_values"] = [text]
|
||||
else:
|
||||
print("unique_id or extra_pnginfo is None.")
|
||||
return {"ui": {"text": [text]}, "result": ([text],)}
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtSin:
|
||||
"""
|
||||
Computes the sine of a PyTorch tensor element-wise.
|
||||
|
||||
category: PyTorch wrapper - Math operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Computes the element-wise sine of a PyTorch tensor.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of numerical type, representing angles in radians.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying the sine function.
|
||||
"""
|
||||
return (torch.sin(tens_a),)
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtSinh:
|
||||
"""
|
||||
Computes the hyperbolic sine of a PyTorch tensor element-wise.
|
||||
|
||||
category: PyTorch wrapper - Math operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Computes the element-wise hyperbolic sine of a PyTorch tensor.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of numerical type.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying the hyperbolic sine function.
|
||||
"""
|
||||
return (torch.sinh(tens_a),)
|
||||
@@ -7,7 +7,7 @@ class PtSize:
|
||||
"""
|
||||
Extracts the PyTorch Size object of a PyTorch tensor using the size() method.
|
||||
|
||||
category: PyTorch wrapper
|
||||
category: PyTorch wrapper - Size object support
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -26,7 +26,7 @@ class PtSize:
|
||||
|
||||
RETURN_TYPES: tuple = ("PTSIZE",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "PyTorch wrapper"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens: torch.Tensor) -> tuple:
|
||||
"""
|
||||
|
||||
@@ -7,7 +7,7 @@ class PtSizeCreate:
|
||||
"""
|
||||
Creates a PyTorch Size using values entered in the text field.
|
||||
|
||||
category: PyTorch wrapper
|
||||
category: PyTorch wrapper - Size object support
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -26,7 +26,7 @@ class PtSizeCreate:
|
||||
|
||||
RETURN_TYPES: tuple = ("PTSIZE",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "PyTorch wrapper"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, data: str) -> tuple:
|
||||
"""
|
||||
|
||||
@@ -6,7 +6,7 @@ class PtSizeToNumpy:
|
||||
"""
|
||||
Converts PyTorch Size object to NumPy ndarray.
|
||||
|
||||
category: PyTorch wrapper
|
||||
category: PyTorch wrapper - Size object support
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -25,7 +25,7 @@ class PtSizeToNumpy:
|
||||
|
||||
RETURN_TYPES: tuple = ("NDARRAY",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "PyTorch wrapper"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, sz: torch.Size) -> tuple:
|
||||
"""
|
||||
|
||||
@@ -6,7 +6,7 @@ class PtSizeToString:
|
||||
"""
|
||||
Converts PyTorch Size object to a Python string.
|
||||
|
||||
category: PyTorch wrapper
|
||||
category: PyTorch wrapper - Size object support
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -25,7 +25,7 @@ class PtSizeToString:
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "PyTorch wrapper"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, sz: torch.Size) -> tuple:
|
||||
"""
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtSub:
|
||||
"""
|
||||
Subtracts one PyTorch tensor from another.
|
||||
|
||||
category: PyTorch wrapper - Arithmetic operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {}),
|
||||
"tens_b": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor, tens_b: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Subtracts one PyTorch tensor from another.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of any shape.
|
||||
tens_b (torch.Tensor): A PyTorch tensor of shape that supports subtraction from `tens_a`.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor.
|
||||
"""
|
||||
return (torch.sub(tens_a, tens_b),)
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtTan:
|
||||
"""
|
||||
Computes the tangent of a PyTorch tensor element-wise.
|
||||
|
||||
category: PyTorch wrapper - Math operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Computes the element-wise tangent of a PyTorch tensor.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of numerical type, representing angles in radians.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying the tangent function.
|
||||
"""
|
||||
return (torch.tan(tens_a),)
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict
|
||||
import torch
|
||||
|
||||
class PtTanh:
|
||||
"""
|
||||
Computes the hyperbolic tangent of a PyTorch tensor element-wise.
|
||||
|
||||
category: PyTorch wrapper - Math operations
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the required input types.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary of required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"tens_a": ("TENSOR", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("TENSOR",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens_a: torch.Tensor) -> tuple:
|
||||
"""
|
||||
Computes the element-wise hyperbolic tangent of a PyTorch tensor.
|
||||
|
||||
Args:
|
||||
tens_a (torch.Tensor): A PyTorch tensor of numerical type.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the resultant tensor after applying the hyperbolic tangent function.
|
||||
"""
|
||||
return (torch.tanh(tens_a),)
|
||||
@@ -6,7 +6,7 @@ class PtToImage:
|
||||
"""
|
||||
Casts a PyTorch tensor as an Image tensor.
|
||||
|
||||
category: PyTorch wrapper
|
||||
category: PyTorch wrapper - Tensor data conversion
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -25,7 +25,7 @@ class PtToImage:
|
||||
|
||||
RETURN_TYPES: tuple = ("IMAGE",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "PyTorch wrapper"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens: torch.Tensor) -> tuple:
|
||||
"""
|
||||
|
||||
@@ -6,7 +6,7 @@ class PtToLatent:
|
||||
"""
|
||||
Casts a PyTorch tensor as a latent tensor.
|
||||
|
||||
category: PyTorch wrapper
|
||||
category: PyTorch wrapper - Tensor data conversion
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -25,7 +25,7 @@ class PtToLatent:
|
||||
|
||||
RETURN_TYPES: tuple = ("LATENT",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "PyTorch wrapper"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens: torch.Tensor) -> tuple:
|
||||
"""
|
||||
|
||||
@@ -6,7 +6,7 @@ class PtToNumpy:
|
||||
"""
|
||||
Converts PyTorch tensor to NumPy ndarray.
|
||||
|
||||
category: PyTorch wrapper
|
||||
category: PyTorch wrapper - Tensor data conversion
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -25,7 +25,7 @@ class PtToNumpy:
|
||||
|
||||
RETURN_TYPES: tuple = ("NDARRAY",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "PyTorch wrapper"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens: torch.Tensor) -> tuple:
|
||||
"""
|
||||
|
||||
@@ -6,7 +6,7 @@ class PtToRgbTensors:
|
||||
"""
|
||||
Splits a PyTorch tensor into R, G, and B tensors.
|
||||
|
||||
Category: PyTorch wrapper
|
||||
category: PyTorch wrapper - Tensor data conversion
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -26,7 +26,7 @@ class PtToRgbTensors:
|
||||
RETURN_NAMES: tuple = ("R", "G", "B")
|
||||
RETURN_TYPES: tuple = ("TENSOR", "TENSOR", "TENSOR")
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "PyTorch wrapper"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, tens: torch.Tensor) -> tuple:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user