We review a unified approach for computing: (i) spin-transfer torque in magnetic trilayers like spin-valves and magnetic tunnel junction, where injected charge current flows perpendicularly to interfaces; and (ii) spin-orbit torque in magnetic bilayers of the type ferromagnet/spin-orbit-coupledmaterial, where injected charge current flows parallel to the interface. The experimentally explored and technologically relevant spin-orbit-coupled-materials include 5d heavy metals, topological insulators, Weyl semimetals and transition metal dichalcogenides. Our approach requires to construct the torque operator for a given Hamiltonian of the device and the steady-state nonequilibrium density matrix, where the latter is expressed in terms of the nonequilibrium Green's functions and split into three contributions. Tracing these contributions with the torque operator automatically yields field-like and damping-like components of spin-transfer torque or spin-orbit torque vector, which is particularly advantageous for spin-orbit torque where the direction of these components depends on the unknown-in-advance orientation of the current-driven nonequilibrium spin density in the presence of spin-orbit coupling. We provide illustrative examples by computing spin-transfer torque in a one-dimensional toy model of a magnetic tunnel junction and realistic Co/Cu/Co spin-valve, both of which are described by first-principles Hamiltonians obtained from noncollinear density functional theory calculations; as well as spin-orbit torque in a ferromagnetic layer described by a tight-binding Hamiltonian which includes spin-orbit proximity effect within ferromagnetic monolayers assumed to be generated by the adjacent monolayer transition metal dichalcogenide. In addition, we show how spin-orbit proximity effect, quantified by computing (via first-principles retarded Green's function) spectral functions and spin textures on monolayers of realistic ferromagnetic material like Co in contact with heavy metal or monolayer transition metal dichalcogenide, can be tailored to enhance the magnitude of spin-orbit torque. We also quantify errors made in the calculation of spin-transfer torque when using Hamiltonian from collinear density functional theory, with rigidly rotated magnetic moments to create noncollinear magnetization configurations, instead of proper (but computationally more expensive) self-consistent Hamiltonian obtained from noncollinear density functional theory. * bnikolic@udel.edu 1 For easy navigation, we provide a list of abbreviations used throughout the Chapter: 1D-Particle Current z y x Co Lead Co Lead Cu(a) (b) M free fixed M Co Pt θ θ M free MoS 2 Co M free θ (c) FIG. 2. Schematic view of: (a) FM/NM/FM trilayer for calculations of STT in spin-valves; (b) FM/HM bilayer for calculations of SOT in the presence of the spin Hall current along the z-axis generated by the HM layer; and (c) FM/monolayer-TMD for calculations of SOT in the absence of any spin Hall current. The semi-infinite FM layers in (a) are chosen as Co (0001), and t...