Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for aarch64 via docker #25

Merged
merged 25 commits into from
Jan 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ jobs:
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
target: [x86_64]
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
Expand All @@ -24,7 +28,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
- uses: messense/maturin-action@v1
with:
container: ghcr.io/kornia/kornia-rs/release:latest
container: ghcr.io/kornia/kornia-rs/release-${{ matrix.target }}:latest
target: ${{ matrix.target }}
manylinux: auto
args: --release --out dist -i python${{ matrix.python-version }}
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/release_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ env:
jobs:
build_docker:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- arch: amd64
label: x86_64
- arch: arm64
label: aarch64
steps:
-
name: Checkout the repository
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
Expand All @@ -32,7 +39,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/release.Dockerfile
platforms: linux/amd64
file: ./docker/release-${{ matrix.arch }}.Dockerfile
platforms: linux/${{ matrix.arch }}
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/release:latest
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/release-${{ matrix.label }}:latest
File renamed without changes.
12 changes: 12 additions & 0 deletions docker/release-arm64.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ghcr.io/rust-cross/manylinux2014-cross:aarch64

# rust image comes with sh, we like bash more
SHELL ["/bin/bash", "-c"]

RUN uname -a

RUN apt-get update --fix-missing && \
apt-get install -y --no-install-recommends \
gcc-aarch64-linux-gnu \
&& \
apt-get clean
7 changes: 4 additions & 3 deletions src/dlpack_py.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ use dlpack_rs as dlpack;

use pyo3::prelude::*;
use std::ffi::{c_void, CStr, CString};
use std::os::raw::c_char;

const DLPACK_CAPSULE_NAME: &[u8] = b"dltensor\0";

// desctructor function for the python capsule
unsafe extern "C" fn dlpack_capsule_destructor(capsule: *mut pyo3::ffi::PyObject) {
if pyo3::ffi::PyCapsule_IsValid(capsule, DLPACK_CAPSULE_NAME.as_ptr() as *const i8) == 1 {
if pyo3::ffi::PyCapsule_IsValid(capsule, DLPACK_CAPSULE_NAME.as_ptr() as *const c_char) == 1 {
// println!("Is an invalid capsule!");
return;
}
Expand All @@ -17,7 +18,7 @@ unsafe extern "C" fn dlpack_capsule_destructor(capsule: *mut pyo3::ffi::PyObject

let expected_name = CString::new("dltensor").unwrap();

let current_name_ptr: *const i8 = pyo3::ffi::PyCapsule_GetName(capsule);
let current_name_ptr: *const c_char = pyo3::ffi::PyCapsule_GetName(capsule);
let current_name = CStr::from_ptr(current_name_ptr);
// println!("Expected Name: {:?}", expected_name);
// println!("Current Name: {:?}", current_name);
Expand Down Expand Up @@ -94,7 +95,7 @@ pub fn cvtensor_to_dlpack(x: &cv::Tensor, py: Python) -> PyResult<PyObject> {
let capsule: PyObject = unsafe {
let ptr = pyo3::ffi::PyCapsule_New(
&*dlm_tensor_bx as *const dlpack::DLManagedTensor as *mut c_void,
DLPACK_CAPSULE_NAME.as_ptr() as *const i8,
DLPACK_CAPSULE_NAME.as_ptr() as *const c_char,
Some(dlpack_capsule_destructor as pyo3::ffi::PyCapsule_Destructor),
);
PyObject::from_owned_ptr(py, ptr)
Expand Down