[GitHub] [incubator-tvm] kazum commented on a change in pull request #5052: [TARGET] ONNX codegen
kazum commented on a change in pull request #5052: URL: https://github.com/apache/incubator-tvm/pull/5052#discussion_r429168772 ## File path: src/runtime/contrib/onnx/onnx_module.cc ## @@ -0,0 +1,65 @@ +/* + * 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 onnx_module.cc + * \brief ONNX Module without runtime support + */ +#include +#include +#include + +namespace tvm { +namespace codegen { +using namespace tvm::runtime; + +class ONNXSourceModuleNode : public runtime::ModuleNode { + public: + explicit ONNXSourceModuleNode(String code) : code_(code) {} + + const char* type_key() const { return "onnx"; } + + PackedFunc GetFunction(const std::string& name, const ObjectPtr& sptr_to_self) final { +LOG(FATAL) << "ONNX Source module cannot execute, to get executable module" + << " build TVM with 'onnx' runtime support"; +return PackedFunc(); + } + + std::string GetSource(const std::string& format) final { return code_; } Review comment: The content of `code_` is the source code of this module? If no, I think it's better to return an empty string. ## File path: tests/python/contrib/test_onnx.py ## @@ -0,0 +1,406 @@ +# 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. + +"""Relay to ONNX serialization test cases""" +import pytest +pytest.importorskip('onnx') +pytest.importorskip('onnxruntime') + +import numpy as np +import tvm +from tvm import relay +from tvm.contrib.target.onnx import to_onnx +import onnxruntime as rt + + +def func_to_onnx(func, name): +mod = tvm.IRModule() +mod['main'] = func +onnx_model = to_onnx(mod, {}, name, path=None) +return onnx_model.SerializeToString() + + +def run_onnx(onnx_model, input_data): +sess = rt.InferenceSession(onnx_model) +input_names = {} +for input, data in zip(sess.get_inputs(), input_data): +input_names[input.name] = data +output_name = sess.get_outputs()[0].name +res = sess.run([output_name], input_names) +return res[0] + + +def run_relay(func, data_tuple): +target = 'llvm' +ctx = tvm.context('llvm', 0) +intrp = relay.create_executor("graph", ctx=ctx, target=target) +relay_res = intrp.evaluate(func)(*data_tuple) +return relay_res.asnumpy() + + +def verify_results(relay_func, indata, test_name, rtol=1e-7, atol=0): +relay_res = run_relay(relay_func, indata) +onnx_res = run_onnx(func_to_onnx(relay_func, test_name), indata) +np.testing.assert_allclose(relay_res, onnx_res, rtol=rtol, atol=atol) + + +def test_add(): +dtype = 'float32' +t1 = relay.TensorType((5, 10, 5)) +t2 = relay.TensorType((5, 10, 5)) +x = relay.var("x", t1, dtype=dtype) +y = relay.var("y", t2, dtype=dtype) +z = relay.add(x, y) +func = relay.Function([x, y], z) + +x_data = np.random.rand(5, 10, 5).astype(dtype) +y_data = np.random.rand(5, 10, 5).astype(dtype) + +verify_results(func, [x_data, y_data], 'test_add') + + +def test_bias_add(): +for dtype in ['float16', 'float32']: +xshape = (10, 2, 3, 4) +bshape = (2,) +rtol = 1e-2 if dtype == 'float16' else 1e-5 +x = relay.var("x", shape=xshape, dtype=dtype) +bias = relay.var("bias", dtype=dtype) +z = relay.nn.bias_add(x, bias) +func = relay.Function([x, bias], z) + +x_data = np.random.uniform(size=xshape).astype(dtype) +y_data = np.random.uniform(size=bshape).astype(dtype) + +ve
[GitHub] [incubator-tvm] maheshambule commented on a change in pull request #5052: [TARGET] ONNX codegen
maheshambule commented on a change in pull request #5052: URL: https://github.com/apache/incubator-tvm/pull/5052#discussion_r429256748 ## File path: python/tvm/contrib/target/onnx.py ## @@ -0,0 +1,752 @@ +# 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. +# pylint: disable=invalid-name, import-self, len-as-condition, unused-argument, too-many-lines, redefined-builtin +"""Relay to ONNX codegen """ + +import os +import struct +import numpy +import onnx +import onnx.utils +from onnx import numpy_helper, OperatorSetIdProto, defs +import tvm +import tvm._ffi +from tvm.autotvm.graph_tuner.utils.traverse_graph import _expr2graph_impl +from tvm.relay.expr import Call, TupleGetItem, Var, Constant, Tuple + +ONNX_OPSET_VERSONS_SUPPORTED = [11] + + +def tvm_array_to_list(arr): +return tuple(x.value for x in arr) + + +def get_onnx_version(): +return onnx.__version__ + + +def add_input(data, name, model_container): +dtype = onnx.mapping.NP_TYPE_TO_TENSOR_TYPE[data.dtype] +tensor_value_info = onnx.helper.make_tensor_value_info(name, dtype, shape=data.shape) +model_container.add_inputs([tensor_value_info]) +data_tensor = numpy_helper.from_array(data, name) +model_container.add_initializers([data_tensor]) + + +class OpConverter(object): +""" Operator converter Base Class. +""" + +@classmethod +def convert_attributes(cls, attrs): +"""convert Relay attributes to ONNX attributes. + The derived classes should implement this method + if attributes are required by the operator + otherwise by default no attributes are passed +""" +return {} + +@classmethod +def convert(cls, node, model_container, node_list): +attrs = cls.convert_attributes(node['node'].attrs) +node = onnx.helper.make_node(cls.__name__, + node['input_names'], + node['output_names'], + **attrs) +model_container.add_nodes([node]) + + +def rename(op_name): +""" This method creates dynamic operator of name op_name with empty attributes +""" +return type(op_name, (OpConverter,), {}) + + +class Reshape(object): +""" Operator converter for Reshape. +""" + +@classmethod +def convert(cls, node, model_container, node_list): +"""Converts Relay operator Reshape to ONNX operator. + Relay operator accepts shape as attribute but ONNX operator + accepts it as a input. +""" + +shape = numpy.asarray([a.value for a in node['node'].attrs.newshape], + dtype=numpy.int64) +input_name = 'shape{}'.format(node['output_names'][0]) +node = onnx.helper.make_node(cls.__name__, [node['input_names'][0], input_name], + node['output_names']) +model_container.add_nodes([node]) +add_input(shape, input_name, model_container) + + +class Conv(OpConverter): +""" Operator converter for Conv. +""" + +@classmethod +def convert_attributes(cls, attrs): +return { +'group': attrs.get_int("groups"), +'pads': attrs.get_int_tuple("padding"), +'strides': attrs.get_int_tuple("strides"), +'dilations': attrs.get_int_tuple("dilation"), +'kernel_shape': attrs.get_int_tuple("kernel_size"), +} + + +class MaxPool(OpConverter): +""" Operator converter for MaxPool. +""" + +@classmethod +def convert_attributes(cls, attrs): +return { +'pads': attrs.get_int_tuple("padding"), +'strides': attrs.get_int_tuple("strides"), +'kernel_shape': attrs.get_int_tuple("pool_size"), +} + + +class Transpose(OpConverter): +""" Operator converter for Transpose. +""" + +@classmethod +def convert_attributes(cls, attrs): +return {'perm': attrs.get_int_tuple("axes")} if attrs["axes"] else {} + + +class MatMul(OpConverter): +""" Operator converter for MatMul. +""" + +@classmethod +def convert(cls, node, model_container, node_list): +output_name = 'inter{}'.format(node['output_names'][0]
[GitHub] [incubator-tvm] maheshambule commented on a change in pull request #5052: [TARGET] ONNX codegen
maheshambule commented on a change in pull request #5052: URL: https://github.com/apache/incubator-tvm/pull/5052#discussion_r429256951 ## File path: python/tvm/contrib/target/onnx.py ## @@ -0,0 +1,752 @@ +# 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. +# pylint: disable=invalid-name, import-self, len-as-condition, unused-argument, too-many-lines, redefined-builtin +"""Relay to ONNX codegen """ + +import os +import struct +import numpy +import onnx +import onnx.utils +from onnx import numpy_helper, OperatorSetIdProto, defs +import tvm +import tvm._ffi +from tvm.autotvm.graph_tuner.utils.traverse_graph import _expr2graph_impl +from tvm.relay.expr import Call, TupleGetItem, Var, Constant, Tuple + +ONNX_OPSET_VERSONS_SUPPORTED = [11] + + +def tvm_array_to_list(arr): +return tuple(x.value for x in arr) + + +def get_onnx_version(): +return onnx.__version__ + + +def add_input(data, name, model_container): +dtype = onnx.mapping.NP_TYPE_TO_TENSOR_TYPE[data.dtype] +tensor_value_info = onnx.helper.make_tensor_value_info(name, dtype, shape=data.shape) +model_container.add_inputs([tensor_value_info]) +data_tensor = numpy_helper.from_array(data, name) +model_container.add_initializers([data_tensor]) + + +class OpConverter(object): +""" Operator converter Base Class. +""" + +@classmethod +def convert_attributes(cls, attrs): +"""convert Relay attributes to ONNX attributes. + The derived classes should implement this method + if attributes are required by the operator + otherwise by default no attributes are passed +""" +return {} + +@classmethod +def convert(cls, node, model_container, node_list): +attrs = cls.convert_attributes(node['node'].attrs) +node = onnx.helper.make_node(cls.__name__, + node['input_names'], + node['output_names'], + **attrs) +model_container.add_nodes([node]) + + +def rename(op_name): +""" This method creates dynamic operator of name op_name with empty attributes +""" +return type(op_name, (OpConverter,), {}) + + +class Reshape(object): +""" Operator converter for Reshape. +""" + +@classmethod +def convert(cls, node, model_container, node_list): +"""Converts Relay operator Reshape to ONNX operator. + Relay operator accepts shape as attribute but ONNX operator + accepts it as a input. +""" + +shape = numpy.asarray([a.value for a in node['node'].attrs.newshape], + dtype=numpy.int64) +input_name = 'shape{}'.format(node['output_names'][0]) +node = onnx.helper.make_node(cls.__name__, [node['input_names'][0], input_name], + node['output_names']) +model_container.add_nodes([node]) +add_input(shape, input_name, model_container) + + +class Conv(OpConverter): +""" Operator converter for Conv. +""" + +@classmethod +def convert_attributes(cls, attrs): +return { +'group': attrs.get_int("groups"), +'pads': attrs.get_int_tuple("padding"), +'strides': attrs.get_int_tuple("strides"), +'dilations': attrs.get_int_tuple("dilation"), +'kernel_shape': attrs.get_int_tuple("kernel_size"), +} + + +class MaxPool(OpConverter): +""" Operator converter for MaxPool. +""" + +@classmethod +def convert_attributes(cls, attrs): +return { +'pads': attrs.get_int_tuple("padding"), +'strides': attrs.get_int_tuple("strides"), +'kernel_shape': attrs.get_int_tuple("pool_size"), +} + + +class Transpose(OpConverter): +""" Operator converter for Transpose. +""" + +@classmethod +def convert_attributes(cls, attrs): +return {'perm': attrs.get_int_tuple("axes")} if attrs["axes"] else {} + + +class MatMul(OpConverter): +""" Operator converter for MatMul. +""" + +@classmethod +def convert(cls, node, model_container, node_list): +output_name = 'inter{}'.format(node['output_names'][0]
[GitHub] [incubator-tvm] maheshambule commented on a change in pull request #5052: [TARGET] ONNX codegen
maheshambule commented on a change in pull request #5052: URL: https://github.com/apache/incubator-tvm/pull/5052#discussion_r429260012 ## File path: src/runtime/contrib/onnx/onnx_module.cc ## @@ -0,0 +1,65 @@ +/* + * 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 onnx_module.cc + * \brief ONNX Module without runtime support + */ +#include +#include +#include + +namespace tvm { +namespace codegen { +using namespace tvm::runtime; + +class ONNXSourceModuleNode : public runtime::ModuleNode { + public: + explicit ONNXSourceModuleNode(String code) : code_(code) {} + + const char* type_key() const { return "onnx"; } + + PackedFunc GetFunction(const std::string& name, const ObjectPtr& sptr_to_self) final { +LOG(FATAL) << "ONNX Source module cannot execute, to get executable module" + << " build TVM with 'onnx' runtime support"; +return PackedFunc(); + } + + std::string GetSource(const std::string& format) final { return code_; } Review comment: The ```code_``` contains hex string of subgraph's ModelProto protobuf which can be converted back to ModelProto. 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] maheshambule commented on a change in pull request #5052: [TARGET] ONNX codegen
maheshambule commented on a change in pull request #5052: URL: https://github.com/apache/incubator-tvm/pull/5052#discussion_r429260135 ## File path: tests/python/contrib/test_onnx.py ## @@ -0,0 +1,406 @@ +# 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. + +"""Relay to ONNX serialization test cases""" +import pytest +pytest.importorskip('onnx') +pytest.importorskip('onnxruntime') + +import numpy as np +import tvm +from tvm import relay +from tvm.contrib.target.onnx import to_onnx +import onnxruntime as rt + + +def func_to_onnx(func, name): +mod = tvm.IRModule() +mod['main'] = func +onnx_model = to_onnx(mod, {}, name, path=None) +return onnx_model.SerializeToString() + + +def run_onnx(onnx_model, input_data): +sess = rt.InferenceSession(onnx_model) +input_names = {} +for input, data in zip(sess.get_inputs(), input_data): +input_names[input.name] = data +output_name = sess.get_outputs()[0].name +res = sess.run([output_name], input_names) +return res[0] + + +def run_relay(func, data_tuple): +target = 'llvm' +ctx = tvm.context('llvm', 0) +intrp = relay.create_executor("graph", ctx=ctx, target=target) +relay_res = intrp.evaluate(func)(*data_tuple) +return relay_res.asnumpy() + + +def verify_results(relay_func, indata, test_name, rtol=1e-7, atol=0): +relay_res = run_relay(relay_func, indata) +onnx_res = run_onnx(func_to_onnx(relay_func, test_name), indata) +np.testing.assert_allclose(relay_res, onnx_res, rtol=rtol, atol=atol) + + +def test_add(): +dtype = 'float32' +t1 = relay.TensorType((5, 10, 5)) +t2 = relay.TensorType((5, 10, 5)) +x = relay.var("x", t1, dtype=dtype) +y = relay.var("y", t2, dtype=dtype) +z = relay.add(x, y) +func = relay.Function([x, y], z) + +x_data = np.random.rand(5, 10, 5).astype(dtype) +y_data = np.random.rand(5, 10, 5).astype(dtype) + +verify_results(func, [x_data, y_data], 'test_add') + + +def test_bias_add(): +for dtype in ['float16', 'float32']: +xshape = (10, 2, 3, 4) +bshape = (2,) +rtol = 1e-2 if dtype == 'float16' else 1e-5 +x = relay.var("x", shape=xshape, dtype=dtype) +bias = relay.var("bias", dtype=dtype) +z = relay.nn.bias_add(x, bias) +func = relay.Function([x, bias], z) + +x_data = np.random.uniform(size=xshape).astype(dtype) +y_data = np.random.uniform(size=bshape).astype(dtype) + +verify_results(func, [x_data, y_data], 'test_bias_add', rtol=rtol) + + +def test_conv2d(): +def verify_conv2d(dtype, scale, dshape, kshape, + padding=(1, 1), + groups=1, + dilation=(1, 1), + **attrs): +x = relay.var("x", shape=dshape, dtype=dtype) +w = relay.var("w", shape=kshape, dtype=dtype) +y = relay.nn.conv2d(x, w, +padding=padding, +dilation=dilation, +groups=groups, +**attrs) +func = relay.Function([x, w], y) +data = np.random.uniform(-scale, scale, size=dshape).astype(dtype) +kernel = np.random.uniform(-scale, scale, size=kshape).astype(dtype) +verify_results(func, [data, kernel], 'test_conv2d', rtol=1e-5, atol=1e-5) + +dshape = (1, 32, 18, 18) +kshape = (32, 1, 3, 3) +verify_conv2d("float32", 1, dshape, kshape, + padding=(1, 1), channels=32, groups=32, kernel_size=(3, 3)) + +dshape = (1, 32, 18, 18) +kshape = (32, 4, 3, 3) +verify_conv2d("float32", 1, dshape, kshape, + padding=(1, 1), channels=32, groups=8, kernel_size=(3, 3)) + +# also group conv2d +dshape = (1, 32, 18, 18) +kshape = (64, 1, 3, 3) +verify_conv2d("float32", 1, dshape, kshape, + padding=(1, 1), channels=64, groups=32, kernel_size=(3, 3)) + +# normal conv2d +dshape = (1, 3, 224, 224) +kshape = (10, 3, 3, 3) +verify_conv2d("float32", 1, dshape, kshape, + padding=(1, 1), channels=10, kernel_size=(3, 3)) + +dshape = (1, 3, 224, 224) +kshape = (10, 3, 3, 3) +verify_conv2d("float32", 1
[GitHub] [incubator-tvm] maheshambule commented on a change in pull request #5052: [TARGET] ONNX codegen
maheshambule commented on a change in pull request #5052: URL: https://github.com/apache/incubator-tvm/pull/5052#discussion_r429260948 ## File path: python/tvm/contrib/codegen_onnx.py ## @@ -0,0 +1,752 @@ +# 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 +# Review comment: done 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 pull request #5645: [TARGET] add amd_gpu target
tqchen commented on pull request #5645: URL: https://github.com/apache/incubator-tvm/pull/5645#issuecomment-632731324 See the example case above(the link to mali log) which uses the opencl, but have a separate log by itself 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 opened a new pull request #5649: [AutoTVM] Update XGBoost verbosity option
tqchen opened a new pull request #5649: URL: https://github.com/apache/incubator-tvm/pull/5649 cc @liangfu @hcho3 @merrymercy 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] srkreddy1238 commented on a change in pull request #5052: [TARGET] ONNX codegen
srkreddy1238 commented on a change in pull request #5052: URL: https://github.com/apache/incubator-tvm/pull/5052#discussion_r429299616 ## File path: tests/python/contrib/test_onnx.py ## @@ -0,0 +1,393 @@ +# 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. + +"""Relay to ONNX serialization test cases""" +import pytest +pytest.importorskip('onnx') +pytest.importorskip('onnxruntime') + +import numpy as np +import tvm +from tvm import relay +from tvm.contrib.target.onnx import to_onnx +import onnxruntime as rt + + +def func_to_onnx(func, name): +mod = tvm.IRModule() +mod['main'] = func +onnx_model = to_onnx(mod, {}, name, path=None) +return onnx_model.SerializeToString() + + +def run_onnx(onnx_model, input_data): +sess = rt.InferenceSession(onnx_model) +input_names = {} +for input, data in zip(sess.get_inputs(), input_data): +input_names[input.name] = data +output_name = sess.get_outputs()[0].name +res = sess.run([output_name], input_names) +return res[0] + + +def run_relay(func, data_tuple): +target = 'llvm' +ctx = tvm.context('llvm', 0) +intrp = relay.create_executor("graph", ctx=ctx, target=target) +relay_res = intrp.evaluate(func)(*data_tuple) +return relay_res.asnumpy() + + +def verify_results(relay_func, indata, test_name, rtol=1e-7, atol=0): +relay_res = run_relay(relay_func, indata) +onnx_res = run_onnx(func_to_onnx(relay_func, test_name), indata) +np.testing.assert_allclose(relay_res, onnx_res, rtol=rtol, atol=atol) + + +def test_add(): +dtype = 'float32' +t1 = relay.TensorType((5, 10, 5)) +t2 = relay.TensorType((5, 10, 5)) +x = relay.var("x", t1, dtype=dtype) +y = relay.var("y", t2, dtype=dtype) +z = relay.add(x, y) +func = relay.Function([x, y], z) + +x_data = np.random.rand(5, 10, 5).astype(dtype) +y_data = np.random.rand(5, 10, 5).astype(dtype) + +verify_results(func, [x_data, y_data], 'test_add') + + +def test_bias_add(): +for dtype in ['float16', 'float32']: +xshape = (10, 2, 3, 4) +bshape = (2,) +rtol = 1e-2 if dtype == 'float16' else 1e-5 +x = relay.var("x", shape=xshape, dtype=dtype) +bias = relay.var("bias", dtype=dtype) +z = relay.nn.bias_add(x, bias) +func = relay.Function([x, bias], z) + +x_data = np.random.uniform(size=xshape).astype(dtype) +y_data = np.random.uniform(size=bshape).astype(dtype) + +verify_results(func, [x_data, y_data], 'test_bias_add', rtol=rtol) + + +def test_conv2d(): +def verify_conv2d(dtype, scale, dshape, kshape, + padding=(1, 1), + groups=1, + dilation=(1, 1), + **attrs): +x = relay.var("x", shape=dshape, dtype=dtype) +w = relay.var("w", shape=kshape, dtype=dtype) +y = relay.nn.conv2d(x, w, +padding=padding, +dilation=dilation, +groups=groups, +**attrs) +func = relay.Function([x, w], y) +data = np.random.uniform(-scale, scale, size=dshape).astype(dtype) +kernel = np.random.uniform(-scale, scale, size=kshape).astype(dtype) +verify_results(func, [data, kernel], 'test_conv2d', rtol=1e-5, atol=1e-5) + +dshape = (1, 32, 18, 18) +kshape = (32, 1, 3, 3) +verify_conv2d("float32", 1, dshape, kshape, + padding=(1, 1), channels=32, groups=32, kernel_size=(3, 3)) + +dshape = (1, 32, 18, 18) +kshape = (32, 4, 3, 3) +verify_conv2d("float32", 1, dshape, kshape, + padding=(1, 1), channels=32, groups=8, kernel_size=(3, 3)) + +# also group conv2d +dshape = (1, 32, 18, 18) +kshape = (64, 1, 3, 3) +verify_conv2d("float32", 1, dshape, kshape, + padding=(1, 1), channels=64, groups=32, kernel_size=(3, 3)) + +# normal conv2d +dshape = (1, 3, 224, 224) +kshape = (10, 3, 3, 3) +verify_conv2d("float32", 1, dshape, kshape, + padding=(1, 1), channels=10, kernel_size=(3, 3)) + +dshape = (1, 3, 224, 224) +kshape = (10, 3, 3, 3) +verify_conv2d("float32", 1
[GitHub] [incubator-tvm] tqchen commented on issue #5650: [REFACTOR] PassContext.fallback_device -> PassConfig.config
tqchen commented on issue #5650: URL: https://github.com/apache/incubator-tvm/issues/5650#issuecomment-632740723 cc @zhiics 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 opened a new issue #5650: [REFACTOR] PassContext.fallback_device -> PassConfig.config
tqchen opened a new issue #5650: URL: https://github.com/apache/incubator-tvm/issues/5650 https://github.com/apache/incubator-tvm/pull/5631 Introduces a generic config mechanism to store the pass configuration options. Given that fallback_device is a pas related config, We should probably also migrate PassContext->fallback_device to a special config. e.g.` relay.fallback_device_type` with IntImmNode as its node type 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 edited a comment on issue #5650: [REFACTOR] PassContext.fallback_device -> PassConfig.config
tqchen edited a comment on issue #5650: URL: https://github.com/apache/incubator-tvm/issues/5650#issuecomment-632740723 cc @zhiics @comaniac 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 issue #5373: [REFACTOR][TIR] Migrate HoistIfThenElse to the unified pass manager
tqchen commented on issue #5373: URL: https://github.com/apache/incubator-tvm/issues/5373#issuecomment-632750012 ping @kevinthesun 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] zhiics commented on issue #5650: [REFACTOR] PassContext.fallback_device -> PassConfig.config
zhiics commented on issue #5650: URL: https://github.com/apache/incubator-tvm/issues/5650#issuecomment-632751624 @tqchen Thanks for reminding. I will take a stab next week. 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] areusch commented on pull request #5648: µtvm debug improvements
areusch commented on pull request #5648: URL: https://github.com/apache/incubator-tvm/pull/5648#issuecomment-632754557 @tqchen @tmoreau89 @liangfu @weberlo @u99127 @tom-gall 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 pull request #5651: [RUNTIME] Resolve constexpr issue in debug mode.
tqchen commented on pull request #5651: URL: https://github.com/apache/incubator-tvm/pull/5651#issuecomment-632776222 cc @junrushao1994 @ZihengJiang @jroesch 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 opened a new pull request #5651: [RUNTIME] Resolve constexpr issue in debug mode.
tqchen opened a new pull request #5651: URL: https://github.com/apache/incubator-tvm/pull/5651 static constexpr is a bit weird before c++17. They are not inlined by default and does not have symbols after compilation. It usually isn't a problem when they are inlined(in c++17 they are inlined by default). But will create compilation error when passed to functions that take (const)references. This PR fixes the problem so that we can compile on debugmode. 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] junrushao1994 commented on pull request #5651: [RUNTIME] Resolve constexpr issue in debug mode.
junrushao1994 commented on pull request #5651: URL: https://github.com/apache/incubator-tvm/pull/5651#issuecomment-632786346 Interesting. I think I met this before but didn’t know the root cause. Thank you for the explanation!! 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
[incubator-tvm] branch master updated: HG: Commit message of changeset 6281661. (#5622)
This is an automated email from the ASF dual-hosted git repository. zhic pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git The following commit(s) were added to refs/heads/master by this push: new dbb8be7 HG: Commit message of changeset 6281661. (#5622) dbb8be7 is described below commit dbb8be79908a1e15ccf2028f634b9c6c170b19d7 Author: hlu1 <14827759+h...@users.noreply.github.com> AuthorDate: Fri May 22 09:38:30 2020 -0700 HG: Commit message of changeset 6281661. (#5622) [Relay] Move compiler_begin/end_op to local static objects --- src/relay/analysis/util.cc | 12 ++-- src/relay/transforms/annotate_target.cc| 15 +++ src/relay/transforms/merge_compiler_regions.cc | 18 +++--- src/relay/transforms/partition_graph.cc| 17 ++--- src/relay/transforms/pass_util.h | 20 src/runtime/object.cc | 1 + 6 files changed, 47 insertions(+), 36 deletions(-) diff --git a/src/relay/analysis/util.cc b/src/relay/analysis/util.cc index 6d246c0..a05bb8f 100644 --- a/src/relay/analysis/util.cc +++ b/src/relay/analysis/util.cc @@ -338,13 +338,13 @@ bool IsNDArrayAllGreaterEqual(const runtime::NDArray& tensor, T value) { return true; } -// Cache the operators that are checked recursively to reduce lookup overhead. -static const auto& expand_dims_op = Op::Get("expand_dims"); -static const auto& reshape_op = Op::Get("reshape"); -static const auto& transpose_op = Op::Get("transpose"); -static const auto& squeeze_op = Op::Get("squeeze"); - bool IsAllPositiveConstant(const Expr& expr) { + // Cache the operators that are checked recursively to reduce lookup overhead. + static const auto& expand_dims_op = Op::Get("expand_dims"); + static const auto& reshape_op = Op::Get("reshape"); + static const auto& transpose_op = Op::Get("transpose"); + static const auto& squeeze_op = Op::Get("squeeze"); + // peel through a few common transform ops. if (const auto* constant = expr.as()) { const auto& tensor = constant->data; diff --git a/src/relay/transforms/annotate_target.cc b/src/relay/transforms/annotate_target.cc index 0d97005..bf2788f 100644 --- a/src/relay/transforms/annotate_target.cc +++ b/src/relay/transforms/annotate_target.cc @@ -29,13 +29,12 @@ #include #include +#include "pass_util.h" + namespace tvm { namespace relay { namespace annotate_target { -static const Op& compiler_begin_op = Op::Get("annotation.compiler_begin"); -static const Op& compiler_end_op = Op::Get("annotation.compiler_end"); - const PackedFunc* make_begin_op = runtime::Registry::Get("relay.op.annotation._make.compiler_begin"); const PackedFunc* make_end_op = runtime::Registry::Get("relay.op.annotation._make.compiler_end"); @@ -66,12 +65,12 @@ class AnnotateTargetRewriter : public ExprRewriter { std::string arg_target = "default"; const CallNode* call = arg.as(); - if (call && call->op == compiler_begin_op) { + if (call && call->op == CompilerBeginOp()) { // Argument is already compiler begin node meaning that this is not the first time // running this pass, so we simply remove it and will add a new one later. CHECK_EQ(call->args.size(), 1U); const CallNode* end = call->args[0].as(); -if (end->op == compiler_end_op) { +if (end->op == CompilerEndOp()) { arg_target = end->attrs.as()->compiler; } compiler_ends.push_back(call->args[0]); @@ -115,12 +114,12 @@ class AnnotateTargetRewriter : public ExprRewriter { auto op_node = pre->op.as(); // This graph has annotations, meaning that this is not the first time running this pass. -if (op_node && pre->op == compiler_begin_op) { +if (op_node && pre->op == CompilerBeginOp()) { // Bypass compiler begin due to lack of target information. It will be processed // when the following op handling arguments. CHECK_EQ(pre->args.size(), 1U); return post.as()->args[0]; -} else if (op_node && pre->op == compiler_end_op) { +} else if (op_node && pre->op == CompilerEndOp()) { // Override compiler end with the new target. CHECK_EQ(pre->args.size(), 1U); auto input_expr = post.as()->args[0]; @@ -131,7 +130,7 @@ class AnnotateTargetRewriter : public ExprRewriter { // Peek the first argument. If it is compiler begin then this node had annotated by // another target before, so we also consider that target as a supported target. const CallNode* first_arg_call = pre->args[0].as(); -if (first_arg_call && first_arg_call->op == compiler_begin_op) { +if (first_arg_call && first_arg_call->op == CompilerBeginOp()) { std::string arg_target = first_arg_call->attrs.as()->compiler; if (arg_target != "default") { supported_targets.push_back(arg_target); diff --git a/src
[GitHub] [incubator-tvm] zhiics merged pull request #5622: [Relay] Move compiler_begin/end_op to local static objects
zhiics merged pull request #5622: URL: https://github.com/apache/incubator-tvm/pull/5622 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 pull request #5652: [TIR][BUILD] Remove buffer params from pass config.
tqchen commented on pull request #5652: URL: https://github.com/apache/incubator-tvm/pull/5652#issuecomment-632791420 cc @ZihengJiang @zhiics 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 opened a new pull request #5652: [TIR][BUILD] Remove buffer params from pass config.
tqchen opened a new pull request #5652: URL: https://github.com/apache/incubator-tvm/pull/5652 Buffer configurations can be passed during construction and does not need to be part of the build config. This is a refactor step to simplify the buildconfig for the PassContext migration. 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] zhiics commented on pull request #5622: [Relay] Move compiler_begin/end_op to local static objects
zhiics commented on pull request #5622: URL: https://github.com/apache/incubator-tvm/pull/5622#issuecomment-632791073 Thanks @hlu1 @tqchen 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] mbrookhart opened a new pull request #5653: Convert PatternGrouper to do pre-order, non-recursive analysis
mbrookhart opened a new pull request #5653: URL: https://github.com/apache/incubator-tvm/pull/5653 Fixes https://github.com/apache/incubator-tvm/issues/5647 @comaniac @masahi Thanks! 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] srkreddy1238 commented on a change in pull request #5617: [TENSORFLOW]StatefulPartitionedCall/PartitionedCall Ops support added
srkreddy1238 commented on a change in pull request #5617: URL: https://github.com/apache/incubator-tvm/pull/5617#discussion_r429331590 ## File path: python/tvm/relay/frontend/tensorflow.py ## @@ -2896,15 +2903,29 @@ def _parse_import_prerequisites(self, graph): """ missing_operators = set() for node in graph.node: +try: +from tensorflow.python.framework import op_def_registry Review comment: Can you confirm is op_def_registry is not part of all TF versions ? pls confirn. If this is not in 1.x we shouldn't error as the front end is compatible to TF 1.x now. ## File path: tests/python/frontend/tensorflow/test_forward.py ## @@ -3179,10 +3183,342 @@ def test_forward_isfinite(): _verify_infiniteness_ops(tf.is_finite, "isfinite") +def _test_spop_placeholder_one(): +with tf.Graph().as_default(): Review comment: Advice to use appropriate name instead of _one / _two ...etc. ## File path: python/tvm/relay/frontend/tensorflow.py ## @@ -3155,6 +3176,91 @@ def _convert_control_flow_operator(self, node, inputs, attrs, control_flow_node_ return op +def _partition_call_operator(self, inputs, attr): +""" +Convert the Relay Partition call ops into Relay Function calls and +function definitions from Tensorflow graph library attribute to Relay global +functions + +Parameters +-- +node: TensorFlow graph node object. +A TensorFlow graph node object. + +inputs : List[tvm.relay.Expr] +List of input symbols. + +attrs : Dict[tvm.Attrs] +Dict of operator attributes. + +Returns +--- +op : tvm.relay.Expr +Converted relay expression. +""" + +try: +from tensorflow.python.framework import function_def_to_graph +except ImportError as e: +raise ImportError( +"Unable to import tensorflow which is required {}".format(e)) + +main_graph_proto = self._main_graph_proto +outer_graph_def = main_graph_proto._graph + +node_func_name = attr.get('f').name +func = next((f for f in outer_graph_def.library.function + if f.signature.name == node_func_name), None) +if func: +devices = set(node.device for node in func.node_def) +if len(devices) > 1: +raise Exception("Found inconsistent Device assignment in the "\ +"Stateful Partitioned SubGraph. Rejecting "\ +"the subgraph ") +# Convert function definition to graph +func_input_shapes = func.attr["_input_shapes"].list.shape +subgraph, _ = function_def_to_graph.\ +function_def_to_graph_def(func, func_input_shapes) + +# Computing subgraph's input shape dictionary +subgraph_shape_dict, input_expr_dict = {}, {} +for f_arg, input in zip(func.signature.input_arg, inputs): +input_expr_dict[f_arg.name] = input +subgraph_shape_dict[f_arg.name] = _infer_shape(input, main_graph_proto._mod) + +func_name = 'func_{}'.format(func.signature.name) +try: +global_func = main_graph_proto._mod[func_name] Review comment: Is this the case where the function is called multiple times with in a graph ? ## File path: python/tvm/relay/frontend/tensorflow.py ## @@ -2896,15 +2903,29 @@ def _parse_import_prerequisites(self, graph): """ missing_operators = set() for node in graph.node: +try: +from tensorflow.python.framework import op_def_registry +except ImportError as e: +raise ImportError( +"Unable to import tensorflow which is required {}".format(e)) +getOpDef = op_def_registry._registered_ops.get if hasattr(op_def_registry,\ +"_registered_ops") else op_def_registry.get +op_def = getOpDef(node.op) if node.op == "Placeholder" or node.op == 'PlaceholderWithDefault': pass elif node.op == "Const": pass +elif node.op in ["PartitionedCall", "StatefulPartitionedCall"]: +pass else: if any([node.op in t for t in [_identity_list, _convert_map, _convert_map_rnn, _control_flow_nodes]]): pass +elif op_def is not None and op_def.is_stateful: +raise Exception("Found a stateful operator in this graph {}. "\ Review comment: Better to add this to missing op list (with extended info if needed) still inste
[GitHub] [incubator-tvm] u99127 commented on a change in pull request #5648: µtvm debug improvements
u99127 commented on a change in pull request #5648: URL: https://github.com/apache/incubator-tvm/pull/5648#discussion_r429357376 ## File path: src/runtime/micro/host_driven/utvm_runtime.c ## @@ -101,7 +101,7 @@ void UTVMMain() { // We use a dummy function to signal execution is finished for device // backends which require breakpoints. -void __attribute__((noinline)) UTVMDone() { utvm_done = 1; } +void __attribute__((noinline,noreturn)) UTVMDone() { utvm_done = 1; for (;;) ; } Review comment: Would we want this to trap ever in which case a __builtin_trap might be a trick to play ? 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] tom-gall commented on pull request #5648: µtvm debug improvements
tom-gall commented on pull request #5648: URL: https://github.com/apache/incubator-tvm/pull/5648#issuecomment-632824516 LGTM 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] ANSHUMAN87 opened a new pull request #5654: [REFACTOR][IR] Migrate IRModule ObjectRef to not-null
ANSHUMAN87 opened a new pull request #5654: URL: https://github.com/apache/incubator-tvm/pull/5654 Refer #5318 @tqchen : Please help review, Thanks! 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] ANSHUMAN87 commented on pull request #5625: [Arith] ExtendedEuclidean merge impl to int_operator
ANSHUMAN87 commented on pull request #5625: URL: https://github.com/apache/incubator-tvm/pull/5625#issuecomment-632827740 @yzhliu : Gentle ping! 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] ANSHUMAN87 commented on pull request #5654: [REFACTOR][IR] Migrate IRModule ObjectRef to not-null
ANSHUMAN87 commented on pull request #5654: URL: https://github.com/apache/incubator-tvm/pull/5654#issuecomment-632830825 There are 2 approaches followed here to solve Optional issue in exposed APIs. A0: Using Optional way as mentioned in the reference link. (Ref src/relay/analysis/feature.cc) A1: Making API user provide Empty IRModule. (Ref python/tvm/relay/transform/transform.py) Please let me know, if we should follow only A0 strictly. TIA! 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 merged pull request #5649: [AutoTVM] Update XGBoost verbosity option
tqchen merged pull request #5649: URL: https://github.com/apache/incubator-tvm/pull/5649 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
[incubator-tvm] branch master updated (dbb8be7 -> b26f988)
This is an automated email from the ASF dual-hosted git repository. tqchen pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git. from dbb8be7 HG: Commit message of changeset 6281661. (#5622) add b26f988 [AutoTVM] Update XGBoost verbosity option (#5649) No new revisions were added by this update. Summary of changes: python/tvm/autotvm/tuner/xgboost_cost_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[GitHub] [incubator-tvm] mei-ye closed pull request #5645: [TARGET] add amd_gpu target
mei-ye closed pull request #5645: URL: https://github.com/apache/incubator-tvm/pull/5645 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] tom-gall opened a new pull request #5655: Add MicroTVM tutorial using the STM32F746 discovery board
tom-gall opened a new pull request #5655: URL: https://github.com/apache/incubator-tvm/pull/5655 Add MicroTVM tutorial using the STM32F746 discovery board with a sample tflite model Signed-off-by: Tom Gall Thanks for contributing to TVM! Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @ them in the pull request thread. 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] jroesch merged pull request #5651: [RUNTIME] Resolve constexpr issue in debug mode.
jroesch merged pull request #5651: URL: https://github.com/apache/incubator-tvm/pull/5651 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
[incubator-tvm] branch master updated: [RUNTIME] Resolve constexpr issue in debug mode. (#5651)
This is an automated email from the ASF dual-hosted git repository. jroesch pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git The following commit(s) were added to refs/heads/master by this push: new 896557d [RUNTIME] Resolve constexpr issue in debug mode. (#5651) 896557d is described below commit 896557d935999391dcc8bda001fb67d79e2f9ef8 Author: Tianqi Chen AuthorDate: Fri May 22 13:36:43 2020 -0700 [RUNTIME] Resolve constexpr issue in debug mode. (#5651) static constexpr is a bit weird before c++17. They are not inlined by default and does not have symbols after compilation. It usually isn't a problem when they are inlined(in c++17 they are inlined by default). But will create compilation error when passed to functions that take (const)references. This PR fixes the problem so that we can compile on debugmode. --- include/tvm/runtime/container.h | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/tvm/runtime/container.h b/include/tvm/runtime/container.h index a52e997..1569c67 100644 --- a/include/tvm/runtime/container.h +++ b/include/tvm/runtime/container.h @@ -491,10 +491,10 @@ class ArrayNode : public Object, public InplaceArrayBase { int64_t capacity_; /*! \brief Initial size of ArrayNode */ - static const constexpr int64_t kInitSize = 4; + static constexpr int64_t kInitSize = 4; /*! \brief Expansion factor of the Array */ - static const constexpr int64_t kIncFactor = 2; + static constexpr int64_t kIncFactor = 2; // CRTP parent class friend InplaceArrayBase; @@ -929,7 +929,9 @@ class Array : public ObjectRef { ArrayNode* CopyOnWrite(int64_t reserve_extra) { ArrayNode* p = GetArrayNode(); if (p == nullptr) { - return SwitchContainer(std::max(ArrayNode::kInitSize, reserve_extra)); + // necessary to get around the constexpr address issue before c++17 + const int64_t kInitSize = ArrayNode::kInitSize; + return SwitchContainer(std::max(kInitSize, reserve_extra)); } if (p->capacity_ >= p->size_ + reserve_extra) { return CopyOnWrite();
[GitHub] [incubator-tvm] comaniac opened a new pull request #5656: [BYOC] Pattern Language MergeComposite
comaniac opened a new pull request #5656: URL: https://github.com/apache/incubator-tvm/pull/5656 This PR uses the new Relay pattern language to simplify the `MergeComposite` pass implementation. Here are some highlights and discussions: - **After this PR, the patterns for composite functions must be rewritten.** - All patterns in the unit tests are rewritten to be DFPattern. - All unit tests are passed with the simplified implementation. - The `MergeComposite` pass implementation becomes a simple wrapper to call `PartitionPattern`. - I'll add a test case for a pattern with `optional` after #5653 is merged. cc @mbrookhart @mbaret @masahi @zhiics 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] areusch commented on a change in pull request #5648: µtvm debug improvements
areusch commented on a change in pull request #5648: URL: https://github.com/apache/incubator-tvm/pull/5648#discussion_r429446488 ## File path: src/runtime/micro/host_driven/utvm_runtime.c ## @@ -101,7 +101,7 @@ void UTVMMain() { // We use a dummy function to signal execution is finished for device // backends which require breakpoints. -void __attribute__((noinline)) UTVMDone() { utvm_done = 1; } +void __attribute__((noinline,noreturn)) UTVMDone() { utvm_done = 1; for (;;) ; } Review comment: I think at the moment, since we aren't installing a predictable ISR vector table, we should avoid triggering those. but we can revisit approaches like this when we switch to on-device runtime. 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] masahi commented on a change in pull request #5653: [PatternLang] Convert PatternGrouper to do pre-order, non-recursive analysis
masahi commented on a change in pull request #5653: URL: https://github.com/apache/incubator-tvm/pull/5653#discussion_r429449194 ## File path: src/relay/ir/dataflow_matcher.cc ## @@ -432,26 +432,39 @@ class PatternGrouper : protected MixedModeVisitor { const std::vector& GroupMatches(const DFPattern& pattern, const Expr& pre) { groups_ = {Group()}; gid_assignments_.clear(); -visit_counter_.clear(); pattern_ = pattern; pattern_graph_ = CreateIndexedGraph(pattern_); auto matcher = DFPatternMatcher(pre); matcher_ = &matcher; -this->VisitExpr(pre); +this->VisitExprs(); return this->groups_; } protected: - using ExprVisitor::VisitExpr_; - void VisitLeaf(const Expr& pre) override { -if (matcher_->Match(pattern_, pre)) { - CreateGroup(pre); -} - } - void VisitExpr_(const FunctionNode* op) override { -if (op->attrs->dict.count(attr::kPartitionedFromPattern) == 0) { - ExprVisitor::VisitExpr_(op); + /* \brief Iteratively traverse the Expression in pre-order to find subgraphs + * + * If we traverse the graph in post-order, we can run into situtations where a small subgraph will + * match the pattern. Due to options like AltPattern, a larger subgraph with more nodes later in + * the graph may also match the pattern. With post-order traversal, we mark the smaller subgraph + * as matched and fail to catch the larger subgraph. This problem is fixed by using pre-order + * traversal. + */ + void VisitExprs() { +std::unordered_set pre_partitioned; +for (size_t i = matcher_->expr_graph_.topological_order_.size(); i != 0; --i) { + size_t index = i - 1; Review comment: Having both `i` and `index` seems redundant. 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] vinx13 opened a new pull request #5657: [Relay,Topi][OP] affine_grid and grid_sample
vinx13 opened a new pull request #5657: URL: https://github.com/apache/incubator-tvm/pull/5657 This PR added the `affine_grid` and `grid_sample` operator introduced in [Spatial Transformer Networks](https://arxiv.org/abs/1506.02025). API reference: MXNet: [GridGenerator](https://beta.mxnet.io/api/ndarray/_autogen/mxnet.ndarray.GridGenerator.html), [BilinearSampler](https://beta.mxnet.io/api/ndarray/_autogen/mxnet.ndarray.BilinearSampler.html) Pytorch: [affine_grid](https://pytorch.org/docs/stable/nn.functional.html?highlight=affine_grid#torch.nn.functional.affine_grid), [grid_sample](https://pytorch.org/docs/master/nn.functional.html#torch.nn.functional.grid_sample) cc @masahi @icemelon9 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] masahi commented on a change in pull request #5653: [PatternLang] Convert PatternGrouper to do pre-order, non-recursive analysis
masahi commented on a change in pull request #5653: URL: https://github.com/apache/incubator-tvm/pull/5653#discussion_r429449194 ## File path: src/relay/ir/dataflow_matcher.cc ## @@ -432,26 +432,39 @@ class PatternGrouper : protected MixedModeVisitor { const std::vector& GroupMatches(const DFPattern& pattern, const Expr& pre) { groups_ = {Group()}; gid_assignments_.clear(); -visit_counter_.clear(); pattern_ = pattern; pattern_graph_ = CreateIndexedGraph(pattern_); auto matcher = DFPatternMatcher(pre); matcher_ = &matcher; -this->VisitExpr(pre); +this->VisitExprs(); return this->groups_; } protected: - using ExprVisitor::VisitExpr_; - void VisitLeaf(const Expr& pre) override { -if (matcher_->Match(pattern_, pre)) { - CreateGroup(pre); -} - } - void VisitExpr_(const FunctionNode* op) override { -if (op->attrs->dict.count(attr::kPartitionedFromPattern) == 0) { - ExprVisitor::VisitExpr_(op); + /* \brief Iteratively traverse the Expression in pre-order to find subgraphs + * + * If we traverse the graph in post-order, we can run into situtations where a small subgraph will + * match the pattern. Due to options like AltPattern, a larger subgraph with more nodes later in + * the graph may also match the pattern. With post-order traversal, we mark the smaller subgraph + * as matched and fail to catch the larger subgraph. This problem is fixed by using pre-order + * traversal. + */ + void VisitExprs() { +std::unordered_set pre_partitioned; +for (size_t i = matcher_->expr_graph_.topological_order_.size(); i != 0; --i) { + size_t index = i - 1; Review comment: Having both `i` and `index` seems redundant. Why not ``` for (size_t i = matcher_->expr_graph_.topological_order_.size() - 1; i >= 0; --i) ``` 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] tmoreau89 merged pull request #5648: µtvm debug improvements
tmoreau89 merged pull request #5648: URL: https://github.com/apache/incubator-tvm/pull/5648 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
[incubator-tvm] branch master updated (896557d -> 3e074c5)
This is an automated email from the ASF dual-hosted git repository. moreau pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git. from 896557d [RUNTIME] Resolve constexpr issue in debug mode. (#5651) add 3e074c5 µtvm debug improvements (#5648) No new revisions were added by this update. Summary of changes: python/tvm/micro/base.py | 3 +- python/tvm/micro/device/host.py | 1 + src/runtime/micro/host_driven/utvm_runtime.c | 8 - src/runtime/micro/micro_session.cc | 53 src/runtime/micro/micro_session.h| 4 ++- 5 files changed, 44 insertions(+), 25 deletions(-)
[GitHub] [incubator-tvm] masahi commented on pull request #5657: [Relay,Topi][OP] affine_grid and grid_sample
masahi commented on pull request #5657: URL: https://github.com/apache/incubator-tvm/pull/5657#issuecomment-632907557 interesting. 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] comaniac closed issue #5647: [PatternLang] pattern.partition doesn't include the last optional op.
comaniac closed issue #5647: URL: https://github.com/apache/incubator-tvm/issues/5647 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] comaniac commented on issue #5647: [PatternLang] pattern.partition doesn't include the last optional op.
comaniac commented on issue #5647: URL: https://github.com/apache/incubator-tvm/issues/5647#issuecomment-632907849 Thanks @mbrookhart for the quick fix :) 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] tom-gall commented on pull request #5655: Add MicroTVM tutorial using the STM32F746 discovery board
tom-gall commented on pull request #5655: URL: https://github.com/apache/incubator-tvm/pull/5655#issuecomment-632915897 @areusch 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
[incubator-tvm] branch master updated (3e074c5 -> 9fa8341)
This is an automated email from the ASF dual-hosted git repository. tqchen pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git. from 3e074c5 µtvm debug improvements (#5648) add 9fa8341 [REFACTOR][IR] Migrate IRModule ObjectRef to not-null (#5654) No new revisions were added by this update. Summary of changes: include/tvm/ir/module.h| 12 +--- python/tvm/relay/transform/transform.py| 3 ++- src/relay/analysis/feature.cc | 7 +-- src/relay/analysis/match_exhaustion.cc | 7 ++- src/relay/backend/compile_engine.h | 2 +- src/relay/backend/graph_runtime_codegen.cc | 4 ++-- src/relay/transforms/gradient.cc | 14 -- src/tir/transforms/split_host_device.cc| 2 +- 8 files changed, 26 insertions(+), 25 deletions(-)
[GitHub] [incubator-tvm] tqchen commented on pull request #5654: [REFACTOR][IR] Migrate IRModule ObjectRef to not-null
tqchen commented on pull request #5654: URL: https://github.com/apache/incubator-tvm/pull/5654#issuecomment-632916889 Thanks @ANSHUMAN87 @jroesch ! 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 merged pull request #5654: [REFACTOR][IR] Migrate IRModule ObjectRef to not-null
tqchen merged pull request #5654: URL: https://github.com/apache/incubator-tvm/pull/5654 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] tom-gall edited a comment on pull request #5655: Add MicroTVM tutorial using the STM32F746 discovery board
tom-gall edited a comment on pull request #5655: URL: https://github.com/apache/incubator-tvm/pull/5655#issuecomment-632915897 @areusch @u99127 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] hcho3 opened a new pull request #5658: Upgrade XGBoost to latest
hcho3 opened a new pull request #5658: URL: https://github.com/apache/incubator-tvm/pull/5658 Now that #4953 is fixed in latest XGBoost release (1.1.0), upgrade XGBoost. 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] mbrookhart commented on a change in pull request #5653: [PatternLang] Convert PatternGrouper to do pre-order, non-recursive analysis
mbrookhart commented on a change in pull request #5653: URL: https://github.com/apache/incubator-tvm/pull/5653#discussion_r429468918 ## File path: src/relay/ir/dataflow_matcher.cc ## @@ -432,26 +432,39 @@ class PatternGrouper : protected MixedModeVisitor { const std::vector& GroupMatches(const DFPattern& pattern, const Expr& pre) { groups_ = {Group()}; gid_assignments_.clear(); -visit_counter_.clear(); pattern_ = pattern; pattern_graph_ = CreateIndexedGraph(pattern_); auto matcher = DFPatternMatcher(pre); matcher_ = &matcher; -this->VisitExpr(pre); +this->VisitExprs(); return this->groups_; } protected: - using ExprVisitor::VisitExpr_; - void VisitLeaf(const Expr& pre) override { -if (matcher_->Match(pattern_, pre)) { - CreateGroup(pre); -} - } - void VisitExpr_(const FunctionNode* op) override { -if (op->attrs->dict.count(attr::kPartitionedFromPattern) == 0) { - ExprVisitor::VisitExpr_(op); + /* \brief Iteratively traverse the Expression in pre-order to find subgraphs + * + * If we traverse the graph in post-order, we can run into situtations where a small subgraph will + * match the pattern. Due to options like AltPattern, a larger subgraph with more nodes later in + * the graph may also match the pattern. With post-order traversal, we mark the smaller subgraph + * as matched and fail to catch the larger subgraph. This problem is fixed by using pre-order + * traversal. + */ + void VisitExprs() { +std::unordered_set pre_partitioned; +for (size_t i = matcher_->expr_graph_.topological_order_.size(); i != 0; --i) { + size_t index = i - 1; Review comment: This is something I was too lazy to debug. If I iterate over something of size 4 with the constraint `i > 0`, I get 3 iterations with i = 3, 2, 1 If I use the line you gave me, I get 5 iterations, with i = 3, 2, 1, 0, 18446744073709551615 as the size_t underflows. I can't figure out _why_ that line screws up 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] mbrookhart commented on a change in pull request #5653: [PatternLang] Convert PatternGrouper to do pre-order, non-recursive analysis
mbrookhart commented on a change in pull request #5653: URL: https://github.com/apache/incubator-tvm/pull/5653#discussion_r429471161 ## File path: src/relay/ir/dataflow_matcher.cc ## @@ -432,26 +432,39 @@ class PatternGrouper : protected MixedModeVisitor { const std::vector& GroupMatches(const DFPattern& pattern, const Expr& pre) { groups_ = {Group()}; gid_assignments_.clear(); -visit_counter_.clear(); pattern_ = pattern; pattern_graph_ = CreateIndexedGraph(pattern_); auto matcher = DFPatternMatcher(pre); matcher_ = &matcher; -this->VisitExpr(pre); +this->VisitExprs(); return this->groups_; } protected: - using ExprVisitor::VisitExpr_; - void VisitLeaf(const Expr& pre) override { -if (matcher_->Match(pattern_, pre)) { - CreateGroup(pre); -} - } - void VisitExpr_(const FunctionNode* op) override { -if (op->attrs->dict.count(attr::kPartitionedFromPattern) == 0) { - ExprVisitor::VisitExpr_(op); + /* \brief Iteratively traverse the Expression in pre-order to find subgraphs + * + * If we traverse the graph in post-order, we can run into situtations where a small subgraph will + * match the pattern. Due to options like AltPattern, a larger subgraph with more nodes later in + * the graph may also match the pattern. With post-order traversal, we mark the smaller subgraph + * as matched and fail to catch the larger subgraph. This problem is fixed by using pre-order + * traversal. + */ + void VisitExprs() { +std::unordered_set pre_partitioned; +for (size_t i = matcher_->expr_graph_.topological_order_.size(); i != 0; --i) { + size_t index = i - 1; Review comment: Ah, nvm, I see. Of course i >=0, it's a size_t. I need to use an int. 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] mbrookhart commented on a change in pull request #5653: [PatternLang] Convert PatternGrouper to do pre-order, non-recursive analysis
mbrookhart commented on a change in pull request #5653: URL: https://github.com/apache/incubator-tvm/pull/5653#discussion_r429468918 ## File path: src/relay/ir/dataflow_matcher.cc ## @@ -432,26 +432,39 @@ class PatternGrouper : protected MixedModeVisitor { const std::vector& GroupMatches(const DFPattern& pattern, const Expr& pre) { groups_ = {Group()}; gid_assignments_.clear(); -visit_counter_.clear(); pattern_ = pattern; pattern_graph_ = CreateIndexedGraph(pattern_); auto matcher = DFPatternMatcher(pre); matcher_ = &matcher; -this->VisitExpr(pre); +this->VisitExprs(); return this->groups_; } protected: - using ExprVisitor::VisitExpr_; - void VisitLeaf(const Expr& pre) override { -if (matcher_->Match(pattern_, pre)) { - CreateGroup(pre); -} - } - void VisitExpr_(const FunctionNode* op) override { -if (op->attrs->dict.count(attr::kPartitionedFromPattern) == 0) { - ExprVisitor::VisitExpr_(op); + /* \brief Iteratively traverse the Expression in pre-order to find subgraphs + * + * If we traverse the graph in post-order, we can run into situtations where a small subgraph will + * match the pattern. Due to options like AltPattern, a larger subgraph with more nodes later in + * the graph may also match the pattern. With post-order traversal, we mark the smaller subgraph + * as matched and fail to catch the larger subgraph. This problem is fixed by using pre-order + * traversal. + */ + void VisitExprs() { +std::unordered_set pre_partitioned; +for (size_t i = matcher_->expr_graph_.topological_order_.size(); i != 0; --i) { + size_t index = i - 1; Review comment: This is something I was too lazy to debug. If I iterate over something of size 4 with the constraint `i > 0`, I get 3 iterations with i = 3, 2, 1 If I use the line you gave me, I get 5 iterations, with i = 3, 2, 1, 0, 18446744073709551615 as the size_t underflows. 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] mei-ye opened a new pull request #5659: enable amd_apu device on vulkan target
mei-ye opened a new pull request #5659: URL: https://github.com/apache/incubator-tvm/pull/5659 Thanks for contributing to TVM! Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @ them in the pull request thread. enable amd_apu device on vulkan target. @tqchen, @tmoreau89 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] areusch opened a new pull request #5660: Increase bss section size.
areusch opened a new pull request #5660: URL: https://github.com/apache/incubator-tvm/pull/5660 * Likely broken in PR 5590. This fix unbreaks `tests/micro/test_runtime_micro_on_arm.py` for me. Let's bump the global default, since this is a minimal test case. 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 pull request #5659: enable amd_apu device on vulkan target
tqchen commented on pull request #5659: URL: https://github.com/apache/incubator-tvm/pull/5659#issuecomment-632929975 Thanks @mei-ye , assigning @tmoreau89 BTW, you do not have to reopen another PR for the updates, you can just force push to your original branch and the PR will be updated. 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] areusch commented on pull request #5660: Increase bss section size.
areusch commented on pull request #5660: URL: https://github.com/apache/incubator-tvm/pull/5660#issuecomment-632930007 @tqchen @tmoreau89 @liangfu @weberlo @u99127 @tom-gall 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] masahi commented on a change in pull request #5653: [PatternLang] Convert PatternGrouper to do pre-order, non-recursive analysis
masahi commented on a change in pull request #5653: URL: https://github.com/apache/incubator-tvm/pull/5653#discussion_r429477179 ## File path: src/relay/ir/dataflow_matcher.cc ## @@ -432,26 +432,39 @@ class PatternGrouper : protected MixedModeVisitor { const std::vector& GroupMatches(const DFPattern& pattern, const Expr& pre) { groups_ = {Group()}; gid_assignments_.clear(); -visit_counter_.clear(); pattern_ = pattern; pattern_graph_ = CreateIndexedGraph(pattern_); auto matcher = DFPatternMatcher(pre); matcher_ = &matcher; -this->VisitExpr(pre); +this->VisitExprs(); return this->groups_; } protected: - using ExprVisitor::VisitExpr_; - void VisitLeaf(const Expr& pre) override { -if (matcher_->Match(pattern_, pre)) { - CreateGroup(pre); -} - } - void VisitExpr_(const FunctionNode* op) override { -if (op->attrs->dict.count(attr::kPartitionedFromPattern) == 0) { - ExprVisitor::VisitExpr_(op); + /* \brief Iteratively traverse the Expression in pre-order to find subgraphs + * + * If we traverse the graph in post-order, we can run into situtations where a small subgraph will + * match the pattern. Due to options like AltPattern, a larger subgraph with more nodes later in + * the graph may also match the pattern. With post-order traversal, we mark the smaller subgraph + * as matched and fail to catch the larger subgraph. This problem is fixed by using pre-order + * traversal. + */ + void VisitExprs() { +std::unordered_set pre_partitioned; +for (size_t i = matcher_->expr_graph_.topological_order_.size(); i != 0; --i) { + size_t index = i - 1; Review comment: Ah sorry you are right. What I suggested may get a warning from compiler I think (size_t to int conversion). Moreover, `matcher_->expr_graph_.topological_order_.size() - 1` would wrap around if `matcher_->expr_graph_.topological_order_` is empty. So I think your original code is safer. Can you undo the last commit? Sorry about this. 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] masahi commented on a change in pull request #5653: [PatternLang] Convert PatternGrouper to do pre-order, non-recursive analysis
masahi commented on a change in pull request #5653: URL: https://github.com/apache/incubator-tvm/pull/5653#discussion_r429477179 ## File path: src/relay/ir/dataflow_matcher.cc ## @@ -432,26 +432,39 @@ class PatternGrouper : protected MixedModeVisitor { const std::vector& GroupMatches(const DFPattern& pattern, const Expr& pre) { groups_ = {Group()}; gid_assignments_.clear(); -visit_counter_.clear(); pattern_ = pattern; pattern_graph_ = CreateIndexedGraph(pattern_); auto matcher = DFPatternMatcher(pre); matcher_ = &matcher; -this->VisitExpr(pre); +this->VisitExprs(); return this->groups_; } protected: - using ExprVisitor::VisitExpr_; - void VisitLeaf(const Expr& pre) override { -if (matcher_->Match(pattern_, pre)) { - CreateGroup(pre); -} - } - void VisitExpr_(const FunctionNode* op) override { -if (op->attrs->dict.count(attr::kPartitionedFromPattern) == 0) { - ExprVisitor::VisitExpr_(op); + /* \brief Iteratively traverse the Expression in pre-order to find subgraphs + * + * If we traverse the graph in post-order, we can run into situtations where a small subgraph will + * match the pattern. Due to options like AltPattern, a larger subgraph with more nodes later in + * the graph may also match the pattern. With post-order traversal, we mark the smaller subgraph + * as matched and fail to catch the larger subgraph. This problem is fixed by using pre-order + * traversal. + */ + void VisitExprs() { +std::unordered_set pre_partitioned; +for (size_t i = matcher_->expr_graph_.topological_order_.size(); i != 0; --i) { + size_t index = i - 1; Review comment: Ah sorry you are right. What I suggested may get a warning from compiler I think (size_t to int conversion). Moreover, `matcher_->expr_graph_.topological_order_.size() - 1` would wrap around if `matcher_->expr_graph_.topological_order_` is empty (not sure if this is possible). So I think your original code is safer. Can you undo the last commit? Sorry about this. 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] mbrookhart commented on a change in pull request #5653: [PatternLang] Convert PatternGrouper to do pre-order, non-recursive analysis
mbrookhart commented on a change in pull request #5653: URL: https://github.com/apache/incubator-tvm/pull/5653#discussion_r429477690 ## File path: src/relay/ir/dataflow_matcher.cc ## @@ -432,26 +432,39 @@ class PatternGrouper : protected MixedModeVisitor { const std::vector& GroupMatches(const DFPattern& pattern, const Expr& pre) { groups_ = {Group()}; gid_assignments_.clear(); -visit_counter_.clear(); pattern_ = pattern; pattern_graph_ = CreateIndexedGraph(pattern_); auto matcher = DFPatternMatcher(pre); matcher_ = &matcher; -this->VisitExpr(pre); +this->VisitExprs(); return this->groups_; } protected: - using ExprVisitor::VisitExpr_; - void VisitLeaf(const Expr& pre) override { -if (matcher_->Match(pattern_, pre)) { - CreateGroup(pre); -} - } - void VisitExpr_(const FunctionNode* op) override { -if (op->attrs->dict.count(attr::kPartitionedFromPattern) == 0) { - ExprVisitor::VisitExpr_(op); + /* \brief Iteratively traverse the Expression in pre-order to find subgraphs + * + * If we traverse the graph in post-order, we can run into situtations where a small subgraph will + * match the pattern. Due to options like AltPattern, a larger subgraph with more nodes later in + * the graph may also match the pattern. With post-order traversal, we mark the smaller subgraph + * as matched and fail to catch the larger subgraph. This problem is fixed by using pre-order + * traversal. + */ + void VisitExprs() { +std::unordered_set pre_partitioned; +for (size_t i = matcher_->expr_graph_.topological_order_.size(); i != 0; --i) { + size_t index = i - 1; Review comment: No worries! Undid it. 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] masahi commented on a change in pull request #5653: [PatternLang] Convert PatternGrouper to do pre-order, non-recursive analysis
masahi commented on a change in pull request #5653: URL: https://github.com/apache/incubator-tvm/pull/5653#discussion_r429478715 ## File path: src/relay/ir/dataflow_matcher.cc ## @@ -432,26 +432,39 @@ class PatternGrouper : protected MixedModeVisitor { const std::vector& GroupMatches(const DFPattern& pattern, const Expr& pre) { groups_ = {Group()}; gid_assignments_.clear(); -visit_counter_.clear(); pattern_ = pattern; pattern_graph_ = CreateIndexedGraph(pattern_); auto matcher = DFPatternMatcher(pre); matcher_ = &matcher; -this->VisitExpr(pre); +this->VisitExprs(); return this->groups_; } protected: - using ExprVisitor::VisitExpr_; - void VisitLeaf(const Expr& pre) override { -if (matcher_->Match(pattern_, pre)) { - CreateGroup(pre); -} - } - void VisitExpr_(const FunctionNode* op) override { -if (op->attrs->dict.count(attr::kPartitionedFromPattern) == 0) { - ExprVisitor::VisitExpr_(op); + /* \brief Iteratively traverse the Expression in pre-order to find subgraphs + * + * If we traverse the graph in post-order, we can run into situtations where a small subgraph will + * match the pattern. Due to options like AltPattern, a larger subgraph with more nodes later in + * the graph may also match the pattern. With post-order traversal, we mark the smaller subgraph + * as matched and fail to catch the larger subgraph. This problem is fixed by using pre-order + * traversal. + */ + void VisitExprs() { +std::unordered_set pre_partitioned; +for (size_t i = matcher_->expr_graph_.topological_order_.size(); i != 0; --i) { + size_t index = i - 1; Review comment: Thanks. Grepping the code base with `i - 1` finds many instances of this, and your original code seems to be the solution :) 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] masahi commented on a change in pull request #5653: [PatternLang] Convert PatternGrouper to do pre-order, non-recursive analysis
masahi commented on a change in pull request #5653: URL: https://github.com/apache/incubator-tvm/pull/5653#discussion_r429478715 ## File path: src/relay/ir/dataflow_matcher.cc ## @@ -432,26 +432,39 @@ class PatternGrouper : protected MixedModeVisitor { const std::vector& GroupMatches(const DFPattern& pattern, const Expr& pre) { groups_ = {Group()}; gid_assignments_.clear(); -visit_counter_.clear(); pattern_ = pattern; pattern_graph_ = CreateIndexedGraph(pattern_); auto matcher = DFPatternMatcher(pre); matcher_ = &matcher; -this->VisitExpr(pre); +this->VisitExprs(); return this->groups_; } protected: - using ExprVisitor::VisitExpr_; - void VisitLeaf(const Expr& pre) override { -if (matcher_->Match(pattern_, pre)) { - CreateGroup(pre); -} - } - void VisitExpr_(const FunctionNode* op) override { -if (op->attrs->dict.count(attr::kPartitionedFromPattern) == 0) { - ExprVisitor::VisitExpr_(op); + /* \brief Iteratively traverse the Expression in pre-order to find subgraphs + * + * If we traverse the graph in post-order, we can run into situtations where a small subgraph will + * match the pattern. Due to options like AltPattern, a larger subgraph with more nodes later in + * the graph may also match the pattern. With post-order traversal, we mark the smaller subgraph + * as matched and fail to catch the larger subgraph. This problem is fixed by using pre-order + * traversal. + */ + void VisitExprs() { +std::unordered_set pre_partitioned; +for (size_t i = matcher_->expr_graph_.topological_order_.size(); i != 0; --i) { + size_t index = i - 1; Review comment: Thanks. Grepping the code base with `i - 1` finds many instances of this, and your original code seems to be the common solution :) 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] mbrookhart commented on a change in pull request #5656: [BYOC] Pattern Language MergeComposite
mbrookhart commented on a change in pull request #5656: URL: https://github.com/apache/incubator-tvm/pull/5656#discussion_r429476254 ## File path: tests/python/relay/test_pass_merge_composite.py ## @@ -64,55 +65,53 @@ def make_add_sub_mul_pattern(): -"""Create a pattern to match the following graph. +r"""Create a pattern to match the following graph. add sub \ / \ / mul """ -x = relay.var('x') -y = relay.var('y') -add_node = relay.add(x, y) -sub_node = relay.subtract(x, y) -mul_node = relay.multiply(add_node, sub_node) +x = wildcard() +y = wildcard() +add_node = is_op('add')(x, y) +sub_node = is_op('subtract')(x, y) +mul_node = is_op('multiply')(add_node, sub_node) Review comment: Just FYI, if you think it would be easier, the DFPattern objects on the python side have syntatic sugar for +, -, *, / , | 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] comaniac commented on a change in pull request #5656: [BYOC] Pattern Language MergeComposite
comaniac commented on a change in pull request #5656: URL: https://github.com/apache/incubator-tvm/pull/5656#discussion_r429484128 ## File path: tests/python/relay/test_pass_merge_composite.py ## @@ -64,55 +65,53 @@ def make_add_sub_mul_pattern(): -"""Create a pattern to match the following graph. +r"""Create a pattern to match the following graph. add sub \ / \ / mul """ -x = relay.var('x') -y = relay.var('y') -add_node = relay.add(x, y) -sub_node = relay.subtract(x, y) -mul_node = relay.multiply(add_node, sub_node) +x = wildcard() +y = wildcard() +add_node = is_op('add')(x, y) +sub_node = is_op('subtract')(x, y) +mul_node = is_op('multiply')(add_node, sub_node) Review comment: Wow that's nice to know. I'll change some patterns using this syntax to demonstrate the different ways of making patterns. 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] comaniac commented on pull request #5656: [BYOC] Pattern Language MergeComposite
comaniac commented on pull request #5656: URL: https://github.com/apache/incubator-tvm/pull/5656#issuecomment-632938583 @masahi I found that `test_dnnl_fuse` in `test_pass_partition_graph` is actually failed at the DNNL code compilation, but it won't fail the CI because we don't have DNNL enabled (we should do it soon). The failure in that case is not related to this PR but `bind_params_by_name`. The DNNL function template such as dnnl_fused_conv2d_bias_relu expecting 3 inputs, but you generate the function based on the call node argument, which would be just 1 after `bind_params_by_name`. 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] comaniac edited a comment on pull request #5656: [BYOC] Pattern Language MergeComposite
comaniac edited a comment on pull request #5656: URL: https://github.com/apache/incubator-tvm/pull/5656#issuecomment-632938583 @masahi I found that `test_dnnl_fuse` in `test_pass_partition_graph` is actually failed at the DNNL code compilation, but it won't fail the CI because we don't have DNNL enabled (we should do it soon). The failure in that case is not related to this PR but `bind_params_by_name`. The DNNL function template such as `dnnl_fused_conv2d_bias_relu` expecting 3 inputs, but you generate the function based on the call node argument, which would be just 1 after `bind_params_by_name`. 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] comaniac edited a comment on pull request #5656: [BYOC] Pattern Language MergeComposite
comaniac edited a comment on pull request #5656: URL: https://github.com/apache/incubator-tvm/pull/5656#issuecomment-632938583 @masahi I found that `test_dnnl_fuse` in `test_pass_partition_graph` is actually failed at the DNNL code compilation, but it won't fail the CI because we don't have DNNL enabled (we should do it soon). The failure in that case is not related to this PR but `bind_params_by_name`. The DNNL function template such as `dnnl_fused_conv2d_bias_relu` expecting 3 inputs, but we generate the function call based on the call node argument, which would be just 1 after `bind_params_by_name`. 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] masahi commented on pull request #5656: [BYOC] Pattern Language MergeComposite
masahi commented on pull request #5656: URL: https://github.com/apache/incubator-tvm/pull/5656#issuecomment-632940481 @comaniac I just ran this test. The two fused layer test at https://github.com/apache/incubator-tvm/blob/master/tests/python/relay/test_pass_partition_graph.py#L932 works, but the full mobilenet test https://github.com/apache/incubator-tvm/blob/master/tests/python/relay/test_pass_partition_graph.py#L936 seems to stuck during compilation. Is the the error you are seeing? I remember this test worked no problem when @zhiics enabled compilation with big constants. I don't know when regression was introduced. 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] masahi edited a comment on pull request #5656: [BYOC] Pattern Language MergeComposite
masahi edited a comment on pull request #5656: URL: https://github.com/apache/incubator-tvm/pull/5656#issuecomment-632940481 @comaniac I just ran this test. The two fused layer test at https://github.com/apache/incubator-tvm/blob/master/tests/python/relay/test_pass_partition_graph.py#L932 works, but the full mobilenet test https://github.com/apache/incubator-tvm/blob/master/tests/python/relay/test_pass_partition_graph.py#L936 seems to stuck during compilation. Is this the error you are seeing? I remember this test worked no problem when @zhiics enabled compilation with big constants. I don't know when regression was introduced. 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] comaniac commented on pull request #5656: [BYOC] Pattern Language MergeComposite
comaniac commented on pull request #5656: URL: https://github.com/apache/incubator-tvm/pull/5656#issuecomment-632944262 > @comaniac I just ran this test. The two fused layer test at https://github.com/apache/incubator-tvm/blob/master/tests/python/relay/test_pass_partition_graph.py#L932 works, but the full mobilenet test https://github.com/apache/incubator-tvm/blob/master/tests/python/relay/test_pass_partition_graph.py#L936 seems to stuck during compilation. Is this the error you are seeing? > > I remember this test worked no problem when @zhiics enabled compilation with big constants. I don't know when regression was introduced. Sorry my bad. The original `MergeComposite` pass will recover bind parameters so the composite functions are guaranteed to have the same number of inputs as before. However, composite functions generated by `pattern.partition` still accesses the metadata for constant nodes. That's why the input number doesn't match. I'll try to solve this problem. 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] tom-gall commented on pull request #5660: [uTVM] Increase bss section size.
tom-gall commented on pull request #5660: URL: https://github.com/apache/incubator-tvm/pull/5660#issuecomment-632953040 Tested on my stm32F746. Back to working. Thanks @areusch 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] areusch opened a new pull request #5661: add tvm.micro pydoc to sphinx
areusch opened a new pull request #5661: URL: https://github.com/apache/incubator-tvm/pull/5661 Just adding API docs for now 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] comaniac opened a new issue #5662: [PatternLang] Lift constant nodes to partitioned function arguments
comaniac opened a new issue #5662: URL: https://github.com/apache/incubator-tvm/issues/5662 In #5656, we found that `pattern.partition` will not lift the bind constant nodes to the partitioned function arguments. This results in argument mismatch and could be a potential problem when applying to op fusion. Here is an illustration example: ```python import tvm from tvm import relay from tvm.relay.dataflow_pattern import * from tvm.relay.build_module import bind_params_by_name import numpy as np x = relay.var('x', shape=(1, 3, 224, 224)) w = relay.var('w', shape=(3, 3, 3, 3)) b = relay.var('b', shape=(3,)) conv2d = relay.op.nn.conv2d(x, w) out = relay.op.nn.bias_add(conv2d, b) func = relay.Function([x, w, b], out) mod = tvm.IRModule.from_expr(func) mod["main"] = bind_params_by_name(mod["main"], {'w': tvm.nd.array(np.ones(shape=(3, 3, 3, 3)))}) print('=== Fuse ') print(relay.transform.FuseOps()(mod)) conv2d = is_op('nn.conv2d')(wildcard(), wildcard()) pattern = is_op('nn.bias_add')(conv2d, wildcard()) print('=== Partition ===') print(pattern.partition(mod['main'].body, {'Composite': 'aa'})) ``` Output: ``` === Fuse def @main(%x: Tensor[(1, 3, 224, 224), float32], %b: Tensor[(3), float32]) -> Tensor[(1, 3, 222, 222), float32] { %1 = fn (%p0: Tensor[(1, 3, 224, 224), float32], %p1: Tensor[(3, 3, 3, 3), float64], %p2: Tensor[(3), float32], Primitive=1) -> Tensor[(1, 3, 222, 222), float32] { %0 = nn.conv2d(%p0, %p1, padding=[0, 0, 0, 0]) /* ty=Tensor[(1, 3, 222, 222), float32] */; nn.bias_add(%0, %p2) /* ty=Tensor[(1, 3, 222, 222), float32] */ }; %1(%x, meta[relay.Constant][0] /* ty=Tensor[(3, 3, 3, 3), float64] */ /* ty=Tensor[(3, 3, 3, 3), float64] */, %b) /* ty=Tensor[(1, 3, 222, 222), float32] */ } // meta data omitted. you can use show_meta_data=True to include meta data === Partition === free_var %x: Tensor[(1, 3, 224, 224), float32] free_var %b: Tensor[(3), float32] %1 = fn (%FunctionVar_0_0, %FunctionVar_0_1, Composite="aa", PartitionedFromPattern="nn.conv2d_nn.bias_add_") { %0 = nn.conv2d(%FunctionVar_0_0, meta[relay.Constant][0] /* ty=Tensor[(3, 3, 3, 3), float64] */ /* ty=Tensor[(3, 3, 3, 3), float64] */, padding=[0, 0, 0, 0]); nn.bias_add(%0, %FunctionVar_0_1) }; %1(%x, %b) // meta data omitted. you can use show_meta_data=True to include meta data ``` We can see that the function generated by the op fusion keeps the original arguments and refers to the constant node in the function call. However, the partitioned function directly accesses the constant node from inside of the function body. Ideally, the partitioned should be same as the fused function. cc @mbrookhart @masahi @zhiics 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] tmoreau89 commented on pull request #5659: [TARGET] enable amd_apu device on vulkan target
tmoreau89 commented on pull request #5659: URL: https://github.com/apache/incubator-tvm/pull/5659#issuecomment-632969349 Thanks you @mei-ye I'll close your other PR since it's a duplicate of this one. One question: do you also intend on uploading logs into TopHub for the v1000? 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] tmoreau89 commented on pull request #5659: [TARGET] enable amd_apu device on vulkan target
tmoreau89 commented on pull request #5659: URL: https://github.com/apache/incubator-tvm/pull/5659#issuecomment-632969425 Never mind the other PR was already closed. 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] tmoreau89 commented on pull request #5659: [TARGET] enable amd_apu device on vulkan target
tmoreau89 commented on pull request #5659: URL: https://github.com/apache/incubator-tvm/pull/5659#issuecomment-632969624 Could you also add in the comments that there are a couple fixes applied to the Vulkan runtime? Because this PR could be technically split into two (bug fixes to Vulkan runtime for GPUs, and adding the V1000 target) 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
[incubator-tvm] branch master updated: Upgrade XGBoost to latest (#5658)
This is an automated email from the ASF dual-hosted git repository. tqchen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git The following commit(s) were added to refs/heads/master by this push: new 3827cd0 Upgrade XGBoost to latest (#5658) 3827cd0 is described below commit 3827cd044d843006dc49bb28a058275598c52c29 Author: Philip Hyunsu Cho AuthorDate: Fri May 22 19:40:46 2020 -0700 Upgrade XGBoost to latest (#5658) --- python/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/setup.py b/python/setup.py index fb126ec..682589e 100644 --- a/python/setup.py +++ b/python/setup.py @@ -165,7 +165,7 @@ setup(name='tvm', 'matplotlib'], 'extra_feature': ['tornado', 'psutil', -'xgboost==0.90', +'xgboost>=1.1.0', 'mypy', 'orderedset', 'antlr4-python3-runtime']},
[GitHub] [incubator-tvm] tqchen merged pull request #5658: Upgrade XGBoost to latest
tqchen merged pull request #5658: URL: https://github.com/apache/incubator-tvm/pull/5658 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 merged pull request #5660: [uTVM] Increase bss section size.
tqchen merged pull request #5660: URL: https://github.com/apache/incubator-tvm/pull/5660 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
[incubator-tvm] branch master updated: Increase bss section size. (#5660)
This is an automated email from the ASF dual-hosted git repository. tqchen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git The following commit(s) were added to refs/heads/master by this push: new e2d66e1 Increase bss section size. (#5660) e2d66e1 is described below commit e2d66e1688c0622cce50747ee847872ff60c0389 Author: Andrew Reusch AuthorDate: Fri May 22 19:41:14 2020 -0700 Increase bss section size. (#5660) * Likely broken in PR 5590. --- python/tvm/micro/device/arm/stm32f746xx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/tvm/micro/device/arm/stm32f746xx.py b/python/tvm/micro/device/arm/stm32f746xx.py index 7469585..997093b 100644 --- a/python/tvm/micro/device/arm/stm32f746xx.py +++ b/python/tvm/micro/device/arm/stm32f746xx.py @@ -32,7 +32,7 @@ DEFAULT_SECTION_CONSTRAINTS = { "text": (18000, MemConstraint.ABSOLUTE_BYTES), "rodata": (100, MemConstraint.ABSOLUTE_BYTES), "data": (100, MemConstraint.ABSOLUTE_BYTES), -"bss": (600, MemConstraint.ABSOLUTE_BYTES), +"bss": (640, MemConstraint.ABSOLUTE_BYTES), "args": (4096, MemConstraint.ABSOLUTE_BYTES), "heap": (100.0, MemConstraint.WEIGHT), "workspace": (64000, MemConstraint.ABSOLUTE_BYTES),
[incubator-tvm] branch master updated: [PatternLang] Convert PatternGrouper to do pre-order, non-recursive analysis (#5653)
This is an automated email from the ASF dual-hosted git repository. masahi pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git The following commit(s) were added to refs/heads/master by this push: new 53251c8 [PatternLang] Convert PatternGrouper to do pre-order, non-recursive analysis (#5653) 53251c8 is described below commit 53251c87b2a7be53d00a968629bfc688585d8e4e Author: Matthew Brookhart AuthorDate: Fri May 22 20:17:39 2020 -0700 [PatternLang] Convert PatternGrouper to do pre-order, non-recursive analysis (#5653) * make the PatternGrouper iterate over the input Expr in a non-recursive pre-order fasion * add a comment --- src/relay/ir/dataflow_matcher.cc| 43 +++-- tests/python/relay/test_dataflow_pattern.py | 32 - 2 files changed, 59 insertions(+), 16 deletions(-) diff --git a/src/relay/ir/dataflow_matcher.cc b/src/relay/ir/dataflow_matcher.cc index 980935c..2f25733 100644 --- a/src/relay/ir/dataflow_matcher.cc +++ b/src/relay/ir/dataflow_matcher.cc @@ -43,6 +43,7 @@ class DFPatternMatcher : public DFPatternFunctor> GetMemo() { return Map>(memo_); } + const IndexedGraph expr_graph_; protected: bool VisitDFPattern(const DFPattern& pattern, const Expr& expr) override; @@ -63,7 +64,6 @@ class DFPatternMatcher : public DFPatternFunctor, ObjectHash, ObjectEqual> memo_; std::vector matched_nodes_; - IndexedGraph expr_graph_; bool memoize_ = true; }; @@ -291,7 +291,7 @@ bool DFPatternMatcher::VisitDFPattern_(const CallPatternNode* op, const Expr& ex // Recursively find the Dominator parent along all inputs paths. bool DFPatternMatcher::MatchesPath(const DominatorPatternNode* op, const Expr& expr) { auto call_node = expr.as(); - for (auto node : expr_graph_.node_map_[expr]->inputs_) { + for (auto node : expr_graph_.node_map_.at(expr)->inputs_) { if (!(call_node && node->ref_ == call_node->op)) { memoize_ = true; if (VisitDFPattern(op->parent, node->ref_)) { @@ -315,7 +315,7 @@ bool DFPatternMatcher::DominatesParent(const DominatorPatternNode* op, const Exp while (!stack.empty()) { Expr current = stack.top(); stack.pop(); -for (auto node : expr_graph_.node_map_[current]->dominator_children_) { +for (auto node : expr_graph_.node_map_.at(current)->dominator_children_) { if (visited.count(node->ref_) == 0) { if (VisitDFPattern(op->parent, node->ref_)) { return true; @@ -412,7 +412,7 @@ TVM_REGISTER_GLOBAL("relay.dataflow_pattern.match").set_body_typed(MatchPattern) * This is primarily needed to support the post-dominator analysis required for dominator pattern * matching. */ -class PatternGrouper : protected MixedModeVisitor { +class PatternGrouper { public: /* \brief Internal Group class for storing analysis */ struct Group { @@ -432,26 +432,39 @@ class PatternGrouper : protected MixedModeVisitor { const std::vector& GroupMatches(const DFPattern& pattern, const Expr& pre) { groups_ = {Group()}; gid_assignments_.clear(); -visit_counter_.clear(); pattern_ = pattern; pattern_graph_ = CreateIndexedGraph(pattern_); auto matcher = DFPatternMatcher(pre); matcher_ = &matcher; -this->VisitExpr(pre); +this->VisitExprs(); return this->groups_; } protected: - using ExprVisitor::VisitExpr_; - void VisitLeaf(const Expr& pre) override { -if (matcher_->Match(pattern_, pre)) { - CreateGroup(pre); -} - } - void VisitExpr_(const FunctionNode* op) override { -if (op->attrs->dict.count(attr::kPartitionedFromPattern) == 0) { - ExprVisitor::VisitExpr_(op); + /* \brief Iteratively traverse the Expression in pre-order to find subgraphs + * + * If we traverse the graph in post-order, we can run into situtations where a small subgraph will + * match the pattern. Due to options like AltPattern, a larger subgraph with more nodes later in + * the graph may also match the pattern. With post-order traversal, we mark the smaller subgraph + * as matched and fail to catch the larger subgraph. This problem is fixed by using pre-order + * traversal. + */ + void VisitExprs() { +std::unordered_set pre_partitioned; +for (size_t i = matcher_->expr_graph_.topological_order_.size(); i != 0; --i) { + size_t index = i - 1; + Expr current = matcher_->expr_graph_.topological_order_.at(index)->ref_; + if (auto op = current.as()) { +if (op->attrs->dict.count(attr::kPartitionedFromPattern) != 0) { + pre_partitioned.insert(current); + PostOrderVisit(op->body, + [&pre_partitioned](const Expr& expr) { pre_partitioned.insert(expr); }); +} + } + if (pre_partitioned.count(current) == 0 && matcher_->Match(pattern_, current)) { +CreateGroup(current); + } } } /* \brief Creates a new set of nodes base
[GitHub] [incubator-tvm] masahi merged pull request #5653: [PatternLang] Convert PatternGrouper to do pre-order, non-recursive analysis
masahi merged pull request #5653: URL: https://github.com/apache/incubator-tvm/pull/5653 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] masahi commented on pull request #5653: [PatternLang] Convert PatternGrouper to do pre-order, non-recursive analysis
masahi commented on pull request #5653: URL: https://github.com/apache/incubator-tvm/pull/5653#issuecomment-632977181 Thanks @mbrookhart @comaniac 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] mei-ye commented on pull request #5659: [TARGET] enable amd_apu device on vulkan target
mei-ye commented on pull request #5659: URL: https://github.com/apache/incubator-tvm/pull/5659#issuecomment-632981824 yes, I will check in log to tophub after this. This also fixes two bugs in vulkan runtime: maxComputeWorkGroupInvocations: the maximum total number of compute shader invocations in a single local workgroup. maxComputeWorkGroupSize[3]: the maximum size of a local compute workgroup, per dimension. 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
[incubator-tvm] branch master updated: [Relay, Topi][OP] affine_grid and grid_sample (#5657)
This is an automated email from the ASF dual-hosted git repository. masahi pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git The following commit(s) were added to refs/heads/master by this push: new e369c5a [Relay,Topi][OP] affine_grid and grid_sample (#5657) e369c5a is described below commit e369c5a9cbacb926ca7b95ebc4ae01a6de33c6cd Author: Wuwei Lin AuthorDate: Sat May 23 00:57:58 2020 -0400 [Relay,Topi][OP] affine_grid and grid_sample (#5657) * [Relay,Topi][OP] affine_grid and grid_sample * lint --- include/tvm/relay/attrs/image.h| 28 + python/tvm/relay/frontend/mxnet.py | 22 python/tvm/relay/op/image/_image.py| 20 +++ python/tvm/relay/op/image/image.py | 64 ++ src/relay/op/image/grid_sample.cc | 168 + tests/python/frontend/mxnet/test_forward.py| 38 ++ tests/python/relay/test_op_level5.py | 52 topi/python/topi/image/__init__.py | 1 + topi/python/topi/image/grid_sample.py | 124 ++ topi/python/topi/testing/__init__.py | 1 + topi/python/topi/testing/grid_sample_python.py | 65 ++ topi/tests/python/test_topi_image.py | 83 12 files changed, 666 insertions(+) diff --git a/include/tvm/relay/attrs/image.h b/include/tvm/relay/attrs/image.h index 58fd44b..cf5a6ef 100644 --- a/include/tvm/relay/attrs/image.h +++ b/include/tvm/relay/attrs/image.h @@ -167,6 +167,34 @@ struct Dilation2DAttrs : public tvm::AttrsNode { } }; +/*! \brief Attributes used in image affine_grid operator */ +struct AffineGridAttrs : public tvm::AttrsNode { + Array target_shape; + + TVM_DECLARE_ATTRS(AffineGridAttrs, "relay.attrs.AffineGridAttrs") { +TVM_ATTR_FIELD(target_shape).describe("Specifies the output shape (H, W)."); + } +}; + +/*! \brief Attributes used in image grid_sample operator */ +struct GridSampleAttrs : public tvm::AttrsNode { + String method; + String layout; + + TVM_DECLARE_ATTRS(GridSampleAttrs, "relay.attrs.GridSampleAttrs") { +TVM_ATTR_FIELD(method) +.set_default("bilinear") +.describe( +"Specify the mode to use for scaling." +"bilinear - Bilinear Interpolation"); +TVM_ATTR_FIELD(layout).set_default("NCHW").describe( +"Dimension ordering of input data. Can be 'NCHW', 'NHWC', etc." +"'N', 'C', 'H', 'W' stands for batch, channel, height, and width" +"dimensions respectively. Resize is applied on the 'H' and" +"'W' dimensions."); + } +}; + } // namespace relay } // namespace tvm #endif // TVM_RELAY_ATTRS_IMAGE_H_ diff --git a/python/tvm/relay/frontend/mxnet.py b/python/tvm/relay/frontend/mxnet.py index 9f97ee9..c75612d 100644 --- a/python/tvm/relay/frontend/mxnet.py +++ b/python/tvm/relay/frontend/mxnet.py @@ -757,6 +757,26 @@ def _mx_resize(inputs, attrs): return _op.image.resize(inputs[0], size, coordinate_transformation_mode="align_corners") +def _mx_grid_generator(inputs, attrs): +transform_type = attrs.get_str("transform_type") +if transform_type == 'affine': +target_shape = attrs.get_int_tuple("target_shape") +return _op.image.affine_grid(_op.reshape(inputs[0], (0, 2, 3)), target_shape) +if transform_type == 'warp': +checked_type = _infer_type(inputs[0]).checked_type +batch, _, height, width = get_const_tuple(checked_type.shape) +dtype = checked_type.dtype +identity_affine = relay.const(np.array([[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]], dtype=dtype)) +identity_affine = _op.broadcast_to(identity_affine, (batch, 2, 3)) +normalizer = (2.0 / np.array([width - 1, height - 1])).reshape(1, -1, 1, 1).astype(dtype) +normalized_flow = inputs[0] * relay.const(normalizer) +grid = _op.image.affine_grid(identity_affine, (height, width)) +return grid + normalized_flow +raise ValueError("unknown transform type" + transform_type) + +def _mx_bilinear_sampler(inputs, attrs): +return _op.image.grid_sample(inputs[0], inputs[1], 'bilinear', 'NCHW') + def _mx_roi_pooling(inputs, attrs): new_attrs = {} new_attrs["pooled_size"] = attrs.get_int_tuple("pooled_size") @@ -1996,6 +2016,8 @@ _convert_map = { "_contrib_box_nms" : _mx_box_nms, "_contrib_DeformableConvolution" : _mx_deformable_convolution, "_contrib_AdaptiveAvgPooling2D" : _mx_adaptive_avg_pooling, +"GridGenerator" : _mx_grid_generator, +"BilinearSampler" : _mx_bilinear_sampler, # NLP "RNN" : _mx_rnn_layer, "_rnn_param_concat" : _mx_rnn_param_concat, diff --git a/python/tvm/relay/op/image/_image.py b/python/tvm/relay/op/image/_image.py index 290c0a2..bcb110f 100644 --- a/python/tvm/relay/op/image/_image.py +++ b/python/tvm/relay/op/im
[GitHub] [incubator-tvm] masahi commented on pull request #5657: [Relay,Topi][OP] affine_grid and grid_sample
masahi commented on pull request #5657: URL: https://github.com/apache/incubator-tvm/pull/5657#issuecomment-632985707 Thanks @vinx13 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] masahi merged pull request #5657: [Relay,Topi][OP] affine_grid and grid_sample
masahi merged pull request #5657: URL: https://github.com/apache/incubator-tvm/pull/5657 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] Shawn-Inspur commented on a change in pull request #5600: [TOPI] Improve CUDA softmax scheduling
Shawn-Inspur commented on a change in pull request #5600: URL: https://github.com/apache/incubator-tvm/pull/5600#discussion_r429518516 ## File path: topi/python/topi/cuda/softmax.py ## @@ -53,13 +54,61 @@ def schedule_softmax(outs): raise ValueError('Tag is expected to be softmax_output or log_softmax_output. \ Got {0}'.format(op_tag)) +# The nvptx backend only supports 32-bits warp shuffle instructions. +# +# TODO(tvm-team) Fix nvptx codegen or deprecate nvptx backend. +def sched_warp_softmax(): +if tgt.target_name == "nvptx": +return softmax.dtype == "float32" or softmax.dtype == "int32" +return True Review comment: This makes sense to me. 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] mbrookhart commented on issue #5662: [PatternLang] Lift constant nodes to partitioned function arguments
mbrookhart commented on issue #5662: URL: https://github.com/apache/incubator-tvm/issues/5662#issuecomment-632992650 Hey Cody. This might just be a design misalignment. When writing the partition function, I explicitly dropped the constants from the inputs because I assumed we'd want to propagate constants through the body of the function. If that was an incorrect assumption, this change: ``` diff --git a/src/relay/ir/dataflow_matcher.cc b/src/relay/ir/dataflow_matcher.cc index 980935c34..f89116e34 100644 --- a/src/relay/ir/dataflow_matcher.cc +++ b/src/relay/ir/dataflow_matcher.cc @@ -544,7 +544,7 @@ class PatternGrouper : protected MixedModeVisitor { auto matches = node_map[node->ref_]; for (auto match : matches) { if (fuzzy_matches.count(match) == 0 && match.as() == nullptr && -match.as() == nullptr && match.as() == nullptr) { +match.as() == nullptr) { inputs[match] = Var( "FunctionVar_" + std::to_string(graph_number_) + "_" + std::to_string(var_number), NullValue()); ``` Gives me this result: ``` === Fuse free_var %x: Tensor[(1, 3, 224, 224), float32] free_var %b: Tensor[(3), float32] %1 = fn (%p0: Tensor[(1, 3, 224, 224), float32], %p1: Tensor[(3, 3, 3, 3), float64], %p2: Tensor[(3), float32], Primitive=1) -> Tensor[(1, 3, 222, 222), float32] { %0 = nn.conv2d(%p0, %p1, padding=[0, 0, 0, 0]) /* ty=Tensor[(1, 3, 222, 222), float32] */; nn.bias_add(%0, %p2) /* ty=Tensor[(1, 3, 222, 222), float32] */ }; %1(%x, meta[relay.Constant][0] /* ty=Tensor[(3, 3, 3, 3), float64] */ /* ty=Tensor[(3, 3, 3, 3), float64] */, %b) /* ty=Tensor[(1, 3, 222, 222), float32] */ // meta data omitted. you can use show_meta_data=True to include meta data === Partition === free_var %x: Tensor[(1, 3, 224, 224), float32] free_var %b: Tensor[(3), float32] %1 = fn (%FunctionVar_0_0, %FunctionVar_0_1, %FunctionVar_0_2, Composite="aa", PartitionedFromPattern="nn.conv2d_nn.bias_add_") { %0 = nn.conv2d(%FunctionVar_0_0, %FunctionVar_0_1, padding=[0, 0, 0, 0]); nn.bias_add(%0, %FunctionVar_0_2) }; %1(%x, meta[relay.Constant][0] /* ty=Tensor[(3, 3, 3, 3), float64] */ /* ty=Tensor[(3, 3, 3, 3), float64] */, %b) // meta data omitted. you can use show_meta_data=True to include meta data ``` Where the only difference I see is the naming of function variables and the fact that partition doesn't do type inference by default. If you think that's the correct behavior, care to integrate the single line change into #5656? 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] mbrookhart edited a comment on issue #5662: [PatternLang] Lift constant nodes to partitioned function arguments
mbrookhart edited a comment on issue #5662: URL: https://github.com/apache/incubator-tvm/issues/5662#issuecomment-632992650 Hey Cody. This might just be a design misalignment. When writing the partition function, I explicitly dropped the constants from the inputs because I assumed we'd want to propagate constants through the body of the function. If that was an incorrect assumption, this change: ``` diff --git a/src/relay/ir/dataflow_matcher.cc b/src/relay/ir/dataflow_matcher.cc index 980935c34..f89116e34 100644 --- a/src/relay/ir/dataflow_matcher.cc +++ b/src/relay/ir/dataflow_matcher.cc @@ -544,7 +544,7 @@ class PatternGrouper : protected MixedModeVisitor { auto matches = node_map[node->ref_]; for (auto match : matches) { if (fuzzy_matches.count(match) == 0 && match.as() == nullptr && -match.as() == nullptr && match.as() == nullptr) { +match.as() == nullptr) { inputs[match] = Var( "FunctionVar_" + std::to_string(graph_number_) + "_" + std::to_string(var_number), NullValue()); ``` Gives me this result: ``` === Fuse free_var %x: Tensor[(1, 3, 224, 224), float32] free_var %b: Tensor[(3), float32] %1 = fn (%p0: Tensor[(1, 3, 224, 224), float32], %p1: Tensor[(3, 3, 3, 3), float64], %p2: Tensor[(3), float32], Primitive=1) -> Tensor[(1, 3, 222, 222), float32] { %0 = nn.conv2d(%p0, %p1, padding=[0, 0, 0, 0]) /* ty=Tensor[(1, 3, 222, 222), float32] */; nn.bias_add(%0, %p2) /* ty=Tensor[(1, 3, 222, 222), float32] */ }; %1(%x, meta[relay.Constant][0] /* ty=Tensor[(3, 3, 3, 3), float64] */ /* ty=Tensor[(3, 3, 3, 3), float64] */, %b) /* ty=Tensor[(1, 3, 222, 222), float32] */ // meta data omitted. you can use show_meta_data=True to include meta data === Partition === free_var %x: Tensor[(1, 3, 224, 224), float32] free_var %b: Tensor[(3), float32] %1 = fn (%FunctionVar_0_0, %FunctionVar_0_1, %FunctionVar_0_2, Composite="aa", PartitionedFromPattern="nn.conv2d_nn.bias_add_") { %0 = nn.conv2d(%FunctionVar_0_0, %FunctionVar_0_1, padding=[0, 0, 0, 0]); nn.bias_add(%0, %FunctionVar_0_2) }; %1(%x, meta[relay.Constant][0] /* ty=Tensor[(3, 3, 3, 3), float64] */ /* ty=Tensor[(3, 3, 3, 3), float64] */, %b) // meta data omitted. you can use show_meta_data=True to include meta data ``` Where the only differences I see is the naming of function variables and the fact that partition doesn't do type inference by default. If you think that's the correct behavior, care to integrate the single line change into #5656? 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] mbrookhart edited a comment on issue #5662: [PatternLang] Lift constant nodes to partitioned function arguments
mbrookhart edited a comment on issue #5662: URL: https://github.com/apache/incubator-tvm/issues/5662#issuecomment-632992650 Hey Cody. This might just be a design misalignment. When writing the partition function, I explicitly dropped the constants from the inputs because I assumed we'd want to propagate constants through the body of the function. If that was an incorrect assumption, this change: ``` diff --git a/src/relay/ir/dataflow_matcher.cc b/src/relay/ir/dataflow_matcher.cc index 980935c34..f89116e34 100644 --- a/src/relay/ir/dataflow_matcher.cc +++ b/src/relay/ir/dataflow_matcher.cc @@ -544,7 +544,7 @@ class PatternGrouper : protected MixedModeVisitor { auto matches = node_map[node->ref_]; for (auto match : matches) { if (fuzzy_matches.count(match) == 0 && match.as() == nullptr && -match.as() == nullptr && match.as() == nullptr) { +match.as() == nullptr) { inputs[match] = Var( "FunctionVar_" + std::to_string(graph_number_) + "_" + std::to_string(var_number), NullValue()); ``` Gives me this result: ``` === Fuse free_var %x: Tensor[(1, 3, 224, 224), float32] free_var %b: Tensor[(3), float32] %1 = fn (%p0: Tensor[(1, 3, 224, 224), float32], %p1: Tensor[(3, 3, 3, 3), float64], %p2: Tensor[(3), float32], Primitive=1) -> Tensor[(1, 3, 222, 222), float32] { %0 = nn.conv2d(%p0, %p1, padding=[0, 0, 0, 0]) /* ty=Tensor[(1, 3, 222, 222), float32] */; nn.bias_add(%0, %p2) /* ty=Tensor[(1, 3, 222, 222), float32] */ }; %1(%x, meta[relay.Constant][0] /* ty=Tensor[(3, 3, 3, 3), float64] */ /* ty=Tensor[(3, 3, 3, 3), float64] */, %b) /* ty=Tensor[(1, 3, 222, 222), float32] */ // meta data omitted. you can use show_meta_data=True to include meta data === Partition === free_var %x: Tensor[(1, 3, 224, 224), float32] free_var %b: Tensor[(3), float32] %1 = fn (%FunctionVar_0_0, %FunctionVar_0_1, %FunctionVar_0_2, Composite="aa", PartitionedFromPattern="nn.conv2d_nn.bias_add_") { %0 = nn.conv2d(%FunctionVar_0_0, %FunctionVar_0_1, padding=[0, 0, 0, 0]); nn.bias_add(%0, %FunctionVar_0_2) }; %1(%x, meta[relay.Constant][0] /* ty=Tensor[(3, 3, 3, 3), float64] */ /* ty=Tensor[(3, 3, 3, 3), float64] */, %b) // meta data omitted. you can use show_meta_data=True to include meta data ``` Where the only differences I see is the naming of function variables and the fact that partition doesn't do type inference by default. If you think that's the correct behavior, care to integrate the single line change into #5656? Thanks! 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] mbrookhart edited a comment on issue #5662: [PatternLang] Lift constant nodes to partitioned function arguments
mbrookhart edited a comment on issue #5662: URL: https://github.com/apache/incubator-tvm/issues/5662#issuecomment-632992650 Hey Cody. This might just be a design misalignment. When writing the partition function, I explicitly dropped the constants from the inputs because I assumed we'd want to propagate constants through the body of the function. If that was an incorrect assumption, this change: ``` diff --git a/src/relay/ir/dataflow_matcher.cc b/src/relay/ir/dataflow_matcher.cc index 980935c34..f89116e34 100644 --- a/src/relay/ir/dataflow_matcher.cc +++ b/src/relay/ir/dataflow_matcher.cc @@ -544,7 +544,7 @@ class PatternGrouper : protected MixedModeVisitor { auto matches = node_map[node->ref_]; for (auto match : matches) { if (fuzzy_matches.count(match) == 0 && match.as() == nullptr && -match.as() == nullptr && match.as() == nullptr) { +match.as() == nullptr) { inputs[match] = Var( "FunctionVar_" + std::to_string(graph_number_) + "_" + std::to_string(var_number), NullValue()); ``` Gives me this result: ``` === Fuse free_var %x: Tensor[(1, 3, 224, 224), float32] free_var %b: Tensor[(3), float32] %1 = fn (%p0: Tensor[(1, 3, 224, 224), float32], %p1: Tensor[(3, 3, 3, 3), float64], %p2: Tensor[(3), float32], Primitive=1) -> Tensor[(1, 3, 222, 222), float32] { %0 = nn.conv2d(%p0, %p1, padding=[0, 0, 0, 0]) /* ty=Tensor[(1, 3, 222, 222), float32] */; nn.bias_add(%0, %p2) /* ty=Tensor[(1, 3, 222, 222), float32] */ }; %1(%x, meta[relay.Constant][0] /* ty=Tensor[(3, 3, 3, 3), float64] */ /* ty=Tensor[(3, 3, 3, 3), float64] */, %b) /* ty=Tensor[(1, 3, 222, 222), float32] */ // meta data omitted. you can use show_meta_data=True to include meta data === Partition === free_var %x: Tensor[(1, 3, 224, 224), float32] free_var %b: Tensor[(3), float32] %1 = fn (%FunctionVar_0_0, %FunctionVar_0_1, %FunctionVar_0_2, Composite="aa", PartitionedFromPattern="nn.conv2d_nn.bias_add_") { %0 = nn.conv2d(%FunctionVar_0_0, %FunctionVar_0_1, padding=[0, 0, 0, 0]); nn.bias_add(%0, %FunctionVar_0_2) }; %1(%x, meta[relay.Constant][0] /* ty=Tensor[(3, 3, 3, 3), float64] */ /* ty=Tensor[(3, 3, 3, 3), float64] */, %b) // meta data omitted. you can use show_meta_data=True to include meta data ``` Where the only differences I see is the naming of function variables and the fact that partition doesn't do type inference by default. Do you think that's the correct behavior? It breaks a couple of other unit tests, I'll see if I can fix them. 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] mbrookhart opened a new pull request #5663: [POC][PatternLang]Remove constants from partitioned functions
mbrookhart opened a new pull request #5663: URL: https://github.com/apache/incubator-tvm/pull/5663 Address questions in #5662 cc @comaniac @masahi 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] comaniac commented on issue #5662: [PatternLang] Lift constant nodes to partitioned function arguments
comaniac commented on issue #5662: URL: https://github.com/apache/incubator-tvm/issues/5662#issuecomment-632996700 Thanks for the advise! This major difference affects how the constant values will be used in the runtime, and I consider Relay functions should be used as same as Relay ops. For example, we may have ``` %0 = nn.conv2d(%data, meta[relay.Constant][0]; ``` If we treat `nn.conv2d` as a Relay function, we can see that even one if its arguments is a constant, we still maintain its function signature and pass the constant node via the call. Since this concept is applicable to fused and composite functions, I think it would be better for pattern language to have the same behavior. Meanwhile, I would like to ask @tqchen @zhiics @yzhliu for double confirm. If we all agree with this behavior, I'll be glad to apply the change to #5663 :) 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] comaniac edited a comment on issue #5662: [PatternLang] Lift constant nodes to partitioned function arguments
comaniac edited a comment on issue #5662: URL: https://github.com/apache/incubator-tvm/issues/5662#issuecomment-632996700 Thanks for the advise! This major difference affects how the constant values will be used in the runtime, and I consider Relay functions should be used as same as Relay ops. For example, we may have ``` %0 = nn.conv2d(%data, meta[relay.Constant][0]; ``` If we treat `nn.conv2d` as a Relay function, we can see that even one if its arguments is a constant, we still maintain its function signature and pass the constant node via the call. Since this concept is applicable to fused and composite functions, I think it would be better for pattern language to have the same behavior. Meanwhile, I would like to ask @tqchen @zhiics @yzhliu for double confirm :) 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