Source code for elasticai.creator.base_modules.torch_math_operations
import torch
from .conv1d import MathOperations as Conv1dOps
from .linear import MathOperations as LinearOps
from .lstm_cell import MathOperations as LSTMOps
[docs]
class TorchMathOperations(LinearOps, Conv1dOps, LSTMOps):
[docs]
def quantize(self, a: torch.Tensor) -> torch.Tensor:
return a
[docs]
def add(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:
return a + b
[docs]
def mul(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:
return a * b
[docs]
def matmul(self, a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:
return torch.matmul(a, b)