Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lib/kernels/include/kernels/reshape_kernels.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,28 @@

#include "kernels/accessor.h"
#include "kernels/device.h"
#include "utils/required_core.h"

namespace FlexFlow {

class ReshapePerDeviceState : public PerDeviceOpState {
public:
ReshapePerDeviceState(FFHandler handler);
DataType data_type;
struct ReshapePerDeviceState {
req<DataType> data_type;
};

FF_VISITABLE_STRUCT(ReshapePerDeviceState, data_type);

namespace Kernels {
namespace Reshape {

ReshapePerDeviceState init_kernel(DataType data_type);

void forward_kernel(ffStream_t stream,
ReshapePerDeviceState const *m,
ReshapePerDeviceState const &per_device_state,
GenericTensorAccessorR const &input,
GenericTensorAccessorW const &output);

void backward_kernel(ffStream_t stream,
ReshapePerDeviceState const *m,
ReshapePerDeviceState const &per_device_state,
GenericTensorAccessorW const &input,
GenericTensorAccessorR const &output);

Expand Down
14 changes: 7 additions & 7 deletions lib/kernels/src/cuda/reshape_kernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@

namespace FlexFlow {

ReshapePerDeviceState::ReshapePerDeviceState(FFHandler handler)
: PerDeviceOpState(handler) {}
ReshapePerDeviceState init_kernel(DataType data_type) {
return ReshapePerDeviceState{data_type};
}

namespace Kernels {
namespace Reshape {
Expand All @@ -41,7 +42,6 @@ struct ForwardKernel {
template <DataType T>
struct BackwardKernel {
void operator()(cudaStream_t stream,
ReshapePerDeviceState const *m,
GenericTensorAccessorW const &input,
GenericTensorAccessorR const &output) {
float alpha = 1.0f;
Expand All @@ -54,17 +54,17 @@ struct BackwardKernel {
}

void forward_kernel(cudaStream_t stream,
ReshapePerDeviceState const *m,
ReshapePerDeviceState const &m,
GenericTensorAccessorR const &input,
GenericTensorAccessorW const &output) {
DataTypeDispatch1<ForwardKernel>{}(m->data_type, stream, m, input, output);
DataTypeDispatch1<ForwardKernel>{}(m.data_type, stream, input, output);
}

void backward_kernel(cudaStream_t stream,
ReshapePerDeviceState const *m,
ReshapePerDeviceState const &m,
GenericTensorAccessorW const &input,
GenericTensorAccessorR const &output) {
DataTypeDispatch1<BackwardKernel>{}(m->data_type, stream, m, input, output);
DataTypeDispatch1<BackwardKernel>{}(m.data_type, stream, input, output);
}

} // namespace Reshape
Expand Down
Loading