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
f15477f7
Commit
f15477f7
authored
Apr 17, 2019
by
Shucai Xiao
Browse files
fix potential bugs in current code.
parent
08818a51
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
11 deletions
+26
-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
+22
-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 @
f15477f7
...
@@ -21,7 +21,7 @@ struct unary
...
@@ -21,7 +21,7 @@ struct unary
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
check_shapes
{
inputs
}.
has
(
1
);
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 @
f15477f7
...
@@ -593,15 +593,30 @@ struct cpu_unary
...
@@ -593,15 +593,30 @@ struct cpu_unary
{
{
Op
op
;
Op
op
;
std
::
string
name
()
const
{
return
op
.
name
();
}
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
compute
(
context
&
,
const
shape
&
output_shape
,
std
::
vector
<
argument
>
args
)
const
{
{
argument
result
{
output_shape
};
argument
result
{
output_shape
};
result
.
visit
([
&
](
auto
output
)
{
result
.
visit
([
&
](
auto
output
)
{
args
[
0
].
visit
([
&
](
auto
input
)
{
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
;
return
result
;
}
}
};
};
...
@@ -772,7 +787,11 @@ struct cpu_binary
...
@@ -772,7 +787,11 @@ struct cpu_binary
{
{
Op
op
;
Op
op
;
std
::
string
name
()
const
{
return
op
.
name
();
}
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
compute
(
context
&
,
const
shape
&
output_shape
,
std
::
vector
<
argument
>
args
)
const
{
{
argument
result
{
output_shape
};
argument
result
{
output_shape
};
...
...
src/targets/gpu/adjust_allocation.cpp
View file @
f15477f7
...
@@ -10,14 +10,10 @@ namespace gpu {
...
@@ -10,14 +10,10 @@ namespace gpu {
void
adjust_allocation
::
apply
(
program
&
p
)
const
void
adjust_allocation
::
apply
(
program
&
p
)
const
{
{
std
::
vector
<
std
::
string
>
ins_names
=
{
"gpu::fp_conversion"
};
for
(
auto
ins
:
iterator_for
(
p
))
for
(
auto
ins
:
iterator_for
(
p
))
{
{
// skip instructions not in the set
if
(
ins
->
name
()
==
"load"
)
if
(
std
::
find
(
ins_names
.
begin
(),
ins_names
.
end
(),
ins
->
name
())
==
ins_names
.
end
())
{
continue
;
continue
;
}
auto
alias_ins
=
instruction
::
get_output_alias
(
ins
,
true
);
auto
alias_ins
=
instruction
::
get_output_alias
(
ins
,
true
);
if
(
alias_ins
->
name
()
==
"hip::allocate"
)
if
(
alias_ins
->
name
()
==
"hip::allocate"
)
...
...
src/targets/gpu/include/migraphx/gpu/oper.hpp
View file @
f15477f7
...
@@ -45,7 +45,7 @@ struct unary_device : oper<Derived>
...
@@ -45,7 +45,7 @@ struct unary_device : oper<Derived>
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
{
check_shapes
{
inputs
,
*
this
}.
has
(
2
);
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
argument
compute
(
context
&
ctx
,
const
shape
&
,
const
std
::
vector
<
argument
>&
args
)
const
...
@@ -63,7 +63,7 @@ struct binary_device : oper<Derived>
...
@@ -63,7 +63,7 @@ struct binary_device : oper<Derived>
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
{
check_shapes
{
inputs
,
*
this
}.
has
(
3
);
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
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