Skip to content
Snippets Groups Projects
Commit 78467ffe authored by Michal Szczepanski's avatar Michal Szczepanski
Browse files

constructor fixed, add input producers to resize node

parent 97ba9b77
No related branches found
No related tags found
2 merge requests!152Update Aidge export to take a graph view has an argument instead of a...,!125Operator resize
......@@ -12,7 +12,6 @@
#ifndef AIDGE_CORE_OPERATOR_Resize_H_
#define AIDGE_CORE_OPERATOR_Resize_H_
#include <cassert>
#include <memory>
#include <vector>
......@@ -25,19 +24,36 @@
namespace Aidge {
enum class ResizeAttr { NoROI, NoScales, NoSizes };
class Resize_Op : public OperatorTensor,
public Registrable<Resize_Op, std::string, std::unique_ptr<OperatorImpl>(const Resize_Op&)>
{
public Registrable<Resize_Op, std::string, std::unique_ptr<OperatorImpl>(const Resize_Op&)>
public StaticAttributes<ResizeAttr,
bool,
bool,
bool> {
public:
static const std::string Type; // du
static const std::string Type;
Resize_Op() : OperatorTensor(Type, 2, 0, 1) {}
// 4 input 0 attribute 1 output
// "data_input", "roi", "scales", "sizes"
Resize_Op() = delete;
using Attributes_ = StaticAttributes<ResizeAttr,
bool,
bool,
bool>;
template <ResizeAttr e>
using attr = typename Attributes_::template attr<e>;
constexpr Resize_Op(const bool noROI, const bool noScales, const bool noSizes)
: OperatorTensor(Type, 1, 3, 1),
// input tensor, onnx optional input [roi/scales/sizes] *constant, output
Attributes_(attr<ResizeAttr::NoROI>( noROI),
attr<ResizeAttr::NoScales>( noScales),
attr<ResizeAttr::NoSizes>( noSizes)) {}
/**
* @brief Copy-constructor. Copy the operator attributes and its output tensor(s), but not its input tensors (the new operator has no input associated).
* @brief Copy-constructor. Copy the operator attributes and its output tensor(s),
* but not its input tensors (the new operator has no input associated).
* @param op Operator to copy.
*/
Resize_Op(const Resize_Op& op)
......@@ -63,13 +79,10 @@ public:
// function see inputs
bool forwardDims(bool allowDataDependency = false) override final;
void setBackend(const std::string& name, DeviceIdx_t device = 0) override final{
// // to select which backend CUDA / CPU?
// mImpl = Registrar<Resize_Op>::create(name)(*this);
// mOutputs[0]->setBackend(name, device);
}
void setBackend(const std::string& name, DeviceIdx_t device = 0) override final;
static const std::vector<std::string> getInputsName(){
// roi, scales, sizes, even if considered as const parameters/input
return {"data_input", "roi ", "scales", "sizes"};
}
static const std::vector<std::string> getOutputsName(){
......@@ -77,11 +90,29 @@ public:
}
};
// WTF
inline std::shared_ptr<Node> Resize(const std::string &name = "") {
// FIXME: properly handle default w&b initialization in every cases
return std::make_shared<Node>(std::make_shared<Resize_Op>(), name);
inline std::shared_ptr<Node> Resize(const std::size_t nbInputDims,
const bool noROI,
const bool noScales,
const bool noSizes,
const std::string &name = "") {
resize_node = std::make_shared<Node>(std::make_shared<Resize_Op>(noROI, noScales, noSizes), name);
// create empty producers of the same as the rank of input size [nbInputDims]
addProducer(resize_node, 1, std::array<DimSize_t, 1>({noROI ? 0 : nbInputDims}), "roi"); // already sets roi dims
addProducer(resize_node, 2, std::array<DimSize_t, 1>({noScales ? 0 : nbInputDims}), "scales"); // already sets scales dims
addProducer(resize_node, 3, std::array<DimSize_t, 1>({noSizes ? 0 : nbInputDims}), "sizes"); // already sets sizes dims
return resize_node;
}
} // namespace Aidge
namespace {
template <>
const char *const EnumStrings<Aidge::ResizeAttr>::data[] = {
"noROI",
"noScales",
"noSizes"
}; // do we keep it?
}
#endif /* AIDGE_CORE_OPERATOR_Resize_H_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment