jikechao opened a new issue, #14917:
URL: https://github.com/apache/tvm/issues/14917
For the Keras model with `PReLU` layer, It can be converted to RelayIR but
crashes when compiling it and throw "**Incompatible broadcast type
TensorType([4, 2, 3], float32) and TensorType([1, 2, 3, 4], float32)**"
### Actual behavior
```
Incompatible broadcast type TensorType([4, 2, 3], float32) and
TensorType([1, 2, 3, 4], float32)
The type inference pass was unable to infer a type for this expression.
This usually occurs when an operator call is under constrained in some way,
check other reported errors for hints of what may of happened.
The type inference pass was unable to infer a type for this expression.
This usually occurs when an operator call is under constrained in some way,
check other reported errors for hints of what may of happened.
Traceback (most recent call last):
File "test.py", line 24, in <module>
model = relay.build_module.create_executor("graph", mod, tvm.cpu(0),
'llvm', params).evaluate()
File
"/workplace/software/tvm/tvm/python/tvm/relay/backend/interpreter.py", line
170, in evaluate
return self._make_executor()
File "/workplace/software/tvm/tvm/python/tvm/relay/build_module.py", line
513, in _make_executor
self.mod = InferType()(self.mod)
File "/workplace/software/tvm/tvm/python/tvm/ir/transform.py", line 160,
in __call__
return _ffi_transform_api.RunPass(self, mod)
File "/workplace/software/tvm/tvm/python/tvm/_ffi/_ctypes/packed_func.py",
line 238, in __call__
raise get_last_ffi_error()
tvm.error.DiagnosticError: Traceback (most recent call last):
7: TVMFuncCall
6:
tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<tvm::runtime::TypedPackedFunc<tvm::IRModule
(tvm::transform::Pass,
tvm::IRModule)>::AssignTypedLambda<tvm::transform::$_6>(tvm::transform::$_6,
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>
>)::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}>
>::Call(tvm::runtime::PackedFuncObj const*, tvm::runtime::TVMArgs,
tvm::runtime::TVMRetValue*)
5: tvm::transform::Pass::operator()(tvm::IRModule) const
4: tvm::transform::Pass::operator()(tvm::IRModule,
tvm::transform::PassContext const&) const
3: tvm::transform::ModulePassNode::operator()(tvm::IRModule,
tvm::transform::PassContext const&) const
2:
tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<tvm::runtime::TypedPackedFunc<tvm::IRModule
(tvm::IRModule,
tvm::transform::PassContext)>::AssignTypedLambda<tvm::relay::transform::InferType()::$_2>(tvm::relay::transform::InferType()::$_2)::{lambda(tvm::runtime::TVMArgs
const&, tvm::runtime::TVMRetValue*)#1}> >::Call(tvm::runtime::PackedFuncObj
const*, tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)
1: tvm::DiagnosticContext::Render()
0: _ZN3tvm7runtime6detail
File "/workplace/software/tvm/tvm/src/ir/diagnostic.cc", line 131
DiagnosticError: one or more error diagnostics were emitted, please check
diagnostic render for output.
```
### Steps to reproduce
```
import tvm
import tvm.relay as relay
from tensorflow import keras
from tensorflow.keras import layers, models
from tensorflow.keras import backend as K
K.set_image_data_format('channels_first')
input_shape = (1, 2, 3, 4)
x = layers.Input(shape=input_shape[1:], dtype='float32')
layer = keras.layers.PReLU()
layer.set_weights(layer.get_weights())
y = layer(x)
model = models.Model(x, y)
print(model.summary())
shape_dict = {'input_1': input_shape}
mod, params = relay.frontend.from_keras(model, shape_dict,layout='NCHW')
print(mod)
with tvm.transform.PassContext(opt_level=3):
model = relay.build_module.create_executor("graph", mod, tvm.cpu(0),
'llvm', params).evaluate()
```
### Triage
* frontend:keras
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]