Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
SparseConvNet
Commits
1171aae3
Commit
1171aae3
authored
Jun 28, 2019
by
Michal Pandy
Browse files
Replace map find and inserts with just inserts
parent
711076a2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
32 deletions
+28
-32
sparseconvnet/SCN/Metadata/ConvolutionRules.h
sparseconvnet/SCN/Metadata/ConvolutionRules.h
+6
-5
sparseconvnet/SCN/Metadata/FullConvolutionRules.h
sparseconvnet/SCN/Metadata/FullConvolutionRules.h
+6
-5
sparseconvnet/SCN/Metadata/IOLayersRules.h
sparseconvnet/SCN/Metadata/IOLayersRules.h
+11
-18
sparseconvnet/SCN/Metadata/Metadata.cpp
sparseconvnet/SCN/Metadata/Metadata.cpp
+5
-4
No files found.
sparseconvnet/SCN/Metadata/ConvolutionRules.h
View file @
1171aae3
...
...
@@ -22,13 +22,14 @@ void Convolution_InputSgToRulesAndOutputSg(SparseGrid<dimension> &inputGrid,
for
(
auto
j
:
outRegion
)
{
auto
inRegion
=
InputRegionCalculator
<
dimension
>
(
j
,
size
,
stride
);
Int
rulesOffset
=
inRegion
.
offset
(
inIter
.
first
);
auto
outIter
=
outputGrid
.
mp
.
f
in
d
(
j
);
if
(
outIter
==
outputGrid
.
mp
.
end
())
{
outIter
=
outputGrid
.
mp
.
insert
(
std
::
make_pair
(
j
,
outputGrid
.
ctr
++
)).
first
;
auto
mapVal
=
outputGrid
.
mp
.
in
sert
(
std
::
make_pair
(
j
,
0
)
);
if
(
mapVal
.
second
)
{
mapVal
.
first
->
second
=
outputGrid
.
ctr
++
;
}
rules
[
rulesOffset
].
push_back
(
inIter
.
second
+
inputGrid
.
ctr
);
rules
[
rulesOffset
].
push_back
(
outIter
->
second
);
rules
[
rulesOffset
].
push_back
(
mapVal
.
first
->
second
);
}
}
}
...
...
sparseconvnet/SCN/Metadata/FullConvolutionRules.h
View file @
1171aae3
...
...
@@ -21,13 +21,14 @@ void FullConvolution_InputSgToRulesAndOutputSg(
InputRegionCalculator
<
dimension
>
(
inIter
.
first
,
size
,
stride
);
for
(
auto
j
:
outRegion
)
{
Int
rulesOffset
=
outRegion
.
offset
(
j
);
auto
outIter
=
outputGrid
.
mp
.
f
in
d
(
j
);
if
(
outIter
==
outputGrid
.
mp
.
end
())
{
outIter
=
outputGrid
.
mp
.
insert
(
std
::
make_pair
(
j
,
outputGrid
.
ctr
++
)).
first
;
auto
mapVal
=
outputGrid
.
mp
.
in
sert
(
std
::
make_pair
(
j
,
0
)
);
if
(
mapVal
.
second
)
{
mapVal
.
first
->
second
=
outputGrid
.
ctr
++
;
}
rules
[
rulesOffset
].
push_back
(
inIter
.
second
+
inputGrid
.
ctr
);
rules
[
rulesOffset
].
push_back
(
outIter
->
second
);
rules
[
rulesOffset
].
push_back
(
mapVal
.
first
->
second
);
}
}
}
...
...
sparseconvnet/SCN/Metadata/IOLayersRules.h
View file @
1171aae3
...
...
@@ -66,10 +66,8 @@ void inputLayerRules(SparseGrids<dimension> &SGs, RuleBook &rules, long *coords,
for
(
Int
j
=
0
;
j
<
dimension
;
j
++
)
p
[
j
]
=
coords
[
j
];
coords
+=
dimension
;
auto
iter
=
sg
.
mp
.
find
(
p
);
if
(
iter
==
sg
.
mp
.
end
())
{
sg
.
mp
[
p
]
=
nActive
++
;
outputRows
.
resize
(
nActive
);
if
(
sg
.
mp
.
insert
(
make_pair
(
p
,
nActive
)).
second
)
{
outputRows
.
resize
(
++
nActive
);
}
outputRows
[
sg
.
mp
[
p
]].
push_back
(
i
);
}
...
...
@@ -83,11 +81,9 @@ void inputLayerRules(SparseGrids<dimension> &SGs, RuleBook &rules, long *coords,
if
(
idx
+
1
>=
(
Int
)
SGs
.
size
())
SGs
.
resize
(
idx
+
1
);
auto
&
sg
=
SGs
[
idx
];
auto
iter
=
sg
.
mp
.
find
(
p
);
if
(
iter
==
sg
.
mp
.
end
())
{
sg
.
mp
[
p
]
=
nActive
++
;
outputRows
.
resize
(
nActive
);
}
if
(
sg
.
mp
.
insert
(
make_pair
(
p
,
nActive
)).
second
)
{
outputRows
.
resize
(
++
nActive
);
}
outputRows
[
sg
.
mp
[
p
]].
push_back
(
i
);
}
}
...
...
@@ -186,9 +182,8 @@ void blRules(SparseGrids<dimension> &SGs, RuleBook &rules, long *coords,
for
(
Int
j
=
0
;
j
<
dimension
;
++
j
)
p
[
j
]
=
*
c
++
;
if
(
p
[
0
]
>=
0
)
{
auto
iter
=
sg
.
mp
.
find
(
p
);
if
(
iter
==
sg
.
mp
.
end
())
{
sg
.
mp
[
p
]
=
nAct
++
;
if
(
sg
.
mp
.
insert
(
make_pair
(
p
,
nAct
)).
second
)
{
nAct
++
;
ors
.
push_back
(
i
);
}
else
{
ors
[
sg
.
mp
[
p
]]
=
i
;
...
...
@@ -201,9 +196,8 @@ void blRules(SparseGrids<dimension> &SGs, RuleBook &rules, long *coords,
for
(
Int
j
=
0
;
j
<
dimension
;
++
j
)
p
[
j
]
=
*
c
++
;
if
(
p
[
0
]
>=
0
)
{
auto
iter
=
sg
.
mp
.
find
(
p
);
if
(
iter
==
sg
.
mp
.
end
())
{
sg
.
mp
[
p
]
=
nAct
++
;
if
(
sg
.
mp
.
insert
(
make_pair
(
p
,
nAct
)).
second
)
{
nAct
++
;
ors
.
push_back
(
i
);
}
}
...
...
@@ -254,9 +248,8 @@ void blRules(SparseGrids<dimension> &SGs, RuleBook &rules, long *coords,
for
(
Int
j
=
0
;
j
<
dimension
;
++
j
)
p
[
j
]
=
*
c
++
;
if
(
p
[
0
]
>=
0
)
{
auto
iter
=
sg
.
mp
.
find
(
p
);
if
(
iter
==
sg
.
mp
.
end
())
{
sg
.
mp
[
p
]
=
nAct
++
;
if
(
sg
.
mp
.
insert
(
make_pair
(
p
,
nAct
)).
second
)
{
nAct
++
;
ors
.
resize
(
nAct
);
}
ors
[
sg
.
mp
[
p
]].
push_back
(
i
);
...
...
sparseconvnet/SCN/Metadata/Metadata.cpp
View file @
1171aae3
...
...
@@ -32,14 +32,15 @@ void addPointToSparseGridMapAndFeatures(SparseGridMap<dimension> &mp,
long
nPlanes
,
/*float*/
at
::
Tensor
features
,
float
*
vec
,
bool
overwrite
)
{
auto
iter
=
mp
.
find
(
p
);
if
(
iter
==
mp
.
end
())
{
iter
=
mp
.
insert
(
std
::
make_pair
(
p
,
nActive
++
)).
first
;
auto
mapVal
=
mp
.
insert
(
std
::
make_pair
(
p
,
nActive
));
if
(
mapVal
.
second
)
{
nActive
++
;
features
.
resize_
({(
int
)
nActive
,
nPlanes
});
std
::
memcpy
(
features
.
data
<
float
>
()
+
(
nActive
-
1
)
*
nPlanes
,
vec
,
sizeof
(
float
)
*
nPlanes
);
}
else
if
(
overwrite
)
{
std
::
memcpy
(
features
.
data
<
float
>
()
+
iter
->
second
*
nPlanes
,
vec
,
std
::
memcpy
(
features
.
data
<
float
>
()
+
mapVal
.
first
->
second
*
nPlanes
,
vec
,
sizeof
(
float
)
*
nPlanes
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment