This repository was archived by the owner on Jan 3, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +52
-0
lines changed Expand file tree Collapse file tree 5 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -90,3 +90,9 @@ std::shared_ptr<runtime::Executable> runtime::Backend::load(istream& input_strea
9090{
9191 throw runtime_error (" load opertion unimplemented." );
9292}
93+
94+ bool runtime::Backend::set_config (const map<string, string>& config, string& error)
95+ {
96+ error = " set_config not supported" ;
97+ return false ;
98+ }
Original file line number Diff line number Diff line change @@ -139,4 +139,13 @@ class ngraph::runtime::Backend
139139 // \param op_name is the name of the backend specific op
140140 // \returns a shared pointer to the op if found, else nullptr
141141 virtual std::shared_ptr<ngraph::Node> get_backend_op (const std::string& op_name, ...);
142+
143+ // / \brief Allows sending backend specific configuration. The map contains key, value pairs
144+ // / specific to a particluar backend. The definition of these key, value pairs is
145+ // / defined by each backend.
146+ // / \param config The configuration map sent to the backend
147+ // / \param error An error string describing any error encountered
148+ // / \returns true if the configuration is supported, false otherwise. On false the error
149+ // / parameter value is valid.
150+ virtual bool set_config (const std::map<std::string, std::string>& config, std::string& error);
142151};
Original file line number Diff line number Diff line change @@ -105,3 +105,16 @@ std::shared_ptr<runtime::Executable> runtime::interpreter::INTBackend::load(istr
105105 }
106106 return exec;
107107}
108+
109+ bool runtime::interpreter::INTBackend::set_config (const map<string, string>& config, string& error)
110+ {
111+ bool rc = false ;
112+ auto it = config.find (" test_echo" );
113+ error = " " ;
114+ if (it != config.end ())
115+ {
116+ error = it->second ;
117+ rc = true ;
118+ }
119+ return rc;
120+ }
Original file line number Diff line number Diff line change @@ -58,6 +58,8 @@ class ngraph::runtime::interpreter::INTBackend : public Backend
5858
5959 bool is_supported (const Node& node) const override ;
6060
61+ bool set_config (const std::map<std::string, std::string>& config, std::string& error) override ;
62+
6163private:
6264 std::set<std::string> m_unsupported_op_name_list;
6365};
Original file line number Diff line number Diff line change @@ -37,6 +37,28 @@ TEST(backend_api, invalid_name)
3737 ASSERT_ANY_THROW (ngraph::runtime::Backend::create (" COMPLETELY-BOGUS-NAME" ));
3838}
3939
40+ TEST (backend_api, config)
41+ {
42+ auto backend = runtime::Backend::create (" INTERPRETER" );
43+ string error;
44+ string message = " hello" ;
45+ map<string, string> config = {{" test_echo" , message}};
46+ EXPECT_TRUE (backend->set_config (config, error));
47+ EXPECT_STREQ (error.c_str (), message.c_str ());
48+ EXPECT_FALSE (backend->set_config ({}, error));
49+ EXPECT_STREQ (error.c_str (), " " );
50+ }
51+
52+ TEST (backend_api, config_unsupported)
53+ {
54+ auto backend = runtime::Backend::create (" NOP" );
55+ string error;
56+ string message = " hello" ;
57+ map<string, string> config = {{" test_echo" , message}};
58+ EXPECT_FALSE (backend->set_config (config, error));
59+ EXPECT_FALSE (error == " " );
60+ }
61+
4062TEST (backend_api, save_load)
4163{
4264 Shape shape{2 , 2 };
You can’t perform that action at this time.
0 commit comments