Skip to content
Open
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6a7d306
protobuf upgrade
Sunny-Anand Aug 7, 2025
e745797
fix git error for macos
Sunny-Anand Aug 7, 2025
2bc50fa
updates
Sunny-Anand Aug 7, 2025
c4a7ae1
updates
Sunny-Anand Aug 7, 2025
f32f22a
updates
Sunny-Anand Aug 7, 2025
bae4408
updates
Sunny-Anand Aug 7, 2025
a1d9a3a
updates osx
Sunny-Anand Aug 10, 2025
7efe63f
updates osx
Sunny-Anand Aug 10, 2025
a3d4701
updates osx
Sunny-Anand Aug 10, 2025
c69a66f
updates osx
Sunny-Anand Aug 10, 2025
f0c3c9b
updates osx
Sunny-Anand Aug 10, 2025
a269c63
updates osx
Sunny-Anand Aug 10, 2025
f88f3bd
updates osx
Sunny-Anand Aug 10, 2025
ab79c14
updates osx
Sunny-Anand Aug 10, 2025
c1b6106
updates osx
Sunny-Anand Aug 10, 2025
c543bae
updates osx
Sunny-Anand Aug 11, 2025
00b384e
updates osx
Sunny-Anand Aug 11, 2025
90e06b4
updates osx
Sunny-Anand Aug 11, 2025
6b93539
updates osx
Sunny-Anand Aug 11, 2025
b12664a
updates osx
Sunny-Anand Aug 11, 2025
c1bc4ac
updates osx
Sunny-Anand Aug 11, 2025
2594aeb
updates osx
Sunny-Anand Aug 11, 2025
28d335f
updates osx
Sunny-Anand Aug 11, 2025
0e55aa6
Merge branch 'main' into protobuf-update
AlexandreEichenberger Aug 11, 2025
6750e53
add cppcheck suppression
Sunny-Anand Aug 11, 2025
7a2474b
update s390x
Sunny-Anand Aug 12, 2025
f87d82d
update s390x
Sunny-Anand Aug 12, 2025
92bdbce
update s390x
Sunny-Anand Aug 12, 2025
9beeb47
updates
Sunny-Anand Aug 13, 2025
137e940
updates
Sunny-Anand Aug 13, 2025
0394448
Merge branch 'main' into protobuf-update
Sunny-Anand Aug 13, 2025
d298915
Merge branch 'main' into protobuf-update
Sunny-Anand Aug 13, 2025
c972e44
revert to using cpp implementation using whl files - can't use bazel …
Sunny-Anand Aug 14, 2025
e08b36c
comment the install
Sunny-Anand Aug 14, 2025
577f5bf
update the clone path
Sunny-Anand Aug 14, 2025
59518c5
update the clone path
Sunny-Anand Aug 14, 2025
8774fe6
Merge branch 'main' into protobuf-update
Sunny-Anand Aug 25, 2025
e296fd6
Merge branch 'main' into protobuf-update
Sunny-Anand Sep 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Detailed instructions are provided below.
```
python >= 3.8
gcc >= 6.4
protobuf >= 4.21.12
protobuf >= 4.25.1
cmake >= 3.13.4
make >= 4.2.1 or ninja >= 1.10.2
java >= 1.11 (optional)
Expand Down
37 changes: 28 additions & 9 deletions docker/Dockerfile.llvm-project
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ RUN distro=$(cat /etc/os-release|grep -Po '(?<=^ID=").*(?=")|(?<=^ID=)[^"].*[^"]
libtool make maven ninja-build openjdk-11-jdk-headless \
python3 python3-dev python3-distutils python3-numpy \
python3-pip python3-pytest-xdist python3-setuptools \
python3-typing-extensions zlib1g-dev && \
python3-typing-extensions zlib1g-dev wget tar && \
rm -rf /var/lib/apt/lists/* && \
ln -sf /usr/bin/pytest-3 /usr/bin/pytest; \
elif [ "${distro}" = "rhel" ] || [ "${distro}" = "fedora" ]; then \
Expand All @@ -48,7 +48,7 @@ RUN distro=$(cat /etc/os-release|grep -Po '(?<=^ID=").*(?=")|(?<=^ID=)[^"].*[^"]
file java-11-openjdk-devel java-11-openjdk-headless \
gcc gcc-c++ git libtool make ncurses-devel ninja-build \
python39 python39-devel python39-pip python39-setuptools \
python39-wheel tzdata-java zlib-devel && \
python39-wheel tzdata-java zlib-devel wget tar && \
# Workaround broken ubi8 amd64 image installing python3.12 as
# dependency of clang, which also breaks the /usr/bin/pip3
# symlink creation
Expand All @@ -64,13 +64,32 @@ RUN distro=$(cat /etc/os-release|grep -Po '(?<=^ID=").*(?=")|(?<=^ID=)[^"].*[^"]
&& pip3 install --upgrade pip

# Install protobuf
ARG PROTOBUF_VERSION=21.12
RUN git clone -b v${PROTOBUF_VERSION} --recursive https://github.com/protocolbuffers/protobuf.git \
&& cd protobuf && ./autogen.sh \
&& ./configure --enable-static=no \
&& make -j${NPROC} install && ldconfig \
&& cd python && python3 setup.py install --cpp_implementation \
&& cd ../.. && rm -rf protobuf
ARG PROTOBUF_VERSION=25.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version is 4.25.1 in other places. What's the reason?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no difference between the 2 as you can see the commit is the same. The different naming style is due to the fact that 3. or 4. or 5. is a different release style adopted by protobuf for python verions.
Image

So all the places where there is a python pip reference the 4.25.1 version is used while in onnx-mlir we rely on the c++ protobuf so the verion is 25.1

https://pypi.org/project/protobuf/4.25.1/

ARG INSTALL_PROTOBUF_PATH=/usr/local
ARG BUILD_TYPE=Release
ARG CORE_NUMBER=2
ARG ORIGINAL_PATH=${pwd}
RUN cd .. && \
wget https://github.com/abseil/abseil-cpp/releases/download/20230802.2/abseil-cpp-20230802.2.tar.gz && \
tar -xvf abseil-cpp-20230802.2.tar.gz && \
wget https://github.com/protocolbuffers/protobuf/releases/download/v25.1/protobuf-25.1.tar.gz && \
tar -xvf protobuf-25.1.tar.gz
RUN cd /protobuf-25.1 && \
mkdir build_source && cd build_source && \
cmake -G Ninja ../ \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_INSTALL_PREFIX=$INSTALL_PROTOBUF_PATH \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-Dprotobuf_BUILD_TESTS=OFF \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DABSL_ROOT_DIR="${ORIGINAL_PATH}/abseil-cpp-20230802.2"\
-DCMAKE_CXX_STANDARD=17 \
-DABSL_PROPAGATE_CXX_STD=on \
&& cmake --build . --target install --parallel $CORE_NUMBER

RUN export PATH=$INSTALL_PROTOBUF_PATH/include:$INSTALL_PROTOBUF_PATH/lib:$INSTALL_PROTOBUF_PATH/bin:$PATH && \
export LDFLAGS="-L$INSTALL_PROTOBUF_PATH/lib" && \
export CPPFLAGS="-I$INSTALL_PROTOBUF_PATH/include"

# Install jsoniter
ARG JSONITER_VERSION=0.9.23
Expand Down
6 changes: 3 additions & 3 deletions docs/BuildOnWindows.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Build protobuf as a static library.

[same-as-file]: <> (utils/install-protobuf.cmd)
```shell
REM Check out protobuf v21.12
set protobuf_version=21.12
REM Check out protobuf v4.25.1
set protobuf_version=4.25.1
git clone -b v%protobuf_version% --recursive https://github.com/protocolbuffers/protobuf.git

