[Numpy-discussion] Re: New feature: binary (arbitrary base) rounding

2022-11-11 Thread Michael Siebert
Hi all, an advantage of sub-byte datatypes is the potential for accelerated computing. For GPUs, int4 is already happening. Or take int1 for example: if one had two arrays of size 64, that would be eight bytes. Now, if one wanted to add those two arrays, one could simply xor them as a uint64 (o

[Numpy-discussion] Re: New feature: binary (arbitrary base) rounding

2022-11-11 Thread Sebastian Berg
On Fri, 2022-11-11 at 09:13 -0700, Greg Lucas wrote: > > > > OK, more below.  But unfortunately `int2` and `int4` *are* > > problematic, > > because the NumPy array uses a byte-sized strided layout, so you > > would > > have to store them in a full byte, which is probably not what you > > want. >

[Numpy-discussion] Re: New feature: binary (arbitrary base) rounding

2022-11-11 Thread Greg Lucas
> > OK, more below. But unfortunately `int2` and `int4` *are* problematic, > because the NumPy array uses a byte-sized strided layout, so you would > have to store them in a full byte, which is probably not what you want. > I am always thinking of adding a provision for it in the DTypes so that

[Numpy-discussion] Re: New feature: binary (arbitrary base) rounding

2022-11-11 Thread Sebastian Berg
On Fri, 2022-11-11 at 14:55 +0100, Oscar Gustafsson wrote: > Thanks! That does indeed look like a promising approach! And for sure > it > would be better to avoid having to reimplement the whole array-part > and > only focus on the data types. (If successful, my idea of a project > would > basicall

[Numpy-discussion] Re: New feature: binary (arbitrary base) rounding

2022-11-11 Thread Oscar Gustafsson
Thanks! That does indeed look like a promising approach! And for sure it would be better to avoid having to reimplement the whole array-part and only focus on the data types. (If successful, my idea of a project would basically solve all the custom numerical types discussed, bfloat16, int2, int4 et

[Numpy-discussion] Re: New feature: binary (arbitrary base) rounding

2022-11-10 Thread Francesc Alted
On Tue, Nov 8, 2022 at 11:43 AM Sebastian Berg wrote: > > I suspect that this would be more something for a project similar to > Warrens ufunclab: > > https://github.com/WarrenWeckesser/ufunclab > > I.e. written as a NumPy ufunc, but not in NumPy iself. > Hey, ufunclab is really cool and ins

[Numpy-discussion] Re: New feature: binary (arbitrary base) rounding

2022-11-10 Thread Sebastian Berg
On Thu, 2022-11-10 at 14:55 +0100, Oscar Gustafsson wrote: > Den tors 10 nov. 2022 kl 13:10 skrev Sebastian Berg < > sebast...@sipsolutions.net>: > > > On Thu, 2022-11-10 at 11:08 +0100, Oscar Gustafsson wrote: > > > > > > > > I'm not an expert, but I never encountered rounding floating > > > > p

[Numpy-discussion] Re: New feature: binary (arbitrary base) rounding

2022-11-10 Thread Oscar Gustafsson
Den tors 10 nov. 2022 kl 13:10 skrev Sebastian Berg < sebast...@sipsolutions.net>: > On Thu, 2022-11-10 at 11:08 +0100, Oscar Gustafsson wrote: > > > > > > I'm not an expert, but I never encountered rounding floating point > > > numbers > > > in bases different from 2 and 10. > > > > > > > I agree

[Numpy-discussion] Re: New feature: binary (arbitrary base) rounding

2022-11-10 Thread Sebastian Berg
On Thu, 2022-11-10 at 11:08 +0100, Oscar Gustafsson wrote: > > > > I'm not an expert, but I never encountered rounding floating point > > numbers > > in bases different from 2 and 10. > > > > I agree that this is probably not very common. More a possibility if > one > would supply a base argumen

[Numpy-discussion] Re: New feature: binary (arbitrary base) rounding

2022-11-10 Thread Oscar Gustafsson
> > I'm not an expert, but I never encountered rounding floating point numbers > in bases different from 2 and 10. > I agree that this is probably not very common. More a possibility if one would supply a base argument to around. However, it is worth noting that Matlab has the quant function, htt

[Numpy-discussion] Re: New feature: binary (arbitrary base) rounding

2022-11-10 Thread Stefano Miccoli
On 8 Nov 2022, at 15:32, numpy-discussion-requ...@python.org wrote: Thanks for the proposal. I don't have much of an opinion on this and right now I am mainly wondering whether there is prior art which can inform us that this is relatively widely us

[Numpy-discussion] Re: New feature: binary (arbitrary base) rounding

2022-11-10 Thread Oscar Gustafsson
Den tis 8 nov. 2022 kl 11:44 skrev Sebastian Berg < sebast...@sipsolutions.net>: > On Thu, 2022-11-03 at 11:37 +0100, Oscar Gustafsson wrote: > > Hi all, > > > > I hope this is the correct way to propose a new feature. > > https://github.com/numpy/numpy/issues/22522 > > > > Thanks for the proposal

[Numpy-discussion] Re: New feature: binary (arbitrary base) rounding

2022-11-08 Thread Sebastian Berg
On Thu, 2022-11-03 at 11:37 +0100, Oscar Gustafsson wrote: > Hi all, > > I hope this is the correct way to propose a new feature. > https://github.com/numpy/numpy/issues/22522 > Thanks for the proposal. I don't have much of an opinion on this and right now I am mainly wondering whether there is