This PR fixes a bug in jax.image._resize where the local `method_id`
variable may be used without being defined first.
This bug can be easily reproduced by passing to `jax.image.resize`
parameter `method` a `ResizeMethod` instead of an `str`. By doing
this, `method_id` is never defined and the instruction
`if method_id == ResizeMethod.NEAREST` raises an error. Currently,
this can be easily bypassed assigning parameter `method` a `str`.
To fix this bug, it only needs to rename `method_id` to `method`,
the same name of the input parameter.
* Change image resize implementation to use a matmul per dimension.
This should have better space scaling behaviors than the previous gather approach. In particular, it does not require temporary memory that scales with the batch size or number of features of an image.
* Plumb precision option through to image resize API.
* Add jax.image.resize.
This is a port of `tf.image.resize()` and the `ScaleAndTranslate` operator.
While I don't expect this implementation to be particularly fast, it is a useful generic implementation to which we can add optimized special cases as the need arises.