[Question] [Feature Request] __matmul__, Internal Type Hinting

Đang mở
#271 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
api, developer-experience

Hướng nghiên cứu

Bắt đầu bằng việc xem xét các Python bindings xoay quanh arrayfire.Array, set_backend(), clibrary.get() và af.get_devicr_info(), sau đó kiểm tra cách các phương thức công khai hiện có được cung cấp và kiểm thử. Làm rõ liệu dự án có muốn matmul, các runtime wrapper và type hint tĩnh hay không trước khi thay đổi bất kỳ điều gì. Công việc được xem là hoàn tất khi có phạm vi đã được thống nhất, với kiểu dữ liệu nhất quán và hành vi đã được xác minh cho public API được chọn.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

I wanted to add support for @ operation in python. The __matmult__ operation, that's how it's overloaded, in the arrayfire.Array class.

It's a simple monkey patch on user code. But it'd be nice if it was official.

I went to my local source code and added it, but I wanted to start learning the internal more and maybe do some contribution. Just wondering if it's not redundant or unwanted.

I saw that the internal Python types aren't hinted properly.

The set_backend() takes a string, but that's primitive obsession. It should take a string litteral list.

from typing import Literal

backend: Literal["cuda", "opencl", "cpu"]

Or it should take an Enum.
And other functions.

or clibrary.get() returns a None. That's just due to Lazy Loading.

But a Typed Python interface could exist. Some wrapper python class might be needed so that the type of the exposed code is visible.

All of this would help learning by simply using the autocomplete features of the IDE or text editor.

I hope each backend offers at least some common interface. It should, as the goal of arrayfire is hardware agnostism.

So, every method should be discoverable by the linter at "code editing" time. Just put _ and __ if it's really private.

So get().af wouldn't cause false linting errors.

Anyway, I might get into it if I have time. It seems like a nice contribution, and a nitpick of mine.

the typing package nd TYPE/CHECKING, and simple wrappers are quite powerful.

However, I know that you might not want to expose internal details at all, and so might have purposly not the type hinting of everything. But it's also possible that doing so is just a tedious boilerplate. I'd be fine with doing said tedious boilerplate to make it easier to use and understand.

So, if it's by choice that there isn't any type hinting and wrapper, then I won't do it. But If it's something you'd be interested in, I might do some work on it.

Also there was a bug with af.get_devicr_info(), it seems to give the default device, not active device. Tested it with my cpu graphics card and amd graphics card on arch linux. I'll edit this section once I'm back on my PC. (Away right now).

Ngôn ngữ chính
Python
Star
422
Fork
63
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của arrayfire/arrayfire-python

Tất cả issue của arrayfire/arrayfire-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.