[GitHub] [incubator-tvm] tqchen commented on a change in pull request #5863: [TIR][REFACTOR][API-CHANGE] Change Call.name to Call.op(RelayExpr)

2020-06-22 Thread GitBox


tqchen commented on a change in pull request #5863:
URL: https://github.com/apache/incubator-tvm/pull/5863#discussion_r443835313



##
File path: src/tir/op/builtin.cc
##
@@ -0,0 +1,155 @@
+/*
+ * 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.
+ */
+
+/*!
+ * \file tir/op/builtin.cc
+ *
+ *  builtin intrinsic operators.
+ */
+#include 
+#include 
+#include 
+#include 
+
+namespace tvm {
+namespace tir {
+namespace builtin {
+
+#define TIR_DEFINE_BUILTIN_FUNC(OpName)\
+  const Op& OpName() { \
+static const Op& op = Op::Get("tir." #OpName); \
+return op; \
+  }\
+  TVM_REGISTER_OP("tir." #OpName)
+
+TIR_DEFINE_BUILTIN_FUNC(reinterpret).set_num_inputs(1);
+
+TIR_DEFINE_BUILTIN_FUNC(likely).set_num_inputs(1).set_attr("TVectorizable",
 true);
+
+TIR_DEFINE_BUILTIN_FUNC(bitwise_and)
+.set_num_inputs(2)
+.set_attr("TVectorizable", true);
+
+TIR_DEFINE_BUILTIN_FUNC(bitwise_or)
+.set_num_inputs(2)
+.set_attr("TVectorizable", true);
+
+TIR_DEFINE_BUILTIN_FUNC(bitwise_xor)
+.set_num_inputs(2)
+.set_attr("TVectorizable", true);
+
+TIR_DEFINE_BUILTIN_FUNC(bitwise_not)
+.set_num_inputs(1)
+.set_attr("TVectorizable", true);
+
+TIR_DEFINE_BUILTIN_FUNC(shift_left)
+.set_num_inputs(2)
+.set_attr("TVectorizable", true);
+
+TIR_DEFINE_BUILTIN_FUNC(shift_right)
+.set_num_inputs(2)
+.set_attr("TVectorizable", true);
+
+TIR_DEFINE_BUILTIN_FUNC(large_uint_imm).set_num_inputs(2);
+
+TIR_DEFINE_BUILTIN_FUNC(address_of).set_num_inputs(1);
+
+TIR_DEFINE_BUILTIN_FUNC(if_then_else).set_num_inputs(3);
+
+TIR_DEFINE_BUILTIN_FUNC(isnullptr).set_num_inputs(1);
+
+TIR_DEFINE_BUILTIN_FUNC(isnan).set_num_inputs(1);
+
+TIR_DEFINE_BUILTIN_FUNC(popcount).set_num_inputs(1);
+
+TIR_DEFINE_BUILTIN_FUNC(fma).set_num_inputs(3).set_attr("TVectorizable",
 true);
+
+TIR_DEFINE_BUILTIN_FUNC(call_extern);
+
+TIR_DEFINE_BUILTIN_FUNC(call_llvm_intrin);
+
+TIR_DEFINE_BUILTIN_FUNC(call_spirv_glsl450);
+
+TIR_DEFINE_BUILTIN_FUNC(prefetch);
+
+TIR_DEFINE_BUILTIN_FUNC(tvm_access_ptr).set_num_inputs(5);
+
+TIR_DEFINE_BUILTIN_FUNC(tvm_static_handle).set_num_inputs(0);
+
+TIR_DEFINE_BUILTIN_FUNC(tvm_context_id).set_num_inputs(0);
+
+TIR_DEFINE_BUILTIN_FUNC(tvm_tuple);
+
+TIR_DEFINE_BUILTIN_FUNC(tvm_struct_get).set_num_inputs(3);
+
+TIR_DEFINE_BUILTIN_FUNC(tvm_struct_set).set_num_inputs(4);
+
+TIR_DEFINE_BUILTIN_FUNC(tvm_throw_last_error).set_num_inputs(0);
+
+TIR_DEFINE_BUILTIN_FUNC(tvm_stack_alloca).set_num_inputs(2);
+
+TIR_DEFINE_BUILTIN_FUNC(tvm_stack_make_shape);
+
+TIR_DEFINE_BUILTIN_FUNC(tvm_stack_make_array).set_num_inputs(6);
+
+// When num_inputs are not set, the function is assumed to be variable length.

Review comment:
   Not at the moment, so far we are only providing these information 
without checking them to ease migration. A checker is certainly an important 
followup step





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




[GitHub] [incubator-tvm] tqchen commented on a change in pull request #5863: [TIR][REFACTOR][API-CHANGE] Change Call.name to Call.op(RelayExpr)

2020-06-22 Thread GitBox


tqchen commented on a change in pull request #5863:
URL: https://github.com/apache/incubator-tvm/pull/5863#discussion_r443819279



##
File path: python/tvm/contrib/nvcc.py
##
@@ -98,7 +98,8 @@ def compile_cuda(code,
 (out, _) = proc.communicate()
 
 if proc.returncode != 0:
-msg = "Compilation error:\n"
+msg = code

Review comment:
   Yes, I find it is useful to append code along with error messages during 
debugging 





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




[GitHub] [incubator-tvm] tqchen commented on a change in pull request #5863: [TIR][REFACTOR][API-CHANGE] Change Call.name to Call.op(RelayExpr)

2020-06-22 Thread GitBox


tqchen commented on a change in pull request #5863:
URL: https://github.com/apache/incubator-tvm/pull/5863#discussion_r443819013



##
File path: include/tvm/tir/op_attr_types.h
##
@@ -0,0 +1,48 @@
+/*

Review comment:
   Most op belongs to either TIR primitive op or relay primitive op, so it 
might be fine to have parallels 





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




[GitHub] [incubator-tvm] tqchen commented on a change in pull request #5863: [TIR][REFACTOR][API-CHANGE] Change Call.name to Call.op(RelayExpr)

2020-06-22 Thread GitBox


tqchen commented on a change in pull request #5863:
URL: https://github.com/apache/incubator-tvm/pull/5863#discussion_r443818595



##
File path: include/tvm/tir/expr.h
##
@@ -888,66 +888,43 @@ class CallNode : public PrimExprNode {
 /*! \brief Intrinsic functions that are pure. */
 PureIntrinsic = 5
   };
-  /*! \brief The name of the function/intrinsic. */
-  String name;
+  /*!
+   * \brief The operator(function) being invoked
+   *
+   *  - It can be tvm::Op which corresponds to the primitive 
operators(intrinsics).
+   *  - It can also be another function in the IRModule (GlobalVar).
+   */
+  RelayExpr op;

Review comment:
   Any suggested alternatives and rationale?





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