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
gaoqiong
MIGraphX
Commits
5856e5d0
Commit
5856e5d0
authored
Apr 17, 2019
by
Shucai Xiao
Browse files
Merge branch 'adjust_gpu_allocation' into ins_fp32_fp16
parents
adcd9f39
7c3b9d48
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
11 deletions
+25
-11
src/include/migraphx/op/unary.hpp
src/include/migraphx/op/unary.hpp
+1
-1
src/targets/cpu/lowering.cpp
src/targets/cpu/lowering.cpp
+21
-3
src/targets/gpu/adjust_allocation.cpp
src/targets/gpu/adjust_allocation.cpp
+1
-5
src/targets/gpu/include/migraphx/gpu/oper.hpp
src/targets/gpu/include/migraphx/gpu/oper.hpp
+2
-2
No files found.
src/include/migraphx/op/unary.hpp
View file @
5856e5d0
...
...
@@ -21,7 +21,7 @@ struct unary
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
check_shapes
{
inputs
}.
has
(
1
);
return
inputs
.
at
(
0
);
return
{
inputs
.
at
(
0
)
.
type
(),
inputs
.
at
(
0
).
lens
()}
;
}
};
...
...
src/targets/cpu/lowering.cpp
View file @
5856e5d0
...
...
@@ -593,15 +593,29 @@ struct cpu_unary
{
Op
op
;
std
::
string
name
()
const
{
return
op
.
name
();
}
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
return
inputs
.
front
();
}
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
return
{
inputs
.
front
().
type
(),
inputs
.
front
().
lens
()};
}
argument
compute
(
context
&
,
const
shape
&
output_shape
,
std
::
vector
<
argument
>
args
)
const
{
argument
result
{
output_shape
};
result
.
visit
([
&
](
auto
output
)
{
args
[
0
].
visit
([
&
](
auto
input
)
{
std
::
transform
(
input
.
begin
(),
input
.
end
(),
output
.
begin
(),
op
.
fcn
());
if
(
input
.
get_shape
().
packed
())
{
std
::
transform
(
input
.
begin
(),
input
.
end
(),
output
.
begin
(),
op
.
fcn
());
}
else
{
shape_for_each
(
output
.
get_shape
(),
[
&
](
const
auto
&
idx
)
{
output
(
idx
.
begin
(),
idx
.
end
())
=
op
.
fcn
()(
input
(
idx
.
begin
(),
idx
.
end
()));
});
}
});
});
return
result
;
}
};
...
...
@@ -784,7 +798,11 @@ struct cpu_binary
{
Op
op
;
std
::
string
name
()
const
{
return
op
.
name
();
}
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
return
inputs
.
front
();
}
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
// operator will generate standard output shape
return
{
inputs
.
front
().
type
(),
inputs
.
front
().
lens
()};
}
argument
compute
(
context
&
,
const
shape
&
output_shape
,
std
::
vector
<
argument
>
args
)
const
{
argument
result
{
output_shape
};
...
...
src/targets/gpu/adjust_allocation.cpp
View file @
5856e5d0
...
...
@@ -9,14 +9,10 @@ namespace gpu {
void
adjust_allocation
::
apply
(
program
&
p
)
const
{
std
::
vector
<
std
::
string
>
ins_names
=
{
"gpu::fp_conversion"
};
for
(
auto
ins
:
iterator_for
(
p
))
{
// skip instructions not in the set
if
(
std
::
find
(
ins_names
.
begin
(),
ins_names
.
end
(),
ins
->
name
())
==
ins_names
.
end
())
{
if
(
ins
->
name
()
==
"load"
)
continue
;
}
auto
alias_ins
=
instruction
::
get_output_alias
(
ins
,
true
);
if
(
alias_ins
->
name
()
==
"hip::allocate"
)
...
...
src/targets/gpu/include/migraphx/gpu/oper.hpp
View file @
5856e5d0
...
...
@@ -45,7 +45,7 @@ struct unary_device : oper<Derived>
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
check_shapes
{
inputs
,
*
this
}.
has
(
2
);
return
inputs
.
at
(
0
);
return
{
inputs
.
at
(
0
)
.
type
(),
inputs
.
at
(
0
).
lens
()}
;
}
argument
compute
(
context
&
ctx
,
const
shape
&
,
const
std
::
vector
<
argument
>&
args
)
const
...
...
@@ -63,7 +63,7 @@ struct binary_device : oper<Derived>
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
check_shapes
{
inputs
,
*
this
}.
has
(
3
);
return
inputs
.
at
(
0
);
return
{
inputs
.
at
(
0
)
.
type
(),
inputs
.
at
(
0
).
lens
()}
;
}
argument
compute
(
context
&
ctx
,
const
shape
&
,
const
std
::
vector
<
argument
>&
args
)
const
...
...
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