Skip to content
Snippets Groups Projects
Commit 5ff1d75c authored by Cyril Moineau's avatar Cyril Moineau
Browse files

getAvailableImplSpecs now return a vector for binding purposes.

parent 0d9dd30a
No related branches found
No related tags found
3 merge requests!279v0.4.0,!253v0.4.0,!163Export refactor
...@@ -28,7 +28,7 @@ class Operator; ...@@ -28,7 +28,7 @@ class Operator;
/** /**
* @brief ImplSpec stores the requirements or the specifications of an implementation. * @brief ImplSpec stores the requirements or the specifications of an implementation.
* *
*/ */
struct ImplSpec { struct ImplSpec {
struct IOSpec { struct IOSpec {
...@@ -73,10 +73,15 @@ inline bool operator<(const ImplSpec& lhs, const ImplSpec& rhs) { ...@@ -73,10 +73,15 @@ inline bool operator<(const ImplSpec& lhs, const ImplSpec& rhs) {
|| (lhs.inputs == rhs.inputs && lhs.outputs == rhs.outputs && lhs.attrs < rhs.attrs); || (lhs.inputs == rhs.inputs && lhs.outputs == rhs.outputs && lhs.attrs < rhs.attrs);
} }
inline bool operator==(const ImplSpec& lhs, const ImplSpec& rhs) {
return !(lhs < rhs) && !(rhs < lhs);
}
/** /**
* @brief Impl stores the details of a specific implementation. * @brief Impl stores the details of a specific implementation.
* It is associated to a ImplSpec in a registry. * It is associated to a ImplSpec in a registry.
* *
*/ */
template <class FwdFunc, class BwdFunc> template <class FwdFunc, class BwdFunc>
struct Impl { struct Impl {
...@@ -108,7 +113,7 @@ public: ...@@ -108,7 +113,7 @@ public:
/** /**
* @brief Get the operator required implementation specification, according * @brief Get the operator required implementation specification, according
* to the current operator configuration. * to the current operator configuration.
* *
*/ */
ImplSpec getRequiredSpec() const; ImplSpec getRequiredSpec() const;
...@@ -116,15 +121,15 @@ public: ...@@ -116,15 +121,15 @@ public:
* @brief Get the best implementation that matches \p requiredSpecs. * @brief Get the best implementation that matches \p requiredSpecs.
* If no implementation matches \p requiredSpecs, \p requiredSpecs is * If no implementation matches \p requiredSpecs, \p requiredSpecs is
* returned. * returned.
* *
*/ */
ImplSpec getBestMatch(const ImplSpec& requiredSpecs) const; ImplSpec getBestMatch(const ImplSpec& requiredSpecs) const;
/** /**
* @brief Get an adapted meta operator corresponding to the required * @brief Get an adapted meta operator corresponding to the required
* specifications \p requiredSpecs from the implementation specifications * specifications \p requiredSpecs from the implementation specifications
* \p spec. * \p spec.
* *
* @param spec Implementation specification * @param spec Implementation specification
* @param requiredSpecs Required specifications * @param requiredSpecs Required specifications
* @return std::shared_ptr<Node> Adapted meta op or nullptr * @return std::shared_ptr<Node> Adapted meta op or nullptr
...@@ -132,12 +137,12 @@ public: ...@@ -132,12 +137,12 @@ public:
std::shared_ptr<Node> getAdaptation(const ImplSpec& spec, const ImplSpec& requiredSpecs) const; std::shared_ptr<Node> getAdaptation(const ImplSpec& spec, const ImplSpec& requiredSpecs) const;
/** /**
* @brief Get the best adapted meta operator corresponding to the required * @brief Get the best adapted meta operator corresponding to the required
* specifications \p requiredSpecs. * specifications \p requiredSpecs.
* The best adaptation is the one with the lowest overhead cost. * The best adaptation is the one with the lowest overhead cost.
* Currently, it is the one requiring the least number of additionnal * Currently, it is the one requiring the least number of additionnal
* operators to match the available implementations. * operators to match the available implementations.
* *
* @param requiredSpecs Required specifications * @param requiredSpecs Required specifications
* @return std::shared_ptr<Node> Adapted meta op or nullptr * @return std::shared_ptr<Node> Adapted meta op or nullptr
*/ */
...@@ -147,7 +152,7 @@ public: ...@@ -147,7 +152,7 @@ public:
protected: protected:
virtual std::shared_ptr<ProdConso> getProdConso() const; virtual std::shared_ptr<ProdConso> getProdConso() const;
virtual std::set<ImplSpec> getAvailableImplSpecs() const; virtual std::vector<ImplSpec> getAvailableImplSpecs() const;
bool checkIOSpec(const ImplSpec::IOSpec& required, const ImplSpec::IOSpec& spec) const; bool checkIOSpec(const ImplSpec::IOSpec& required, const ImplSpec::IOSpec& spec) const;
const Operator &mOp; const Operator &mOp;
......
...@@ -55,9 +55,9 @@ public: ...@@ -55,9 +55,9 @@ public:
); );
} }
std::set<ImplSpec> getAvailableImplSpecs() const noexcept override { std::vector<ImplSpec> getAvailableImplSpecs() const noexcept override {
PYBIND11_OVERRIDE_NAME( PYBIND11_OVERRIDE_NAME(
std::set<ImplSpec>, std::vector<ImplSpec>,
OperatorImpl, OperatorImpl,
"get_available_impl_specs", "get_available_impl_specs",
getAvailableImplSpecs getAvailableImplSpecs
...@@ -81,6 +81,10 @@ void init_OperatorImpl(py::module& m){ ...@@ -81,6 +81,10 @@ void init_OperatorImpl(py::module& m){
.def(py::init<const DynamicAttributes&>(), py::arg("attr") = DynamicAttributes()) .def(py::init<const DynamicAttributes&>(), py::arg("attr") = DynamicAttributes())
.def(py::init<const ImplSpec::IOSpec&, const DynamicAttributes&>(), py::arg("io"), py::arg("attr") = DynamicAttributes()) .def(py::init<const ImplSpec::IOSpec&, const DynamicAttributes&>(), py::arg("io"), py::arg("attr") = DynamicAttributes())
.def(py::init<const ImplSpec::IOSpec&, const ImplSpec::IOSpec&, const DynamicAttributes&>(), py::arg("i"), py::arg("o"), py::arg("attr") = DynamicAttributes()) .def(py::init<const ImplSpec::IOSpec&, const ImplSpec::IOSpec&, const DynamicAttributes&>(), py::arg("i"), py::arg("o"), py::arg("attr") = DynamicAttributes())
.def("__eq__", static_cast<bool(*)(const ImplSpec&, const ImplSpec&)>(&operator==))
.def("__repr__", [](ImplSpec self){
return fmt::format("{}\n", self);
})
; ;
py::class_<OperatorImpl, std::shared_ptr<OperatorImpl>, pyOperatorImpl>(m, "OperatorImpl", py::dynamic_attr()) py::class_<OperatorImpl, std::shared_ptr<OperatorImpl>, pyOperatorImpl>(m, "OperatorImpl", py::dynamic_attr())
...@@ -98,4 +102,4 @@ void init_OperatorImpl(py::module& m){ ...@@ -98,4 +102,4 @@ void init_OperatorImpl(py::module& m){
.def("get_available_impl_specs", &OperatorImpl_Publicist::getAvailableImplSpecs) .def("get_available_impl_specs", &OperatorImpl_Publicist::getAvailableImplSpecs)
; ;
} }
} } // namespace Aidge
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