encode_pytorch_tensor_to_plain_matrix
Engine.encode_pytorch_tensor_to_plain_matrix(tensor, level)
- Encodes a PyTorch tensor into a plain matrix for matrix multiplication.
- Input:
- tensor: torch.Tensor
- The tensor should be a square matrix, with both dimensions equal to
Engine.slot_count.
- level: optional
- Specifies the maximum multiplication level for encoding. Lower levels reduce space usage but also reduce the maximum multiplication depth.
- Output:
import torch
from desilofhe import Engine
engine = Engine(slot_count=64)
tensor = torch.arange(64 * 64).reshape(64, 64)
plain_matrix = engine.encode_pytorch_tensor_to_plain_matrix(tensor)
plain_matrix_level_2 = engine.encode_pytorch_tensor_to_plain_matrix(
tensor, level=2
)