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,
...
@@ -22,13 +22,14 @@ void Convolution_InputSgToRulesAndOutputSg(SparseGrid<dimension> &inputGrid,
for
(
auto
j
:
outRegion
)
{
for
(
auto
j
:
outRegion
)
{
auto
inRegion
=
InputRegionCalculator
<
dimension
>
(
j
,
size
,
stride
);
auto
inRegion
=
InputRegionCalculator
<
dimension
>
(
j
,
size
,
stride
);
Int
rulesOffset
=
inRegion
.
offset
(
inIter
.
first
);
Int
rulesOffset
=
inRegion
.
offset
(
inIter
.
first
);
auto
outIter
=
outputGrid
.
mp
.
f
in
d
(
j
);
auto
mapVal
=
outputGrid
.
mp
.
in
sert
(
std
::
make_pair
(
j
,
0
)
);
if
(
outIter
==
outputGrid
.
mp
.
end
())
{
outIter
=
if
(
mapVal
.
second
)
{
outputGrid
.
mp
.
insert
(
std
::
make_pair
(
j
,
outputGrid
.
ctr
++
)).
first
;
mapVal
.
first
->
second
=
outputGrid
.
ctr
++
;
}
}
rules
[
rulesOffset
].
push_back
(
inIter
.
second
+
inputGrid
.
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(
...
@@ -21,13 +21,14 @@ void FullConvolution_InputSgToRulesAndOutputSg(
InputRegionCalculator
<
dimension
>
(
inIter
.
first
,
size
,
stride
);
InputRegionCalculator
<
dimension
>
(
inIter
.
first
,
size
,
stride
);
for
(
auto
j
:
outRegion
)
{
for
(
auto
j
:
outRegion
)
{
Int
rulesOffset
=
outRegion
.
offset
(
j
);
Int
rulesOffset
=
outRegion
.
offset
(
j
);
auto
outIter
=
outputGrid
.
mp
.
f
in
d
(
j
);
auto
mapVal
=
outputGrid
.
mp
.
in
sert
(
std
::
make_pair
(
j
,
0
)
);
if
(
outIter
==
outputGrid
.
mp
.
end
())
{
outIter
=
if
(
mapVal
.
second
)
{
outputGrid
.
mp
.
insert
(
std
::
make_pair
(
j
,
outputGrid
.
ctr
++
)).
first
;
mapVal
.
first
->
second
=
outputGrid
.
ctr
++
;
}
}
rules
[
rulesOffset
].
push_back
(
inIter
.
second
+
inputGrid
.
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,
...
@@ -66,10 +66,8 @@ void inputLayerRules(SparseGrids<dimension> &SGs, RuleBook &rules, long *coords,
for
(
Int
j
=
0
;
j
<
dimension
;
j
++
)
for
(
Int
j
=
0
;
j
<
dimension
;
j
++
)
p
[
j
]
=
coords
[
j
];
p
[
j
]
=
coords
[
j
];
coords
+=
dimension
;
coords
+=
dimension
;
auto
iter
=
sg
.
mp
.
find
(
p
);
if
(
sg
.
mp
.
insert
(
make_pair
(
p
,
nActive
)).
second
)
{
if
(
iter
==
sg
.
mp
.
end
())
{
outputRows
.
resize
(
++
nActive
);
sg
.
mp
[
p
]
=
nActive
++
;
outputRows
.
resize
(
nActive
);
}
}
outputRows
[
sg
.
mp
[
p
]].
push_back
(
i
);
outputRows
[
sg
.
mp
[
p
]].
push_back
(
i
);
}
}
...
@@ -83,11 +81,9 @@ void inputLayerRules(SparseGrids<dimension> &SGs, RuleBook &rules, long *coords,
...
@@ -83,11 +81,9 @@ void inputLayerRules(SparseGrids<dimension> &SGs, RuleBook &rules, long *coords,
if
(
idx
+
1
>=
(
Int
)
SGs
.
size
())
if
(
idx
+
1
>=
(
Int
)
SGs
.
size
())
SGs
.
resize
(
idx
+
1
);
SGs
.
resize
(
idx
+
1
);
auto
&
sg
=
SGs
[
idx
];
auto
&
sg
=
SGs
[
idx
];
auto
iter
=
sg
.
mp
.
find
(
p
);
if
(
sg
.
mp
.
insert
(
make_pair
(
p
,
nActive
)).
second
)
{
if
(
iter
==
sg
.
mp
.
end
())
{
outputRows
.
resize
(
++
nActive
);
sg
.
mp
[
p
]
=
nActive
++
;
}
outputRows
.
resize
(
nActive
);
}
outputRows
[
sg
.
mp
[
p
]].
push_back
(
i
);
outputRows
[
sg
.
mp
[
p
]].
push_back
(
i
);
}
}
}
}
...
@@ -186,9 +182,8 @@ void blRules(SparseGrids<dimension> &SGs, RuleBook &rules, long *coords,
...
@@ -186,9 +182,8 @@ void blRules(SparseGrids<dimension> &SGs, RuleBook &rules, long *coords,
for
(
Int
j
=
0
;
j
<
dimension
;
++
j
)
for
(
Int
j
=
0
;
j
<
dimension
;
++
j
)
p
[
j
]
=
*
c
++
;
p
[
j
]
=
*
c
++
;
if
(
p
[
0
]
>=
0
)
{
if
(
p
[
0
]
>=
0
)
{
auto
iter
=
sg
.
mp
.
find
(
p
);
if
(
sg
.
mp
.
insert
(
make_pair
(
p
,
nAct
)).
second
)
{
if
(
iter
==
sg
.
mp
.
end
())
{
nAct
++
;
sg
.
mp
[
p
]
=
nAct
++
;
ors
.
push_back
(
i
);
ors
.
push_back
(
i
);
}
else
{
}
else
{
ors
[
sg
.
mp
[
p
]]
=
i
;
ors
[
sg
.
mp
[
p
]]
=
i
;
...
@@ -201,9 +196,8 @@ void blRules(SparseGrids<dimension> &SGs, RuleBook &rules, long *coords,
...
@@ -201,9 +196,8 @@ void blRules(SparseGrids<dimension> &SGs, RuleBook &rules, long *coords,
for
(
Int
j
=
0
;
j
<
dimension
;
++
j
)
for
(
Int
j
=
0
;
j
<
dimension
;
++
j
)
p
[
j
]
=
*
c
++
;
p
[
j
]
=
*
c
++
;
if
(
p
[
0
]
>=
0
)
{
if
(
p
[
0
]
>=
0
)
{
auto
iter
=
sg
.
mp
.
find
(
p
);
if
(
sg
.
mp
.
insert
(
make_pair
(
p
,
nAct
)).
second
)
{
if
(
iter
==
sg
.
mp
.
end
())
{
nAct
++
;
sg
.
mp
[
p
]
=
nAct
++
;
ors
.
push_back
(
i
);
ors
.
push_back
(
i
);
}
}
}
}
...
@@ -254,9 +248,8 @@ void blRules(SparseGrids<dimension> &SGs, RuleBook &rules, long *coords,
...
@@ -254,9 +248,8 @@ void blRules(SparseGrids<dimension> &SGs, RuleBook &rules, long *coords,
for
(
Int
j
=
0
;
j
<
dimension
;
++
j
)
for
(
Int
j
=
0
;
j
<
dimension
;
++
j
)
p
[
j
]
=
*
c
++
;
p
[
j
]
=
*
c
++
;
if
(
p
[
0
]
>=
0
)
{
if
(
p
[
0
]
>=
0
)
{
auto
iter
=
sg
.
mp
.
find
(
p
);
if
(
sg
.
mp
.
insert
(
make_pair
(
p
,
nAct
)).
second
)
{
if
(
iter
==
sg
.
mp
.
end
())
{
nAct
++
;
sg
.
mp
[
p
]
=
nAct
++
;
ors
.
resize
(
nAct
);
ors
.
resize
(
nAct
);
}
}
ors
[
sg
.
mp
[
p
]].
push_back
(
i
);
ors
[
sg
.
mp
[
p
]].
push_back
(
i
);
...
...
sparseconvnet/SCN/Metadata/Metadata.cpp
View file @
1171aae3
...
@@ -32,14 +32,15 @@ void addPointToSparseGridMapAndFeatures(SparseGridMap<dimension> &mp,
...
@@ -32,14 +32,15 @@ void addPointToSparseGridMapAndFeatures(SparseGridMap<dimension> &mp,
long
nPlanes
,
long
nPlanes
,
/*float*/
at
::
Tensor
features
,
/*float*/
at
::
Tensor
features
,
float
*
vec
,
bool
overwrite
)
{
float
*
vec
,
bool
overwrite
)
{
auto
iter
=
mp
.
find
(
p
);
if
(
iter
==
mp
.
end
())
{
auto
mapVal
=
mp
.
insert
(
std
::
make_pair
(
p
,
nActive
));
iter
=
mp
.
insert
(
std
::
make_pair
(
p
,
nActive
++
)).
first
;
if
(
mapVal
.
second
)
{
nActive
++
;
features
.
resize_
({(
int
)
nActive
,
nPlanes
});
features
.
resize_
({(
int
)
nActive
,
nPlanes
});
std
::
memcpy
(
features
.
data
<
float
>
()
+
(
nActive
-
1
)
*
nPlanes
,
vec
,
std
::
memcpy
(
features
.
data
<
float
>
()
+
(
nActive
-
1
)
*
nPlanes
,
vec
,
sizeof
(
float
)
*
nPlanes
);
sizeof
(
float
)
*
nPlanes
);
}
else
if
(
overwrite
)
{
}
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
);
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