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
7abdd2f0
Commit
7abdd2f0
authored
Jul 02, 2018
by
Paul
Browse files
Formatting
parent
eea003a5
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
89 additions
and
37 deletions
+89
-37
src/include/migraph/manage_ptr.hpp
src/include/migraph/manage_ptr.hpp
+2
-1
src/include/migraph/operators.hpp
src/include/migraph/operators.hpp
+41
-11
src/include/migraph/raw_data.hpp
src/include/migraph/raw_data.hpp
+4
-2
src/include/migraph/requires.hpp
src/include/migraph/requires.hpp
+1
-1
src/include/migraph/shape.hpp
src/include/migraph/shape.hpp
+1
-1
src/onnx/onnx.cpp
src/onnx/onnx.cpp
+4
-1
src/onnx/verify_onnx.cpp
src/onnx/verify_onnx.cpp
+2
-1
src/targets/miopen/include/migraph/miopen/miopen.hpp
src/targets/miopen/include/migraph/miopen/miopen.hpp
+6
-5
test/eval_test.cpp
test/eval_test.cpp
+6
-4
test/miopen/miopen.cpp
test/miopen/miopen.cpp
+10
-6
test/operation.cpp
test/operation.cpp
+12
-4
No files found.
src/include/migraph/manage_ptr.hpp
View file @
7abdd2f0
...
...
@@ -51,6 +51,7 @@ shared<T> share(T p)
}
// namespace migraph
#define MIGRAPH_MANAGE_PTR(T, F) migraph::manage_ptr<std::remove_pointer_t<T>, decltype(&F), &F> // NOLINT
#define MIGRAPH_MANAGE_PTR(T, F) \
migraph::manage_ptr<std::remove_pointer_t<T>, decltype(&F), &F> // NOLINT
#endif
src/include/migraph/operators.hpp
View file @
7abdd2f0
...
...
@@ -97,7 +97,10 @@ struct check_shapes
struct
not_computable
{
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
};
struct
convolution
...
...
@@ -167,7 +170,10 @@ struct convolution
}
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
convolution
&
op
)
{
...
...
@@ -214,7 +220,10 @@ struct pooling
}};
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
pooling
&
op
)
{
...
...
@@ -237,7 +246,10 @@ struct activation
return
inputs
.
front
();
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
activation
&
op
)
{
os
<<
op
.
name
()
<<
":"
<<
op
.
mode
;
...
...
@@ -275,7 +287,10 @@ struct transpose
}
return
{
t
,
output_lens
,
output_strides
};
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
};
struct
contiguous
...
...
@@ -292,7 +307,10 @@ struct contiguous
}
return
{
t
,
lens
};
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
};
struct
reshape
...
...
@@ -320,7 +338,10 @@ struct reshape
return
s
;
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
reshape
&
op
)
{
...
...
@@ -346,7 +367,10 @@ struct gemm
return
{
t
,
{
a
.
lens
()[
0
],
b
.
lens
()[
1
]}};
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
gemm
&
op
)
{
...
...
@@ -363,7 +387,10 @@ struct unary
check_shapes
{
inputs
}.
has
(
1
);
return
inputs
.
at
(
0
);
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
};
struct
identity
:
unary
...
...
@@ -477,7 +504,10 @@ struct binary
check_shapes
{
inputs
}.
has
(
2
).
same_type
().
same_dims
();
return
inputs
.
at
(
0
);
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
};
struct
add
:
binary
...
...
src/include/migraph/raw_data.hpp
View file @
7abdd2f0
...
...
@@ -131,7 +131,8 @@ struct raw_data : raw_data_base
template
<
class
T
,
class
U
,
MIGRAPH_REQUIRES
(
std
::
is_base_of
<
raw_data_base
,
T
>{}
&&
std
::
is_base_of
<
raw_data_base
,
U
>
{})
>
MIGRAPH_REQUIRES
(
std
::
is_base_of
<
raw_data_base
,
T
>{}
&&
std
::
is_base_of
<
raw_data_base
,
U
>
{})
>
bool
operator
==
(
const
T
&
x
,
const
U
&
y
)
{
auto
&&
xshape
=
x
.
get_shape
();
...
...
@@ -153,7 +154,8 @@ bool operator==(const T& x, const U& y)
template
<
class
T
,
class
U
,
MIGRAPH_REQUIRES
(
std
::
is_base_of
<
raw_data_base
,
T
>{}
&&
std
::
is_base_of
<
raw_data_base
,
U
>
{})
>
MIGRAPH_REQUIRES
(
std
::
is_base_of
<
raw_data_base
,
T
>{}
&&
std
::
is_base_of
<
raw_data_base
,
U
>
{})
>
bool
operator
!=
(
const
T
&
x
,
const
U
&
y
)
{
return
!
(
x
==
y
);
...
...
src/include/migraph/requires.hpp
View file @
7abdd2f0
src/include/migraph/shape.hpp
View file @
7abdd2f0
src/onnx/onnx.cpp
View file @
7abdd2f0
...
...
@@ -25,7 +25,10 @@ struct unknown
else
return
input
.
front
();
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
argument
compute
(
context
&
,
shape
,
std
::
vector
<
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
unknown
&
x
)
{
os
<<
x
.
name
();
...
...
src/onnx/verify_onnx.cpp
View file @
7abdd2f0
...
...
@@ -26,7 +26,8 @@ migraph::argument run_gpu(std::string file)
auto
s
=
p
.
get_parameter_shape
(
"Input3"
);
auto
input3
=
migraph
::
miopen
::
to_gpu
(
migraph
::
generate_argument
(
s
));
auto
output
=
migraph
::
miopen
::
to_gpu
(
migraph
::
generate_argument
(
p
.
get_parameter_shape
(
"output"
)));
auto
output
=
migraph
::
miopen
::
to_gpu
(
migraph
::
generate_argument
(
p
.
get_parameter_shape
(
"output"
)));
auto
handle
=
migraph
::
miopen
::
make_obj
<
migraph
::
miopen
::
miopen_handle
>
(
&
miopenCreate
);
auto
out
=
p
.
eval
({{
"Input3"
,
input3
},
{
"output"
,
output
}});
...
...
src/targets/miopen/include/migraph/miopen/miopen.hpp
View file @
7abdd2f0
...
...
@@ -9,7 +9,8 @@ namespace migraph {
namespace
miopen
{
using
miopen_handle
=
MIGRAPH_MANAGE_PTR
(
miopenHandle_t
,
miopenDestroy
);
using
tensor_descriptor
=
MIGRAPH_MANAGE_PTR
(
miopenTensorDescriptor_t
,
miopenDestroyTensorDescriptor
);
using
tensor_descriptor
=
MIGRAPH_MANAGE_PTR
(
miopenTensorDescriptor_t
,
miopenDestroyTensorDescriptor
);
using
convolution_descriptor
=
MIGRAPH_MANAGE_PTR
(
miopenConvolutionDescriptor_t
,
miopenDestroyConvolutionDescriptor
);
using
pooling_descriptor
=
MIGRAPH_MANAGE_PTR
(
miopenPoolingDescriptor_t
,
...
...
test/eval_test.cpp
View file @
7abdd2f0
...
...
@@ -8,7 +8,8 @@
struct
sum_op
{
std
::
string
name
()
const
{
return
"sum"
;
}
migraph
::
argument
compute
(
migraph
::
context
&
,
migraph
::
shape
,
std
::
vector
<
migraph
::
argument
>
args
)
const
migraph
::
argument
compute
(
migraph
::
context
&
,
migraph
::
shape
,
std
::
vector
<
migraph
::
argument
>
args
)
const
{
migraph
::
argument
result
;
if
(
args
.
size
()
!=
2
)
...
...
@@ -37,7 +38,8 @@ struct sum_op
struct
minus_op
{
std
::
string
name
()
const
{
return
"minus"
;
}
migraph
::
argument
compute
(
migraph
::
context
&
,
migraph
::
shape
,
std
::
vector
<
migraph
::
argument
>
args
)
const
migraph
::
argument
compute
(
migraph
::
context
&
,
migraph
::
shape
,
std
::
vector
<
migraph
::
argument
>
args
)
const
{
migraph
::
argument
result
;
if
(
args
.
size
()
!=
2
)
...
...
@@ -118,8 +120,8 @@ void param_test()
auto
y
=
p
.
add_parameter
(
"y"
,
{
migraph
::
shape
::
int64_type
});
p
.
add_instruction
(
sum_op
{},
x
,
y
);
auto
result
=
p
.
eval
(
{{
"x"
,
migraph
::
literal
{
1
}.
get_argument
()},
{
"y"
,
migraph
::
literal
{
2
}.
get_argument
()}});
auto
result
=
p
.
eval
(
{{
"x"
,
migraph
::
literal
{
1
}.
get_argument
()},
{
"y"
,
migraph
::
literal
{
2
}.
get_argument
()}});
EXPECT
(
result
==
migraph
::
literal
{
3
});
EXPECT
(
result
!=
migraph
::
literal
{
4
});
}
...
...
test/miopen/miopen.cpp
View file @
7abdd2f0
...
...
@@ -35,7 +35,8 @@ migraph::argument run_gpu()
e
.
second
=
migraph
::
miopen
::
to_gpu
(
e
.
second
);
}
m
[
"output"
]
=
migraph
::
miopen
::
to_gpu
(
migraph
::
generate_argument
(
p
.
get_parameter_shape
(
"output"
)));
m
[
"output"
]
=
migraph
::
miopen
::
to_gpu
(
migraph
::
generate_argument
(
p
.
get_parameter_shape
(
"output"
)));
return
migraph
::
miopen
::
from_gpu
(
p
.
eval
(
m
));
}
...
...
@@ -97,7 +98,8 @@ struct test_conv_relu
{
migraph
::
program
p
;
auto
input
=
p
.
add_parameter
(
"x"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}});
auto
weights
=
p
.
add_parameter
(
"w"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}});
auto
weights
=
p
.
add_parameter
(
"w"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}});
auto
conv
=
p
.
add_instruction
(
migraph
::
convolution
{},
input
,
weights
);
p
.
add_instruction
(
migraph
::
activation
{
"relu"
},
conv
);
return
p
;
...
...
@@ -117,8 +119,10 @@ struct test_conv_pooling
migraph
::
program
create_program
()
const
{
migraph
::
program
p
;
auto
input
=
p
.
add_parameter
(
"x"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
4
,
3
,
32
,
32
}});
auto
weights
=
p
.
add_parameter
(
"w"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}});
auto
input
=
p
.
add_parameter
(
"x"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
4
,
3
,
32
,
32
}});
auto
weights
=
p
.
add_parameter
(
"w"
,
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}});
auto
conv
=
p
.
add_instruction
(
migraph
::
convolution
{},
input
,
weights
);
auto
pooling
=
p
.
add_instruction
(
migraph
::
pooling
{
"max"
},
conv
);
p
.
add_instruction
(
migraph
::
activation
{
"relu"
},
pooling
);
...
...
test/operation.cpp
View file @
7abdd2f0
...
...
@@ -8,8 +8,12 @@ struct simple_operation
{
int
data
=
1
;
std
::
string
name
()
const
{
return
"simple"
;
}
migraph
::
shape
compute_shape
(
std
::
vector
<
migraph
::
shape
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
migraph
::
argument
compute
(
migraph
::
context
&
,
migraph
::
shape
,
std
::
vector
<
migraph
::
argument
>
)
const
migraph
::
shape
compute_shape
(
std
::
vector
<
migraph
::
shape
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
migraph
::
argument
compute
(
migraph
::
context
&
,
migraph
::
shape
,
std
::
vector
<
migraph
::
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
...
...
@@ -23,8 +27,12 @@ struct simple_operation
struct
simple_operation_no_print
{
std
::
string
name
()
const
{
return
"simple"
;
}
migraph
::
shape
compute_shape
(
std
::
vector
<
migraph
::
shape
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
migraph
::
argument
compute
(
migraph
::
context
&
,
migraph
::
shape
,
std
::
vector
<
migraph
::
argument
>
)
const
migraph
::
shape
compute_shape
(
std
::
vector
<
migraph
::
shape
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
migraph
::
argument
compute
(
migraph
::
context
&
,
migraph
::
shape
,
std
::
vector
<
migraph
::
argument
>
)
const
{
MIGRAPH_THROW
(
"not computable"
);
}
...
...
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