question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Should ShapeDtypeStruct.size exist?

See original GitHub issue

ShapeDtypeStruct 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:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
shoyercommented, Feb 9, 2020

Rather than using attrs, I would rather require Python 3.6+ with the dataclasses backport.

1reaction
tomhennigancommented, Feb 7, 2020

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__.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found