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][TF FE]: Support RGBToHSV operation for TensorFlow #24792

Open
rkazants opened this issue May 31, 2024 · 14 comments
Open

[Good First Issue][TF FE]: Support RGBToHSV operation for TensorFlow #24792

rkazants opened this issue May 31, 2024 · 14 comments
Labels
category: TF FE OpenVINO TensorFlow FrontEnd good first issue Good for newcomers no_stale Do not mark as stale

Comments

@rkazants
Copy link
Contributor

rkazants commented May 31, 2024

Context

OpenVINO component responsible for support of TensorFlow models is called as TensorFlow Frontend (TF FE). TF FE converts a model represented in TensorFlow opset to a model in OpenVINO opset.

In order to infer TensorFlow models with RGBToHSV operation by OpenVINO, TF FE needs to be extended with this operation support.

What needs to be done?

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

Here is an example of loader implementation for TensorFlow Einsum operation:

OutputVector translate_einsum_op(const NodeContext& node) { 
     auto op_type = node.get_op_type(); 
     TENSORFLOW_OP_VALIDATION(node, op_type == "Einsum", "Internal error: incorrect usage of translate_einsum_op."); 
     auto equation = node.get_attribute<std::string>("equation"); 
  
     OutputVector inputs; 
     for (size_t input_ind = 0; input_ind < node.get_input_size(); ++input_ind) { 
         inputs.push_back(node.get_input(input_ind)); 
     } 
  
     auto einsum = make_shared<Einsum>(inputs, equation); 
     set_node_name(node.get_name(), einsum); 
     return {einsum}; 
 } 

In this example, translate_einsum_op converts TF Einsum into OV Einsum. NodeContext object passed into the loader packs all info about inputs and attributes of Einsum operation. The loader retrieves an attribute of the equation by using the NodeContext::get_attribute() method, prepares input vector, creates Einsum operation from OV opset and returns a vector of outputs.

Responsibility of a loader is to parse operation attributes, prepare inputs and express TF operation via OV operations sub-graph. Example for Einsum demonstrates the resulted sub-graph with one operation. In PR #19007 you can see operation decomposition into multiple node sub-graph.

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

export TEST_DEVICE=CPU
cd openvino/tests/layer_tests/tensorflow_tests
pytest test_tf_Shape.py

Example Pull Requests

#24511

Hint

Check this out: #24511

Resources

Contact points

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

Ticket

No response

@rkazants rkazants added good first issue Good for newcomers no_stale Do not mark as stale category: TF FE OpenVINO TensorFlow FrontEnd labels May 31, 2024
@sumwun1
Copy link

sumwun1 commented May 31, 2024

I've never contributed to an open source project before (besides fixing typos in documentation), but I do have 2 or 3 years of C++ experience and I've read this repository's contributing.md. Is there anything I still need to do before I assign this to myself and start working?

@duydl
Copy link
Contributor

duydl commented Jun 1, 2024

@sumwun1 go ahead. The main converting logic is already implemented. You would only need to check how to add new TF FE ops (see Change Files in relevant PR)

@rkazants
Copy link
Contributor Author

rkazants commented Jun 1, 2024

Hi @sumwun1, the task is your yours. Please proceed with execution:)
Pay attention to that we anticipate PR for 2 weeks after which we release GFI for other people if no progress.

Best regards,
Roman

@sumwun1
Copy link

sumwun1 commented Jun 2, 2024

This has nothing to do with this particular issue, but is there some way to get notifications for every comment that either mentions my username or is a response to my comments? After I posted on this thread, I was able to find it again only because I searched my username in the search bar.

@sumwun1
Copy link

sumwun1 commented Jun 10, 2024

@rkazants Where can I find documentation for classes like NodeContext or functions like make_shared? Those are the things I was supposed to use for this issue, right?

@rkazants
Copy link
Contributor Author

rkazants commented Jun 10, 2024

@rkazants Where can I find documentation for classes like NodeContext or functions like make_shared? Those are the things I was supposed to use for this issue, right?

NodeContext class belongs to developer API so you can find documentation in the code: https://github.com/openvinotoolkit/openvino/blob/master/src/frontends/common/include/openvino/frontend/node_context.hpp

make_shared is a standard C++ API to work with smart pointers.

Check implementation of HSVToRGB as a reference: #24875

Best regards,
Roman

@sumwun1
Copy link

sumwun1 commented Jun 11, 2024

Where's the documentation for ov::frontend::tensorflow::create_same_type_const_scalar? I tried searching Google and Openvino's documentation site and couldn't find it.

@sumwun1
Copy link

sumwun1 commented Jun 13, 2024

Where's the documentation for ov::frontend::tensorflow::create_same_type_const_scalar? I tried searching Google and Openvino's documentation site and couldn't find it.

@rkazants ?

@sumwun1
Copy link

sumwun1 commented Jun 15, 2024

@rkazants None of the tests are passing on my computer, even the ones from pull requests that were already merged, which makes me think I accidentally set up pytest wrong. How do I read the test output to see what's wrong? Here's one of the outputs.
HSVToRGB.txt

@rkazants
Copy link
Contributor Author

@rkazants None of the tests are passing on my computer, even the ones from pull requests that were already merged, which makes me think I accidentally set up pytest wrong. How do I read the test output to see what's wrong? Here's one of the outputs. HSVToRGB.txt

Hi @sumwun1, responded in Discord.
Please be informed that we have to release GFI in ~2 weeks if we see no progress and assign to other person. This GFI has a good reference for moving forward.

Best regards,
Roman

@sumwun1
Copy link

sumwun1 commented Jun 16, 2024

Hi @sumwun1, responded in Discord. Please be informed that we have to release GFI in ~2 weeks if we see no progress and assign to other person. This GFI has a good reference for moving forward.

Best regards, Roman

@rkazants This is the fork I've been using for this issue. You can see the progress I've made on there.
https://github.com/sumwun1/openvino

@sumwun1
Copy link

sumwun1 commented Jun 20, 2024

https://drive.google.com/file/d/1te31UzQAmZQCsEkMp1Yi8yKqHTWubZ45/view?usp=sharing
I got this absolutely massive error message when running "cmake --build . --config Release --verbose". I used the Windows 10 terminal instead of WSL this time. What can I do to try to fix it? Would it help if I include the number of jobs? If yes, how many jobs should I specify?

@rkazants
Copy link
Contributor Author

Hi @sumwun1,

I generate .sln file and build OV inside MSVS:

cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=ON ..

Best regards,
Roman

@sumwun1
Copy link

sumwun1 commented Jun 21, 2024

I got an error saying "CMake Error: The source directory "D:/src" does not appear to contain CMakeLists.txt." (D:/src is the folder that contains my copy of Openvino) Should I put CMakeLists.txt in that folder or somehow make Cmake look for the file in a different folder?

I also tried following the Linux build instructions using WSL, and I was unable to run "sudo ./install_build_dependencies.sh" even though the file was in my working directory. How can I fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: TF FE OpenVINO TensorFlow FrontEnd good first issue Good for newcomers no_stale Do not mark as stale
Projects
Status: Contributors Needed
Development

No branches or pull requests

3 participants