1 #include "caffe2/sgd/iter_op.h" 3 #ifdef CAFFE2_USE_MKLDNN 4 #include <caffe2/ideep/operators/operator_fallback_ideep.h> 5 #include <caffe2/ideep/utils/ideep_operator.h> 14 BlobSerializerBase::SerializationAcceptor acceptor) {
15 CAFFE_ENFORCE(typeMeta.Match<std::unique_ptr<std::mutex>>());
17 blob_proto.set_name(name);
18 blob_proto.set_type(
"std::unique_ptr<std::mutex>");
19 blob_proto.set_content(
"");
20 acceptor(name, SerializeBlobProtoAsString_EnforceCheck(blob_proto));
23 void MutexDeserializer::Deserialize(
const BlobProto& ,
Blob* blob) {
24 *blob->
GetMutable<std::unique_ptr<std::mutex>>() =
25 caffe2::make_unique<std::mutex>();
31 #ifdef CAFFE2_USE_MKLDNN 35 REGISTER_BLOB_SERIALIZER(
36 (TypeMeta::Id<std::unique_ptr<std::mutex>>()),
43 .EnforceInplace({{0, 0}})
45 Stores a singe integer, that gets incremented on each call to Run(). 46 Useful for tracking the iteration count during SGD, for example. 49 OPERATOR_SCHEMA(AtomicIter) 52 .EnforceInplace({{1, 0}}) 54 Similar to Iter, but takes a mutex as the first input to make sure that 55 updates are carried out atomically. This can be used in e.g. Hogwild sgd 58 .Input(0, "mutex",
"The mutex used to do atomic increment.")
59 .Input(1,
"iter",
"The iter counter as an int64_t TensorCPU.");
62 NO_GRADIENT(AtomicIter);
Blob is a general container that hosts a typed pointer.
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
T * GetMutable()
Gets a mutable pointer to the stored object.
void Serialize(const void *pointer, TypeMeta typeMeta, const string &name, BlobSerializerBase::SerializationAcceptor acceptor) override
Serializes a std::unique_ptr<std::mutex>.
A templated class to allow one to wrap a CPU operator as an IDEEP operator.