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
4566709b
Commit
4566709b
authored
Sep 15, 2018
by
Paul
Browse files
Renamed to use name function directly
parent
25f560c3
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
43 additions
and
43 deletions
+43
-43
src/dead_code_elimination.cpp
src/dead_code_elimination.cpp
+1
-1
src/eliminate_allocation.cpp
src/eliminate_allocation.cpp
+1
-1
src/eliminate_contiguous.cpp
src/eliminate_contiguous.cpp
+1
-1
src/fwd_conv_batchnorm_rewrite.cpp
src/fwd_conv_batchnorm_rewrite.cpp
+4
-4
src/include/migraph/instruction.hpp
src/include/migraph/instruction.hpp
+1
-1
src/onnx/verify_onnx.cpp
src/onnx/verify_onnx.cpp
+8
-8
src/program.cpp
src/program.cpp
+9
-9
src/simplify_reshapes.cpp
src/simplify_reshapes.cpp
+3
-3
src/targets/cpu/cpu_lowering.cpp
src/targets/cpu/cpu_lowering.cpp
+4
-4
src/targets/gpu/eliminate_workspace.cpp
src/targets/gpu/eliminate_workspace.cpp
+1
-1
src/targets/gpu/fuse_ops.cpp
src/targets/gpu/fuse_ops.cpp
+2
-2
src/targets/gpu/lowering.cpp
src/targets/gpu/lowering.cpp
+7
-7
src/targets/gpu/write_literals.cpp
src/targets/gpu/write_literals.cpp
+1
-1
No files found.
src/dead_code_elimination.cpp
View file @
4566709b
...
...
@@ -17,7 +17,7 @@ void dead_code_elimination::apply(program& p) const
continue
;
const
auto
i
=
std
::
prev
(
ins
);
// Skip instruction with empty shape as output unless its a builtin
if
(
i
->
result
.
elements
()
==
0
and
not
(
i
->
op
.
name
().
front
()
==
'@'
))
if
(
i
->
result
.
elements
()
==
0
and
not
(
i
->
name
().
front
()
==
'@'
))
continue
;
// Skip the last instruction
if
(
i
==
last
)
...
...
src/eliminate_allocation.cpp
View file @
4566709b
...
...
@@ -14,7 +14,7 @@ void eliminate_allocation::apply(program& p) const
std
::
vector
<
std
::
pair
<
instruction_ref
,
std
::
size_t
>>
allocs
;
for
(
auto
ins
:
iterator_for
(
p
))
{
if
(
ins
->
op
.
name
()
!=
allocation_op
)
if
(
ins
->
name
()
!=
allocation_op
)
continue
;
allocs
.
emplace_back
(
ins
,
n
);
std
::
size_t
size
=
ins
->
get_shape
().
bytes
();
...
...
src/eliminate_contiguous.cpp
View file @
4566709b
...
...
@@ -32,7 +32,7 @@ void eliminate_contiguous::apply(program& p) const
{
// TODO: Pass in names for the operator in the constructor instead
// of using ends_with
if
(
ends_with
(
arg
->
op
.
name
(),
"contiguous"
))
if
(
ends_with
(
arg
->
name
(),
"contiguous"
))
{
auto
new_args
=
args
;
auto
prev
=
arg
->
arguments
.
front
();
...
...
src/fwd_conv_batchnorm_rewrite.cpp
View file @
4566709b
...
...
@@ -10,17 +10,17 @@ void fwd_conv_batchnorm_rewrite::apply(program& p) const
{
for
(
auto
ins
:
iterator_for
(
p
))
{
if
(
ins
->
op
.
name
()
!=
"batch_norm_inference"
)
if
(
ins
->
name
()
!=
"batch_norm_inference"
)
continue
;
if
(
not
std
::
all_of
(
ins
->
arguments
.
begin
()
+
1
,
ins
->
arguments
.
end
(),
[](
auto
arg
)
{
return
arg
->
op
.
name
()
==
"@literal"
;
return
arg
->
name
()
==
"@literal"
;
}))
continue
;
auto
conv_ins
=
ins
->
arguments
[
0
];
if
(
conv_ins
->
op
.
name
()
!=
"convolution"
)
if
(
conv_ins
->
name
()
!=
"convolution"
)
continue
;
if
(
conv_ins
->
arguments
[
1
]
->
op
.
name
()
!=
"@literal"
)
if
(
conv_ins
->
arguments
[
1
]
->
name
()
!=
"@literal"
)
continue
;
// Get scale, bias, mean, variance from instruction_ref
const
auto
&
gamma
=
ins
->
arguments
[
1
]
->
get_literal
();
...
...
src/include/migraph/instruction.hpp
View file @
4566709b
...
...
@@ -32,7 +32,7 @@ struct instruction
result
=
r
;
for
(
auto
&&
ins
:
output
)
{
assert
(
ins
->
op
.
name
().
front
()
!=
'@'
);
assert
(
ins
->
name
().
front
()
!=
'@'
);
ins
->
recompute_shape
();
}
}
...
...
src/onnx/verify_onnx.cpp
View file @
4566709b
...
...
@@ -57,20 +57,20 @@ void verify_instructions(const migraph::program& prog, double tolerance = 80)
{
for
(
auto
&&
ins
:
prog
)
{
if
(
ins
.
op
.
name
().
front
()
==
'@'
)
if
(
ins
.
name
().
front
()
==
'@'
)
continue
;
if
(
ins
.
op
.
name
()
==
"broadcast"
)
if
(
ins
.
name
()
==
"broadcast"
)
continue
;
if
(
ins
.
op
.
name
()
==
"transpose"
)
if
(
ins
.
name
()
==
"transpose"
)
continue
;
if
(
ins
.
op
.
name
()
==
"reshape"
)
if
(
ins
.
name
()
==
"reshape"
)
continue
;
auto
create_program
=
[
&
]
{
migraph
::
program
p
;
std
::
vector
<
migraph
::
instruction_ref
>
inputs
;
for
(
auto
&&
arg
:
ins
.
arguments
)
{
if
(
arg
->
op
.
name
()
==
"@literal"
)
if
(
arg
->
name
()
==
"@literal"
)
inputs
.
push_back
(
p
.
add_literal
(
arg
->
lit
));
else
inputs
.
push_back
(
...
...
@@ -81,13 +81,13 @@ void verify_instructions(const migraph::program& prog, double tolerance = 80)
};
try
{
std
::
cout
<<
"Verify: "
<<
ins
.
op
.
name
()
<<
std
::
endl
;
std
::
cout
<<
"Verify: "
<<
ins
.
name
()
<<
std
::
endl
;
std
::
cout
<<
create_program
()
<<
std
::
endl
;
verify_program
(
ins
.
op
.
name
(),
create_program
,
tolerance
);
verify_program
(
ins
.
name
(),
create_program
,
tolerance
);
}
catch
(...)
{
std
::
cout
<<
"Instruction "
<<
ins
.
op
.
name
()
<<
" threw an exception."
<<
std
::
endl
;
std
::
cout
<<
"Instruction "
<<
ins
.
name
()
<<
" threw an exception."
<<
std
::
endl
;
throw
;
}
}
...
...
src/program.cpp
View file @
4566709b
...
...
@@ -31,7 +31,7 @@ static void print_program(std::ostream& os, const program& p, F annonate)
for
(
auto
ins
:
iterator_for
(
p
))
{
std
::
string
var_name
=
"@"
+
std
::
to_string
(
count
);
if
(
ins
->
op
.
name
()
==
"@param"
)
if
(
ins
->
name
()
==
"@param"
)
{
var_name
=
any_cast
<
builtin
::
param
>
(
ins
->
op
).
parameter
;
}
...
...
@@ -40,7 +40,7 @@ static void print_program(std::ostream& os, const program& p, F annonate)
os
<<
ins
->
op
;
if
(
ins
->
op
.
name
()
==
"@literal"
)
if
(
ins
->
name
()
==
"@literal"
)
{
if
(
ins
->
lit
.
get_shape
().
elements
()
>
10
)
os
<<
"{ ... }"
;
...
...
@@ -188,7 +188,7 @@ shape program::get_parameter_shape(std::string name) const
{
auto
ins
=
std
::
find_if
(
impl
->
instructions
.
begin
(),
impl
->
instructions
.
end
(),
[
&
](
const
instruction
&
x
)
{
if
(
x
.
op
.
name
()
==
"@param"
)
if
(
x
.
name
()
==
"@param"
)
{
return
any_cast
<
builtin
::
param
>
(
x
.
op
).
parameter
==
name
;
}
...
...
@@ -208,7 +208,7 @@ std::unordered_map<std::string, shape> program::get_parameter_shapes() const
std
::
unordered_map
<
std
::
string
,
shape
>
result
;
for
(
auto
&&
ins
:
impl
->
instructions
)
{
if
(
ins
.
op
.
name
()
==
"@param"
)
if
(
ins
.
name
()
==
"@param"
)
{
auto
&&
name
=
any_cast
<
builtin
::
param
>
(
ins
.
op
).
parameter
;
result
[
name
]
=
ins
.
result
;
...
...
@@ -258,7 +258,7 @@ void program::compile(const target& t, tracer trace)
{
auto
index
=
std
::
distance
(
impl
->
instructions
.
begin
(),
invalid
);
MIGRAPH_THROW
(
p
.
name
()
+
" pass produces invalid program at instruction "
+
std
::
to_string
(
index
)
+
": "
+
invalid
->
op
.
name
());
std
::
to_string
(
index
)
+
": "
+
invalid
->
name
());
}
trace
();
#endif
...
...
@@ -284,17 +284,17 @@ argument generic_eval(const program& p,
values
.
reserve
(
16
);
for
(
auto
ins
:
iterator_for
(
p
))
{
if
(
ins
->
op
.
name
()
==
"@literal"
)
if
(
ins
->
name
()
==
"@literal"
)
{
results
.
emplace
(
ins
,
trace
(
ins
,
[
&
]
{
return
ins
->
lit
.
get_argument
();
}));
}
else
if
(
ins
->
op
.
name
()
==
"@param"
)
else
if
(
ins
->
name
()
==
"@param"
)
{
results
.
emplace
(
ins
,
trace
(
ins
,
[
&
]
{
return
params
.
at
(
any_cast
<
builtin
::
param
>
(
ins
->
op
).
parameter
);
}));
}
else
if
(
ins
->
op
.
name
()
==
"@outline"
)
else
if
(
ins
->
name
()
==
"@outline"
)
{
results
.
emplace
(
ins
,
trace
(
ins
,
[
&
]
{
return
argument
{
ins
->
result
,
nullptr
};
}));
}
...
...
@@ -385,7 +385,7 @@ void program::perf_report(std::ostream& os, std::size_t n, parameter_map params)
for
(
auto
&&
p
:
ins_vec
)
{
double
avg
=
common_average
(
p
.
second
);
op_times
[
p
.
first
->
op
.
name
()]
+=
avg
;
op_times
[
p
.
first
->
name
()]
+=
avg
;
total_instruction_time
+=
avg
;
}
double
calculate_overhead_time
=
total_time
-
total_instruction_time
;
...
...
src/simplify_reshapes.cpp
View file @
4566709b
...
...
@@ -25,15 +25,15 @@ void simplify_reshapes::apply(program& p) const
{
for
(
auto
ins
:
iterator_for
(
p
))
{
if
(
not
is_reshaper
(
ins
->
op
.
name
()))
if
(
not
is_reshaper
(
ins
->
name
()))
continue
;
if
(
ins
->
output
.
size
()
!=
1
)
continue
;
if
(
is_reshaper
(
ins
->
output
.
front
()
->
op
.
name
()))
if
(
is_reshaper
(
ins
->
output
.
front
()
->
name
()))
continue
;
// Gather reshapes
std
::
vector
<
instruction_ref
>
reshapes
{
ins
};
while
(
is_reshaper
(
reshapes
.
back
()
->
op
.
name
()))
while
(
is_reshaper
(
reshapes
.
back
()
->
name
()))
{
assert
(
!
reshapes
.
back
()
->
arguments
.
empty
());
assert
(
p
.
has_instruction
(
reshapes
.
back
()
->
arguments
.
front
()));
...
...
src/targets/cpu/cpu_lowering.cpp
View file @
4566709b
...
...
@@ -579,17 +579,17 @@ struct cpu_apply
init
();
for
(
auto
it
:
iterator_for
(
*
prog
))
{
if
(
it
->
op
.
name
()
==
"activation"
)
if
(
it
->
name
()
==
"activation"
)
{
apply_activation
(
it
);
}
else
if
(
it
->
op
.
name
()
==
"pooling"
)
else
if
(
it
->
name
()
==
"pooling"
)
{
apply_pooling
(
it
);
}
else
if
(
apply_map
.
count
(
it
->
op
.
name
())
>
0
)
else
if
(
apply_map
.
count
(
it
->
name
())
>
0
)
{
apply_map
.
at
(
it
->
op
.
name
())(
it
);
apply_map
.
at
(
it
->
name
())(
it
);
}
}
}
...
...
src/targets/gpu/eliminate_workspace.cpp
View file @
4566709b
...
...
@@ -18,7 +18,7 @@ void eliminate_workspace::apply(program& p) const
{
if
(
ins
->
output
.
size
()
!=
1
)
continue
;
if
(
ins
->
op
.
name
()
!=
"hip::allocate"
)
if
(
ins
->
name
()
!=
"hip::allocate"
)
continue
;
auto
&&
a
=
any_cast
<
hip_allocate
>
(
ins
->
op
);
if
(
a
.
tag
==
"workspace"
)
...
...
src/targets/gpu/fuse_ops.cpp
View file @
4566709b
...
...
@@ -26,10 +26,10 @@ void fuse_ops::apply(program& p) const
{
for
(
auto
ins
:
iterator_for
(
p
))
{
if
(
ins
->
op
.
name
()
!=
"gpu::relu"
)
if
(
ins
->
name
()
!=
"gpu::relu"
)
continue
;
auto
add_ins
=
ins
->
arguments
.
front
();
if
(
add_ins
->
op
.
name
()
!=
"gpu::add"
)
if
(
add_ins
->
name
()
!=
"gpu::add"
)
continue
;
auto
args
=
add_ins
->
arguments
;
// Use the allocation from the relu operator
...
...
src/targets/gpu/lowering.cpp
View file @
4566709b
...
...
@@ -322,31 +322,31 @@ struct miopen_apply
for
(
auto
it
=
prog
->
begin
();
it
!=
prog
->
end
();
it
++
)
{
auto
s
=
it
->
get_shape
();
if
(
it
->
op
.
name
()
==
"convolution"
)
if
(
it
->
name
()
==
"convolution"
)
{
check_shape
(
s
,
apply_convolution
(
it
));
}
else
if
(
it
->
op
.
name
()
==
"activation"
)
else
if
(
it
->
name
()
==
"activation"
)
{
check_shape
(
s
,
apply_activation
(
it
));
}
else
if
(
it
->
op
.
name
()
==
"pooling"
)
else
if
(
it
->
name
()
==
"pooling"
)
{
check_shape
(
s
,
apply_pooling
(
it
));
}
else
if
(
it
->
op
.
name
()
==
"add"
)
else
if
(
it
->
name
()
==
"add"
)
{
check_shape
(
s
,
apply_add
(
it
));
}
else
if
(
it
->
op
.
name
()
==
"gemm"
)
else
if
(
it
->
name
()
==
"gemm"
)
{
check_shape
(
s
,
apply_gemm
(
it
));
}
else
if
(
it
->
op
.
name
()
==
"contiguous"
)
else
if
(
it
->
name
()
==
"contiguous"
)
{
check_shape
(
s
,
apply_contiguous
(
it
));
}
else
if
(
it
->
op
.
name
()
==
"batch_norm_inference"
)
else
if
(
it
->
name
()
==
"batch_norm_inference"
)
{
check_shape
(
s
,
apply_batch_norm_inference
(
it
));
}
...
...
src/targets/gpu/write_literals.cpp
View file @
4566709b
...
...
@@ -28,7 +28,7 @@ void write_literals::apply(program& p) const
assert
(
ctx
!=
nullptr
);
for
(
auto
ins
:
iterator_for
(
p
))
{
if
(
ins
->
op
.
name
()
==
"@literal"
)
if
(
ins
->
name
()
==
"@literal"
)
{
argument
a
=
to_gpu
(
ins
->
lit
.
get_argument
());
std
::
size_t
n
=
ctx
->
literals
.
size
();
...
...
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