Should ShapeDtypeStruct.size exist?
See original GitHub issueShapeDtypeStruct
currently has dtype
and shape
. We could add numpy’s size
property via
class ShapeDtypeStruct(object):
__slots__ = ["shape", "dtype"]
def __init__(self, shape, dtype):
self.shape = shape
self.dtype = dtype
@property
def size(self):
return np.prod(self.shape, dtype=int)
Do you want this patch?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
jax._src.api - JAX documentation - Read the Docs
This parameter is useful when lowering functions that involve parallel communication collectives, and it specifies the axis name/size environment that would ...
Read more >jax._src.tree_util.broadcast_prefix Example - Program Talk
This parameter is useful when lowering functions that involve parallel communication collectives, and it specifies the axis name/size environment that would ...
Read more >NumPyro Documentation - Read the Docs
Pyro Primitives: NumPyro programs can contain regular Python and NumPy code ... If unspecified, all dimensions will be considered event dims.
Read more >tools/train/train.py · dalle-mini/dalle-mini at ... - Hugging Face
Can be True (will retrieve associated wandb artifact), a local directory or a ... metadata={"help": "Batch size per data parallel device for training."},....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Rather than using attrs, I would rather require Python 3.6+ with the dataclasses backport.
Understood re namedtuple, while we wait for dataclasses is it worth taking a dep on attrs to make these pod classes more consistent and easier to read (e.g. generated slots, eq, hash, immutability etc)?
I vote for (2) and agree with not exposing the internal
ShapedArray
. I think a complete implementation would have:shape
,dtype
,ndim
,size
,__len__
and of course__eq__
and__hash__
.