Skip to main content

AscendNPU IR Compiler - Python bindings for bishengir-compile

Project description

AscendNPU IR Compiler

Python bindings for the bishengir-compile compiler.

Installation

pip install ascendnpu-ir

Usage

import ascendnpuir

mlir_str = """
module {
  func.func @add(%arg0: memref<16xi16, #hivm.address_space<gm>>, %arg1: memref<16xi16, #hivm.address_space<gm>>, %arg2: memref<16xi16, #hivm.address_space<gm>>) attributes {hacc.entry, hacc.function_kind = #hacc.function_kind<DEVICE>} {
    %alloc = memref.alloc() : memref<16xi16, #hivm.address_space<ub>>
    hivm.hir.load ins(%arg0 : memref<16xi16, #hivm.address_space<gm>>) outs(%alloc : memref<16xi16, #hivm.address_space<ub>>)
    %alloc_0 = memref.alloc() : memref<16xi16, #hivm.address_space<ub>>
    hivm.hir.load ins(%arg1 : memref<16xi16, #hivm.address_space<gm>>) outs(%alloc_0 : memref<16xi16, #hivm.address_space<ub>>)
    %alloc_1 = memref.alloc() : memref<16xi16, #hivm.address_space<ub>>
    hivm.hir.vadd ins(%alloc, %alloc_0 : memref<16xi16, #hivm.address_space<ub>>, memref<16xi16, #hivm.address_space<ub>>) outs(%alloc_1 : memref<16xi16, #hivm.address_space<ub>>)
    hivm.hir.store ins(%alloc_1 : memref<16xi16, #hivm.address_space<ub>>) outs(%arg2 : memref<16xi16, #hivm.address_space<gm>>)
    return
  }
}
"""
output_path = "exmaple.o"
options = [
    "-enable-hivm-compile=true",
]

# Compile a model
res = ascendnpuir.compile(
    mlir_str,
    output_path=output_path,
    option=options,
)
print(f"Compiled to: {output_path}")

Building from Source

To build the wheel package from source, you need to first build the bishengir-compile binary:

# Build the compiler
cd build-tools
./build.sh

# Build the wheel package
./build_wheel.sh

The wheel package will be created in the bishengir/python/wheel/dist directory.

Requirements

  • Python 3.9 or higher
  • bishengir-compile binary (built from source)

License

Apache License 2.0

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

ascendnpu_ir-1.0.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distributions

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

ascendnpu_ir-1.0.0-cp312-cp312-manylinux2014_x86_64.whl (103.3 MB view details)

Uploaded CPython 3.12

ascendnpu_ir-1.0.0-cp312-cp312-manylinux2014_aarch64.whl (101.7 MB view details)

Uploaded CPython 3.12

ascendnpu_ir-1.0.0-cp311-cp311-manylinux2014_x86_64.whl (103.3 MB view details)

Uploaded CPython 3.11

ascendnpu_ir-1.0.0-cp311-cp311-manylinux2014_aarch64.whl (101.7 MB view details)

Uploaded CPython 3.11

ascendnpu_ir-1.0.0-cp310-cp310-manylinux2014_x86_64.whl (103.3 MB view details)

Uploaded CPython 3.10

ascendnpu_ir-1.0.0-cp310-cp310-manylinux2014_aarch64.whl (101.7 MB view details)

Uploaded CPython 3.10

ascendnpu_ir-1.0.0-cp39-cp39-manylinux2014_x86_64.whl (103.3 MB view details)

Uploaded CPython 3.9

ascendnpu_ir-1.0.0-cp39-cp39-manylinux2014_aarch64.whl (101.7 MB view details)

Uploaded CPython 3.9

File details

Details for the file ascendnpu_ir-1.0.0.tar.gz.

File metadata

  • Download URL: ascendnpu_ir-1.0.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for ascendnpu_ir-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a59227ccf15d0888666f8860d48e528bb55242b62c17c7115c5b2ed4af3171a7
