Skip to content
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

bugfix(modules): input buffer check #146

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions paibox/components/_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@
math.ceil(in_channels * in_h * kw / HwConfig.N_FANIN_PER_DENDRITE_ANN)
)
)

if not kw * valid_interval > HwConfig.N_TIMESLOT_MAX / (2**E):
deep = min(in_h - kw, kw - 1) * valid_interval + 1
if not HwConfig.N_TIMESLOT_MAX / (2**E) > deep:

Check warning on line 216 in paibox/components/_modules.py

View check run for this annotation

Codecov / codecov/patch

paibox/components/_modules.py#L215-L216

Added lines #L215 - L216 were not covered by tests
raise ResourceError(
f"the input size of {self.name} is too large. Please adjust the input size or the number of channels."
)
Expand Down
14 changes: 8 additions & 6 deletions paibox/components/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,12 @@
) -> BuiltComponentType:
assert len(self.source[0].shape_out) == 2
self.ostream_attr = incoming_stream_attr
twe = 1 + self.ostream_attr.t_last_vld

ich, ih = self.source[0].shape_out

if build_options.get("check_before_compile"):
self._input_buffer_len_check(ich, ih, ih, incoming_stream_attr.interval)

Check warning on line 918 in paibox/components/functional.py

View check run for this annotation

Codecov / codecov/patch

paibox/components/functional.py#L918

Added line #L918 was not covered by tests
n_delays = NodeList()
s_delays = NodeList()
s_weight = NodeList()
Expand All @@ -932,7 +936,7 @@
shape=(ich, ih),
delay=incoming_stream_attr.interval * i + 1,
tick_wait_start=self.tick_wait_start,
tick_wait_end=self.tick_wait_end,
tick_wait_end=twe - incoming_stream_attr.interval * i,
keep_shape=self.keep_shape,
name=f"n{i}_{self.name}",
)
Expand Down Expand Up @@ -1049,7 +1053,6 @@
ow,
)
twe = 1 + self.ostream_attr.t_last_vld

if build_options.get("check_before_compile"):
self._input_buffer_len_check(cin, ih, kw, incoming_stream_attr.interval)

Expand All @@ -1069,13 +1072,12 @@
keep_shape=self.keep_shape,
name=f"nd_{self.name}",
)

for i in range(kw):
neuron = ANNBypassNeuron(
(cin, ih),
delay=incoming_stream_attr.interval * i + 1,
tick_wait_start=self.tick_wait_start,
tick_wait_end=twe,
tick_wait_end=twe - incoming_stream_attr.interval * i,
name=f"n{i}_delay_{self.name}",
)
n_delays.append(neuron)
Expand Down Expand Up @@ -1235,7 +1237,7 @@
(cin, ih),
delay=incoming_stream_attr.interval * i + 1,
tick_wait_start=self.tick_wait_start,
tick_wait_end=twe,
tick_wait_end=twe - incoming_stream_attr.interval * i,
keep_shape=self.keep_shape,
name=f"n{i}_{self.name}",
)
Expand Down Expand Up @@ -1367,7 +1369,7 @@
(cin, ih),
delay=incoming_stream_attr.interval * i + 1,
tick_wait_start=self.tick_wait_start,
tick_wait_end=twe,
tick_wait_end=twe - incoming_stream_attr.interval * i,
keep_shape=self.keep_shape,
name=f"n{i}_{self.name}",
)
Expand Down
Loading