You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by jr...@apache.org on 2020/11/05 21:41:18 UTC

[incubator-tvm] 22/23: WIP

This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch cargo-build
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git

commit e8bb83d33e7ad44ff16c72d9de61c2de722d12a8
Author: Jared Roesch <jr...@octoml.ai>
AuthorDate: Thu Oct 29 15:31:05 2020 -0700

    WIP
---
 rust/tvm/src/python.rs | 34 ++++++----------------------------
 1 file changed, 6 insertions(+), 28 deletions(-)

diff --git a/rust/tvm/src/python.rs b/rust/tvm/src/python.rs
index 2b2d374..50ce7b0 100644
--- a/rust/tvm/src/python.rs
+++ b/rust/tvm/src/python.rs
@@ -20,20 +20,6 @@
 use pyo3::prelude::*;
 use once_cell::sync::OnceCell;
 
-// static TVM_PYTHON: OnceCell<Py<PyModule>> = OnceCell::new();
-
-// fn initialize() -> Py<PyModule> {
-//     TVM_PYTHON.get_or_init(|| {
-//         let gil = Python::acquire_gil();
-//         let py = gil.python();
-//         PyModule::new(py, "__tvm__rust__module__").map_err(|e| {
-//             // We can't display Python exceptions via std::fmt::Display,
-//             // so print the error here manually.
-//             e.print_and_set_sys_last_vars(py);
-//         }).expect("failed to initialize the Python interface").into()
-//     }).clone()
-// }
-
 /// Load the Python interpreter into the address space.
 ///
 /// This enables the ability for Rust code to call TVM
@@ -53,27 +39,19 @@ pub fn load() -> Result<String, ()> {
     })
 }
 
-fn import_python<'p, 'b: 'p>(py: Python<'p>, to_import: &'b str) -> PyResult<&'p PyModule> {
-    let imported_mod = py.import(to_import)?;
-    PyModule::from_code(py,
-        r#"
-import tvm
-from tvm import relay
-tvm.cleanup()
-"#, "blah", "my_mod")?;
-    // py_mod.add(to_import, imported_mod)?;
-    Ok(imported_mod)
-}
-
 pub fn import(mod_to_import: &str) -> PyResult<()> {
     let gil = Python::acquire_gil();
     let py = gil.python();
-    // let main_mod = initialize();
-    // let main_mod = main_mod.as_ref(py);
     import_python(py, mod_to_import)?;
     Ok(())
 }
 
+fn import_python<'p, 'b: 'p>(py: Python<'p>, to_import: &'b str) -> PyResult<&'p PyModule> {
+    let imported_mod = py.import(to_import)?;
+    Ok(imported_mod)
+}
+
+
 fn load_python_tvm_(py: Python) -> PyResult<String> {
     let imported_mod = import_python(py, "tvm")?;
     let version: String = imported_mod.get("__version__")?.extract()?;