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 = "example.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.10 or higher
- bishengir-compile binary (built from source)
License
Apache License 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ascendnpu_ir-1.1.0.tar.gz.
File metadata
- Download URL: ascendnpu_ir-1.1.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d47b1b2de319e2a733308b2a4c6dd87133b017082d13003f8f00e23f3173e68f
|
|
| MD5 |
a484f07a3c3631c3897b5d5eae3c7349
|
|
| BLAKE2b-256 |
ec57493a1a08c58e655687c1103bbf118bc1de99a675809e34a9f6f7f1a429ec
|
File details
Details for the file ascendnpu_ir-1.1.0-cp313-cp313-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: ascendnpu_ir-1.1.0-cp313-cp313-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 142.8 MB
- Tags: CPython 3.13, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b32c233f003795645e13594ae757cf3e91c5abab290dffb1c58f2259a01cf44
|
|
| MD5 |
fb0b93165e833bd09f4f86107823e27f
|
|
| BLAKE2b-256 |
79d171aa43977a142e0c8d76f87320d2257ff9371e51ba3f3ed56b1b10d3a1e5
|
File details
Details for the file ascendnpu_ir-1.1.0-cp313-cp313-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: ascendnpu_ir-1.1.0-cp313-cp313-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 135.7 MB
- Tags: CPython 3.13, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a96304baa7cf21d6a5e9c5cfc8dcd25eb1864b92c5a08ee2133f840fd4d50418
|
|
| MD5 |
7adae193cdacfb96cd9e66bc3c733a04
|
|
| BLAKE2b-256 |
3b283eeefb5018f916ffb812f7918a86d1f1fcc7f77a2d51d850474442f95e4e
|
File details
Details for the file ascendnpu_ir-1.1.0-cp312-cp312-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: ascendnpu_ir-1.1.0-cp312-cp312-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 142.8 MB
- Tags: CPython 3.12, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
206b3f9030e3eb8c9807e0fb4e756f5501b548b23670c23dd1bcc579269a1948
|
|
| MD5 |
7a532760ffcba1f7d62596793a08cd4e
|
|
| BLAKE2b-256 |
68f6c6f5ffc607ad706c6a11cde0fe3071cf1e4c95562dbbf112f6de36a56ef3
|
File details
Details for the file ascendnpu_ir-1.1.0-cp312-cp312-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: ascendnpu_ir-1.1.0-cp312-cp312-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 135.7 MB
- Tags: CPython 3.12, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d0025d4713e3e82c80cfadc55efb85a50641644fa04659ecb12bbda0f7cfa47
|
|
| MD5 |
66f2b6be0d2faf72635835427f839533
|
|
| BLAKE2b-256 |
c49bc9c45ac97147a34f2b21616e540f08d614e397d47bb1f6d7a1bb454eba15
|
File details
Details for the file ascendnpu_ir-1.1.0-cp311-cp311-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: ascendnpu_ir-1.1.0-cp311-cp311-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 142.8 MB
- Tags: CPython 3.11, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1726fe74952b2a6c3c0d8d001c500441db6f4d36239217f5c6809480d1a7318
|
|
| MD5 |
69cbe535d808b4d12b9652a6ca2e7f4e
|
|
| BLAKE2b-256 |
e4d2c9ecc6236de6f41e348402ceae70b519b9fe9362573b7ba6a3cde5b65aa6
|
File details
Details for the file ascendnpu_ir-1.1.0-cp311-cp311-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: ascendnpu_ir-1.1.0-cp311-cp311-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 135.7 MB
- Tags: CPython 3.11, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a4321110af5cc3aae854a69f2184292016237f09d79944c5e8b552cbc844347
|
|
| MD5 |
718f758dd70f470b9d33c19c4ac335c4
|
|
| BLAKE2b-256 |
9cf5ce923580d5bb40b4918431b392edd4a427f52ad049ee7fd564d32e2a1235
|
File details
Details for the file ascendnpu_ir-1.1.0-cp310-cp310-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: ascendnpu_ir-1.1.0-cp310-cp310-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 142.8 MB
- Tags: CPython 3.10, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dc9e8436de8373a4bb68a8fcbfd346c8a0d3160cb338047cbdf4ecfdb1776ab
|
|
| MD5 |
9dfc8c2d2850af797c47cfb055be04fb
|
|
| BLAKE2b-256 |
c1af9c3c3fb493d11572d64a2a0ca4511a1236da5aecf8ff9b54f4184a58d801
|
File details
Details for the file ascendnpu_ir-1.1.0-cp310-cp310-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: ascendnpu_ir-1.1.0-cp310-cp310-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 135.7 MB
- Tags: CPython 3.10, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aff2b528624a18c46546f720d7df84a2c9305e33b0c129833365370c09339d9f
|
|
| MD5 |
928f88b29989516bb5b0d56305927600
|
|
| BLAKE2b-256 |
7eb8ff315514dfbd61ed0742ccb6218fff2e55ffd2e8911a25c8dd3382d3a1e7
|