Files
2025-03-10 14:34:01 -07:00

42 lines
980 B
Python

from typing import Any, Dict
import torch
import ast
class PtSize:
"""
Extracts the PyTorch Size object of a PyTorch tensor using the size() method.
category: PyTorch wrapper - Size object support
"""
@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": {
"tens": ("TENSOR",),
}
}
RETURN_TYPES: tuple = ("PTSIZE",)
FUNCTION: str = "f"
CATEGORY: str = "Data Analysis"
def f(self, tens: torch.Tensor) -> tuple:
"""
Extracts the PyTorch Size object of a PyTorch tensor using the size() method.
Args:
tens (torch.Tensor): The tensor.
Returns:
tuple: A tuple containing the PyTorch Size.
"""
return (tens.size(),)