MD5 0f845b898751df461163d2bdd63ae0de
BLAKE2b-256 203b68645eef9a3a8afce44f49ef955150ffd9307d694db2b39053c2196fc93e

See more details on using hashes here.

File details

Details for the file ascendnpu_ir-1.0.0-cp312-cp312-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ascendnpu_ir-1.0.0-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9c08984fc47eb0d7daafc81ba38945f732b75a0991d793036e425afee18e90ef
MD5 0a3a0ad42407c14dbbbb6a8b972a3aee
BLAKE2b-256 d2d011ee6da2685ae7da7b051360cd21339aaa6043a9da10627f0bb41805ba24

See more details on using hashes here.

File details

Details for the file ascendnpu_ir-1.0.0-cp312-cp312-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ascendnpu_ir-1.0.0-cp312-cp312-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 cedd3ccfacb03f2ec49ac6187a5f3a6de38963e39266487bf3a08b211a511c6f
MD5 91f93f4a6a56b89e039318251f08ddab
BLAKE2b-256 c3dfb2ca119abb36083747926620369c6f6a7f8c9efa5f266d0fda226a5d13a0

See more details on using hashes here.

File details

Details for the file ascendnpu_ir-1.0.0-cp311-cp311-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ascendnpu_ir-1.0.0-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8d51853c50f70d435d7badde1acb901b533b3dcafdd7f958341d958c777b9c06
MD5 d870941f7e782b5ab42b196d4c002789
BLAKE2b-256 85f321ac21268629bce06822b2b8ef04addcc3ecb2e4c676c5e3236a9f3b1294

See more details on using hashes here.

File details

Details for the file ascendnpu_ir-1.0.0-cp311-cp311-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ascendnpu_ir-1.0.0-cp311-cp311-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2bacd8e523b52c7a69df13dc4dd349893800229202d17511e287aa9fbad2f79f
MD5 595b33d4d29e78ce519cf2122a3b7cfe
BLAKE2b-256 6c0b90723bc5ce14f8bb2db87552d19590cdd636d3b3b734ce3461e8f2186954

See more details on using hashes here.

File details

Details for the file ascendnpu_ir-1.0.0-cp310-cp310-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ascendnpu_ir-1.0.0-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e3d6f5bb589d7592c9142068e31a4499e9732a0ece6047da9ec1eae092f78d91
MD5 bae64a230c367095fd740e9e3aa63c11
BLAKE2b-256 48643cbc2f6777c2262acc8410767a6e299ad14cf1ea1c63ec4f6248dfba3e62

See more details on using hashes here.

File details

Details for the file ascendnpu_ir-1.0.0-cp310-cp310-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ascendnpu_ir-1.0.0-cp310-cp310-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a0270ab3db26bb298c63faefa7b74f108446f6352c7dc7c1355b926f876e20ca
MD5 7834db826a71b88681ddfb8cf61102f4
BLAKE2b-256 5b9c153a94eac989d98da4627c75296c0f52b3d31a862c3f5931afe1127d7b22

See more details on using hashes here.

File details

Details for the file ascendnpu_ir-1.0.0-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ascendnpu_ir-1.0.0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 238d04a588ccf1fa07eaf8f1bcef4ab5e88c04ce114f6bb03f8d97d0ca2d49fe
MD5 5c13a72f77ca576a3f4453d3e77c4900
BLAKE2b-256 9144bd0b0d09e067eac0c621549c5e18f15aa88dfba30d5b0055cc467e7965e0

See more details on using hashes here.

File details

Details for the file ascendnpu_ir-1.0.0-cp39-cp39-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ascendnpu_ir-1.0.0-cp39-cp39-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 214c7b6fe1b105a24907082b283c3d2522e69971d3cb6578d2bd9523bab6c2d4
MD5 4aed61fd6f1a2cfbbd8660845b356963
BLAKE2b-256 297022222e10d8a608f77e4720b730f0b15b6628ea4fe00970c5cd5d6e4fa5b6

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