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
b7d1ff95
Commit
b7d1ff95
authored
Feb 27, 2022
by
Shucai Xiao
Browse files
backup temp changes
parent
eb22c0e5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
6 deletions
+15
-6
CMakeLists.txt
CMakeLists.txt
+1
-1
src/include/migraphx/shape.hpp
src/include/migraphx/shape.hpp
+1
-1
src/targets/gpu/device/mul_add.cpp
src/targets/gpu/device/mul_add.cpp
+13
-4
No files found.
CMakeLists.txt
View file @
b7d1ff95
...
@@ -234,7 +234,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
...
@@ -234,7 +234,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set
(
CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
/lib
)
set
(
CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
/lib
)
set
(
CMAKE_RUNTIME_OUTPUT_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
/bin
)
set
(
CMAKE_RUNTIME_OUTPUT_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
/bin
)
add_subdirectory
(
src
)
add_subdirectory
(
src
)
add_subdirectory
(
doc
)
#
add_subdirectory(doc)
add_subdirectory
(
test
)
add_subdirectory
(
test
)
add_subdirectory
(
tools
)
add_subdirectory
(
tools
)
...
...
src/include/migraphx/shape.hpp
View file @
b7d1ff95
...
@@ -223,11 +223,11 @@ struct shape
...
@@ -223,11 +223,11 @@ struct shape
static
type_t
parse_type
(
const
std
::
string
&
s
);
static
type_t
parse_type
(
const
std
::
string
&
s
);
const
std
::
vector
<
shape
>&
sub_shapes
()
const
;
const
std
::
vector
<
shape
>&
sub_shapes
()
const
;
std
::
size_t
element_space
()
const
;
private:
private:
std
::
shared_ptr
<
const
shape_impl
>
impl
;
std
::
shared_ptr
<
const
shape_impl
>
impl
;
std
::
size_t
element_space
()
const
;
};
};
void
migraphx_to_value
(
value
&
v
,
const
shape
&
s
);
void
migraphx_to_value
(
value
&
v
,
const
shape
&
s
);
...
...
src/targets/gpu/device/mul_add.cpp
View file @
b7d1ff95
...
@@ -21,7 +21,7 @@ namespace device {
...
@@ -21,7 +21,7 @@ namespace device {
// }
// }
//}
//}
__global__
void
mul_add_kernel
(
void
*
a
,
void
*
x
,
void
*
b
,
void
*
r
,
int
n
)
__global__
void
mul_add_kernel
(
void
*
a
,
int
an
,
void
*
x
,
int
xn
,
void
*
b
,
int
bn
,
void
*
r
,
int
n
)
{
{
int
id
=
blockDim
.
x
*
blockIdx
.
x
+
threadIdx
.
x
;
int
id
=
blockDim
.
x
*
blockIdx
.
x
+
threadIdx
.
x
;
__half2
*
ha
=
reinterpret_cast
<
__half2
*>
(
a
);
__half2
*
ha
=
reinterpret_cast
<
__half2
*>
(
a
);
...
@@ -30,7 +30,7 @@ __global__ void mul_add_kernel(void* a, void* x, void* b, void* r, int n)
...
@@ -30,7 +30,7 @@ __global__ void mul_add_kernel(void* a, void* x, void* b, void* r, int n)
__half2
*
hr
=
reinterpret_cast
<
__half2
*>
(
r
);
__half2
*
hr
=
reinterpret_cast
<
__half2
*>
(
r
);
if
(
id
<
n
)
if
(
id
<
n
)
{
{
hr
[
id
]
=
__hadd2
(
__hmul2
(
ha
[
id
],
hx
[
id
]),
hb
[
id
]);
hr
[
id
]
=
__hadd2
(
__hmul2
(
ha
[
id
%
an
],
hx
[
id
%
xn
]),
hb
[
id
%
bn
]);
}
}
}
}
...
@@ -44,13 +44,22 @@ void mul_add(hipStream_t stream,
...
@@ -44,13 +44,22 @@ void mul_add(hipStream_t stream,
auto
type
=
result
.
get_shape
().
type
();
auto
type
=
result
.
get_shape
().
type
();
if
(
type
==
shape
::
half_type
)
if
(
type
==
shape
::
half_type
)
{
{
auto
elem_num
=
result
.
get_shape
().
elements
()
/
2
;
std
::
cout
<<
"case1"
<<
std
::
endl
;
int
s1e
=
arg1
.
get_shape
().
element_space
()
/
2
;
int
s2e
=
arg2
.
get_shape
().
element_space
()
/
2
;
int
s3e
=
arg3
.
get_shape
().
element_space
()
/
2
;
int
elem_num
=
result
.
get_shape
().
elements
()
/
2
;
s1e
=
(
s1e
==
0
?
1
:
s1e
);
s2e
=
(
s2e
==
0
?
1
:
s2e
);
s3e
=
(
s3e
==
0
?
1
:
s3e
);
std
::
cout
<<
"re ="
<<
elem_num
<<
", s1e = "
<<
s1e
<<
", s2e = "
<<
s2e
<<
", s3e = "
<<
s3e
<<
std
::
endl
;
int
block_size
=
1024
;
int
block_size
=
1024
;
int
block_num
=
(
elem_num
+
block_size
-
1
)
/
block_size
;
int
block_num
=
(
elem_num
+
block_size
-
1
)
/
block_size
;
mul_add_kernel
<<<
block_num
,
block_size
>>>
(
arg1
.
data
(),
arg2
.
data
(),
arg3
.
data
(),
result
.
data
(),
elem_num
);
mul_add_kernel
<<<
block_num
,
block_size
>>>
(
arg1
.
data
(),
s1e
,
arg2
.
data
(),
s2e
,
arg3
.
data
(),
s3e
,
result
.
data
(),
elem_num
);
}
}
else
else
{
{
std
::
cout
<<
"case2"
<<
std
::
endl
;
nary
(
stream
,
result
,
arg1
,
arg2
,
arg3
)([](
auto
x
,
auto
a
,
auto
b
)
nary
(
stream
,
result
,
arg1
,
arg2
,
arg3
)([](
auto
x
,
auto
a
,
auto
b
)
__device__
{
return
a
*
x
+
b
;
});
__device__
{
return
a
*
x
+
b
;
});
}
}
...
...
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