Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Good First Issue][JAX FE]: Support jax.lax.logistic operation for JAX #26576

Closed
rkazants opened this issue Sep 12, 2024 · 12 comments · Fixed by #28240
Closed

[Good First Issue][JAX FE]: Support jax.lax.logistic operation for JAX #26576

rkazants opened this issue Sep 12, 2024 · 12 comments · Fixed by #28240
Assignees
Labels
category: JAX FE OpenVINO JAX FrontEnd good first issue Good for newcomers no_stale Do not mark as stale

Comments

@rkazants
Copy link
Contributor

Context

OpenVINO component responsible for support of JAX/Flax models is called as JAX Frontend (JAX FE). JAX FE converts a JAX/Flax model represented by ClosedJAXpr graph object with operations from jax.lax opset to OpenVINO IR containing operations from OpenVINO opset.

In order to infer JAX/Flax models containing jax.lax.logistic operation by OpenVINO, JAX FE needs to be extended with this operation support.

What needs to be done?

For jax.lax.logistic operation support, you need to implement the corresponding loader into JAX FE op directory and to register it into the dictionary of Loaders. One loader is responsible for conversion (or decomposition) of one type of JAX operation.

Here is an example of loader implementation for jax.lax.reshape operation:

OutputVector translate_reshape(const NodeContext& context) {
    num_inputs_check(context, 1, 1);
    Output<Node> input = context.get_input(0);
    auto new_sizes = context.const_named_param<std::vector<int64_t>>("new_sizes");
    if (context.has_param("dimensions")) {
        auto dimensions = context.const_named_param<std::vector<int64_t>>("dimensions");
        // transpose the input first.
        auto permutation_node = std::make_shared<v0::Constant>(element::i64, Shape{dimensions.size()}, dimensions);
        input = std::make_shared<v1::Transpose>(input, permutation_node);
    }

    auto new_shape_node = std::make_shared<v0::Constant>(element::i64, Shape{new_sizes.size()}, new_sizes);
    Output<Node> res = std::make_shared<v1::Reshape>(input, new_shape_node, false);
    return {res};
};

In this example, translate_reshape expresses jax.lax.reshape using OpenVINO opset. Since jax.lax.reshape performs transposition and tensor reshaping according to JAX documentation, the resulted decomposition contains OpenVINO Transpose and Reshape operations. For Transpose and Reshape nodes, this conversion parses constant parameters dimensions to permute input tensor and new_size that is the target shape of the result.

Once you are done with implementation of the translator, you need to implement the corresponding layer tests test_logistic.py and put it into layer_tests/jax_tests directory. Example how to run some layer test:

export TEST_DEVICE=CPU
export JAX_TRACE_MODE=JAXPR
export 
cd openvino/tests/layer_tests/jax_tests
pytest test_reshape.py

Example Pull Requests

Resources

Contact points

  • @openvinotoolkit/openvino-jax-frontend-maintainers
  • @rkazants in GitHub and Discord

Ticket

No response

@rkazants rkazants added good first issue Good for newcomers no_stale Do not mark as stale category: JAX FE OpenVINO JAX FrontEnd labels Sep 12, 2024
@github-project-automation github-project-automation bot moved this to Contributors Needed in Good first issues Sep 12, 2024
@sacredvoid
Copy link

Hi @rkazants! I would like to take up this issue.

@rkazants rkazants moved this from Contributors Needed to Assigned in Good first issues Sep 13, 2024
@rkazants
Copy link
Contributor Author

Hi @sacredvoid, the task is yours.

Best regards,
Roman

@sacredvoid
Copy link

sacredvoid commented Sep 13, 2024

Had a doubt, I'm currently on a windows machine, trying to build OpenVino. Is there a guide to properly build openvino for windows? Encountered an issue while building. @rkazants

@rkazants
Copy link
Contributor Author

Had a doubt, I'm currently on a windows machine, trying to build OpenVino. Is there a guide to properly build openvino for windows? Encountered an issue while building. @rkazants

Hi, checkout our wiki: https://github.com/openvinotoolkit/openvino/wiki

@Aman-patel-13
Copy link

I want to solve this issue could you please assign me. @rkazants

@mlukasze
Copy link
Contributor

mlukasze commented Nov 6, 2024

@sacredvoid are you working on this task or should we reassign it?

@sacredvoid
Copy link

Kindly reassign it, thank you.

@mlukasze
Copy link
Contributor

mlukasze commented Nov 7, 2024

not a problem, maybe other ticket will be more fisible for you, in more convinient time? :)

@mlukasze mlukasze moved this from Assigned to Contributors Needed in Good first issues Nov 7, 2024
@Aryan8912
Copy link
Contributor

.take

Copy link
Contributor

github-actions bot commented Nov 8, 2024

Thank you for looking into this issue! Please let us know if you have any questions or require any help.

@mlukasze mlukasze moved this from Contributors Needed to Assigned in Good first issues Nov 8, 2024
Aryan8912 added a commit to Aryan8912/openvino that referenced this issue Nov 8, 2024
@rkazants rkazants moved this from Assigned to Contributors Needed in Good first issues Dec 9, 2024
@11happy
Copy link
Contributor

11happy commented Dec 30, 2024

.take

Copy link
Contributor

Thank you for looking into this issue! Please let us know if you have any questions or require any help.

@p-wysocki p-wysocki moved this from Contributors Needed to Assigned in Good first issues Jan 2, 2025
github-merge-queue bot pushed a commit that referenced this issue Jan 3, 2025
**Overview:**
This PR fixes #26576.

**Testing:**
- Tested the Updated code
- Verified that other functionalities remain unaffected

![Screenshot from 2025-01-01
13-11-04](https://github.com/user-attachments/assets/5acfabc2-dded-4c65-b408-d4174fa3c025)

**Dependencies:**
- No dependencies on other pull requests

**CC:**
- @rkazants

---------

Signed-off-by: 11happy <[email protected]>
Co-authored-by: Roman Kazantsev <[email protected]>
@github-project-automation github-project-automation bot moved this from Assigned to Closed in Good first issues Jan 3, 2025
jane-intel pushed a commit to jane-intel/openvino that referenced this issue Jan 3, 2025
**Overview:**
This PR fixes openvinotoolkit#26576.

**Testing:**
- Tested the Updated code
- Verified that other functionalities remain unaffected

![Screenshot from 2025-01-01
13-11-04](https://github.com/user-attachments/assets/5acfabc2-dded-4c65-b408-d4174fa3c025)

**Dependencies:**
- No dependencies on other pull requests

**CC:**
- @rkazants

---------

Signed-off-by: 11happy <[email protected]>
Co-authored-by: Roman Kazantsev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: JAX FE OpenVINO JAX FrontEnd good first issue Good for newcomers no_stale Do not mark as stale
Projects
Status: Closed
6 participants