rkimball commented on a change in pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656#discussion_r510302622



##########
File path: rust/tvm/src/ir/span.rs
##########
@@ -1,22 +1,75 @@
 /*
- * 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 crate::runtime::ObjectRef;
-
-pub type Span = ObjectRef;
+* 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 crate::runtime::{Object, ObjectRef, String as TString};
+use tvm_macros::Object;
+
+/// A source file name, contained in a Span.
+
+#[repr(C)]
+#[derive(Object)]
+#[type_key = "SourceName"]
+#[ref_name = "SourceName"]
+pub struct SourceNameNode {
+    pub base: Object,
+    pub name: TString,
+}
+
+//  /*!
+//   * \brief The source name of a file span.
+//   * \sa SourceNameNode, Span
+//   */
+//  class SourceName : public ObjectRef {
+//   public:
+//    /*!
+//     * \brief Get an SourceName for a given operator name.
+//     *  Will raise an error if the source name has not been registered.
+//     * \param name Name of the operator.
+//     * \return SourceName valid throughout program lifetime.
+//     */
+//    TVM_DLL static SourceName Get(const String& name);
+
+//    TVM_DEFINE_OBJECT_REF_METHODS(SourceName, ObjectRef, SourceNameNode);
+//  };

Review comment:
       Fix this double commented

##########
File path: rust/tvm/src/ir/diagnostics/mod.rs
##########
@@ -0,0 +1,233 @@
+/*
+ * 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 super::module::IRModule;
+use super::span::*;
+use crate::runtime::function::Result;
+use crate::runtime::object::{Object, ObjectPtr, ObjectRef};
+use crate::runtime::{
+    array::Array,
+    function::{self, Function, ToFunction},
+    string::String as TString,
+};
+/// The diagnostic interface to TVM, used for reporting and rendering
+/// diagnostic information by the compiler. This module exposes
+/// three key abstractions: a Diagnostic, the DiagnosticContext,
+/// and the DiagnosticRenderer.
+use tvm_macros::{external, Object};
+
+pub mod codespan;
+
+external! {
+    #[name("node.ArrayGetItem")]
+    fn get_renderer() -> DiagnosticRenderer;
+
+    #[name("diagnostics.DiagnosticRenderer")]
+    fn diagnostic_renderer(func: Function) -> DiagnosticRenderer;
+
+    #[name("diagnostics.Emit")]
+    fn emit(ctx: DiagnosticContext, diagnostic: Diagnostic) -> ();
+
+    #[name("diagnostics.DiagnosticContextRender")]
+    fn diagnostic_context_render(ctx: DiagnosticContext) -> ();
+
+    #[name("diagnostics.DiagnosticRendererRender")]
+    fn diagnositc_renderer_render(renderer: DiagnosticRenderer,ctx: 
DiagnosticContext) -> ();
+
+    #[name("diagnostics.ClearRenderer")]
+    fn clear_renderer() -> ();
+}
+
+/// The diagnostic level, controls the printing of the message.
+#[repr(C)]
+pub enum DiagnosticLevel {
+    Bug = 10,
+    Error = 20,
+    Warning = 30,
+    Note = 40,
+    Help = 50,
+}
+
+/// A compiler diagnostic.
+#[repr(C)]
+#[derive(Object)]
+#[ref_name = "Diagnostic"]
+#[type_key = "Diagnostic"]
+pub struct DiagnosticNode {
+    pub base: Object,
+    /// The level.
+    pub level: DiagnosticLevel,
+    /// The span at which to report an error.
+    pub span: Span,
+    /// The diagnostic message.
+    pub message: TString,
+}
+
+impl Diagnostic {
+    pub fn new(level: DiagnosticLevel, span: Span, message: TString) {
+        todo!()
+    }
+
+    pub fn bug(span: Span) -> DiagnosticBuilder {
+        todo!()
+    }
+
+    pub fn error(span: Span) -> DiagnosticBuilder {
+        todo!()
+    }
+
+    pub fn warning(span: Span) -> DiagnosticBuilder {
+        todo!()
+    }
+
+    pub fn note(span: Span) -> DiagnosticBuilder {
+        todo!()
+    }
+
+    pub fn help(span: Span) -> DiagnosticBuilder {
+        todo!()
+    }
+}
+
+/// A wrapper around std::stringstream to build a diagnostic.
+pub struct DiagnosticBuilder {
+    /// The level.
+    pub level: DiagnosticLevel,
+
+    /// The span of the diagnostic.
+    pub span: Span,
+
+    /// The in progress message.
+    pub message: String,
+}
+
+impl DiagnosticBuilder {
+    pub fn new(level: DiagnosticLevel, span: Span) -> DiagnosticBuilder {
+        DiagnosticBuilder { level, span, message: "".into() }
+    }
+}
+
+//   /*! \brief Display diagnostics in a given display format.
+//    *
+//    * A diagnostic renderer is responsible for converting the
+//    * raw diagnostics into consumable output.
+//    *
+//    * For example the terminal renderer will render a sequence
+//    * of compiler diagnostics to std::out and std::err in
+//    * a human readable form.
+//    */

Review comment:
       ```suggestion
   /// \brief Display diagnostics in a given display format.
   ///   
   /// A diagnostic renderer is responsible for converting the
   /// raw diagnostics into consumable output.
   ///  
   /// For example the terminal renderer will render a sequence
   /// of compiler diagnostics to std::out and std::err in
   /// a human readable form.
   ///
   ```

##########
File path: CMakeLists.txt
##########
@@ -79,6 +79,7 @@ tvm_option(USE_ARM_COMPUTE_LIB "Build with Arm Compute 
Library" OFF)
 tvm_option(USE_ARM_COMPUTE_LIB_GRAPH_RUNTIME "Build with Arm Compute Library 
graph runtime" OFF)
 tvm_option(USE_TENSORRT_CODEGEN "Build with TensorRT Codegen support" OFF)
 tvm_option(USE_TENSORRT_RUNTIME "Build with TensorRT runtime" OFF)
+tvm_option(USE_RUST_EXT "Build with Rust based compiler extensions" OFF)

Review comment:
       The help string should probably say something about STATIC and DYNAMIC

##########
File path: cmake/modules/RustExt.cmake
##########
@@ -0,0 +1,26 @@
+if(USE_RUST_EXT)
+    set(RUST_SRC_DIR "${CMAKE_SOURCE_DIR}/rust")
+    set(CARGO_OUT_DIR "${CMAKE_SOURCE_DIR}/rust/target")
+
+    if(USE_RUST_EXT STREQUAL "STATIC")
+        set(COMPILER_EXT_PATH "${CARGO_OUT_DIR}/release/libcompiler_ext.a")
+    elseif(USE_RUST_EXT STREQUAL "DYNAMIC")
+        set(COMPILER_EXT_PATH "${CARGO_OUT_DIR}/release/libcompiler_ext.so")
+    else()
+        message(FATAL_ERROR "invalid setting for RUST_EXT")

Review comment:
       ```suggestion
           message(FATAL_ERROR "invalid setting for USE_RUST_EXT")
   ```




----------------------------------------------------------------
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:
[email protected]


Reply via email to