heterocl.scheme¶
Quantization scheme.
-
class
Scheme
(inputs, func)[source]¶ Bases:
object
A quantization scheme.
To create a scheme, use
heterocl.create_scheme
. A scheme has two methods: one is to downsize tensors to integer type and the other is to quantize tensors to non-integer type. The scheme should only be created by the API. Users should not directly call the constructor.- Parameters
inputs (list of Tensor) – A list of input tensors to the scheme
func (callable) – The algorithm definition
- Variables
See also
Examples
# example 1 - downsize hcl.init(hcl.Int(32)) A = hcl.placeholder((10,)) def kernel(A): return hcl.compute(A.shape, lambda x: A[x]+1, "B") s = hcl.create_scheme(A, kernel) # downsize tensor B to a 4-bit unsigned integer s.downsize(kernel.B, hcl.UInt(4)) # example 1 - quantize hcl.init(hcl.Float()) A = hcl.placeholder((10,)) def kernel(A): return hcl.compute(A.shape, lambda x: A[x]+1, "B") s = hcl.create_scheme(A, kernel) # quantize tensor B to a 4-bit unsigned fixed point s.quantize(kernel.B, hcl.Fixed(4, 2))
-
current
= <heterocl.scheme.Scheme object>¶ The current scheme.