    def _codegen_param_setup(
        self,
        tensor: Tensor,
    ) -> None:
        """
        Generate code needed for setting up a constant in Model/ModelContainer.
        """
        name = tensor._attrs["name"]
        data = tensor._attrs["data"]
        const_slice = self._tensor_slice_func(tensor, "constants")
        if data is not None:
            # Owned constant. Set up logic for copying the constant in from *.so.
            self.set_up_constants.append(const_slice)
            self.set_up_constants.append(
                set_value(
                    f'constant_name_to_ptr_["{name}"]',
                    f"const_cast<const void**>(reinterpret_cast<void**>(&{name}))",
                )
            )
            self._codegen_bound_constant(tensor)
            if not tensor._attrs.get("is_internal_constant", False):
                self.reset_constants.append(const_slice)
            if self.constants_data_file is not None:
                self._add_owned_constant(tensor)
        elif tensor._attrs["constant_folding_output_idx"] is not None:
            self.set_up_constant_folding_outputs_offsets.append(
                set_value(
                    f'constant_folding_outputs_offsets_[{tensor._attrs["constant_folding_output_idx"]}]',
                    tensor._attrs["offset"],
                )
            )
            self.tensor_slice.append(const_slice)
            if not tensor._attrs.get("is_internal_constant", False):
                self.reset_constants.append(const_slice)
        elif not isinstance(tensor, IntVarTensor):
            # Unbound constant. We will expect the user to set this via SetConstant.
            self.set_up_constant_names.append(
                set_value(
                    f'unbound_constant_name_to_idx_["{name}"]',
                    self.unbound_constant_idx,
                )
            )
            original_name = tensor._attrs.get("original_name")
            if original_name is not None:
                self.set_up_constant_original_names.append(
                    set_value(
                        f'constant_name_to_original_name_["{name}"]',
                        f'"{original_name}"',
                    )
                )
            self._record_param_tensor_info(
                tensor,
                self.unbound_constant_idx + self.num_inputs + self.num_outputs,
            )
            self.unbound_constant_idx += 1
            self.set_inputs.append(check_not_null(tensor))
            self.set_up_constants.append(
                set_value(
                    f'constant_name_to_ptr_["{name}"]',
                    f"const_cast<const void**>(reinterpret_cast<void**>(&{name}))",
                )
            )
Generate code needed for setting up a constant in Model/ModelContainer.
python/aitemplate/backend/codegen.py