1 #pragma once 2 3 #include <optional> 4 #include <string> 5 #include <unordered_map> 6 7 #include <torch/csrc/Export.h> 8 9 namespace torch::jit { 10 11 struct Graph; 12 struct Value; 13 14 // \brief Parse IR from \p STR constructing the corresponding IR in\ GRAPH. 15 // if parse_tensor_constants is true will construct empty tensors 16 // for Tensor constants with random or unitialized contents, otherwise will 17 // throw 18 TORCH_API void parseIR( 19 const std::string& str, 20 torch::jit::Graph* graph, 21 bool parse_tensor_constants = false); 22 23 /** \brief Parse IR from \p STR constructing the corresponding IR in\ GRAPH. 24 * 25 * \p VMAP is filled with String to Value pairs allowing to index Values in the 26 * newly created graph by their name in the original IR string. 27 * if parse_tensor_constants is true will construct empty tensors 28 * for Tensor constants with random or unitialized contents, otherwise will 29 * throw 30 */ 31 TORCH_API void parseIR( 32 const std::string& str, 33 torch::jit::Graph* graph, 34 std::unordered_map<std::string, Value*>& vmap, 35 bool parse_tensor_constants = false); 36 37 } // namespace torch::jit 38