Skip to content
Open
Changes from all commits
Commits
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
22 changes: 6 additions & 16 deletions lake/utils/parse_clkwork_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import collections
from lake.utils.util import transform_strides_and_ranges


ControllerInfo = collections.namedtuple('ControllerInfo',
'dim extent cyc_stride in_data_stride cyc_strt \
Expand All @@ -8,21 +10,6 @@
verbose_controller_info = False


def transform_strides_and_ranges(ranges, strides, dimensionality):
assert len(ranges) == len(strides), "Strides and ranges should be same length..."
tform_ranges = [range_item - 2 for range_item in ranges[0:dimensionality]]
range_sub_1 = [range_item - 1 for range_item in ranges]
tform_strides = [strides[0]]
offset = 0
for i in range(dimensionality - 1):
offset -= (range_sub_1[i] * strides[i])
tform_strides.append(strides[i + 1] + offset)
for j in range(len(ranges) - dimensionality):
tform_strides.append(0)
tform_ranges.append(0)
return (tform_ranges, tform_strides)


def search_for_config(cfg_file, key):
lines = cfg_file
matches = [l for l in lines if key in l]
Expand Down Expand Up @@ -145,7 +132,10 @@ def map_controller(controller, name):
print()

# Now transforms ranges and strides
(tform_extent, tform_cyc_strides) = transform_strides_and_ranges(ctrl_ranges, ctrl_cyc_strides, ctrl_dim)
tform_cyc_strides = None
if ctrl_cyc_strt is not None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What happens if it is None?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If it's None, we don't call transform_strides_and_ranges on a controller that doesn't exist, which will throw some error. However, I don't remember what caused the need for this when we were testing with Joey before...I think the controller didn't exist for some reason, but that doesn't seem to make sense now...

(tform_extent, tform_cyc_strides) = transform_strides_and_ranges(ctrl_ranges, ctrl_cyc_strides, ctrl_dim)

tform_in_data_strides = None
if ctrl_in_data_strt is not None:
(tform_extent, tform_in_data_strides) = transform_strides_and_ranges(ctrl_ranges, ctrl_in_data_strides, ctrl_dim)
Expand Down