Commit Graph

7 Commits

Author SHA1 Message Date
Hexus (Shihao Xu)
bd95f8f948 Resolve name conflict of ContextManager (#7244)
* Resolve conflicting name, ContextManager

Concept name `Context Manager` is taken by Python. See https://docs.python.org/3.6/reference/datamodel.html#with-statement-context-managers

It says,
A context manager is an object that defines the runtime context to be established when executing a with statement. The context manager handles the entry into, and the exit from, the desired runtime context for the execution of the block of code.

The `ContextManager` here is more like a registry. 
And there is a C++ registry in caffe2 codebase `caffe2/caffe2/core/registry.h`.
There is also a Caffe2DBRegistry, declared by calling `CAFFE_DECLARE_REGISTRY(Caffe2DBRegistry, DB, const string&, Mode);` in `caffe2/caffe2/core/db.h`.

I think we can follow the concept name `Registry`, calling it `ContextRegistry`.

* Make Classes and Functions internal to this module start with "_"

Make Classes and Functions internal to this module start with "_"

* Update context.py

* Update context.py
2018-06-22 00:41:51 -04:00
Orion Reblitz-Richardson
1d5780d42c Remove Apache headers from source.
* LICENSE file contains details, so removing from individual source files.
2018-03-27 13:10:18 -07:00
Yangqing Jia
8286ce1e3a Re-license to Apache
Summary: Closes https://github.com/caffe2/caffe2/pull/1260

Differential Revision: D5906739

Pulled By: Yangqing

fbshipit-source-id: e482ba9ba60b5337d9165f28f7ec68d4518a0902
2017-09-28 16:22:00 -07:00
Kittipat Virochsiri
058815955d Add default implementation of __call__ for context manager
Summary: Making it more convenient to wrap code int context

Reviewed By: boryiingsu

Differential Revision: D5680991

fbshipit-source-id: 07b7e4d5aa657184039a7d18192b68fe11c1a570
2017-08-22 17:46:22 -07:00
Aaron Markham
58f7f2b441 doxygen python block added
Summary: Closes https://github.com/caffe2/caffe2/pull/226

Differential Revision: D4793550

Pulled By: JoelMarcey

fbshipit-source-id: cc33e58186304fa8dcac2ee9115dcc271d785b1e
2017-03-29 06:46:16 -07:00
Alisson Gusatti Azzolini
b7783a1976 Make ContextManager thread-safe
Summary: ContextManager was thread local. This caused issues because the context registration needs to be global. What needs to be thread local is the current context.

Reviewed By: jhcross

Differential Revision: D4556050

fbshipit-source-id: 5de1c0d9fd0a778c4cb1eadef01f9a1ab488f603
2017-02-13 19:45:35 -08:00
Yangqing Jia
238ceab825 fbsync. TODO: check if build files need update. 2016-11-15 00:00:46 -08:00