Error in Tutorial 5
Closed this issue · 3 comments
smc447 commented
I think this error has something to do with LLVM, so I also added it as an issue even though I didn't get the message to report it
Code:
import heterocl as hcl
##############################################################################
# Data Types Supported by HeteroCL
# --------------------------------
# HeteroCL supports both bit-accurate data types and floating points. We show
# some examples below. If no argument is provided, the default bitwidth for
# each type is 32.
hcl.Int(15) # 15-bit signed integer
hcl.UInt(24) # 24-bit unsigned integer
hcl.Fixed(13, 5) # 13-bit signed fixed point with 5 fractional bits
hcl.UFixed(44, 30) # 44-bit unsigned fixed point with 30 fractional bits
hcl.Float(32) # single-precision floating point
hcl.Float(64) # double-precision floating point
##############################################################################
# These data types can be used in ``hcl.init`` to set the default data type
hcl.init(hcl.Float())
##############################################################################
# Data Type Customization
# -----------------------
# Another important hardware customization is data type customization, which
# can be data quantization or downsizing a data type. Data quantization has
# been proved to improve hardware efficiency in many accelerators. In HeteroCL,
# to apply data type customization, we need to use ``hcl.create_scheme``,
A = hcl.placeholder((10,))
def quantization(A):
return hcl.compute(A.shape, lambda x: hcl.tanh(A[x]), "B")
##############################################################################
# First, let's build the application without applying any quantization scheme.
s = hcl.create_schedule([A], quantization)
f = hcl.build(s)
The error happens at hcl.build(s).
Error Message:
loc("-":6:12): error: failed to legalize operation 'math.tanh'
loc("-":2:3): error: cannot be converted to LLVM IR: missing `LLVMTranslationDialectInterface` registration for dialect for op: func.func
Traceback (most recent call last):
File "/export/scratch/users/smc447/tutorial/tutorial_05_dtype.py", line 50, in <module>
f = hcl.build(s)
File "/home/smc447/heterocl-mlir/python/heterocl/build_module.py", line 74, in build
raise e
File "/home/smc447/heterocl-mlir/python/heterocl/build_module.py", line 72, in build
return build_llvm(schedule, target, stmt)
File "/home/smc447/heterocl-mlir/python/heterocl/build_module.py", line 360, in build_llvm
execution_engine = ExecutionEngine(module, opt_level=0, shared_libs=shared_libs)
RuntimeError: Failure while creating the ExecutionEngine.
zzzDavid commented
The math dialect is registered but somehow the conversion pattern to lower math dialect did not take effect. I'll take a closer look and try this built-in pass -convert-math-to-llvm
zzzDavid commented
Lowering math operations to LLVM has been supported.
Closing this thread as tutorial 5 passes test and is added in the CI