-
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 7 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 @@ | ||
| Requires: py3-PyYAML py3-cmsml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| ### RPM external py3-cms-tfaot 1.0.0 | ||
| ## INITENV +PATH PYTHON3PATH %i/${PYTHON3_LIB_SITE_PACKAGES} | ||
|
|
||
| %define github_user riga | ||
| %define tag a2bbd06cbed0efa1fa191cc2f50a6b03067e59d2 | ||
| %define branch master | ||
| Source: git+https://github.com/%{github_user}/cms-tfaot.git?obj=%{branch}/%{tag}&export=%{n}-%{realversion}&output=/%{n}-%{realversion}-%{tag}.tgz | ||
|
|
||
| BuildRequires: py3-pip py3-setuptools py3-wheel | ||
| Requires: py3-cmsml py3-tensorflow | ||
|
|
||
| %prep | ||
| %setup -n %{n}-%{realversion} | ||
|
|
||
| %build | ||
|
|
||
| %install | ||
| pip3 install . --prefix=%{i} --no-deps | ||
|
|
||
| # copy test models | ||
| mkdir -p %{i}/share | ||
| cp -r test_models %{i}/share | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,11 @@ | ||
| <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"/> | ||
| <flags LDFLAGS="-Wl,--unresolved-symbols=ignore-in-shared-libs"/> | ||
|
||
|
|
||
| <use name="eigen"/> | ||
| <use name="tensorflow-includes"/> | ||
| </tool> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,14 +4,15 @@ | |
|
|
||
| Source99: scram-tools.file/tools/eigen/env | ||
|
|
||
| Requires: eigen py3-tensorflow | ||
| Requires: eigen py3-tensorflow abseil-cpp | ||
| BuildRequires: cmake | ||
|
|
||
| %prep | ||
|
|
||
| cp -r ${PY3_TENSORFLOW_ROOT}/lib/python%{cms_python3_major_minor_version}/site-packages/tensorflow . | ||
|
|
||
| %build | ||
|
|
||
| source %{_sourcedir}/env | ||
| export CPATH="${CPATH}:${EIGEN_ROOT}/include/eigen3" | ||
|
|
||
|
|
@@ -21,11 +22,17 @@ CXXFLAGS="-fPIC %{arch_build_flags} ${CMS_EIGEN_CXX_FLAGS}" | |
| %endif | ||
|
|
||
| pushd tensorflow/xla_aot_runtime_src | ||
| # the CMakelists.txt file is not intended to produce a shared library so create a static one first | ||
| cmake . -DCMAKE_CXX_FLAGS="${CXXFLAGS}" -DCMAKE_CXX_STANDARD=%{cms_cxx_standard} -DBUILD_SHARED_LIBS=OFF | ||
| make %{makeprocesses} | ||
|
|
||
| # build the shared library, linking missing symbols from abseil | ||
| gcc -shared -o libtf_xla_runtime.so -Wl,--whole-archive libtf_xla_runtime.a -Wl,--no-whole-archive \ | ||
| -L${ABSEIL_CPP_ROOT}/lib -labsl_strings -labsl_str_format_internal | ||
|
||
| popd | ||
|
|
||
| %install | ||
|
|
||
| mkdir -p %{i}/lib/archive | ||
| mv tensorflow/xla_aot_runtime_src/libtf_xla_runtime.a %{i}/lib/archive/libtf_xla_runtime-static.a | ||
| mv tensorflow/xla_aot_runtime_src/libtf_xla_runtime.so %{i}/lib/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| ## 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 | ||
|
|
||
| %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 | ||
|
|
||
| %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 👍 |
||
| 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.
@riga , for pip based packages it is batter to use the default way of building ( i.e. using https://github.com/cms-sw/cmsdist/blob/IB/CMSSW_14_1_X/master/build-with-pip.file ). So please drop this spec and add
cmsdist/pip/cms-tfaot.filewith following contentsThere 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.
👍 Changed in 7838448.