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
097506c3
Commit
097506c3
authored
Sep 14, 2022
by
Po-Yen, Chen
Browse files
Use rangified copy() to copy elements
parent
ff6a04fd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
17 deletions
+19
-17
example/37_permute/common.hpp
example/37_permute/common.hpp
+11
-3
example/37_permute/run_permute_bundle_example.inc
example/37_permute/run_permute_bundle_example.inc
+4
-8
example/37_permute/run_permute_element_example.inc
example/37_permute/run_permute_element_example.inc
+4
-6
No files found.
example/37_permute/common.hpp
View file @
097506c3
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#pragma once
#pragma once
#include <algorithm>
#include <cassert>
#include <cassert>
#include <cstddef>
#include <cstddef>
#include <cstdlib>
#include <cstdlib>
...
@@ -211,11 +212,18 @@ inline constexpr bool is_random_access_range_v = is_random_access_range<Range>::
...
@@ -211,11 +212,18 @@ inline constexpr bool is_random_access_range_v = is_random_access_range<Range>::
}
// namespace detail
}
// namespace detail
template
<
typename
Range
>
namespace
ranges
{
auto
front
(
Range
&&
range
)
->
decltype
(
std
::
forward
<
Range
>
(
range
).
front
())
template
<
typename
InputRange
,
typename
OutputIterator
>
inline
auto
copy
(
InputRange
&&
range
,
OutputIterator
iter
)
->
decltype
(
std
::
copy
(
std
::
begin
(
std
::
forward
<
InputRange
>
(
range
)),
std
::
end
(
std
::
forward
<
InputRange
>
(
range
)),
iter
))
{
{
return
std
::
forward
<
Range
>
(
range
).
front
();
return
std
::
copy
(
std
::
begin
(
std
::
forward
<
InputRange
>
(
range
)),
std
::
end
(
std
::
forward
<
InputRange
>
(
range
)),
iter
);
}
}
}
// namespace ranges
template
<
typename
Axes
>
template
<
typename
Axes
>
inline
std
::
enable_if_t
<
detail
::
is_random_access_range_v
<
Axes
>
,
bool
>
inline
std
::
enable_if_t
<
detail
::
is_random_access_range_v
<
Axes
>
,
bool
>
...
...
example/37_permute/run_permute_bundle_example.inc
View file @
097506c3
...
@@ -35,14 +35,10 @@ bool run_permute_bundle(const Problem& problem)
...
@@ -35,14 +35,10 @@ bool run_permute_bundle(const Problem& problem)
const
void
*
input_bundle_data
=
input_device_buf
.
GetDeviceBuffer
();
const
void
*
input_bundle_data
=
input_device_buf
.
GetDeviceBuffer
();
void
*
output_bundle_data
=
output_device_buf
.
GetDeviceBuffer
();
void
*
output_bundle_data
=
output_device_buf
.
GetDeviceBuffer
();
std
::
copy
(
begin
(
input_bundle_shape
),
end
(
input_bundle_shape
),
begin
(
input_bundle_lengths
));
ranges
::
copy
(
input_bundle_shape
,
begin
(
input_bundle_lengths
));
std
::
copy
(
begin
(
input_bundle_tensor
.
GetStrides
()),
ranges
::
copy
(
input_bundle_tensor
.
GetStrides
(),
begin
(
input_bundle_strides
));
end
(
input_bundle_tensor
.
GetStrides
()),
ranges
::
copy
(
output_bundle_shape
,
begin
(
output_bundle_lengths
));
begin
(
input_bundle_strides
));
ranges
::
copy
(
output_bundle_tensor
.
GetStrides
(),
begin
(
output_bundle_strides
));
std
::
copy
(
begin
(
output_bundle_shape
),
end
(
output_bundle_shape
),
begin
(
output_bundle_lengths
));
std
::
copy
(
begin
(
output_bundle_tensor
.
GetStrides
()),
end
(
output_bundle_tensor
.
GetStrides
()),
begin
(
output_bundle_strides
));
static_assert
(
std
::
is_default_constructible_v
<
DevicePermuteInstance
>
);
static_assert
(
std
::
is_default_constructible_v
<
DevicePermuteInstance
>
);
...
...
example/37_permute/run_permute_element_example.inc
View file @
097506c3
...
@@ -30,12 +30,10 @@ bool run_permute_element(const Problem& problem)
...
@@ -30,12 +30,10 @@ bool run_permute_element(const Problem& problem)
const
void
*
input_data
=
input_device_buf
.
GetDeviceBuffer
();
const
void
*
input_data
=
input_device_buf
.
GetDeviceBuffer
();
void
*
output_data
=
output_device_buf
.
GetDeviceBuffer
();
void
*
output_data
=
output_device_buf
.
GetDeviceBuffer
();
std
::
copy
(
begin
(
input_shape
),
end
(
input_shape
),
begin
(
input_lengths
));
ranges
::
copy
(
input_shape
,
begin
(
input_lengths
));
std
::
copy
(
ranges
::
copy
(
input_tensor
.
GetStrides
(),
begin
(
input_strides
));
begin
(
input_tensor
.
GetStrides
()),
end
(
input_tensor
.
GetStrides
()),
begin
(
input_strides
));
ranges
::
copy
(
output_shape
,
begin
(
output_lengths
));
std
::
copy
(
begin
(
output_shape
),
end
(
output_shape
),
begin
(
output_lengths
));
ranges
::
copy
(
output_tensor
.
GetStrides
(),
begin
(
output_strides
));
std
::
copy
(
begin
(
output_tensor
.
GetStrides
()),
end
(
output_tensor
.
GetStrides
()),
begin
(
output_strides
));
static_assert
(
std
::
is_default_constructible_v
<
DevicePermuteInstance
>
);
static_assert
(
std
::
is_default_constructible_v
<
DevicePermuteInstance
>
);
...
...
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