Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
01543cc4
Commit
01543cc4
authored
May 03, 2019
by
Paul
Browse files
Fix dangling reference
parent
0666f839
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
7 deletions
+44
-7
src/include/migraphx/operation.hpp
src/include/migraphx/operation.hpp
+1
-1
src/include/migraphx/reflect.hpp
src/include/migraphx/reflect.hpp
+38
-3
src/targets/gpu/include/migraphx/gpu/miopen.hpp
src/targets/gpu/include/migraphx/gpu/miopen.hpp
+4
-2
tools/include/operation.hpp
tools/include/operation.hpp
+1
-1
No files found.
src/include/migraphx/operation.hpp
View file @
01543cc4
...
@@ -69,7 +69,7 @@ auto operator<<(std::ostream& os, const T& x) -> decltype(os << x.name())
...
@@ -69,7 +69,7 @@ auto operator<<(std::ostream& os, const T& x) -> decltype(os << x.name())
{
{
os
<<
x
.
name
();
os
<<
x
.
name
();
char
delim
=
'['
;
char
delim
=
'['
;
reflect_each
(
x
,
[
&
](
auto
&
y
,
auto
name
)
{
reflect_each
(
x
,
[
&
](
auto
&
&
y
,
auto
name
)
{
os
<<
delim
;
os
<<
delim
;
os
<<
name
<<
"="
;
os
<<
name
<<
"="
;
stream_write_value
(
os
,
y
);
stream_write_value
(
os
,
y
);
...
...
src/include/migraphx/reflect.hpp
View file @
01543cc4
...
@@ -39,6 +39,41 @@ auto reflectable_impl(rank<1>, T&& x)
...
@@ -39,6 +39,41 @@ auto reflectable_impl(rank<1>, T&& x)
template
<
class
T
>
template
<
class
T
>
auto
reflectable_impl
(
rank
<
0
>
,
T
&&
)
->
decltype
(
std
::
false_type
{});
auto
reflectable_impl
(
rank
<
0
>
,
T
&&
)
->
decltype
(
std
::
false_type
{});
template
<
class
T
>
struct
remove_rvalue_reference
{
using
type
=
T
;
};
template
<
class
T
>
struct
remove_rvalue_reference
<
T
&&>
{
using
type
=
T
;
};
template
<
class
T
>
struct
wrapper
{
using
type
=
typename
remove_rvalue_reference
<
T
>::
type
;
type
data
;
type
get
()
const
{
return
data
;
}
};
template
<
class
T
>
wrapper
<
T
>
wrap
(
std
::
remove_reference_t
<
T
>&
x
)
{
return
wrapper
<
T
>
{
std
::
forward
<
T
>
(
x
)};
}
template
<
class
...
Ts
>
std
::
tuple
<
typename
remove_rvalue_reference
<
Ts
>::
type
...
>
auto_tuple
(
Ts
&&
...
xs
)
{
return
{
std
::
forward
<
Ts
>
(
xs
)...};
}
}
// namespace detail
}
// namespace detail
template
<
class
T
>
template
<
class
T
>
...
@@ -53,14 +88,14 @@ auto reflect(T& x, Selector f)
...
@@ -53,14 +88,14 @@ auto reflect(T& x, Selector f)
template
<
class
T
>
template
<
class
T
>
auto
reflect_tie
(
T
&
x
)
auto
reflect_tie
(
T
&
x
)
{
{
return
reflect
(
x
,
[](
auto
&&
y
,
auto
&&
...)
{
return
std
::
ref
(
y
);
})(
return
reflect
(
x
,
[](
auto
&&
y
,
auto
&&
...)
{
return
detail
::
wrap
<
decltype
(
y
)
>
(
y
);
})(
[](
auto
&&
...
xs
)
{
return
std
::
ti
e
(
xs
.
get
()...);
});
[](
auto
&&
...
xs
)
{
return
detail
::
auto_tupl
e
(
xs
.
get
()...);
});
}
}
template
<
class
T
,
class
F
>
template
<
class
T
,
class
F
>
void
reflect_each
(
T
&
x
,
F
f
)
void
reflect_each
(
T
&
x
,
F
f
)
{
{
return
reflect
(
x
,
[](
auto
&&
y
,
auto
...
ys
)
{
return
pack
(
std
::
ref
(
y
),
ys
...);
})(
return
reflect
(
x
,
[](
auto
&&
y
,
auto
...
ys
)
{
return
pack
(
detail
::
wrap
<
decltype
(
y
)
>
(
y
),
ys
...);
})(
[
&
](
auto
&&
...
xs
)
{
[
&
](
auto
&&
...
xs
)
{
each_args
([
&
](
auto
p
)
{
p
([
&
](
auto
&&
y
,
auto
...
ys
)
{
f
(
y
.
get
(),
ys
...);
});
},
xs
...);
each_args
([
&
](
auto
p
)
{
p
([
&
](
auto
&&
y
,
auto
...
ys
)
{
f
(
y
.
get
(),
ys
...);
});
},
xs
...);
});
});
...
...
src/targets/gpu/include/migraphx/gpu/miopen.hpp
View file @
01543cc4
...
@@ -165,24 +165,26 @@ inline fused_operator_args make_fused_args()
...
@@ -165,24 +165,26 @@ inline fused_operator_args make_fused_args()
template
<
class
F
>
template
<
class
F
>
auto
reflect
(
miopenActivationDescriptor_t
ad
,
F
f
)
auto
reflect
(
miopenActivationDescriptor_t
ad
,
F
f
)
{
{
assert
(
ad
!=
nullptr
);
miopenActivationMode_t
mode
=
miopenActivationPASTHRU
;
miopenActivationMode_t
mode
=
miopenActivationPASTHRU
;
double
alpha
=
0.0
;
double
alpha
=
0.0
;
double
beta
=
0.0
;
double
beta
=
0.0
;
double
gamma
=
0.0
;
double
gamma
=
0.0
;
miopenGetActivationDescriptor
(
ad
,
&
mode
,
&
alpha
,
&
beta
,
&
gamma
);
miopenGetActivationDescriptor
(
ad
,
&
mode
,
&
alpha
,
&
beta
,
&
gamma
);
return
pack
(
f
(
mode
,
"mode"
),
f
(
alpha
,
"alpha"
),
f
(
beta
,
"beta"
),
f
(
gamma
,
"gamma"
));
return
pack
(
f
(
std
::
move
(
mode
)
,
"mode"
),
f
(
std
::
move
(
alpha
)
,
"alpha"
),
f
(
std
::
move
(
beta
)
,
"beta"
),
f
(
std
::
move
(
gamma
)
,
"gamma"
));
}
}
template
<
class
F
>
template
<
class
F
>
auto
reflect
(
miopenLRNDescriptor_t
lrnd
,
F
f
)
auto
reflect
(
miopenLRNDescriptor_t
lrnd
,
F
f
)
{
{
assert
(
lrnd
!=
nullptr
);
miopenLRNMode_t
mode
=
miopenLRNWithinChannel
;
miopenLRNMode_t
mode
=
miopenLRNWithinChannel
;
unsigned
int
n
=
0
;
unsigned
int
n
=
0
;
double
alpha
=
0.0
;
double
alpha
=
0.0
;
double
beta
=
0.0
;
double
beta
=
0.0
;
double
k
=
0.0
;
double
k
=
0.0
;
miopenGetLRNDescriptor
(
lrnd
,
&
mode
,
&
n
,
&
alpha
,
&
beta
,
&
k
);
miopenGetLRNDescriptor
(
lrnd
,
&
mode
,
&
n
,
&
alpha
,
&
beta
,
&
k
);
return
pack
(
f
(
mode
,
"mode"
),
f
(
n
,
"n"
),
f
(
alpha
,
"alpha"
),
f
(
beta
,
"beta"
),
f
(
k
,
"k"
));
return
pack
(
f
(
std
::
move
(
mode
)
,
"mode"
),
f
(
std
::
move
(
n
),
"n"
),
f
(
std
::
move
(
alpha
)
,
"alpha"
),
f
(
std
::
move
(
beta
)
,
"beta"
),
f
(
std
::
move
(
k
)
,
"k"
));
}
}
}
// namespace gpu
}
// namespace gpu
...
...
tools/include/operation.hpp
View file @
01543cc4
...
@@ -69,7 +69,7 @@ auto operator<<(std::ostream& os, const T& x) -> decltype(os << x.name())
...
@@ -69,7 +69,7 @@ auto operator<<(std::ostream& os, const T& x) -> decltype(os << x.name())
{
{
os
<<
x
.
name
();
os
<<
x
.
name
();
char
delim
=
'['
;
char
delim
=
'['
;
reflect_each
(
x
,
[
&
](
auto
&
y
,
auto
name
)
{
reflect_each
(
x
,
[
&
](
auto
&
&
y
,
auto
name
)
{
os
<<
delim
;
os
<<
delim
;
os
<<
name
<<
"="
;
os
<<
name
<<
"="
;
stream_write_value
(
os
,
y
);
stream_write_value
(
os
,
y
);
...
...
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