-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
701 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#ifndef _FLEXFLOW_ARG_MAX_H_ | ||
#define _FLEXFLOW_ARG_MAX_H_ | ||
|
||
#include "flexflow/inference.h" | ||
#include "flexflow/model.h" | ||
#include "flexflow/node.h" | ||
#include "flexflow/ops/argmax_params.h" | ||
|
||
namespace FlexFlow { | ||
|
||
class ArgMaxMeta : public OpMeta { | ||
public: | ||
#if defined(FF_USE_CUDA) || defined(FF_USE_HIP_CUDA) | ||
cudnnTensorDescriptor_t inputTensor, outputTensor; | ||
cudnnReduceTensorDescriptor_t reduceMaxDesc; | ||
#else | ||
miopenTensorDescriptor_t inputTensor, outputTensor; | ||
miopenReduceTensorDescriptor_t reduceMaxDesc; | ||
#endif | ||
ArgMaxMeta(FFHandler handle, | ||
Op const *op, | ||
Legion::Domain const &input_domain, | ||
Legion::Domain const &output_domain, | ||
GenericTensorAccessorW input); | ||
}; | ||
|
||
class ArgMax : public Op { | ||
public: | ||
using Params = ArgMaxParams; | ||
using Input = ParallelTensor; | ||
ArgMax(FFModel &model, const ParallelTensor input, char const *name); | ||
ArgMax(FFModel &model, ArgMax const &other, const ParallelTensor input); | ||
ArgMax(FFModel &model, | ||
Params const ¶ms, | ||
Input const input, | ||
char const *name = nullptr); | ||
void init(FFModel const &) override; | ||
void init_inference(FFModel const &, | ||
std::vector<ParallelTensor> const &, | ||
std::vector<ParallelTensor> const &, | ||
MachineView const *mv = nullptr) override; | ||
void forward(FFModel const &) override; | ||
void backward(FFModel const &) override; | ||
Legion::FutureMap inference(FFModel const &, | ||
BatchConfig const &, | ||
std::vector<ParallelTensor> const &, | ||
std::vector<ParallelTensor> const &, | ||
MachineView const *mv = nullptr) override; | ||
void print_layer(FFModel const &model) override { | ||
assert(0); | ||
} | ||
static Op * | ||
create_operator_from_layer(FFModel &model, | ||
Layer const *layer, | ||
std::vector<ParallelTensor> const &inputs); | ||
|
||
static OpMeta *init_task(Legion::Task const *task, | ||
std::vector<Legion::PhysicalRegion> const ®ions, | ||
Legion::Context ctx, | ||
Legion::Runtime *runtime); | ||
static InferenceResult | ||
inference_task(Legion::Task const *task, | ||
std::vector<Legion::PhysicalRegion> const ®ions, | ||
Legion::Context ctx, | ||
Legion::Runtime *runtime); | ||
void serialize(Legion::Serializer &s) const override; | ||
static PCG::Node deserialize(FFModel &ff, | ||
Legion::Deserializer &d, | ||
ParallelTensor inputs[], | ||
int num_inputs); | ||
Op *materialize(FFModel &ff, | ||
ParallelTensor inputs[], | ||
int num_inputs) const override; | ||
bool measure_operator_cost(Simulator *sim, | ||
MachineView const &pc, | ||
CostMetrics &cost_metrics) const override; | ||
template <typename DT> | ||
static void forward_kernel(ArgMaxMeta const *m, | ||
DT *input_ptr, | ||
int *indices_ptr, | ||
int length, | ||
int batch_size, | ||
ffStream_t stream); | ||
static void forward_kernel_wrapper(ArgMaxMeta const *m, | ||
GenericTensorAccessorW const &input, | ||
GenericTensorAccessorW const &indices, | ||
int batch_size); | ||
Params get_params() const; | ||
|
||
public: | ||
}; | ||
|
||
}; // namespace FlexFlow | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef _FLEXFLOW_ARGMAX_PARAMS_H | ||
#define _FLEXFLOW_ARGMAX_PARAMS_H | ||
|
||
#include "flexflow/ffconst.h" | ||
#include "flexflow/parallel_tensor.h" | ||
|
||
namespace FlexFlow { | ||
|
||
struct ArgMaxParams { | ||
OperatorType op_type; | ||
bool is_valid(ParallelTensorShape const &) const; | ||
}; | ||
bool operator==(ArgMaxParams const &, ArgMaxParams const &); | ||
|
||
} // namespace FlexFlow | ||
|
||
namespace std { | ||
template <> | ||
struct hash<FlexFlow::ArgMaxParams> { | ||
size_t operator()(FlexFlow::ArgMaxParams const &) const; | ||
}; | ||
} // namespace std | ||
|
||
#endif // _FLEXFLOW_ARGMAX_PARAMS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.