Skip to content

Commit e23c8f9

Browse files
committed
remove unused, untested code
1 parent fca9cc4 commit e23c8f9

File tree

15 files changed

+0
-1264
lines changed

15 files changed

+0
-1264
lines changed

iron/operators/axpy/design.py

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
from ml_dtypes import bfloat16
5-
from pathlib import Path
65
import numpy as np
7-
import argparse
8-
import sys
96

107
from aie.iron import Kernel, ObjectFifo, Program, Runtime, Worker
118
from aie.iron.placers import SequentialPlacer
@@ -125,104 +122,3 @@ def core_body(of_in1, of_in2, of_out, axpy):
125122

126123
# Place program components (assign them resources on the device) and generate an MLIR module
127124
return Program(dev, rt).resolve_program(SequentialPlacer())
128-
129-
130-
if __name__ == "__main__":
131-
132-
def str_to_device(device: str):
133-
if device == "npu":
134-
return NPU1()
135-
elif device == "npu2":
136-
return NPU2()
137-
else:
138-
raise ValueError(f"Device name {device} is unknown.")
139-
140-
p = argparse.ArgumentParser()
141-
# Parse command line arguments
142-
143-
# Device name is required to select the AIE device: npu or npu2
144-
p.add_argument(
145-
"-d",
146-
"--dev",
147-
required=True,
148-
dest="device",
149-
help="AIE Device",
150-
type=str_to_device,
151-
)
152-
# Transfer size is required to define the size of the data to be transferred
153-
# It must be a multiple of tile_size and divisible by the number of columns and channels
154-
p.add_argument("-l", "--length", required=True, dest="length", help="Transfer size")
155-
# Number of columns is required to define the number of columns to be used
156-
# It must be less than or equal to 4 for npu and 8 for npu2
157-
p.add_argument(
158-
"-co", "--columns", required=True, dest="cols", help="Number of columns"
159-
)
160-
# Number of channels is required to define the number of channels to be used
161-
# It must be 1 or 2
162-
p.add_argument(
163-
"-ch", "--channels", required=True, dest="chans", help="Number of channels"
164-
)
165-
# Tile size (elements per tile) - defaults to 1024 for backward compatibility
166-
p.add_argument(
167-
"-ts",
168-
"--tile-size",
169-
required=False,
170-
dest="tile_size",
171-
default="1024",
172-
help="Tile size (elements per tile)",
173-
)
174-
# Trace Size
175-
p.add_argument(
176-
"-t", "--trace-size", required=True, dest="trace_size", help="Trace size"
177-
)
178-
# Trace Size
179-
p.add_argument(
180-
"-s",
181-
"--scalar-factor",
182-
required=True,
183-
dest="scalar_factor",
184-
help="Scalar factor",
185-
)
186-
p.add_argument(
187-
"--output-file-path",
188-
"-o",
189-
type=str,
190-
help="Output file path for the generated MLIR module",
191-
)
192-
193-
opts = p.parse_args(sys.argv[1:])
194-
195-
length = int(opts.length)
196-
columns = int(opts.cols)
197-
dev = opts.device
198-
199-
# Validate columns based on device type
200-
if isinstance(dev, NPU1) and columns > 4:
201-
raise ValueError("[ERROR] NPU device cannot allocate more than 4 columns")
202-
elif isinstance(dev, NPU2) and columns > 8:
203-
raise ValueError("[ERROR] NPU2 device cannot allocate more than 8 columns")
204-
205-
channels = int(opts.chans)
206-
if channels < 1 or channels > 2:
207-
raise ValueError("Number of channels must be 1 or 2")
208-
tile_size = int(opts.tile_size)
209-
if length % (tile_size * columns) != 0:
210-
print(
211-
"transfer size ("
212-
+ str(length)
213-
+ ") must be a multiple of "
214-
+ str(tile_size * columns)
215-
+ " (tile_size * columns)"
216-
)
217-
raise ValueError
218-
trace_size = int(opts.trace_size) if opts.trace_size is not None else 0
219-
scalar_factor = float(opts.scalar_factor)
220-
221-
module = my_axpy(
222-
dev, length, columns, channels, tile_size, trace_size, scalar_factor
223-
)
224-
225-
output_file_path = Path(opts.output_file_path)
226-
227-
with open(output_file_path, "w") as f:
228-
f.write(str(module))

