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
composable_kernel
Commits
19147f59
Commit
19147f59
authored
Sep 05, 2022
by
Po-Yen, Chen
Browse files
Use more specific method to write example
parent
665b73ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
example/36_elementwise_permute/run_elementwise_permute_example.inc
...6_elementwise_permute/run_elementwise_permute_example.inc
+10
-10
No files found.
example/36_elementwise_permute/run_elementwise_permute_example.inc
View file @
19147f59
...
...
@@ -24,7 +24,7 @@ void host_elementwise4D(HostTensorB& B,
bool
run_elementwise_permute
(
const
ExecutionConfig
&
config
,
const
Problem
&
problem
)
{
std
::
size_t
N
=
4
,
C
=
16
,
H
=
32
,
W
=
32
;
auto
[
N
,
C
,
H
,
W
]
=
problem
.
shape
;
std
::
vector
<
std
::
size_t
>
nchw
=
{
N
,
C
,
H
,
W
};
std
::
vector
<
std
::
size_t
>
nhwc
=
{
N
,
H
,
W
,
C
};
Tensor
<
ADataType
>
a
(
nchw
);
...
...
@@ -48,19 +48,19 @@ bool run_elementwise_permute(const ExecutionConfig& config, const Problem& probl
std
::
copy
(
a
.
mDesc
.
GetStrides
()
.
begin
(),
a
.
mDesc
.
GetStrides
()
.
end
(),
a_strides
.
begin
());
std
::
copy
(
b
.
mDesc
.
GetStrides
()
.
begin
(),
b
.
mDesc
.
GetStrides
()
.
end
(),
b_strides
.
begin
());
auto
broadcastP
ermute
=
DeviceElementwisePermuteInstance
{};
auto
argument
=
broadcastPermute
.
MakeArgumentPointer
(
ab_lengths
,
{
a_strides
},
{
b_strides
},
input
,
output
,
PassThrough
{});
auto
p
ermute
=
DeviceElementwisePermuteInstance
{};
auto
argument
=
permute
.
MakeArgument
(
ab_lengths
,
{
a_strides
},
{
b_strides
},
input
,
output
,
PassThrough
{});
if
(
!
broadcastP
ermute
.
IsSupportedArgument
(
argument
.
get
()
))
if
(
!
p
ermute
.
IsSupportedArgument
(
argument
))
{
throw
std
::
runtime_error
(
"The runtime parameters seems not supported by the device instance, exiting!"
);
std
::
cerr
<<
"The runtime parameters seems not supported by the device instance, exiting!"
<<
std
::
endl
;
return
false
;
};
auto
broadcastPermute_invoker_ptr
=
broadcastPermute
.
MakeInvokerPointer
();
float
ave_time
=
broadcastPermute_invoker_ptr
->
Run
(
argument
.
get
(),
StreamConfig
{
nullptr
,
config
.
time_kernel
});
auto
invoker
=
permute
.
MakeInvoker
();
float
ave_time
=
invoker
.
Run
(
argument
,
StreamConfig
{
nullptr
,
config
.
time_kernel
});
std
::
cout
<<
"Perf: "
<<
ave_time
<<
" ms"
<<
std
::
endl
;
...
...
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