2022-09-29 14:52:50 +08:00
|
|
|
#pragma once
|
|
|
|
#include "core/operator.h"
|
|
|
|
|
|
|
|
namespace infini {
|
2023-02-13 22:48:20 +08:00
|
|
|
/**
|
|
|
|
* @brief Copy a tensor along a centain dimension for multiple times.
|
|
|
|
*
|
|
|
|
*/
|
2022-09-29 14:52:50 +08:00
|
|
|
class ExtendObj : public OperatorObj {
|
|
|
|
int dim, num; // copy num times at the dim.
|
|
|
|
|
|
|
|
public:
|
2023-02-13 22:48:20 +08:00
|
|
|
/**
|
|
|
|
* @brief Construct a new Extend object.
|
|
|
|
*
|
|
|
|
* @param graph The computation graph that this operator belongs to.
|
|
|
|
* @param input The input tensor.
|
|
|
|
* @param output The extened tensor.
|
|
|
|
* @param dim The dimension to extend on.
|
|
|
|
* @param num The number of times to copy when extending. The dimension size
|
|
|
|
* of `dim` becomes `num+1` times after extending.
|
|
|
|
*/
|
2022-09-29 14:52:50 +08:00
|
|
|
ExtendObj(GraphObj *graph, Tensor input, Tensor output, int dim,
|
|
|
|
int num = 1);
|
2023-02-12 18:27:52 +08:00
|
|
|
OP_CLONE(ExtendObj);
|
2023-11-23 13:11:50 +08:00
|
|
|
optional<vector<Shape>> inferShape(const TensorVec &inputs) override;
|
2022-09-29 14:52:50 +08:00
|
|
|
|
|
|
|
std::string toString() const override;
|
|
|
|
int numInputs() const override { return 1; }
|
|
|
|
int numOutputs() const override { return 1; }
|
|
|
|
int getDim() const { return dim; }
|
|
|
|
int getNum() const { return num; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
vector<int> getWorkloadVector() const override;
|
|
|
|
vector<int> getOpAttrVector() const override;
|
|
|
|
};
|
2022-10-15 16:29:28 +08:00
|
|
|
} // namespace infini
|