iron/operators/dequant/design.py

Lines changed: 0 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
from ml_dtypes import bfloat16
5-
from pathlib import Path
65
import numpy as np
7-
import argparse
8-
import sys
96

107
from aie.iron import Kernel, ObjectFifo, Program, Runtime, Worker
118
from aie.iron.placers import SequentialPlacer
@@ -156,117 +153,3 @@ def core_body(of_in1, of_out, dequant_kernel):
156153

157154
# Place program components (assign them resources on the device) and generate an MLIR module
158155
return Program(dev, rt).resolve_program(SequentialPlacer())
159-
160-
161-
if __name__ == "__main__":
162-
163-
def str_to_device(device: str):
164-
if device == "npu":
165-
return NPU1()
166-
elif device == "npu2":
167-
return NPU2()
168-
else:
169-
raise ValueError(f"Device name {device} is unknown.")
170-
171-
p = argparse.ArgumentParser()
172-
# Parse command line arguments
173-
174-
# Device name is required to select the AIE device: npu or npu2
175-
p.add_argument(
176-
"-d",
177-
"--dev",
178-
required=True,
179-
dest="device",
180-
help="AIE Device",
181-
type=str_to_device,
182-
)
183-
# Transfer size is required to define the size of the data to be transferred
184-
# It must be a multiple of tile size and divisible by the number of columns and 2 channels per column
185-
p.add_argument("-l", "--length", required=True, dest="length", help="Transfer size")
186-
# Number of columns is required to define the number of columns to be used
187-
# It must be less than or equal to 4 for npu and 8 for npu2
188-
p.add_argument(
189-
"-co", "--columns", required=True, dest="cols", help="Number of columns"
190-
)
191-
# Number of channels is required to define the number of channels to be used
192-
# It must be 1 or 2
193-
p.add_argument(
194-
"-ch", "--channels", required=True, dest="chans", help="Number of channels"
195-
)
196-
# Tile size (columns per tile) - defaults to 1024 for backward compatibility
197-
p.add_argument(
198-
"-ts",
199-
"--tile-size",
200-
required=False,
201-
dest="tile_size",
202-
default="1024",
203-
help="Tile size (columns per tile)",
204-
)
205-
# Group size (elements per scaling factor)
206-
p.add_argument(
207-
"-gs",
208-
"--group_size",
209-
required=False,
210-
dest="group_size",
211-
default="32",
212-
help="Dequantization group size (super block size)",
213-
)
214-
# Trace Size
215-
p.add_argument(
216-
"-tr", "--trace-size", required=True, dest="trace_size", help="Trace size"
217-
)
218-
p.add_argument(
219-
"--output-file-path",
220-
"-o",
221-
type=str,
222-
help="Output file path for the generated MLIR module",
223-
)
224-
225-
opts = p.parse_args(sys.argv[1:])
226-
227-
length = int(opts.length)
228-
columns = int(opts.cols)
229-
dev = opts.device
230-
231-
# Validate columns based on device type
232-
if isinstance(dev, NPU1) and columns > 4:
233-
raise ValueError("[ERROR] NPU device cannot allocate more than 4 columns")
234-
elif isinstance(dev, NPU2) and columns > 8:
235-
raise ValueError("[ERROR] NPU2 device cannot allocate more than 8 columns")
236-
237-
channels = int(opts.chans)
238-
if channels < 1 or channels > 2:
239-
raise ValueError("Number of channels must be 1 or 2")
240-
tile_size = int(opts.tile_size)
241-
group_size = int(opts.group_size)
242-
if (((length // 2) % tile_size) % columns % channels) != 0:
243-
print(
244-
"input transfer size in Bytes ("
245-
+ str(length // 2)
246-
+ ") must be a multiple of "
247-
+ str(tile_size)
248-
+ f" and divisible by the number of columns ({columns}) and {channels} channels per column"
249-
)
250-
raise ValueError
251-
if (((length * 2) % tile_size) % columns % channels) != 0:
252-
print(
253-
"output transfer size in Bytes ("
254-
+ str(length * 2)
255-
+ ") must be a multiple of "
256-
+ str(tile_size)
257-
+ f" and divisible by the number of columns ({columns}) and {channels} channels per column"
258-
)
259-
raise ValueError
260-
if tile_size % group_size != 0:
261-
print(f"Tile {tile_size} size must be a multiple of group size ({group_size})")
262-
raise ValueError
263-
trace_size = int(opts.trace_size) if opts.trace_size is not None else 0
264-
265-
module = my_dequant_kernel(
266-
dev, length, columns, channels, trace_size, tile_size, group_size
267-
)
268-
269-
output_file_path = Path(opts.output_file_path)
270-
271-
with open(output_file_path, "w") as f:
272-
f.write(str(module))

iron/operators/elementwise_add/design.py

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
from ml_dtypes import bfloat16
5-
from pathlib import Path
65
import numpy as np
7-
import argparse
8-
import sys
96

107
from aie.iron import Kernel, ObjectFifo, Program, Runtime, Worker
118
from aie.iron.placers import SequentialPlacer
@@ -125,93 +122,3 @@ def core_body(of_in1, of_in2, of_out, eltwise_add):
125122

126123
# Place program components (assign them resources on the device) and generate an MLIR module
127124
return Program(dev, rt).resolve_program(SequentialPlacer())
128-
129-
130-
if __name__ == "__main__":
131-
132-
def str_to_device(device: str):
133-
if device == "npu":
134-
return NPU1()
135-
elif device == "npu2":
136-
return NPU2()
137-
else:
138-
raise ValueError(f"Device name {device} is unknown.")
139-
140-
p = argparse.ArgumentParser()
141-
# Parse command line arguments
142-
143-
# Device name is required to select the AIE device: npu or npu2
144-
p.add_argument(
145-
"-d",
146-
"--dev",
147-
required=True,
148-
dest="device",
149-
help="AIE Device",
150-
type=str_to_device,
151-
)
152-
# Transfer size is required to define the size of the data to be transferred
153-
# It must be a multiple of tile_size and divisible by the number of columns and channels
154-
p.add_argument("-l", "--length", required=True, dest="length", help="Transfer size")
155-
# Number of columns is required to define the number of columns to be used
156-
# It must be less than or equal to 4 for npu and 8 for npu2
157-
p.add_argument(
158-
"-co", "--columns", required=True, dest="cols", help="Number of columns"
159-
)
160-
# Number of channels is required to define the number of channels to be used
161-
# It must be 1 or 2
162-
p.add_argument(
163-
"-ch", "--channels", required=True, dest="chans", help="Number of channels"
164-
)
165-
# Tile size (elements per tile) - defaults to 1024 for backward compatibility
166-
p.add_argument(
167-
"-ts",
168-
"--tile-size",
169-
required=False,
170-
dest="tile_size",
171-
default="1024",
172-
help="Tile size (elements per tile)",
173-
)
174-
# Trace Size
175-
p.add_argument(
176-
"-t", "--trace-size", required=True, dest="trace_size", help="Trace size"
177-
)
178-
p.add_argument(
179-
"--output-file-path",
180-
"-o",
181-
type=str,
182-
help="Output file path for the generated MLIR module",
183-
)
184-
185-
opts = p.parse_args(sys.argv[1:])
186-
187-
length = int(opts.length)
188-
columns = int(opts.cols)
189-
dev = opts.device
190-
191-
# Validate columns based on device type
192-
if isinstance(dev, NPU1) and columns > 4:
193-
raise ValueError("[ERROR] NPU device cannot allocate more than 4 columns")
194-
elif isinstance(dev, NPU2) and columns > 8:
195-
raise ValueError("[ERROR] NPU2 device cannot allocate more than 8 columns")
196-
197-
channels = int(opts.chans)
198-
if channels < 1 or channels > 2:
199-
raise ValueError("Number of channels must be 1 or 2")
200-
tile_size = int(opts.tile_size)
201-
if length % (tile_size * columns) != 0:
202-
print(
203-
"transfer size ("
204-
+ str(length)
205-
+ ") must be a multiple of "
206-
+ str(tile_size * columns)
207-
+ " (tile_size * columns)"
208-
)
209-
raise ValueError
210-
trace_size = int(opts.trace_size) if opts.trace_size is not None else 0
211-
212-
module = my_eltwise_add(dev, length, columns, channels, tile_size, trace_size)
213-
214-
output_file_path = Path(opts.output_file_path)
215-
216-
with open(output_file_path, "w") as f:
217-
f.write(str(module))

0 commit comments

Comments
 (0)