[Question] [Feature Request] __matmul__, Internal Type Hinting
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 25/100
- Tipo de issue
- Funcionalidade
- Clareza
- Precisa de esclarecimento
- Status de atividade
- Estagnada
- Stack de tecnologia
- python
- Domínio
- api, developer-experience
Direção de pesquisa
Comece revisando os bindings Python em torno de arrayfire.Array, set_backend(), clibrary.get() e af.get_devicr_info(), depois inspecione como os métodos públicos existentes são expostos e testados. Esclareça se o projeto quer matmul, wrappers de runtime e dicas de tipo estáticas antes de alterar qualquer coisa. Considera-se concluído quando houver um escopo acordado, com tipagem consistente e comportamento verificado para a API pública selecionada.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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).
- Linguagem predominante
- Python
- Estrelas
- 422
- Forks
- 63
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de arrayfire/arrayfire-python
-
Unwrap phase function Aberta
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 25/100
arrayfire/arrayfire-python#270 ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
arrayfire/arrayfire-python#269 ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 38/100
arrayfire/arrayfire-python#268 · 1 comentário ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 48/100
arrayfire/arrayfire-python#267 · 1 comentário · 1 reação ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 45/100
arrayfire/arrayfire-python#266 ·
Todas as issues de arrayfire/arrayfire-python
Issues semelhantes
-
Add: hunch Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
AbdelStark/awesome-typesafe#104 ·
-
enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
DiamondLightSource/dodal#2211 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
openml/openml-python#1749 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
sipyourdrink-ltd/bernstein#6191 ·