1 #include "caffe2/core/context.h" 2 #include "caffe2/core/operator.h" 7 class GetAllBlobNamesOp final :
public Operator<CPUContext> {
9 GetAllBlobNamesOp(
const OperatorDef& operator_def, Workspace* ws)
10 : Operator<CPUContext>(operator_def, ws),
11 include_shared_(GetSingleArgument<int>(
"include_shared", true)),
14 bool RunOnDevice()
override {
15 auto* out = Output(0);
16 const auto& blobs = include_shared_ ? ws_->Blobs() : ws_->LocalBlobs();
17 out->Resize(blobs.size());
18 std::copy(blobs.begin(), blobs.end(), out->mutable_data<std::string>());
27 REGISTER_CPU_OPERATOR(GetAllBlobNames, GetAllBlobNamesOp);
28 OPERATOR_SCHEMA(GetAllBlobNames)
32 Return a 1D tensor of strings containing the names 33 of each blob in the active workspace. 37 "(bool, default true) Whether to include blobs " 38 "inherited from parent workspaces.")
39 .Output(0,
"blob_names",
"1D tensor of strings containing blob names.");
40 SHOULD_NOT_DO_GRADIENT(GetAllBlobNamesOp);
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...