Skip to main content

hetorch.passes.builtin.packing

InputPackingPass: Transform input tensors into packed ciphertext format

Classes

InputPackingPass(strategy: <class 'str'>, slot_count: typing.Optional[int])

Transform input tensors into packed ciphertext format

This pass annotates input nodes with packing information, which downstream passes must respect. The actual packing is performed by the backend during encryption.

Attributes: strategy: Packing strategy ("row_major", "column_major", "diagonal", "custom") slot_count: Number of slots per ciphertext (None = use backend default)

Methods:

__init__(self, strategy: str = 'row_major', slot_count: Optional[int] = None)

Initialize InputPackingPass

Args: strategy: Packing strategy name slot_count: Number of slots per ciphertext (None = backend default)

analyze_cost(self, graph_module: torch.fx.graph_module.GraphModule, context: hetorch.compiler.context.CompilationContext) -\> hetorch.backend.cost_model.CostAnalysis

Analyze cost impact of this pass

Args: graph_module: Graph module to analyze context: Compilation context

Returns: Cost analysis result

transform(self, graph_module: torch.fx.graph_module.GraphModule, context: hetorch.compiler.context.CompilationContext) -\> torch.fx.graph_module.GraphModule

Apply input packing transformation

Args: graph_module: Input graph module context: Compilation context

Returns: Transformed graph module with packing annotations

validate(self, graph_module: torch.fx.graph_module.GraphModule, context: hetorch.compiler.context.CompilationContext) -\> bool

Validate that the pass can be applied

Args: graph_module: Graph module to validate context: Compilation context

Returns: True if validation passes

Raises: PassValidationError: If validation fails