Grating garlic in a stir-fry releases more of its flavor and aroma quickly, ensuring it infuses the oil and other ingredients more thoroughly than chopped garlic. This is especially useful when you want a strong garlic presence.
When garlic is grated, its cell walls are ruptured to a much greater extent than when it's chopped. This releases a higher concentration of allicin, the compound responsible for garlic's pungent flavor and aroma. In a stir-fry, where cooking time is typically short and high heat is used, grating garlic allows it to quickly impart its flavor to the oil and other ingredients. Chopping garlic, while still effective, doesn't release as much flavor as quickly, potentially resulting in a less intense garlic flavor in the final dish. The smaller particles of grated garlic also distribute more evenly throughout the stir-fry, ensuring a consistent flavor profile in every bite. Furthermore, grated garlic tends to brown and crisp up more readily than chopped garlic, adding a pleasant textural element to the dish.
Be careful not to burn grated garlic, as it cooks very quickly. Add it towards the end of the stir-fry process, after other vegetables have started to soften, to prevent it from becoming bitter.