Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
calng
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
calibration
calng
Commits
beb32df5
Commit
beb32df5
authored
2 years ago
by
David Hammer
Browse files
Options
Downloads
Patches
Plain Diff
Fix reconfigure bug and prevent sources from being sorted
parent
a79b501a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!10
DetectorAssembler: assemble with extra shape (multiple frames)
,
!9
Stacking shmem matcher
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/calng/ShmemTrainMatcher.py
+48
-6
48 additions, 6 deletions
src/calng/ShmemTrainMatcher.py
with
48 additions
and
6 deletions
src/calng/ShmemTrainMatcher.py
+
48
−
6
View file @
beb32df5
...
...
@@ -13,6 +13,7 @@ from karabo.bound import (
Hash
,
Schema
,
State
,
VectorHash
,
)
from
TrainMatcher
import
TrainMatcher
...
...
@@ -106,8 +107,8 @@ class ShmemTrainMatcher(TrainMatcher.TrainMatcher):
"
While source stacking is optimized and can use thread pool, key
"
"
stacking will iterate over all paths in matched sources and naively
"
"
call np.stack for each key pattern. In either case, data that is used
"
"
for stacking is removed from its original location (e.g. key is
erased
"
"
from hash).
"
"
for stacking is removed from its original location (e.g. key is
"
"
erased
from hash).
"
)
.
setColumns
(
merge_schema
())
.
assignmentOptional
()
...
...
@@ -139,7 +140,8 @@ class ShmemTrainMatcher(TrainMatcher.TrainMatcher):
self
.
_source_stacking_indices
=
{}
self
.
_source_stacking_sources
=
{}
self
.
_key_stacking_sources
=
{}
self
.
_prepare_merge_groups
(
self
.
get
(
"
merge
"
))
self
.
_have_prepared_merge_groups
=
False
self
.
_prepare_merge_groups
()
super
().
initialization
()
self
.
_shmem_handler
=
shmem_utils
.
ShmemCircularBufferReceiver
()
if
self
.
get
(
"
useThreadPool
"
):
...
...
@@ -154,7 +156,8 @@ class ShmemTrainMatcher(TrainMatcher.TrainMatcher):
def
preReconfigure
(
self
,
conf
):
super
().
preReconfigure
(
conf
)
if
conf
.
has
(
"
merge
"
)
or
conf
.
has
(
"
sources
"
):
self
.
_prepare_merge_groups
(
conf
[
"
merge
"
])
self
.
_have_prepared_merge_groups
=
False
# re-prepare in postReconfigure after sources *and* merge are in self
if
conf
.
has
(
"
useThreadPool
"
):
if
self
.
_thread_pool
is
not
None
:
self
.
_thread_pool
.
shutdown
()
...
...
@@ -167,11 +170,16 @@ class ShmemTrainMatcher(TrainMatcher.TrainMatcher):
else
:
self
.
output
=
None
def
_prepare_merge_groups
(
self
,
merge
):
def
postReconfigure
(
self
):
super
().
postReconfigure
()
if
not
self
.
_have_prepared_merge_groups
:
self
.
_prepare_merge_groups
()
def
_prepare_merge_groups
(
self
):
source_group_patterns
=
[]
key_group_patterns
=
[]
# split by type, prepare regexes
for
row
in
merge
:
for
row
in
self
.
get
(
"
merge
"
)
:
if
not
row
[
"
select
"
]:
continue
group_type
=
MergeGroupType
(
row
[
"
type
"
])
...
...
@@ -225,6 +233,7 @@ class ShmemTrainMatcher(TrainMatcher.TrainMatcher):
self
.
_key_stacking_sources
.
setdefault
(
source
,
[]).
append
(
(
key_re
,
new_key
)
)
self
.
_have_prepared_merge_groups
=
True
def
_update_stacking_buffer
(
self
,
new_source
,
key
,
individual_shape
,
axis
,
dtype
):
# TODO: handle ValueError for max of empty sequence
...
...
@@ -334,3 +343,36 @@ class ShmemTrainMatcher(TrainMatcher.TrainMatcher):
self
.
info
[
"
sent
"
]
+=
1
self
.
info
[
"
trainId
"
]
=
train_id
self
.
rate_out
.
update
()
def
_maybe_connect_data
(
self
,
conf
,
update
=
False
,
state
=
None
):
"""
Temporary override on _maybe_connect_data to avoid sorting sources list (we
need it for stacking order)
"""
if
self
[
"
state
"
]
not
in
(
State
.
CHANGING
,
State
.
ACTIVE
):
return
last_state
=
self
[
"
state
"
]
self
.
updateState
(
State
.
CHANGING
)
# unwatch removed sources
def
src_names
(
c
):
# do not assign a lambda expression, use a def
return
{
s
[
"
source
"
]
for
s
in
c
[
"
sources
"
]}
for
source
in
src_names
(
self
).
difference
(
src_names
(
conf
)):
self
.
monitor
.
unwatch_source
(
source
)
new_conf
=
VectorHash
()
for
src
in
conf
[
"
sources
"
]:
source
=
src
[
"
source
"
]
if
src
[
"
select
"
]:
src
[
"
status
"
]
=
self
.
monitor
.
watch_source
(
source
,
src
[
"
offset
"
])
else
:
self
.
monitor
.
unwatch_source
(
source
)
src
[
"
status
"
]
=
""
new_conf
.
append
(
src
)
if
update
:
self
.
set
(
"
sources
"
,
new_conf
)
else
:
conf
[
"
sources
"
]
=
new_conf
self
.
updateState
(
state
or
last_state
)
This diff is collapsed.
Click to expand it.
David Hammer
@hammerd
mentioned in commit
9495dda8
·
2 years ago
mentioned in commit
9495dda8
mentioned in commit 9495dda895756fcd9a2ebb5f8adbaa050e067f33
Toggle commit list
David Hammer
@hammerd
mentioned in commit
99de26dd
·
2 years ago
mentioned in commit
99de26dd
mentioned in commit 99de26dda08d02c1c2b5efc1f1f462cfc4f0ce63
Toggle commit list
David Hammer
@hammerd
mentioned in commit
3566342d
·
2 years ago
mentioned in commit
3566342d
mentioned in commit 3566342d031db1bb435b6430f100afdbaaa6c4bf
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment