1 #include <torch/csrc/jit/passes/inplace_check.h> 2 3 namespace torch::jit { 4 CheckInplace(Block * block)5static void CheckInplace(Block* block) { 6 for (auto node : block->nodes()) { 7 if (node->kind() == prim::PythonOp && node->hasAttribute(attr::inplace)) { 8 if (node->i(attr::inplace)) { 9 throw std::runtime_error( 10 std::string("inplace ") + static_cast<PythonOp*>(node)->name() + 11 " not supported in the JIT"); 12 } 13 } 14 } 15 } 16 CheckInplace(std::shared_ptr<Graph> & graph)17void CheckInplace(std::shared_ptr<Graph>& graph) { 18 CheckInplace(graph->block()); 19 } 20 21 } // namespace torch::jit 22