Files
HowToSD-ComfyUI-Pt-Wrapper/modules/pytorch_wrapper/pt_bitwise_left_shift.py
T
2025-03-10 14:34:01 -07:00

43 lines
1.3 KiB
Python

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),)