1. A method comprising: for a source program that implements a deep learning network, the deep learning network including network layers and network parameters, storing, in a memory, a framework that includes a base layer class type that defines at least one of a setup function, a predict function, or a cleanup function, a plurality of subclass types of a class hierarchy that inherit from the base layer class type, the plurality of subclass types representing abstractions of functionality performed by deep learning network layer types, where the plurality of subclass types are independent of any particular processor architecture, and an interface layer that interfaces the class hierarchy to sets of predefined deep learning functions, where the sets of predefined deep learning functions are configured for execution at target hardware platforms; generating code, by a processor coupled to the memory, for executing the source program on a target platform, the generating including: generating, by the processor, one or more in-memory intermediate representations (IRs) for the source program; mapping a group of the network layers of the deep learning network to respective ones of the plurality of subclass types; adding to the one or more IRs statements to instantiate objects for the respective ones of the plurality of subclass types that map to the group of network layers of the deep learning network, and first calls to perform the at least one of the setup function, the predict function, or the cleanup function on the objects, utilizing the one or more IRs to produce the code, where the code includes the objects instantiated in response to the statements and second calls from the objects instantiated in response to the statements to a selected one of the sets of predefined deep learning functions via the interface layer; and linking the selected one of the sets of predefined deep learning functions to the generated code.