Skip to content

Commit

Permalink
Address review comments by @smuzaffar.
Browse files Browse the repository at this point in the history
  • Loading branch information
riga committed Feb 14, 2024
1 parent cc33bb3 commit f77258c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 16 deletions.
5 changes: 3 additions & 2 deletions pip/tensorflow.file
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Requires: py3-tensorboard py3-opt-einsum py3-tensorflow-estimator py3-wrapt py3-google-pasta py3-scipy
Requires: tensorflow-sources
%define PipPreBuildPy PIPFILE=${TENSORFLOW_SOURCES_ROOT}/tensorflow-%{realversion}-cp%{cms_python3_major_minor}-cp%{cms_python3_major_minor}-linux_%{_arch}.whl
%define PipPostBuild rm -f %{i}/bin/tensorboard* ; rm -r %{i}/lib/python%{cms_python3_major_minor_version}/site-packages/tensorflow/xla_aot_runtime_src ; ls %{i}/bin/* | xargs -i mv '{}' '{}3'
%define PipPostBuild rm -f %{i}/bin/tensorboard* ; ls %{i}/bin/* | xargs -i mv '{}' '{}3'
%define PipDepsPost | grep -v libclang
## INCLUDE tensorflow-requires
Requires: py3-funcsigs py3-pbr py3-packaging py3-appdirs py3-pyparsing py3-mock py3-Werkzeug
Expand All @@ -19,7 +19,8 @@ Requires: llvm
%define PipPostInstall \
for f in %{RelocateFiles} ; do \
[ ! -f %{i}/$f ] || sed -i -e 's|/[^ ]*/%{cmsplatf}/external/|%{cmsroot}/%{cmsplatf}/external/|' %{i}/$f \
done
done ; \
sed -i 's/assert((arg_size(index)/assert(((size_t)arg_size(index)/' %{i}/lib/python%{cms_python3_major_minor_version}/site-packages/tensorflow/include/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.h

%define PipPostPost \
for f in %{RelocateFiles} ; do \
Expand Down
6 changes: 6 additions & 0 deletions scram-tools.file/tools/py3-tensorflow/py3-tensorflow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<tool name="py3-tensorflow" version="@TOOL_VERSION@">
<client>
<environment name="PY3_TENSORFLOW_BASE" default="@TOOL_ROOT@"/>
</client>
<runtime name="PATH" value="$PY3_TENSORFLOW_BASE/bin" type="path"/>
</tool>
6 changes: 6 additions & 0 deletions scram-tools.file/tools/py3-tensorflow/tensorflow-includes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<tool name="tensorflow-includes" version="@TOOL_VERSION@">
<client>
<environment name="TENSORFLOW_INCLUDES_BASE" default="@TOOL_ROOT@"/>
<environment name="INCLUDE" default="$TENSORFLOW_INCLUDES_BASE/@PYTHON3_LIB_SITE_PACKAGES@/tensorflow/include"/>
</client>
</tool>
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
</client>
<lib name="tf_xla_runtime-static"/>
<use name="eigen"/>
<use name="tensorflow-includes"/>
</tool>
5 changes: 5 additions & 0 deletions scram-tools.file/tools/tensorflow-xla-runtime/vectorized.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<tool name="tensorflow-xla-runtime_@TOOL_VECTORIZATION@" version="@TOOL_VERSION@">
<client>
<environment name="@TOOL_VECTORIZATION_KEY@_LIBDIR" default="@TOOL_ROOT@/lib"/>
</client>
</tool>
19 changes: 5 additions & 14 deletions tensorflow-xla-runtime.spec
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
### RPM external tensorflow-xla-runtime 2.12.0
## INCLUDE cpp-standard

Requires: eigen tensorflow-sources
Requires: eigen py3-tensorflow
BuildRequires: cmake

%prep
unzip -q -o ${TENSORFLOW_SOURCES_ROOT}/tensorflow-%{realversion}-cp%{cms_python3_major_minor}-cp%{cms_python3_major_minor}-linux_%{_arch}.whl

%build
cp -r ${PY3_TENSORFLOW_ROOT}/lib/python%{cms_python3_major_minor_version}/site-packages/tensorflow .

# fix a single comparison between size_t and int
sed -i -r 's/assert\(\(arg_size\(index\)/assert\(\(\(size_t\)arg_size\(index\)/' tensorflow/include/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.h
%build

export CPATH="${CPATH}:${EIGEN_ROOT}/include/eigen3"
export CPATH="${CPATH}:%{i}/tensorflow/include"
export CPATH="${CPATH}:%{i}/tensorflow/include/third_party/eigen3"

pushd tensorflow/xla_aot_runtime_src
cmake . -DCMAKE_CXX_FLAGS="-fPIC -msse3"
cmake . -DCMAKE_CXX_FLAGS="-fPIC -msse3" -DCMAKE_CXX_STANDARD=%{cms_cxx_standard} -DBUILD_SHARED_LIBS=OFF
make %{makeprocesses}
# this builds a shared library, but when used some symbols are missig (e.g `tsl::mutex::unlock()')
# so it does not seem intended to be used as a shared lib
gcc -shared -o libtf_xla_runtime.so -Wl,--whole-archive libtf_xla_runtime.a -Wl,--no-whole-archive
popd

%install

mv tensorflow/include %{i}

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/libtf_xla_runtime.so

0 comments on commit f77258c

Please sign in to comment.