Built-in Functions
Memory, SIMD, and CIM operations in CIM-DSL
Memory Operations
Buffer
Allocate a memory tile with specified shape, type, and location:
buf = Buffer(<4, 8>, int8, __LOCAL__);Prop
Type
Trans
Transfer data between memory regions:
Trans(src_buffer, dst_buffer);Load / Save
Access individual elements by index:
val = Load(buf, [row, col]);
Save(buf, [row, col], value);Shape
Query dimension size at runtime:
n = Shape(vector, 0); // Get size of dimension 0Slice
Create a subview of a buffer with explicit offsets, sizes, and steps:
slice = Slice(buf, [offset0, offset1], [size0, size1], [step0, step1]);Prop
Type
This is an alternative to NumPy-style slicing syntax. Both buf[0:2, 1:3] and Slice(buf, [0, 1], [2, 2], [1, 1]) produce equivalent results.
CIM Operations
CIMSet
Configure active CIM macros using a bitmask:
mask = Buffer(<N_VCOL>, int1, __INPUT_MEMORY__);
CIMSet(mask);CIMComputeDense
Execute dense matrix-vector multiplication on CIM hardware:
CIMComputeDense(input_buffer, weight_macros);CIMOutput
Read results from CIM output registers:
CIMOutput(length, offset, output_buffer);Prop
Type
SIMD Operations
Vector operations via the SIMD function:
SIMD(op_code, src1, src2, dst);VVADDVector-vector addVSADDVector-scalar addVVMULVector-vector multiplyVSMULVector-scalar multiplyVS_SUBVector-scalar subtractVS_DIVVector-scalar divideVVMAXElement-wise maximumVFLOORElement-wise floorSOFTMAXSoftmax activationGELUGELU activationV_EXPElement-wise exponentialVSQRTElement-wise square rootVSETSet all elements to valueREDUCE_SUMSum all elementsREDUCE_MAXFind maximum elementUse with the Reduce function:
Reduce(REDUCE_SUM, src_vector, dst_vector);QUANTIZEQuantize to lower precisionRESADD_QUANTIZEResidual add + quantizeRESMUL_QUANTIZEResidual multiply + quantizeUtility Functions
Min(a, b)Max(a, b)Print(val)SpecialRegSet
Configure special registers for CIM and SIMD operations:
SpecialRegSet(SPECIAL_REG_INPUT_BIT_WIDTH, 8);
SpecialRegSet(SPECIAL_REG_SIMD_OUTPUT_BIT_WIDTH, 32);Configure bit widths before performing CIM or SIMD operations to ensure correct data handling.
Last updated on