Skip to main content

A cell magic enabling one to run HEIR pipelines in Jupyter notebooks.

Project description

HEIR Jupyter playground

This is a way to start running HEIR compiler passes in a Jupyter notebook or IPython notebook without having to build the entire HEIR project from scratch.

Uses the nightly HEIR build.

Usage

Load Jupyter:

jupyter notebook

In Jupyter:

%pip install heir_play
%load_ext heir_play
%%heir_opt --convert-if-to-select --canonicalize

func.func @secret_condition_with_non_secret_int(%inp: i16, %cond: !secret.secret<i1>) -> !secret.secret<i16> {
  %0 = secret.generic ins(%inp, %cond : i16, !secret.secret<i1>) {
  ^bb0(%copy_inp: i16, %secret_cond: i1):
    %1 = scf.if %secret_cond -> (i16) {
      %2 = arith.addi %copy_inp, %copy_inp : i16
      scf.yield %2 : i16
    } else {
      scf.yield %copy_inp : i16
    }
    secret.yield %1 : i16
  } -> !secret.secret<i16>
  return %0 : !secret.secret<i16>
}

The cell should output something similar to

Running heir-opt...
module {
  func.func @secret_condition_with_non_secret_int(%arg0: i16, %arg1: !secret.secret<i1>) -> !secret.secret<i16> {
    %0 = arith.addi %arg0, %arg0 : i16
    %1 = secret.generic ins(%arg1 : !secret.secret<i1>) {
    ^bb0(%arg2: i1):
      %2 = arith.select %arg2, %0, %arg0 : i16
      secret.yield %2 : i16
    } -> !secret.secret<i16>
    return %1 : !secret.secret<i16>
  }
}

Limitations

Right now, heir-opt as a standalone binary is not able to run lowerings to boolean TFHE schemes due to an external dependency on ABC (see #885). If you try to run any pipeline requiring the yosys-optimizer pass, will see the following error from ABC:

ERROR: ABC: execution of command ""external/edu_berkeley_abc/abc" -s -f /tmp/yosys-abc-iEdp1F/abc.script 2>&1" failed: return code 127.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

heir_play-0.0.2.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

heir_play-0.0.2-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file heir_play-0.0.2.tar.gz.

File metadata

  • Download URL: heir_play-0.0.2.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for heir_play-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2810988d9b807441b5af560610e7612a04766df921ef96c5b0cecfdedcb5589a
MD5 1c4385c8d9d00d4951fefc7d192da4c5
BLAKE2b-256 7df7c80dacfe3d1ad4053a33d39c71b3d99ef915a996adaf7c467d352c143dc5

See more details on using hashes here.

File details

Details for the file heir_play-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: heir_play-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for heir_play-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 420d3d5d9bfecd2b9ba70a124fd66a668e9d9cd2e3ffda0cd82a9b04b4603411
MD5 de4a126dc327cc1fc185829c163ee8ef
BLAKE2b-256 e404d15b5c8456a8d9ea839927c1cbed4a0a3956982c2783ff96721786744a5b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page