Terahertz (THz) communications recently attract significant attention and become an emerging technology pillar for sixth generation (6G) wireless systems. Due to the serious path attenuation of THz signals, THz communication is applicable for the short-distance indoor scenarios. However, the THz waves are easily blocked by obstacles, leading to a communication interruption. To this end, an intelligent reflecting surface (IRS), which interacts with incident THz waves in a controlled manner by adjusting the discrete phase shifts of the IRS elements, is considered as a promising technology to mitigate blockage vulnerability and enhance coverage capability for indoor scenarios. In light of graphene-enabled hardware structure of an IRS, the IRS-assisted THz multiple-input multiple-output (MIMO) system model is developed. Moreover, an iterative atom pruning based subspace pursuit (IAP-SP) scheme is developed for channel estimation. Compared to the classical subspace pursuit (SP) scheme, the proposed IAP-SP algorithm can substantially reduce the computational complexity while maintaining accurate channel recovery. With the estimated channel, a data rate maximization problem is formulated, which can be converted to a discrete phase shift search problem. The exhaustive search method is firstly proposed to obtain the optimal transmission rate but endure extremely high computational burden. Then, a local search method is proposed to decrease the number of possible discrete phase candidates of IRS while undergoes obvious performance loss. Interestingly, a novel feedforward fully connected structure based deep neural network (DNN) scheme is put forward, which has the ability to learn how to output the optimal phase shift configurations by inputting the features of estimated channel. Simulation results demonstrate that, in contrast with the exhaustive search scheme and the local search scheme, the proposed DNN-based scheme achieves a near-optimal communication rate performance. Meanwhile, the DNN-based scheme enormously alleviates the computational complexity and allows for dynamic parameter adaption in rapid-varying channel conditions. INDEX TERMS Terahertz (THz) communications, sixth generation (6G), intelligent reflecting surface (IRS), channel estimation, deep neural network (DNN).