-
Notifications
You must be signed in to change notification settings - Fork 102
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
PTQ with ResNet conv2x layers #1433
Open
singagan
wants to merge
12
commits into
main
Choose a base branch
from
gagan_resnet_ptq
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3ad06df
initial ptq with conv2x
singagan dacdc6a
ptq for offloaded resnet conv2x
singagan d82a686
black fixes for resnet ptq
singagan eccf94f
disable ptq
singagan 34c56e2
Merge branch 'main' into gagan_resnet_ptq
singagan acece73
Merge branch 'main' into gagan_resnet_ptq
singagan 44576a7
Merge branch 'main' into gagan_resnet_ptq
singagan 67c1ee9
Merge branch 'main' into gagan_resnet_ptq
singagan cc9c43b
PTQ readme
singagan d3bd186
PTQ readme
singagan 896e0d6
black fix
singagan c1d4779
PTQ readme update
singagan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# | ||
# Copyright (C) 2024, Advanced Micro Devices, Inc. | ||
|
||
# parameters | ||
# -DBOOST_ROOT: Path to Boost install | ||
# -DOpenCV_DIR: Path to OpenCV install | ||
# -DXRT_INC_DIR: Full path to src/runtime_src/core/include in XRT cloned repo | ||
# -DXRT_LIB_DIR: Path to xrt_coreutil.lib | ||
# -DTARGET_NAME: Target name to be built | ||
|
||
# cmake needs this line | ||
cmake_minimum_required(VERSION 3.1) | ||
|
||
find_program(WSL NAMES powershell.exe) | ||
|
||
if (NOT WSL) | ||
set(BOOST_ROOT /usr/include/boost CACHE STRING "Path to Boost install") | ||
set(OpenCV_DIR /usr/include/opencv4 CACHE STRING "Path to OpenCV install") | ||
set(XRT_INC_DIR /opt/xilinx/xrt/include CACHE STRING "Path to XRT cloned repo") | ||
set(XRT_LIB_DIR /opt/xilinx/xrt/lib CACHE STRING "Path to xrt_coreutil.lib") | ||
else() | ||
set(BOOST_ROOT C:/Technical/thirdParty/boost_1_83_0 CACHE STRING "Path to Boost install") | ||
set(OpenCV_DIR C:/Technical/thirdParty/opencv/build CACHE STRING "Path to OpenCV install") | ||
set(XRT_INC_DIR C:/Technical/XRT/src/runtime_src/core/include CACHE STRING "Path to XRT cloned repo") | ||
set(XRT_LIB_DIR C:/Technical/xrtNPUfromDLL CACHE STRING "Path to xrt_coreutil.lib") | ||
endif () | ||
|
||
set(EDGEDETECT_WIDTH 1920 CACHE STRING "image width") | ||
set(EDGEDETECT_HEIGHT 1080 CACHE STRING "image height") | ||
|
||
set(TARGET_NAME test CACHE STRING "Target to be built") | ||
|
||
SET (ProjectName ${TARGET_NAME}) | ||
SET (currentTarget ${TARGET_NAME}) | ||
|
||
if ( WSL ) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}) | ||
endif () | ||
|
||
project(${ProjectName}) | ||
|
||
# Find packages | ||
find_package(Boost REQUIRED) | ||
find_package(OpenCV REQUIRED) | ||
message("opencv library paht: ${OpenCV_LIB_PATH}") | ||
message("opencv libs: ${OpenCV_LIBS}") | ||
|
||
|
||
add_executable(${currentTarget} | ||
${CMAKE_CURRENT_SOURCE_DIR}/../../../utils/OpenCVUtils.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/../../../utils/xrtUtils.cpp | ||
test.cpp | ||
) | ||
|
||
target_compile_definitions(${currentTarget} PUBLIC | ||
EDGEDETECT_WIDTH=${EDGEDETECT_WIDTH} | ||
EDGEDETECT_HEIGHT=${EDGEDETECT_HEIGHT} | ||
DISABLE_ABI_CHECK=1 | ||
) | ||
|
||
target_include_directories (${currentTarget} PUBLIC | ||
${CMAKE_CURRENT_SOURCE_DIR}/../../../utils | ||
${XRT_INC_DIR} | ||
${OpenCV_INCLUDE_DIRS} | ||
${Boost_INCLUDE_DIRS} | ||
) | ||
|
||
target_link_directories(${currentTarget} PUBLIC | ||
${XRT_LIB_DIR} | ||
${OpenCV_LIB_PATH} | ||
${Boost_LIBRARY_DIRS} | ||
) | ||
|
||
if (NOT WSL) | ||
target_link_libraries(${currentTarget} PUBLIC | ||
xrt_coreutil | ||
${OpenCV_LIBS} | ||
boost_program_options | ||
boost_filesystem | ||
) | ||
else() | ||
target_link_libraries(${currentTarget} PUBLIC | ||
xrt_coreutil | ||
${OpenCV_LIBS} | ||
) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
##===- Makefile -----------------------------------------------------------===## | ||
# | ||
# This file licensed under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# | ||
##===----------------------------------------------------------------------===## | ||
|
||
srcdir := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
|
||
include ${srcdir}/../../../makefile-common | ||
|
||
mlirFileName = aie | ||
|
||
VPATH := ${srcdir}/../../../../aie_kernels/aie2 | ||
|
||
all: build/conv2dk1_i8.o build/conv2dk1_skip_init.o build/conv2dk3.o build/conv2dk1_skip.o build/conv2dk1_ui8.o build/final.xclbin | ||
|
||
build/${mlirFileName}.mlir: ${srcdir}/aie2.py | ||
mkdir -p ${@D} | ||
python3 $< > $@ | ||
insts.txt: build/${mlirFileName}.mlir | ||
aiecc.py -v --aie-only-generate-npu --npu-insts-name=$@ $< | ||
|
||
build/conv2dk1_i8.o: conv2dk1.cc | ||
xchesscc -d ${CHESSCC2_FLAGS} -DINT8_ACT -c $< -o $@ | ||
|
||
build/conv2dk3.o: conv2dk3.cc | ||
xchesscc -d ${CHESSCC2_FLAGS} -DUINT8_ACT -c $< -o $@ | ||
|
||
build/conv2dk1_skip_init.o: conv2dk1_skip_init.cc | ||
xchesscc -d ${CHESSCC2_FLAGS} -DINT8_ACT -c $< -o $@ | ||
|
||
build/conv2dk1_ui8.o: conv2dk1.cc | ||
xchesscc -d ${CHESSCC2_FLAGS} -DUINT8_ACT -c $< -o $@ | ||
|
||
build/conv2dk1_skip.o: conv2dk1_skip.cc | ||
xchesscc -d ${CHESSCC2_FLAGS} -DUINT8_ACT -c $< -o $@ | ||
|
||
build/final.xclbin: build/${mlirFileName}.mlir build/conv2dk1_i8.o build/conv2dk1_skip_init.o build/conv2dk3.o build/conv2dk1_skip.o build/conv2dk1_ui8.o | ||
cd build && aiecc.py --basic-alloc-scheme --aie-generate-cdo --aie-generate-npu --no-compile-host \ | ||
--xclbin-name=${@F} --npu-insts-name=insts.txt ${<F} | ||
clean: | ||
rm -rf build/*.elf* build/*.lst build/*.bif log* build/${mlirFileName}.mlir.prj build/*.xclbin sim \ | ||
build/chess* build/insts.txt \ | ||
build/*.log build/aie_partition.json build/*.bin build/BOOT.BIN _x test.exe | ||
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. there is no test.exe being build |
||
|
||
run_py: | ||
${powershell} python3 ${srcdir}/test.py -x build/final.xclbin -i build/insts.txt -k MLIR_AIE |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this CMakeList.txt needed? Testing is only supported through a Python test.py file.