You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/06/10 17:52:18 UTC

[GitHub] [incubator-tvm] mwillsey commented on a change in pull request #5764: [WIP] `tvm` crate stage 3 of Rust refactor

mwillsey commented on a change in pull request #5764:
URL: https://github.com/apache/incubator-tvm/pull/5764#discussion_r438302423



##########
File path: rust/runtime/tests/test_wasm32/Cargo.toml
##########
@@ -22,5 +22,6 @@ license = "Apache-2.0"
 authors = ["TVM Contributors"]
 
 [dependencies]
+anyhow = "*"

Review comment:
       ```suggestion
   anyhow = "1"
   ```
   
   Probably want to pin to 1 here.

##########
File path: rust/tvm/src/ir/array.rs
##########
@@ -0,0 +1,74 @@
+use std::convert::TryFrom;
+use std::marker::PhantomData;
+
+use crate::runtime::object::{ObjectRef, ToObjectRef};
+
+use tvm_rt::external;
+use tvm_rt::RetValue;
+
+use anyhow::Result;
+
+#[derive(Clone)]
+pub struct Array<T: ToObjectRef> {
+    object: ObjectRef,
+    _data: PhantomData<T>,
+}
+
+external! {
+    #[name("node.ArrayGetItem")]
+    fn array_get_item(array: ObjectRef, index: isize) -> ObjectRef;
+}
+
+impl<T: ToObjectRef> Array<T> {
+    pub fn from_vec(data: Vec<T>) -> Result<Array<T>> {
+        unimplemented!()

Review comment:
       Are these `unimplemented!`s intentional?

##########
File path: rust/tvm/examples/resnet/build.rs
##########
@@ -0,0 +1,42 @@
+/*
+ * 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 std::{path::Path, process::Command};
+
+fn main() {
+    let output = Command::new("python3")
+        .arg(concat!(env!("CARGO_MANIFEST_DIR"), "/src/build_resnet.py"))
+        .arg(&format!("--build-dir={}", env!("CARGO_MANIFEST_DIR")))
+        .output()
+        .expect("Failed to execute command");
+    assert!(
+        Path::new(&format!("{}/deploy_lib.o", env!("CARGO_MANIFEST_DIR"))).exists(),
+        "Could not prepare demo: {}",
+        String::from_utf8(output.stderr)
+            .unwrap()
+            .trim()
+            .split("\n")

Review comment:
       ```suggestion
               .lines()
   ```
   Might save you some Windows pain




----------------------------------------------------------------
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:
users@infra.apache.org