-
Notifications
You must be signed in to change notification settings - Fork 13
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
tensorflow instrumentation bug #7
Comments
I found the issues. The issue is that tensorflow APIs called via tensorflow unit tests have different API names compared to APIs listed in the official documentation. For example when you run:
Your code hijacks the class name inside this test file which is
|
hi @nimashiri , I think there's some misunderstanding here and I am happy to help. Based on your description, I am guessing you are trying to instrument the unit test class You can find the API list we used in api_list.txt, or the full API list on the latest version here. In other words, to collect traces for public APIs by running tests, FreeFuzz does not instrument the test class like If you are seeking to instrument such non-public APIs for your use case, you may want to extend the current instrumentation and handle more special issues (like |
Thanks. Not actually, I am going to instrument public APIs inside tensorflow library tests. But, I don't know which public tests did you run to collect APIs? Because in the paper, you mentioned that you have collected around 216 APIs from tests. My question is that which tests? I don't know their locations. My assumption is that when I run kernel tests, the code should automatically instrument public APIs inside kernel tests or op tests. But, it gives me the results shown above. |
If I remember correctly, for pytorch we just directly run all the *.py files inside some folder for testing purposes (e.g., https://github.com/pytorch/pytorch/tree/master/test). I agree that our test collection is incomplete in that some test files need to be invoked in a specialized way (e.g., passing command line arguments? I am not sure), also I do not even consider tests written in C++ or other languages. Also, our testing environment is not the standard developer's environment, so actually a subset of the py test files that we ran failed (while they should not fail in the correct environment setting such as the CI), thus leaving a large proportion of code uncovered by existing tests. I can't clearly remember how we run TensorFlow's test cases. We are sorry that our test case collection is done in an ad-hoc way. As you may have already noticed, the coverage in terms of percentage is actually quite low in terms of the total LOC in the code base. Thanks again for these nice questions! Inspired by what you have said, I firmly believe FreeFuzz's methodology can actually be much stronger if the test collection stage can be more complete and robust, as the current test cases collection is done in a way that is far from ideal. Challenge:
@dengyinlin Please feel free to correct me if I am wrong. |
I really enjoyed reading FreeFuzz, it is easy to read and the idea is sound and exciting. That is why I decided to work on FreeFuzz as baseline. Freefuzz works perfectly for Torch test cases. However, for TensorFlow private APIs, instead of hijacking private APIs, it hijacks the class where private APIs are located, as explained above. Challenges: 2 - This is already done but not published yet, the work is on arxiv. 3 - The distinction is in their parent module. In Tensorflow Public APIs, most critical APis are in raw_ops module while in the private section, they are in different module like array_aps, bincount_ops, or ops itself. In the paper you mentioned that you put a lot of efforts to calculate code coverage for FreeFuzz. Is it possible to share to code with me? |
hi @nimashiri, thanks for your interest!
I run all the public tests, i.e. all files that ends with
Yes, you are right, the instrumentation code needs not be changed for running any developer tests. We just run them like normal TensorFlow programs.
I try to re-run the instrumentation again (on TensorFlow 2.4) on developer tests following the readme, but I don't get results like
|
Hi @dengyinlin Thanks for the reply. For docs and Wild models, I get what I expect. For kernel tests, I get wrong results.
Not from:
How do you install tensorflow 2.4? I have the same version. |
I see, actually I did not test the instrumentation on TensorFlow from source. For instrumentation, I install tensorflow from pip, and instrument the |
Wow! very different compared to my approach, let me do it in this way and I let you know the results. I really appreciate that. |
For code coverage, tools already exist for Pytorch: For Tensorflow, the coverage collection was also very difficult. Back then I figured out the command line for collecting coverage, but the setup of tooling is really painful (tensorflow/tensorflow#51091), and the technical challenge was resolved by our collaborator @YangChenyuan, whom I am sincerely grateful to. Chenyuan may be able to give you more advice on that if you meet problems in collecting coverage later. As far as I remember, there was a version incompatibility bug regarding Bazel and Gcov. Just two sidenotes:
|
@dengyinlin @Anjiang-Wei I solved the issue. I also updated the instrumentation and now it supports all internal/private tensorflow APIs. It also covers user/public APIs. |
Hi,
When I want to instrument tensorflow APIs, I get weird results as shown in the attached image.
For example, I get:
As you can see,
__main__
andTest
are in the API name which is wrong.Also, all value spaces are same for all APIs.
Any Idea why it happens?
Thanks.
![gg](https://user-images.githubusercontent.com/17060581/204103314-4885aaf7-142c-40f3-8acb-6aba2228070b.png)
The text was updated successfully, but these errors were encountered: