Hello, I’m working with Tir and Relay. Now I want to deploy 1bit net in the tir lower procedure, but when I used Bool as the DataDType, I encountered some problems. The Storage Flatten Pass convert Bool to Int(8), which caused me to lose 1 bit information.
// TODO(Lunderberg): Move the handling of boolean into a
// dedicated pass.
// Boolean tensors are backed by a Int8 array.
if (e.flattened_buffer->dtype == DataType::Bool()) {
auto writer = e.flattened_buffer.CopyOnWrite();
writer->dtype = DataType::Int(8);
}
···
I found that using the int1 type can retain 1 bit information in Tir. However, in Ndarray, “bits=1” is automatically converted to bool type, so I have to insert a pass in the relay phase to convert bool to int1. In this way, I can get the desired Tir form, and use the following to carry out the intrinsic pipeline and codegen. The Tir like this:
primfn(...)
buffers = {placeholder: Buffer(placeholder_20: Pointer(int1), int1, [43008], [], elem_offset=10752),
Conv2dOutput: Buffer(Conv2dOutput_2: Pointer(int1), int1, [86016], [])}
{
allocate(placeholder.global_0: Pointer(global int1), int1, [9216, 2240]), storage_scope = global;
allocate(Conv2dOutput.global_0: Pointer(global int1), int1, [20480, 3392]), storage_scope = global {
}
}
So is it reasonable for me to do this? And what will happen to Tir 1-bit processing later?