Skip to content

Commit 3762e0d

Browse files
committed
Implement replace_all_uses_with function
1 parent 2efe9bb commit 3762e0d

File tree

3 files changed

+230
-20
lines changed

3 files changed

+230
-20
lines changed

backends/xnnpack/_passes/channels_last_tagged_reshape_pass.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def input_to_nhwc(
283283
]
284284
else:
285285
# Need to create NHWC node
286-
# TODO: If input is dequant does that it's from dynamic quantization?
286+
# TODO: Replace with check to determine if dynamic quant
287287
input_is_dequant = is_dequant(input_node)
288288

289289
if input_is_dequant:
@@ -301,10 +301,8 @@ def input_to_nhwc(
301301

302302
if input_is_dequant:
303303
# Replace downstream input_nodes with NHWC node
304-
for user in list(input_node.users):
305-
if user is not input_node_nhwc:
306-
user.replace_input_with(input_node, input_node_nhwc)
307-
graph_module.recompile()
304+
input_node.replace_all_uses_with(input_node_nhwc)
305+
input_node_nhwc.args = (input_node,)
308306

309307
self.insert_copy_and_assign_partner_nodes_quantization_sensitive(
310308
graph_module=graph_module,

backends/xnnpack/test/ops/test_conv2d.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def _test_dq_conv2d(
244244

245245
DynamicallyQuantizedPartitioner = XnnpackPartitioner(
246246
config_precisions=ConfigPrecisionType.DYNAMIC_QUANT,
247-
per_op_mode=False,
247+
per_op_mode=True,
248248
)
249249

250250
tester = Tester(m, inputs, dynamic_shapes=dynamic_shapes)
@@ -762,9 +762,11 @@ def get_inputs(self):
762762
return (torch.randn(1, 3, 8, 8),)
763763

764764
model = SimpleConv2d()
765+
inputs = model.get_inputs()
766+
765767
self._test_dq_conv2d(
766768
model,
767-
model.get_inputs(),
769+
inputs,
768770
dynamic_shapes=None,
769771
atol=3.0,
770772
)
Lines changed: 223 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,231 @@
1-
CC = gcc
2-
CFLAGS = -O3 -march=native -std=c99 -pedantic -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes
1+
# CMAKE generated file: DO NOT EDIT!
2+
# Generated by "Unix Makefiles" Generator, CMake Version 3.31
33

4-
all: test_float test_double fast_copy.o fht.o
4+
# Default target executed when no arguments are given to make.
5+
default_target: all
6+
.PHONY : default_target
57

6-
OBJ := dumb_fht.o fast_copy.o fht.o
8+
# Allow only one "make -f Makefile2" at a time, but pass parallelism.
9+
.NOTPARALLEL:
710

8-
%.o: %.c
9-
$(CC) $< -o $@ -c $(CFLAGS)
11+
#=============================================================================
12+
# Special targets provided by cmake.
1013

11-
test_%: test_%.c $(OBJ)
12-
$(CC) $< $(OBJ) -o $@ $(CFLAGS)
14+
# Disable implicit rules so canonical targets will work.
15+
.SUFFIXES:
1316

14-
test_double_header_only: test_double_header_only.c
15-
$(CC) $< -o $@ $(CFLAGS)
17+
# Disable VCS-based implicit rules.
18+
% : %,v
1619

17-
test_float_header_only: test_double_header_only.c
18-
$(CC) $< -o $@ $(CFLAGS)
20+
# Disable VCS-based implicit rules.
21+
% : RCS/%
1922

23+
# Disable VCS-based implicit rules.
24+
% : RCS/%,v
25+
26+
# Disable VCS-based implicit rules.
27+
% : SCCS/s.%
28+
29+
# Disable VCS-based implicit rules.
30+
% : s.%
31+
32+
.SUFFIXES: .hpux_make_needs_suffix_list
33+
34+
# Command-line flag to silence nested $(MAKE).
35+
$(VERBOSE)MAKESILENT = -s
36+
37+
#Suppress display of executed commands.
38+
$(VERBOSE).SILENT:
39+
40+
# A target that is always out of date.
41+
cmake_force:
42+
.PHONY : cmake_force
43+
44+
#=============================================================================
45+
# Set environment variables for the build.
46+
47+
# The shell in which to execute make rules.
48+
SHELL = /bin/sh
49+
50+
# The CMake executable.
51+
CMAKE_COMMAND = /opt/anaconda3/envs/executorch/lib/python3.10/site-packages/cmake/data/bin/cmake
52+
53+
# The command to remove a file.
54+
RM = /opt/anaconda3/envs/executorch/lib/python3.10/site-packages/cmake/data/bin/cmake -E rm -f
55+
56+
# Escaping for special characters.
57+
EQUALS = =
58+
59+
# The top-level source directory on which CMake was run.
60+
CMAKE_SOURCE_DIR = /Users/zuby/PycharmProjects/src/executorch
61+
62+
# The top-level build directory on which CMake was run.
63+
CMAKE_BINARY_DIR = /Users/zuby/PycharmProjects/src/executorch
64+
65+
#=============================================================================
66+
# Targets provided globally by CMake.
67+
68+
# Special rule for the target edit_cache
69+
edit_cache:
70+
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake cache editor..."
71+
/opt/anaconda3/envs/executorch/lib/python3.10/site-packages/cmake/data/bin/ccmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
72+
.PHONY : edit_cache
73+
74+
# Special rule for the target edit_cache
75+
edit_cache/fast: edit_cache
76+
.PHONY : edit_cache/fast
77+
78+
# Special rule for the target rebuild_cache
79+
rebuild_cache:
80+
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake to regenerate build system..."
81+
/opt/anaconda3/envs/executorch/lib/python3.10/site-packages/cmake/data/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
82+
.PHONY : rebuild_cache
83+
84+
# Special rule for the target rebuild_cache
85+
rebuild_cache/fast: rebuild_cache
86+
.PHONY : rebuild_cache/fast
87+
88+
# Special rule for the target list_install_components
89+
list_install_components:
90+
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Available install components are: \"Unspecified\""
91+
.PHONY : list_install_components
92+
93+
# Special rule for the target list_install_components
94+
list_install_components/fast: list_install_components
95+
.PHONY : list_install_components/fast
96+
97+
# Special rule for the target install
98+
install: preinstall
99+
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Install the project..."
100+
/opt/anaconda3/envs/executorch/lib/python3.10/site-packages/cmake/data/bin/cmake -P cmake_install.cmake
101+
.PHONY : install
102+
103+
# Special rule for the target install
104+
install/fast: preinstall/fast
105+
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Install the project..."
106+
/opt/anaconda3/envs/executorch/lib/python3.10/site-packages/cmake/data/bin/cmake -P cmake_install.cmake
107+
.PHONY : install/fast
108+
109+
# Special rule for the target install/local
110+
install/local: preinstall
111+
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Installing only the local directory..."
112+
/opt/anaconda3/envs/executorch/lib/python3.10/site-packages/cmake/data/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
113+
.PHONY : install/local
114+
115+
# Special rule for the target install/local
116+
install/local/fast: preinstall/fast
117+
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Installing only the local directory..."
118+
/opt/anaconda3/envs/executorch/lib/python3.10/site-packages/cmake/data/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
119+
.PHONY : install/local/fast
120+
121+
# Special rule for the target install/strip
122+
install/strip: preinstall
123+
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Installing the project stripped..."
124+
/opt/anaconda3/envs/executorch/lib/python3.10/site-packages/cmake/data/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
125+
.PHONY : install/strip
126+
127+
# Special rule for the target install/strip
128+
install/strip/fast: preinstall/fast
129+
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Installing the project stripped..."
130+
/opt/anaconda3/envs/executorch/lib/python3.10/site-packages/cmake/data/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
131+
.PHONY : install/strip/fast
132+
133+
# The main all target
134+
all: cmake_check_build_system
135+
cd /Users/zuby/PycharmProjects/src/executorch && $(CMAKE_COMMAND) -E cmake_progress_start /Users/zuby/PycharmProjects/src/executorch/CMakeFiles /Users/zuby/PycharmProjects/src/executorch/extension/llm/custom_ops/spinquant/third-party/FFHT//CMakeFiles/progress.marks
136+
cd /Users/zuby/PycharmProjects/src/executorch && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 extension/llm/custom_ops/spinquant/third-party/FFHT/all
137+
$(CMAKE_COMMAND) -E cmake_progress_start /Users/zuby/PycharmProjects/src/executorch/CMakeFiles 0
138+
.PHONY : all
139+
140+
# The main clean target
20141
clean:
21-
rm -f test_float test_double test_float_header_only test_double_header_only $(OBJ)
142+
cd /Users/zuby/PycharmProjects/src/executorch && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 extension/llm/custom_ops/spinquant/third-party/FFHT/clean
143+
.PHONY : clean
144+
145+
# The main clean target
146+
clean/fast: clean
147+
.PHONY : clean/fast
148+
149+
# Prepare targets for installation.
150+
preinstall: all
151+
cd /Users/zuby/PycharmProjects/src/executorch && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 extension/llm/custom_ops/spinquant/third-party/FFHT/preinstall
152+
.PHONY : preinstall
153+
154+
# Prepare targets for installation.
155+
preinstall/fast:
156+
cd /Users/zuby/PycharmProjects/src/executorch && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 extension/llm/custom_ops/spinquant/third-party/FFHT/preinstall
157+
.PHONY : preinstall/fast
158+
159+
# clear depends
160+
depend:
161+
cd /Users/zuby/PycharmProjects/src/executorch && $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
162+
.PHONY : depend
163+
164+
# Convenience name for target.
165+
extension/llm/custom_ops/spinquant/third-party/FFHT/CMakeFiles/dumb_fht.dir/rule:
166+
cd /Users/zuby/PycharmProjects/src/executorch && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 extension/llm/custom_ops/spinquant/third-party/FFHT/CMakeFiles/dumb_fht.dir/rule
167+
.PHONY : extension/llm/custom_ops/spinquant/third-party/FFHT/CMakeFiles/dumb_fht.dir/rule
168+
169+
# Convenience name for target.
170+
dumb_fht: extension/llm/custom_ops/spinquant/third-party/FFHT/CMakeFiles/dumb_fht.dir/rule
171+
.PHONY : dumb_fht
172+
173+
# fast build rule for target.
174+
dumb_fht/fast:
175+
cd /Users/zuby/PycharmProjects/src/executorch && $(MAKE) $(MAKESILENT) -f extension/llm/custom_ops/spinquant/third-party/FFHT/CMakeFiles/dumb_fht.dir/build.make extension/llm/custom_ops/spinquant/third-party/FFHT/CMakeFiles/dumb_fht.dir/build
176+
.PHONY : dumb_fht/fast
177+
178+
dumb_fht.o: dumb_fht.c.o
179+
.PHONY : dumb_fht.o
180+
181+
# target to build an object file
182+
dumb_fht.c.o:
183+
cd /Users/zuby/PycharmProjects/src/executorch && $(MAKE) $(MAKESILENT) -f extension/llm/custom_ops/spinquant/third-party/FFHT/CMakeFiles/dumb_fht.dir/build.make extension/llm/custom_ops/spinquant/third-party/FFHT/CMakeFiles/dumb_fht.dir/dumb_fht.c.o
184+
.PHONY : dumb_fht.c.o
185+
186+
dumb_fht.i: dumb_fht.c.i
187+
.PHONY : dumb_fht.i
188+
189+
# target to preprocess a source file
190+
dumb_fht.c.i:
191+
cd /Users/zuby/PycharmProjects/src/executorch && $(MAKE) $(MAKESILENT) -f extension/llm/custom_ops/spinquant/third-party/FFHT/CMakeFiles/dumb_fht.dir/build.make extension/llm/custom_ops/spinquant/third-party/FFHT/CMakeFiles/dumb_fht.dir/dumb_fht.c.i
192+
.PHONY : dumb_fht.c.i
193+
194+
dumb_fht.s: dumb_fht.c.s
195+
.PHONY : dumb_fht.s
196+
197+
# target to generate assembly for a file
198+
dumb_fht.c.s:
199+
cd /Users/zuby/PycharmProjects/src/executorch && $(MAKE) $(MAKESILENT) -f extension/llm/custom_ops/spinquant/third-party/FFHT/CMakeFiles/dumb_fht.dir/build.make extension/llm/custom_ops/spinquant/third-party/FFHT/CMakeFiles/dumb_fht.dir/dumb_fht.c.s
200+
.PHONY : dumb_fht.c.s
201+
202+
# Help Target
203+
help:
204+
@echo "The following are some of the valid targets for this Makefile:"
205+
@echo "... all (the default if no target is provided)"
206+
@echo "... clean"
207+
@echo "... depend"
208+
@echo "... edit_cache"
209+
@echo "... install"
210+
@echo "... install/local"
211+
@echo "... install/strip"
212+
@echo "... list_install_components"
213+
@echo "... rebuild_cache"
214+
@echo "... dumb_fht"
215+
@echo "... dumb_fht.o"
216+
@echo "... dumb_fht.i"
217+
@echo "... dumb_fht.s"
218+
.PHONY : help
219+
220+
221+
222+
#=============================================================================
223+
# Special targets to cleanup operation of make.
224+
225+
# Special rule to run CMake to check the build system integrity.
226+
# No rule that depends on this can have commands that come from listfiles
227+
# because they might be regenerated.
228+
cmake_check_build_system:
229+
cd /Users/zuby/PycharmProjects/src/executorch && $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
230+
.PHONY : cmake_check_build_system
231+

0 commit comments

Comments
 (0)