20 #include "caffe2/core/init.h" 21 #include "caffe2/core/operator.h" 22 #include "caffe2/core/operator_schema.h" 24 C10_DEFINE_string(schema,
"",
"Print doc and schema of a particular operator");
26 static bool HasSchema(
const std::string& str) {
27 return caffe2::OpSchemaRegistry::Schema(str);
30 static bool HasDoc(
const std::string& str) {
31 const auto* schema = caffe2::OpSchemaRegistry::Schema(str);
32 return (schema !=
nullptr) && (schema->doc() !=
nullptr);
35 int main(
int argc,
char** argv) {
38 if (!FLAGS_schema.empty()) {
39 const auto* schema = caffe2::OpSchemaRegistry::Schema(FLAGS_schema);
41 std::cerr <<
"Operator " << FLAGS_schema <<
" doesn't have a schema" 45 std::cout <<
"Operator " << FLAGS_schema <<
": " << std::endl << *schema;
49 for (
const auto& pair : *caffe2::gDeviceTypeRegistry()) {
50 std::cout <<
"Device type " << pair.first
51 #ifndef CAFFE2_USE_LITE_PROTO 53 << at::DeviceTypeName(static_cast<caffe2::DeviceType>(pair.first))
57 for (
const auto& key : pair.second->Keys()) {
58 std::cout <<
"\t(schema: " << HasSchema(key) <<
", doc: " << HasDoc(key)
59 <<
")\t" << key << std::endl;
63 std::cout <<
"Operators that have gradients registered:" << std::endl;
64 for (
const auto& key : caffe2::GradientRegistry()->Keys()) {
65 std::cout <<
"\t(schema: " << HasSchema(key) <<
", doc: " 66 << HasDoc(key) <<
")\t" bool GlobalInit(int *pargc, char ***pargv)
Initialize the global environment of caffe2.