Skip to content

Instantly share code, notes, and snippets.

@edgarriba
Last active August 5, 2016 07:08
Show Gist options
  • Save edgarriba/df8ae6e567cb85ea62e7d20a8081f89a to your computer and use it in GitHub Desktop.
Save edgarriba/df8ae6e567cb85ea62e7d20a8081f89a to your computer and use it in GitHub Desktop.
@startuml
package layers #DDDDDD {
enum Engine {
CUSTOM
NNPACK
AVX
AVX2
SSE
OPENCL
}
class Node {
}
abstract class Layer {
- EngineType engine
+ virtual void forward_propagation()
+ virtual void backward_propagation()
}
Node <|-- Layer
class ConvolutionalLayer {
}
Layer <|-- ConvolutionalLayer
}
package core.kernels #DDDDDD {
class OpKernelConstructor {
- Device device
+ OpKernelConstruction(Device device)
}
class OpKernelContext {
}
abstract class OpKernel {
+ OpKernel(OpKernelConstruction context)
+ virtual void compute(OpKernelContext context)
}
ConvolutionalLayer *-- OpKernel
class Conv2dLibDNNOp {
}
class Conv2dOpenCLOp {
}
class Conv2dAVXOp {
}
OpKernel <|-- Conv2dLibDNNOp
OpKernel <|-- Conv2dOpenCLOp
OpKernel <|-- Conv2dAVXOp
Conv2dLibDNNOp ..> Config
Conv2dOpenCLOp ..> Config
Conv2dAVXOp ..> Config
}
class Config {
+ bool hasAVX()
+ bool hasAVX2()
+ bool hasSSE()
+ bool hasNEON()
+ int availableGPUNum()
}
package core.framework #DDDDDD {
class Context {
- bool is_opencl
- CLCudaAPI::Context device_context
}
class Device {
- Context context
+ Device(DeviceType device_type)
+ Device(DeviceType device_type, int platform_id, int device_id)
+ registerOp(Layer op)
}
class Program {
- Device device
- Layer op
- CLCuda::Program op_program
}
note right: A program is per layer type, not per Op.
class OpenCLProgramManager {
+ registerOp(Device device, Layer op)
}
note right: Singleton instance
OpenCLProgramManager *-- Program
Program *-- OpKernel
}
@enduml
@edgarriba
Copy link
Author

@edgarriba
Copy link
Author

hi! I open this gist to iterate over the framework design. IMO, we should reshape the backend API since now we need to share device context between layers depending on the user (or possible future automatic mechanism) specifications like device type, layer backend and type of layer (case of LibDNN for Convs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment