Comments (2)
Hi @Maykeye
You're correct, reason is in lru_cache.
More deeply, that's because hash(2.0) == hash(2)
and 2 == 2.0
, so map[2] == map[2.0]
Switching from plain LRU to typed LRU would solve this problem, but incurs a slow-down, so I'll just to accept current behavior and treat this situation as a programming error (i.e. user should fix it).
As a recovery: _prepare_transformation_recipe.cache_clear().clear_cache()
or restart a kernel (or just overflow cache - also works).
from einops.
(i.e. user should fix it).
The fix is that is appropriate for the user is changing repeat(image, 'h -> (h H)', H=foo/bar) #incorrect call
to repeat(image, 'h -> (h H)', H=foo//bar) #correct call
in the jupyter cell and rerunning it without seeing a error message about float once again.
_prepare_transformation_recipe.cache_clear
is not documented.
The fact it is named _prepare_transformation_recipe
rather than prepare_transformation_recipe
even suggests that user should not know about its very existence.
Maybe just add an assert in _reconstruct_from_shape_uncached
when it's iterating over dimensions that assert not isinstance(dim, float), "dim can't be float!"
: this way cache will not be filled with floats to begin with, and since the result is cached anyway, one call to assert will not slow the world down (besides asserts can even be disabled with python -O
).
from einops.
Related Issues (20)
- [BUG] Please explain in the README how to run tests HOT 1
- [BUG] 5 tests failed HOT 1
- Test test_torch_layer fails: RuntimeError: required keyword attribute 'value' has the wrong type HOT 3
- einops compatible with ONNX export? HOT 3
- [Feature suggestion] All/Any Reduction HOT 2
- [BUG] get_backend is not thread-safe HOT 3
- einops.layers.torch.Rearrange does not accept a list[torch.Tensor] as an input HOT 1
- [Feature suggestion] Support composition/decomposition of axes in `einsum` HOT 2
- *** AttributeError: 'Rearrange' object has no attribute 'recipe'[BUG] HOT 1
- [BUG] batchsize of dataloading
- [BUG] error when import einops HOT 1
- [BUG] Einops repeat throws device error during torchscripting HOT 1
- [Feature suggestion] apple mlx support
- [Feature suggestion] Allow performing a view instead of a reshape HOT 3
- [BUG] einops.repeat returns value with type Never HOT 3
- Add support for keras3 HOT 2
- [Feature suggestion] fixup/support anonymous axes in `parse_shape` HOT 2
- [BUG] `einsum` with `ii->i` raises an unknow axis error. HOT 1
- [Feature suggestion] package downloaded from conda-forge seems missing some functions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from einops.