-
Notifications
You must be signed in to change notification settings - Fork 184
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
Add tools to build TF AOT models #9093
Changes from 11 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 riga | ||
%define tag a9ee8f7d7091015a496f4be0880763a23b5287ab | ||
%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 | ||
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.
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)
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_compile
tool is used by developers to work with new models ... right? Do we want developers to explicitly pass--additional-flags/--target_triple
or may be you can set some default values in side the script ?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
--dev
the tool (almost) mimics what thetfaot-compile.file
does. The default arch for the--target_triple
isx86_64
so 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.