set root_dir=%cd%
Expand All @@ -42,7 +42,7 @@ set PATH=%root_dir%\protobuf_install\bin;%PATH%

If you wish to be able to run all the ONNX-MLIR tests, you will also need to install the matching version of protobuf through pip. Note that this is included in the requirements.txt file at the root of onnx-mlir, so if you plan on using it, you won't need to explicitly install protobuf.
```shell
python3 -m pip install protobuf==4.21.12
python3 -m pip install protobuf==4.25.1
```

#### MLIR
Expand Down
2 changes: 1 addition & 1 deletion docs/Prerequisite.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
```
python >= 3.8
gcc >= 6.4
protobuf >= 4.21.12
protobuf >= 4.25.1
cmake >= 3.13.4
make >= 4.2.1 or ninja >= 1.10.2
java >= 1.11 (optional)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ lit~=15.0
# and np.int which are used heavily in onnx-mlir.
numpy==2.0.1
onnx==1.17.0
protobuf==4.21.12
protobuf==4.25.1
pytest==8.3.2
pytest-xdist==3.6.1
7 changes: 7 additions & 0 deletions utils/cppcheck_scan/cppcheck_suppressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@ preprocessorErrorDirective:/workdir/onnx-mlir/build/third_party/onnx/onnx/onnx-o
# <location file="/workdir/llvm-project/llvm/include/llvm-c/DataTypes.h" line="38" column="0"/>
# </error>
preprocessorErrorDirective:/workdir/llvm-project/llvm/include/llvm-c/DataTypes.h:38
# Build image has a newer protobuf than onnx-mlir source. This causes preprocessor issues when scanning with cppcheck.
# <error id="preprocessorErrorDirective" severity="error" msg="#error &quot;This file was generated by a newer version of protoc which is&quot;" verbose="#error &quot;This file was generated by a newer version of protoc which is&quot;">
# <location file="/workdir/onnx-mlir/build/third_party/onnx/onnx/onnx-data.pb.h" line="15" column="0"/>
# </error>
preprocessorErrorDirective:/workdir/onnx-mlir/build/third_party/onnx/onnx/onnx-data.pb.h:15
preprocessorErrorDirective:/workdir/onnx-mlir/build/third_party/onnx/onnx/onnx-ml.pb.h:15
preprocessorErrorDirective:/workdir/onnx-mlir/build/third_party/onnx/onnx/onnx-operators-ml.pb.h:15
5 changes: 3 additions & 2 deletions utils/install-protobuf.cmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
REM Check out protobuf v21.12
set protobuf_version=21.12
REM Check out protobuf v4.25.1
set protobuf_version=4.25.1
git clone -b v%protobuf_version% --recursive https://github.com/protocolbuffers/protobuf.git

set root_dir=%cd%
git submodule update --init --recursive
md protobuf_build
cd protobuf_build
call cmake %root_dir%\protobuf\cmake -G "Ninja" ^
Expand Down
42 changes: 33 additions & 9 deletions utils/install-protobuf.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
# Check out protobuf
PROTOBUF_VERSION=21.12
git clone -b v${PROTOBUF_VERSION} --depth 1 --recursive https://github.com/protocolbuffers/protobuf.git
# Exit immediately if a command exits with a non-zero status.
set -e

cd protobuf
./autogen.sh
./configure --enable-static=no
make -j$(sysctl -n hw.logicalcpu) install
cd python
python3 setup.py install --cpp_implementation
export INSTALL_PROTOBUF_PATH=~/work/protobuf_install # Changed to a dedicated install directory
export BUILD_TYPE=Release
export CORE_NUMBER=1

# Build protobuf from source with -fPIC on Unix-like system
ORIGINAL_PATH=$(pwd)
cd ..
wget https://github.com/abseil/abseil-cpp/releases/download/20230802.2/abseil-cpp-20230802.2.tar.gz
tar -xvf abseil-cpp-20230802.2.tar.gz

wget https://github.com/protocolbuffers/protobuf/releases/download/v25.1/protobuf-25.1.tar.gz
tar -xvf protobuf-25.1.tar.gz
cd protobuf-25.1
mkdir build_source && cd build_source
cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=$INSTALL_PROTOBUF_PATH -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DABSL_ROOT_DIR="${ORIGINAL_PATH}/../abseil-cpp-20230802.2" -DCMAKE_CXX_STANDARD=17 -DABSL_PROPAGATE_CXX_STD=on ..
if [ "$INSTALL_PROTOBUF_PATH" == "/usr" ]; then
# Don't use sudo for root
if [[ "$(id -u)" == "0" ]]; then
cmake --build . --target install --parallel $CORE_NUMBER
else
# install Protobuf on default system path so it needs sudo permission
sudo cmake --build . --target install --parallel $CORE_NUMBER
fi
else
cmake --build . --target install --parallel $CORE_NUMBER
export PATH=$INSTALL_PROTOBUF_PATH/include:$INSTALL_PROTOBUF_PATH/lib:$INSTALL_PROTOBUF_PATH/bin:$PATH
export LDFLAGS="-L$INSTALL_PROTOBUF_PATH/lib"
export CPPFLAGS="-I$INSTALL_PROTOBUF_PATH/include"
fi
protoc --version
cd $ORIGINAL_PATH
Loading