1 #include "caffe2/core/context.h" 2 #include "caffe2/core/operator.h" 7 class GetAllBlobNamesOp final :
public Operator<CPUContext> {
9 explicit 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 const auto& blobs = include_shared_ ? ws_->Blobs() : ws_->LocalBlobs();
16 auto* out = Output(0, {
static_cast<int64_t
>(blobs.size())}, at::dtype<std::string>());
18 blobs.begin(), blobs.end(), out->template 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 ...