41 lines
967 B
Python
41 lines
967 B
Python
from typing import Any, Dict
|
|
import torch
|
|
|
|
class PtToInt8:
|
|
"""
|
|
Pt To Int8:
|
|
Converts the input tensor's data type to int8.
|
|
|
|
category: PyTorch wrapper - Data type conversion
|
|
"""
|
|
|
|
@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:
|
|
"""
|
|
Converts the input tensor's data type to int8.
|
|
|
|
Args:
|
|
tens_a (torch.Tensor): A PyTorch tensor of numerical type.
|
|
|
|
Returns:
|
|
tuple: A tuple containing the resultant tensor after the operation.
|
|
"""
|
|
return (tens_a.to(torch.int8),)
|