/* * $File: comp_graph.i * * This file is part of MegBrain, a deep learning framework developed by Megvii. * * $Copyright: Copyright (c) 2014-2017 Megvii Inc. All rights reserved. */ %pythoncode{ from .mgb_helper import copy_output, FuncOutputSaver import json } // pythoncode %feature("autodoc", """a callable object compiled from :class:`CompGraph`. .. note:: Only the most recently compiled AsyncExec object can be used. """) AsyncExec; %feature("autodoc", """explicitly release the underlying staticially allocated device memory""") AsyncExec::clear_device_memory; class AsyncExec { public: AsyncExec() = delete; void _execute(); void _wait(); double _get_prev_exec_time(); std::string _to_json_str(); SymbolVarArray _find_mutable_input(); std::vector> _update_static_alloc_plan_and_get_size(); void clear_device_memory(); %include "comp_graph_impl_AsyncExec.py" }; %template(_VectorAsyncExec) std::vector; %feature("autodoc", """use device memory manager in another computing graph to manage memory of this graph, so their memories can be shared. This is safe only when :class:`AsyncExec` compiled from these graphs do not run concurrently.""") CompGraph::share_device_memory_with; %feature("valuewrapper") CompGraph; class CompGraph { public: CompGraph(); AsyncExec _do_compile(bool copy, bool optimize_for_inference); std::vector _do_compile_multi_part(); void _add_output_spec(SymbolVar &var, _CompGraphCallback *callback); void _add_multi_part_endpoint(); void _clear_output_spec(); size_t _release(); CompGraph& share_device_memory_with(CompGraph &other); PyObject* _user_data(); void clear_device_memory(); %extend { size_t _id() const { return $self->get().id(); } size_t _get_ptr_addr() const { return reinterpret_cast(&$self->get()); } std::string get_mem_allocation_info() const { return self->get().get_mem_allocation_info(); } std::string __repr__() const { auto &&graph = $self->get(); return mgb::ssprintf("", graph.id(), &graph); } } %include "comp_graph_impl_CompGraph.py" }; %include "comp_graph_tools.i" // vim: ft=swig