adelbertc commented on a change in pull request #5526:
URL: https://github.com/apache/incubator-tvm/pull/5526#discussion_r421878601



##########
File path: rust/tvm-sys/build.rs
##########
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+extern crate bindgen;
+
+use std::path::PathBuf;
+
+// extern crate cmake;
+
+use std::env;
+// use std::path::Path;
+// use std::process::Command;
+// use cmake::Config;
+
+// fn main() {
+//     if !Path::new("tvm/.git").exists() {

Review comment:
       Delete code?

##########
File path: rust/tvm-sys/build.rs
##########
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+extern crate bindgen;
+
+use std::path::PathBuf;
+
+// extern crate cmake;
+
+use std::env;
+// use std::path::Path;
+// use std::process::Command;
+// use cmake::Config;
+
+// fn main() {
+//     if !Path::new("tvm/.git").exists() {
+//         let _ = Command::new("git")
+//             .args(&["submodule", "update", "--recursive", "--init"])
+//             .status();
+//     }
+
+//     let dst = Config::new("tvm")
+//         .very_verbose(true)
+//         .build();
+
+//     // let dst = dst.join("build");
+
+//     let out_dir = env::var("OUT_DIR").unwrap();
+
+//     println!("{}", out_dir);
+//     // let _ = Command::new("mv")
+//     //     .args(&[format!("{}/build/libtvm.dylib", dst.display()), 
out_dir])
+//     //     .status();
+
+//     println!("cargo:rustc-link-search=native={}/lib", dst.display());
+//     // TODO(@jroesch): hack for dylib behavior
+//     for lib in &[/* "tvm", */ "tvm_runtime", /* "tvm_topi" */] {
+//         // let src = format!("{}/lib/lib{}.dylib", out_dir, lib);
+//         // let dst = format!("{}/../../../deps", out_dir);
+//         // let _ = Command::new("mv")
+//         //     .args(&[src, dst])
+//         //     .status();
+//         println!("cargo:rustc-link-lib=dylib={}", lib);
+//     }
+//     // "-Wl,-rpath,/scratch/library/"
+//     println!("cargo:rustc-env=TVM_HOME={}/build", dst.display());
+//     // panic!("");
+//     // cc::Build::new()
+//     //     .cpp(true)
+//     //     .flag("-std=c++11")
+//     //     .flag("-Wno-ignored-qualifiers")
+//     //     .flag("-Wno-unused-parameter")
+//     //     .include("/Users/jroesch/Git/tvm/include")
+//     //     .include("/Users/jroesch/Git/tvm/3rdparty/dmlc-core/include")
+//     //     .include("/Users/jroesch/Git/tvm/3rdparty/dlpack/include")
+//     //     .include("/Users/jroesch/Git/tvm/3rdparty/HalideIR/src")
+//     //     .file("tvm_wrapper.cc")
+//     //     .compile("tvm_ffi");
+//     // println!("cargo:rustc-link-lib=dylib=tvm");
+//     // println!("cargo:rustc-link-search=/Users/jroesch/Git/tvm/build");
+// }
+
+fn main() {
+    let tvm_home = option_env!("TVM_HOME").map(str::to_string).unwrap_or({
+        let crate_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
+            .canonicalize()
+            .unwrap();
+        crate_dir
+            .parent()
+            .unwrap()
+            .parent()
+            .unwrap()
+            .to_str()
+            .unwrap()
+            .to_string()
+    });
+
+    if cfg!(feature = "bindings") {
+        println!("cargo:rerun-if-env-changed=TVM_HOME");
+        // println!("cargo:rustc-link-lib=dylib=tvm_runtime");
+        // TODO: move to core
+        // println!("cargo:rustc-link-lib=dylib=tvm_runtime");

Review comment:
       Delete?

##########
File path: rust/tvm-sys/src/errors.rs
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use thiserror::Error;

Review comment:
       See my previous comment on using `thiserror`.

##########
File path: rust/tvm-sys/src/context.rs
##########
@@ -0,0 +1,285 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+//! Provides [`Context`] and related device queries.
+//!
+//! Create a new context for device type and device id.
+//!
+//! # Example
+//!
+//! ```
+//! # use tvm_sys::{DeviceType, Context};
+//! let cpu = DeviceType::from("cpu");
+//! let ctx = Context::new(cpu , 0);
+//! let cpu0 = Context::cpu(0);
+//! assert_eq!(ctx, cpu0);
+//! ```
+//!
+//! Or from a supported device name.
+//!
+//! ```
+//! use tvm_sys::Context;
+//! let cpu0 = Context::from("cpu");
+//! println!("{}", cpu0);
+//! ```
+
+use std::convert::TryFrom;
+use std::str::FromStr;
+use std::fmt::{self, Display, Formatter};
+
+use crate::ffi::{self, *};
+use crate::packed_func::{ArgValue, RetValue};
+
+use thiserror::Error;
+use anyhow::Result;

Review comment:
       My take is that libraries should not be using `anyhow::Error` and 
instead should use the stdlib mechanisms so as to not be prescriptive. For 
example the pattern used in 
[reqwest](https://docs.rs/reqwest/0.10.4/src/reqwest/error.rs.html#12-14) seems 
common in my experience. Just my 2c.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to