* @brief Class to calls custom operation
*/
class COpCall final : public VariadicArityNode<COpNode>,
- public loco::NodeMixin<loco::NodeTrait::TensorShape>
+ public loco::NodeMixin<loco::NodeTrait::TensorShape>,
+ public loco::NodeMixin<loco::NodeTrait::DataType>
{
public:
COpCall(unsigned arity) : VariadicArityNode<COpNode>(arity) {}
/// @brief Retrieve attr_data stored with attr_name
template <COpAttrType AT>
- const typename AttrTypeTrait<AT>::Type *attr(const std::string &attr_name);
+ const typename AttrTypeTrait<AT>::Type *attr(const std::string &attr_name) const;
/// @brief get all the names of attr
- std::vector<std::string> attr_names();
+ std::vector<std::string> attr_names() const;
private:
std::string _op;
{
template <COpAttrType AT>
-const typename AttrTypeTrait<AT>::Type *COpCall::attr(const std::string &attr_name)
+const typename AttrTypeTrait<AT>::Type *COpCall::attr(const std::string &attr_name) const
{
COpAttrData *attr_data;
- if (_attrs.find(attr_name) != _attrs.end())
+ auto found = _attrs.find(attr_name);
+ if (found != _attrs.end())
{
- attr_data = _attrs[attr_name].get();
+ attr_data = found->second.get();
return dynamic_cast<const typename AttrTypeTrait<AT>::Type *>(attr_data);
}
else
throw std::runtime_error("Attr already inserted");
}
-std::vector<std::string> COpCall::attr_names()
+std::vector<std::string> COpCall::attr_names() const
{
std::vector<std::string> attr_names;
- for (std::map<std::string, std::unique_ptr<COpAttrData>>::iterator it = _attrs.begin();
- it != _attrs.end(); ++it)
+ for (auto it = _attrs.cbegin(); it != _attrs.cend(); ++it)
{
attr_names.emplace_back(it->first);
}
return attr_names;
}
-#define INSTANTIATE(AT) \
- template const typename AttrTypeTrait<AT>::Type *COpCall::attr<AT>(const std::string &attr_name);
+#define INSTANTIATE(AT) \
+ template const typename AttrTypeTrait<AT>::Type *COpCall::attr<AT>(const std::string &attr_name) \
+ const;
INSTANTIATE(COpAttrType::Float)
INSTANTIATE(COpAttrType::Int)