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 (404 - 412) of a class hierarchy that inherit from the base layer class type, the plurality of subclass types providing abstractions of functionality for deep learning network layer types, where the abstractions 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 (404 - 412); adding to the one or more IRs instantiations of objects for the respective ones of the plurality of subclass types (404 - 412) that map to the group of network layers of the deep learning network, first calls to perform the at least one of the setup function, the predict function, or the cleanup function on the instantiated objects, and second calls from the instantiated objects 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. 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 (404 - 412) of a class hierarchy that inherit from the base layer class type, the plurality of subclass types providing abstractions of functionality for deep learning network layer types, where the abstractions 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; 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 (404 - 412) of a class hierarchy that inherit from the base layer class type, the plurality of subclass types providing abstractions of functionality for deep learning network layer types, where the abstractions 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 (404 - 412); adding to the one or more IRs instantiations of objects for the respective ones of the plurality of subclass types (404 - 412) that map to the group of network layers of the deep learning network, first calls to perform the at least one of the setup function, the predict function, or the cleanup function on the instantiated objects, and second calls from the instantiated objects 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. 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 (404 - 412); adding to the one or more IRs instantiations of objects for the respective ones of the plurality of subclass types (404 - 412) that map to the group of network layers of the deep learning network, first calls to perform the at least one of the setup function, the predict function, or the cleanup function on the instantiated objects, and second calls from the instantiated objects 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.