-
Notifications
You must be signed in to change notification settings - Fork 206
Add tools to build TF AOT models #9093
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
Changes from all commits
1acb32e
17eb401
0acc62b
791f5b9
bca654e
9c78bfb
1ff0e6e
7838448
d2d2575
0d650f6
0677c1b
a964e74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| BuildRequires: py3-pip py3-setuptools py3-wheel | ||
| Requires: py3-PyYAML py3-cmsml | ||
|
|
||
| %define github_user cms-externals | ||
| %define tag a03ccef81c610e051d3d7d172d675fe6c1ff17e2 | ||
| %define branch master | ||
| %define source0 git+https://github.com/%{github_user}/cms-tfaot.git?obj=%{branch}/%{tag}&export=%{n}-%{realversion}&output=/%{n}-%{realversion}-%{tag}.tgz | ||
|
|
||
| # copy test models | ||
| %define PipPostInstall \ | ||
| mkdir -p %{i}/share; \ | ||
| cp -r cmsdist-tmp/pip-req-build-*/test_models %{i}/share/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| <tool name="tensorflow-xla-runtime" version="@TOOL_VERSION@"> | ||
| <client> | ||
| <environment name="TENSORFLOW_XLA_RUNTIME_BASE" default="@TOOL_ROOT@"/> | ||
| <environment name="LIBDIR" default="$TENSORFLOW_XLA_RUNTIME_BASE/lib/archive"/> | ||
| <environment name="LIBDIR" default="$TENSORFLOW_XLA_RUNTIME_BASE/lib"/> | ||
| </client> | ||
| <lib name="tf_xla_runtime-static"/> | ||
| <lib name="tf_xla_runtime"/> | ||
|
|
||
| <use name="eigen"/> | ||
| <use name="tensorflow-includes"/> | ||
| </tool> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- tensorflow/xla_aot_runtime_src/CMakeLists.txt 2024-03-24 08:28:34.000000000 +0100 | ||
| +++ tensorflow/xla_aot_runtime_src/CMakeLists.txt 2024-03-25 11:17:58.108587945 +0100 | ||
| @@ -14,6 +14,8 @@ | ||
| -Wno-sign-compare | ||
| ) | ||
|
|
||
| -add_library(tf_xla_runtime STATIC | ||
| +find_package(absl REQUIRED) | ||
| +add_library(tf_xla_runtime SHARED | ||
| $<TARGET_OBJECTS:tf_xla_runtime_objects> | ||
| ) | ||
| +target_link_libraries(tf_xla_runtime absl::strings absl::str_format_internal) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| ## tfaot common compilation and requirement file | ||
| ## specs including this file should provide: | ||
| ## 1. a variable %{aot_config}, pointing to the aot config file of the model to compile (required) | ||
| ## 2. a variable %{aot_source}, referring to a fetched source to unpack during %prep (optional) | ||
| ## (in this case a "Source" should be defined and %{aot_source} is likely %{n}-%{realversion}) | ||
|
|
||
| BuildRequires: py3-cms-tfaot | ||
| Requires: tensorflow-xla-runtime | ||
|
|
||
| %ifarch ppc64le | ||
| %define build_arch powerpc64le-unknown-linux-gnu | ||
| %else | ||
| %define build_arch %{_arch}-unknown-linux-gnu | ||
| %endif | ||
|
|
||
| %prep | ||
| %if "%{?aot_source}" | ||
| %setup -n %{aot_source} | ||
| %endif | ||
|
|
||
| %build | ||
| cms_tfaot_compile \ | ||
| --aot-config "%{aot_config}" \ | ||
| --tool-name "%{n}" \ | ||
| --tool-base "%{i}" \ | ||
| --output-directory compiled_model \ | ||
| --additional-flags="--target_triple %{build_arch}" | ||
|
|
||
| %install | ||
| mkdir -p %{i}/lib | ||
| mv compiled_model/*.o %{i}/lib/ | ||
|
|
||
| mkdir -p %{i}/include/%{n} | ||
| mv compiled_model/*.h %{i}/include/%{n} | ||
|
|
||
| mkdir -p %{i}/etc/scram.d | ||
| mv compiled_model/%{n}.xml %{i}/etc/scram.d/ | ||
|
|
||
| %post | ||
| %{relocateConfig}etc/scram.d/%{n}.xml | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @riga, there is hard-coded build path in [a]
e.g.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added 👍 |
||
| %relocateConfigAll include/%{n} *.h | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| ### RPM external tfaot-model-test-multi 1.0.0 | ||
|
|
||
| %define aot_config $PY3_CMS_TFAOT_ROOT/share/test_models/multi/aot_config.yaml | ||
|
|
||
| ## INCLUDE tfaot-compile |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| ### RPM external tfaot-model-test-simple 1.0.0 | ||
|
|
||
| %define aot_config $PY3_CMS_TFAOT_ROOT/share/test_models/simple/aot_config.yaml | ||
|
|
||
| ## INCLUDE tfaot-compile |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # test models needed by unit tests in PhysicsTools/TensorFlowAOT | ||
| Requires: tfaot-model-test-simple | ||
| Requires: tfaot-model-test-multi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @riga, looks like this worked ( atleast ppc64le build was successful)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rida, I guess
cms_tfaot_compiletool is used by developers to work with new models ... right? Do we want developers to explicitly pass--additional-flags/--target_tripleor may be you can set some default values in side the script ?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. When run with
--devthe tool (almost) mimics what thetfaot-compile.filedoes. The default arch for the--target_tripleisx86_64so I guess this should apply in most cases. However, in dev mode we could check which arch is currently used and issue a warning, together with instructions on how to change the triple.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smuzaffar I just added a warning in cms-externals/cms-tfaot@a03ccef. Was your plan to move the project to cms-externals? If not, I would adjust the commit hash in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, we should move it to cms-externals. I have added you developers of
cms-externals. Can you please transfer the repo there. If you do not want to transfer then I can fork itThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved it and updated the reference in the spec.