This reproducible bug was triggered by the code snippet below:
from tvm.relay import create_executor
import tvm.relay as relay
import tvm.topi.testing
import numpy as np
import tvm
from tvm.relay.dataflow_pattern import *
import tvm.testing
from tvm.tir.expr import *
from tvm.relay.testing import run_infer_type
def C(x):
return relay.expr.const(x, 'float32')
def approx_exp(x):
x = relay.minimum(relay.maximum(x, C((- 88.0))), C(88.0))
x = (C(127.0) + (x * C(1.44269504)))
xf = relay.floor(x)
i = relay.cast(xf, 'int32')
x = (x - xf)
Y = (C(0.99992522) + (x * (C(0.69583354) + (x * (C(0.22606716) + (x * C(0.078024523)))))))
exponent = relay.left_shift(i, relay.expr.const(23, 'int32'))
exponent = relay.reinterpret(exponent, 'float32')
return (exponent * Y)
def approximate_sigmoid(x):
y = approx_exp(x)
return (y / (y + C(1.0)))
def approximate_tanh(x):
x = (x * C(2.0))
y = approx_exp(x)
return ((y - C(1.0)) / (y + C(1.0)))
a = relay.var('a', relay.TensorType((1000,), 'float32'))
y = approximate_sigmoid(a)
yy = run_infer_type(y)
data = np.linspace((- 5), 5, 100).astype('float32')
intrp = create_executor()
op_res = intrp.evaluate(y, {a: relay.const(data)})
TVM v0.7 offers the following message:
Traceback (most recent call last):
File "/mnt/c/Users/Xavier/Desktop/buggyFile/not sure/18.py", line 40, in <module>
op_res = intrp.evaluate(y, {a: relay.const(data)})
File "/home/lisa/tvm-0.7/python/tvm/relay/backend/interpreter.py", line 182, in evaluate
return self._make_executor(func)()
File "/home/lisa/tvm-0.7/python/tvm/relay/backend/interpreter.py", line 248, in _interp_wrapper
self.mod["main"] = func
File "/home/lisa/tvm-0.7/python/tvm/ir/module.py", line 75, in __setitem__
return self._add(var, val)
File "/home/lisa/tvm-0.7/python/tvm/ir/module.py", line 84, in _add
_ffi_api.Module_Add(self, var, val, update)
File "/home/lisa/tvm-0.7/python/tvm/_ffi/_ctypes/packed_func.py", line 237, in __call__
raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
[bt] (8) /home/lisa/tvm-0.7/build/libtvm.so(TVMFuncCall+0x63) [0x7eff7b33bd63]
[bt] (7) /home/lisa/tvm-0.7/build/libtvm.so(+0x1e8fed8) [0x7eff7a852ed8]
[bt] (6) /home/lisa/tvm-0.7/build/libtvm.so(+0x1e8f091) [0x7eff7a852091]
[bt] (5) /home/lisa/tvm-0.7/build/libtvm.so(tvm::IRModuleNode::Add(tvm::GlobalVar const&, tvm::BaseFunc const&, bool)+0xd7) [0x7eff7a84de37]
[bt] (4) /home/lisa/tvm-0.7/build/libtvm.so(tvm::RunTypeCheck(tvm::IRModule const&, tvm::GlobalVar const&, tvm::relay::Function)+0x5f6) [0x7eff7a84d7e6]
[bt] (3) /home/lisa/tvm-0.7/build/libtvm.so(tvm::relay::InferType(tvm::relay::Function const&, tvm::IRModule const&, tvm::GlobalVar const&)+0x3a2) [0x7eff7b167972]
[bt] (2) /home/lisa/tvm-0.7/build/libtvm.so(tvm::relay::TypeInferencer::Infer(tvm::RelayExpr)+0x78) [0x7eff7b166c08]
[bt] (1) /home/lisa/tvm-0.7/build/libtvm.so(tvm::ErrorReporter::RenderErrors(tvm::IRModule const&, bool)+0x2098) [0x7eff7a839288]
[bt] (0) /home/lisa/tvm-0.7/build/libtvm.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x80) [0x7eff7a73cb60]
File "/home/lisa/tvm-0.7/src/ir/error.cc", line 132
TVMError:
Error(s) have occurred. The program has been annotated with them:
In `main`:
#[version = "0.0.5"]
fn () {
%17 = fn () {
let %a: Tensor[(1000), float32] = meta[relay.Constant][0];
%0 = maximum(%a, -88f);
%1 = minimum(%0, 88f);
%2 = multiply(%1, 1.4427f);
%3 = add(127f, %2);
%4 = floor(%3);
%5 = cast(%4, dtype="int32");
%6 = left_shift(%5, 23);
%7 = reinterpret(%6, dtype="float32");
%8 = subtract(%3, %4);
%9 = multiply(%8, 0.0780245f);
%10 = add(0.226067f, %9);
%11 = multiply(%8, %10);
%12 = add(0.695834f, %11);
%13 = multiply(%8, %12);
%14 = add(0.999925f, %13);
%15 = multiply(%7, %14);
%16 = add(%15, 1f);
divide(%15, %16) in particular dimension 0 conflicts 100 does not match 1000; unable to unify: `Tensor[(100), float32]` and `Tensor[(1000), float32]`;
};
%17()
}
/* For debugging purposes the metadata section has been omitted.
* If you would like to see the full metadata section you can set the
* option to `True` when invoking `astext`.
*/
while TVM v0.8 dev gives the following one:
The Relay type checker is unable to show the following types match.
In particular dimension 0 conflicts: 100 does not match 1000.
The Relay type checker is unable to show the following types match.
In particular `Tensor[(100), float32]` does not match `Tensor[(1000), float32]`
Traceback (most recent call last):
File "/mnt/c/Users/Xavier/Desktop/buggyFile/not sure/18.py", line 40, in <module>
op_res = intrp.evaluate(y, {a: relay.const(data)})
File "/home/lisa/tvm/python/tvm/relay/backend/interpreter.py", line 182, in evaluate
return self._make_executor(func)()
File "/home/lisa/tvm/python/tvm/relay/backend/interpreter.py", line 254, in _interp_wrapper
mod = self.optimize()
File "/home/lisa/tvm/python/tvm/relay/backend/interpreter.py", line 223, in optimize
mod = seq(self.mod)
File "/home/lisa/tvm/python/tvm/ir/transform.py", line 127, in __call__
return _ffi_transform_api.RunPass(self, mod)
File "/home/lisa/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 237, in __call__
raise get_last_ffi_error()
tvm.error.DiagnosticError: Traceback (most recent call last):
[bt] (7) /home/lisa/tvm/build/libtvm.so(TVMFuncCall+0x63) [0x7f82ed3e52a3]
[bt] (6) /home/lisa/tvm/build/libtvm.so(+0x1f39ed4) [0x7f82ec84bed4]
[bt] (5) /home/lisa/tvm/build/libtvm.so(tvm::transform::SequentialNode::operator()(tvm::IRModule, tvm::transform::PassContext const&) const+0x27e) [0x7f82ec8482fe]
[bt] (4) /home/lisa/tvm/build/libtvm.so(tvm::transform::ModulePassNode::operator()(tvm::IRModule, tvm::transform::PassContext const&) const+0x1d4) [0x7f82ec84b534]
[bt] (3) /home/lisa/tvm/build/libtvm.so(+0x28dd442) [0x7f82ed1ef442]
[bt] (2) /home/lisa/tvm/build/libtvm.so(+0x28dc3c7) [0x7f82ed1ee3c7]
[bt] (1) /home/lisa/tvm/build/libtvm.so(tvm::DiagnosticContext::Render()+0x231) [0x7f82ec7fc4f1]
[bt] (0) /home/lisa/tvm/build/libtvm.so(+0x1eea0e8) [0x7f82ec7fc0e8]
File "/home/lisa/tvm/src/ir/diagnostic.cc", line 105
DiagnosticError: one or more error diagnostics were emitted, please check diagnostic render for output.
Is it better for TVM v0.8 dev to give more detailed message such as TVM v0.7, which specifically show where goes wrong?