20 #include "caffe2/core/init.h" 21 #include "caffe2/core/operator.h" 22 #include "caffe2/core/operator_schema.h" 24 CAFFE2_DEFINE_string(schema,
"",
25 "Print doc and schema of a particular operator");
27 static bool HasSchema(
const std::string& str) {
28 return caffe2::OpSchemaRegistry::Schema(str);
31 static bool HasDoc(
const std::string& str) {
32 const auto* schema = caffe2::OpSchemaRegistry::Schema(str);
33 return (schema !=
nullptr) && (schema->doc() !=
nullptr);
36 int main(
int argc,
char** argv) {
39 if (!caffe2::FLAGS_schema.empty()) {
40 const auto* schema = caffe2::OpSchemaRegistry::Schema(
41 caffe2::FLAGS_schema);
43 std::cerr <<
"Operator " << caffe2::FLAGS_schema
44 <<
" doesn't have a schema" << std::endl;
47 std::cout <<
"Operator " << caffe2::FLAGS_schema <<
": " << std::endl
52 for (
const auto& pair : *caffe2::gDeviceTypeRegistry()) {
53 std::cout <<
"Device type " << pair.first
54 #ifndef CAFFE2_USE_LITE_PROTO 55 <<
" (" << caffe2::DeviceType_Name(
56 static_cast<caffe2::DeviceType>(pair.first))
60 for (
const auto& key : pair.second->Keys()) {
61 std::cout <<
"\t(schema: " << HasSchema(key) <<
", doc: " << HasDoc(key)
62 <<
")\t" << key << std::endl;
66 std::cout <<
"Operators that have gradients registered:" << std::endl;
67 for (
const auto& key : caffe2::GradientRegistry()->Keys()) {
68 std::cout <<
"\t(schema: " << HasSchema(key) <<
", doc: " 69 << HasDoc(key) <<
")\t" bool GlobalInit(int *pargc, char ***pargv)
Initialize the global environment of caffe2.