Side note here...I saw you posted a duplicate thread in the Lounge which has been removed (Site Rules). To help you with this original thread, I've made your title more descriptive.
As for the swap in question, I don't have a Mazda3 or personal experience with such a swap but I did find this video of a 2005 Mazda3 swap that might help to give you some idea of what's involved...
Swapping the engine due to major head gasket failure.
youtu.be
I created this video with the YouTube Video Editor (http://www.youtube.com/editor)
youtu.be
It appears that the second generation Mazda3 2.0L is a carry-over from the first generation Mazda3...BUT...The 2012 Mazda3 received an update including a SkyActiv-G 2.0-liter.
I'm no expert but if the 2012 2.0L engine you have in mind is a SkyActiv version, that would presumably make such a swap a lot more complicated.
If the 2012 2.0L engine is not SkyActiv then it may be possible (without major complications) but again I'm no expert...Hopefully someone a lot more familiar with Mazda3 swaps can chime in here!
Ps...The smoothest path (if you're just looking to replace the engine) I would think is to find the exact same type of engine (same year, model etc) in good condition and use that for the swap.