Skip to content

Commit 666dc29

Browse files
committed
More unit test fixes and cpu kernel implementations
1 parent 6d99bf8 commit 666dc29

82 files changed

Lines changed: 994 additions & 132 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/kernels/include/kernels/accessor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ std::pair<ArrayShape, DataType>
242242
TensorShape get_tensor_shape_for_accessor_r(GenericTensorAccessorR const &);
243243
TensorShape get_tensor_shape_for_accessor_w(GenericTensorAccessorW const &);
244244

245-
void copy_accessor_data_to_l_from_r(GenericTensorAccessorW &dst_accessor,
245+
void copy_accessor_data_to_l_from_r(GenericTensorAccessorW const &dst_accessor,
246246
GenericTensorAccessorR const &src_accessor);
247247

248248
template <DataType DT>

lib/kernels/include/kernels/batch_matmul_kernels.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44
#include "kernels/device_stream_t.dtg.h"
55
#include "kernels/ff_handle.h"
6+
#include "kernels/device_handle_t.dtg.h"
67

78
namespace FlexFlow::Kernels::BatchMatmul {
89

910
void forward_kernel(device_stream_t const &stream,
10-
PerDeviceFFHandle const &handle,
11+
device_handle_t const &handle,
1112
float *output_ptr,
1213
float const *a_input_ptr,
1314
float const *b_input_ptr,
@@ -20,7 +21,7 @@ void forward_kernel(device_stream_t const &stream,
2021
int b_seq_length_dim);
2122

2223
void backward_kernel(device_stream_t const &stream,
23-
PerDeviceFFHandle const &handle,
24+
device_handle_t const &handle,
2425
float const *o_ptr,
2526
float const *o_grad_ptr,
2627
float const *a_ptr,

lib/kernels/include/kernels/batch_matmul_kernels_cpu.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
#define _FLEXFLOW_LIB_KERNELS_INCLUDE_KERNELS_BATCH_MATMUL_KERNELS_CPU_H
33

44
#include "kernels/allocation.h"
5-
#include "kernels/ff_handle.h"
65

76
namespace FlexFlow::Kernels::BatchMatmul {
87

9-
void cpu_forward_kernel(PerDeviceFFHandle const &handle,
10-
float *output_ptr,
8+
void cpu_forward_kernel(float *output_ptr,
119
float const *a_input_ptr,
1210
float const *b_input_ptr,
1311
int m,
@@ -18,8 +16,7 @@ void cpu_forward_kernel(PerDeviceFFHandle const &handle,
1816
int a_seq_length_dim,
1917
int b_seq_length_dim);
2018

21-
void cpu_backward_kernel(PerDeviceFFHandle const &handle,
22-
float const *o_ptr,
19+
void cpu_backward_kernel(float const *o_ptr,
2320
float const *o_grad_ptr,
2421
float const *a_ptr,
2522
float *a_grad_ptr,

lib/kernels/include/kernels/batch_norm_kernels.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
#include "kernels/batch_norm_per_device_state.dtg.h"
66
#include "kernels/device_stream_t.dtg.h"
77
#include "kernels/ff_handle.h"
8+
#include "kernels/device_handle_t.dtg.h"
89

910
namespace FlexFlow::Kernels::BatchNorm {
1011

1112
std::optional<BatchNormPerDeviceState>
1213
init_kernel(DeviceType device_type,
13-
PerDeviceFFHandle const &handle,
14+
device_handle_t const &handle,
1415
Allocator &allocator,
1516
float *runningMean,
1617
int output_n,

lib/kernels/include/kernels/conv_2d_kernels.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
#include "kernels/device_stream_t.dtg.h"
77
#include "kernels/ff_handle.h"
88
#include "op-attrs/activation.dtg.h"
9+
#include "kernels/device_handle_t.dtg.h"
910

1011
namespace FlexFlow::Kernels::Conv2D {
1112

1213
std::optional<Conv2DPerDeviceState>
1314
init_kernel(DeviceType device_type,
14-
PerDeviceFFHandle handle,
15+
device_handle_t const &handle,
1516
std::optional<Activation> activation,
1617
int kernel_h,
1718
int kernel_w,

lib/kernels/include/kernels/dropout_kernels.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
#include "kernels/array_shape.h"
66
#include "kernels/device_stream_t.dtg.h"
77
#include "kernels/dropout_per_device_state.dtg.h"
8-
#include "kernels/ff_handle.h"
98
#include <cstddef>
9+
#include "kernels/device_handle_t.dtg.h"
1010

1111
namespace FlexFlow::Kernels::Dropout {
1212

1313
std::optional<DropoutPerDeviceState>
1414
init_kernel(DeviceType device_type,
15-
PerDeviceFFHandle const &handle,
15+
device_handle_t const &handle,
1616
float rate,
1717
unsigned long long seed,
1818
ArrayShape const &output_domain,

lib/kernels/include/kernels/element_binary_kernels.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
#include "op-attrs/datatype.h"
1010
#include "op-attrs/operator_type.h"
1111
#include "pcg/device_type.dtg.h"
12+
#include "kernels/device_handle_t.dtg.h"
1213

1314
namespace FlexFlow::Kernels::ElementBinary {
1415

1516
std::optional<ElementBinaryPerDeviceState>
1617
init_kernel(DeviceType device_type,
17-
PerDeviceFFHandle handle,
18+
device_handle_t const &handle,
1819
OperatorType op_type,
1920
bool should_broadcast_lhs,
2021
bool should_broadcast_rhs,
@@ -30,7 +31,7 @@ void forward_kernel(
3031
float *out_ptr,
3132
OperatorType op_type,
3233
bool broadcast_inputLHS,
33-
PerDeviceFFHandle handle);
34+
device_handle_t const &handle);
3435

3536
void backward_kernel(
3637
device_stream_t const &stream,
@@ -43,7 +44,7 @@ void backward_kernel(
4344
OperatorType op_type,
4445
bool broadcast_inputLHS,
4546
bool broadcast_inputRHS,
46-
PerDeviceFFHandle handle);
47+
device_handle_t const &handle);
4748

4849
void cleanup_kernel(
4950
DeviceType device_type,

lib/kernels/include/kernels/element_unary_kernels.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "kernels/element_unary_per_device_state.dtg.h"
77
#include "kernels/ff_handle.h"
88
#include "op-attrs/ops/element_unary_attrs.dtg.h"
9+
#include "kernels/device_handle_t.dtg.h"
910

1011
namespace FlexFlow::Kernels::ElementUnary {
1112

@@ -19,15 +20,15 @@ void forward_kernel(
1920
device_stream_t const &stream,
2021
std::optional<ElementUnaryPerDeviceState> const &device_state,
2122
ElementUnaryAttrs const &attrs,
22-
PerDeviceFFHandle const &handle,
23+
device_handle_t const &handle,
2324
GenericTensorAccessorR const &input,
2425
GenericTensorAccessorW const &output);
2526

2627
void backward_kernel(
2728
device_stream_t const &stream,
2829
std::optional<ElementUnaryPerDeviceState> const &device_state,
2930
ElementUnaryAttrs const &attrs,
30-
PerDeviceFFHandle const &handle,
31+
device_handle_t const &handle,
3132
GenericTensorAccessorR const &output,
3233
GenericTensorAccessorR const &output_grad,
3334
GenericTensorAccessorR const &input,

lib/kernels/include/kernels/element_unary_kernels_cpu.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
namespace FlexFlow::Kernels::ElementUnary {
99

1010
void cpu_forward_kernel(ElementUnaryAttrs const &attrs,
11-
PerDeviceFFHandle const &handle,
1211
GenericTensorAccessorR const &input,
1312
GenericTensorAccessorW const &output);
1413

1514
void cpu_backward_kernel(ElementUnaryAttrs const &attrs,
16-
PerDeviceFFHandle const &handle,
1715
GenericTensorAccessorR const &output,
1816
GenericTensorAccessorR const &output_grad,
1917
GenericTensorAccessorR const &input,

lib/kernels/include/kernels/fill_tensor_accessor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace FlexFlow {
99

10-
void fill_tensor_accessor(GenericTensorAccessorW &, DataTypeValue val);
10+
void fill_tensor_accessor(GenericTensorAccessorW const &, DataTypeValue val);
1111

1212
GenericTensorAccessorW create_accessor_w_filled_with(
1313
TensorShape const &shape, DataTypeValue val, Allocator const &allocator);

0 commit comments

Comments
 (0)