{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.runlocal.ai/schemas/v1/torch-operators.json",
  "title": "Torch API catalog",
  "description": "An extracted Torch API availability and signature catalog. It contains no copied behavioral documentation.",
  "type": "object",
  "required": [
    "kind",
    "catalog_version",
    "torch_release",
    "source",
    "namespaces",
    "dtypes",
    "callable_count",
    "callables"
  ],
  "properties": {
    "kind": {
      "description": "Always \"runlocal.torch_api_catalog\". Selects this alternative.",
      "type": "string",
      "const": "runlocal.torch_api_catalog"
    },
    "catalog_version": {
      "description": "Always \"2.0\". Selects this alternative.",
      "type": "string",
      "const": "2.0"
    },
    "torch_release": {
      "description": "The exact Torch package version for this catalog.",
      "type": "string",
      "pattern": "^(?:[1-9][0-9]*!)?(?:0|[1-9][0-9]*)(?:\\.(?:0|[1-9][0-9]*))*(?:(?:a|b|rc)(?:0|[1-9][0-9]*))?(?:\\.post(?:0|[1-9][0-9]*))?(?:\\.dev(?:0|[1-9][0-9]*))?(?:\\+[a-z0-9]+(?:\\.[a-z0-9]+)*)?(?![\\s\\S])",
      "maxLength": 128
    },
    "source": {
      "description": "The immutable release and official documentation used for this catalog.",
      "type": "object",
      "required": [
        "repository",
        "tag",
        "commit",
        "package",
        "documentation",
        "license"
      ],
      "properties": {
        "repository": {
          "description": "The official source repository.",
          "type": "string",
          "pattern": "^https://"
        },
        "tag": {
          "description": "The source tag for this Torch release.",
          "type": "string"
        },
        "commit": {
          "description": "The source commit for this Torch release.",
          "type": "string",
          "pattern": "^[0-9a-f]{40}$"
        },
        "package": {
          "description": "The exact Python package requirement used for this catalog.",
          "type": "string"
        },
        "documentation": {
          "description": "The official versioned documentation root.",
          "type": "string",
          "pattern": "^https://"
        },
        "license": {
          "description": "Always \"BSD-3-Clause\". Selects this alternative.",
          "type": "string",
          "const": "BSD-3-Clause"
        }
      },
      "additionalProperties": false
    },
    "namespaces": {
      "description": "The public namespaces that the export reads.",
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string"
      }
    },
    "dtypes": {
      "description": "Each name that the package gives to a dtype, without the torch prefix. Some names state one dtype, such as float32 and float.",
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9_]*$"
      }
    },
    "callable_count": {
      "description": "The number of entries in callables.",
      "type": "integer",
      "minimum": 1
    },
    "callables": {
      "description": "The public callables of the namespaces. A callable whose name ends with an underscore writes into its input and is not included.",
      "type": "array",
      "minItems": 1,
      "items": {
        "description": "Availability and signature metadata for one public callable. The package code, not this record, defines behavior.",
        "type": "object",
        "required": [
          "callable",
          "kind",
          "source",
          "random",
          "signatures",
          "module_state"
        ],
        "properties": {
          "callable": {
            "description": "The fully qualified public Torch callable.",
            "type": "string",
            "pattern": "^torch(?:\\.[A-Za-z_][A-Za-z0-9_]*)+(?![\\s\\S])"
          },
          "kind": {
            "description": "The public Python API category.",
            "type": "string",
            "enum": [
              "function",
              "tensor_method",
              "module"
            ]
          },
          "source": {
            "description": "Where the signatures come from: the type stubs that the package generates from its Python bindings, the ATen operator schemas when a built-in callable has no stub, or Python inspection.",
            "type": "string",
            "enum": [
              "stub",
              "aten",
              "python"
            ]
          },
          "random": {
            "description": "Whether the package tags an overload as random with a seed.",
            "type": "boolean"
          },
          "signatures": {
            "description": "The signatures that a node can state.",
            "type": "array",
            "minItems": 1,
            "items": {
              "description": "One signature. A built-in callable has one call signature for each overload that a node can state.",
              "type": "object",
              "required": [
                "phase",
                "overload",
                "selected_by",
                "parameters",
                "returns",
                "outputs"
              ],
              "properties": {
                "phase": {
                  "description": "Whether this is a call or a module constructor signature.",
                  "type": "string",
                  "enum": [
                    "call",
                    "constructor"
                  ]
                },
                "overload": {
                  "description": "A name for this overload: its position among the stub overloads that a node can state, or its ATen overload name. Empty when the callable has one signature.",
                  "type": "string"
                },
                "selected_by": {
                  "description": "The flag value that selects this signature, or null when the arguments alone select it.",
                  "anyOf": [
                    {
                      "description": "The flag value that selects one branch of a boolean dispatch function, such as return_indices of max_pool2d. The branches return another number of tensors.",
                      "type": "object",
                      "required": [
                        "parameter",
                        "equals",
                        "when_omitted"
                      ],
                      "properties": {
                        "parameter": {
                          "description": "The boolean parameter that selects this signature.",
                          "type": "string",
                          "pattern": "^[A-Za-z_][A-Za-z0-9_]*(?![\\s\\S])"
                        },
                        "equals": {
                          "description": "The value that selects this signature.",
                          "type": "boolean"
                        },
                        "when_omitted": {
                          "description": "Whether the default of the parameter selects this signature.",
                          "type": "boolean"
                        }
                      },
                      "additionalProperties": false
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "parameters": {
                  "description": "The parameters in signature order.",
                  "type": "array",
                  "items": {
                    "description": "One parameter, as the pinned package states it. Text fields are metadata and are not executed.",
                    "type": "object",
                    "required": [
                      "name",
                      "kind",
                      "class",
                      "type",
                      "required",
                      "default",
                      "extents",
                      "json"
                    ],
                    "properties": {
                      "name": {
                        "description": "The Python parameter name.",
                        "type": "string",
                        "pattern": "^[A-Za-z_][A-Za-z0-9_]*(?![\\s\\S])"
                      },
                      "kind": {
                        "description": "The Python signature parameter kind.",
                        "type": "string",
                        "enum": [
                          "positional_only",
                          "positional_or_keyword",
                          "keyword_only",
                          "variadic_positional",
                          "variadic_keyword"
                        ]
                      },
                      "class": {
                        "description": "How a node binds this parameter. tensor takes one tensor. tensors takes a tensor list. value takes a JSON literal. dtype takes a Torch dtype name. size takes integers and dimension names. mutation makes the call write into an argument, so a node can bind only the value that disables it. placement selects a device or a memory layout, which a request does not state, so a node cannot bind it. unsupported has a type that a node cannot state. unknown has no type in the package.",
                        "type": "string",
                        "enum": [
                          "tensor",
                          "tensors",
                          "value",
                          "dtype",
                          "size",
                          "mutation",
                          "placement",
                          "unsupported",
                          "unknown"
                        ]
                      },
                      "type": {
                        "description": "The displayed type from the package, or null when it states none.",
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "required": {
                        "description": "Whether the caller must provide this parameter.",
                        "type": "boolean"
                      },
                      "default": {
                        "description": "The displayed default, or null when there is no default.",
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "extents": {
                        "description": "What a size parameter takes, or null for another class.",
                        "anyOf": [
                          {
                            "description": "one takes one extent. list takes a list of extents. any takes both, such as the stride of a convolution.",
                            "type": "string",
                            "enum": [
                              "one",
                              "list",
                              "any"
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "json": {
                        "description": "The JSON types that a literal argument can have. A value parameter always has them. A tensor, tensors, dtype, or size parameter has them when its type also takes a literal, such as None or a number. Null when the parameter takes no literal.",
                        "anyOf": [
                          {
                            "description": "The JSON types of a literal argument. The pinned package, not this record, defines which values are valid.",
                            "type": "object",
                            "required": [
                              "types",
                              "items"
                            ],
                            "properties": {
                              "types": {
                                "description": "The JSON value types this parameter accepts. An integer is also a number.",
                                "type": "array",
                                "minItems": 1,
                                "uniqueItems": true,
                                "items": {
                                  "description": "One JSON value type.",
                                  "type": "string",
                                  "enum": [
                                    "null",
                                    "boolean",
                                    "integer",
                                    "number",
                                    "string",
                                    "array"
                                  ]
                                }
                              },
                              "items": {
                                "description": "The item types of an array value, or null when the parameter takes no array.",
                                "anyOf": [
                                  {
                                    "description": "The JSON value types of each array item.",
                                    "type": "array",
                                    "minItems": 1,
                                    "uniqueItems": true,
                                    "items": {
                                      "description": "One JSON value type.",
                                      "type": "string",
                                      "enum": [
                                        "null",
                                        "boolean",
                                        "integer",
                                        "number",
                                        "string",
                                        "array"
                                      ]
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            },
                            "additionalProperties": false
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    },
                    "additionalProperties": false
                  }
                },
                "returns": {
                  "description": "The displayed return type, or null.",
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "outputs": {
                  "description": "The flat tensor output count of a call, or null when the package does not state it.",
                  "anyOf": [
                    {
                      "description": "The number of flat tensor outputs returned by a call.",
                      "type": "object",
                      "required": [
                        "minimum",
                        "maximum"
                      ],
                      "properties": {
                        "minimum": {
                          "description": "The minimum number of flat tensor outputs.",
                          "type": "integer",
                          "minimum": 0
                        },
                        "maximum": {
                          "description": "The maximum number of flat tensor outputs, or null when unbounded.",
                          "anyOf": [
                            {
                              "type": "integer",
                              "minimum": 0
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "additionalProperties": false
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "additionalProperties": false
            }
          },
          "module_state": {
            "description": "The module state, or null for a function, a tensor method, or a class whose state the export cannot read.",
            "anyOf": [
              {
                "description": "The module state that a node must supply. The export reads it from instances on the meta device.",
                "type": "object",
                "required": [
                  "parameters",
                  "buffers"
                ],
                "properties": {
                  "parameters": {
                    "description": "The module parameter names.",
                    "type": "array",
                    "items": {
                      "description": "One module parameter or persistent buffer of the public class.",
                      "type": "object",
                      "required": [
                        "name",
                        "when"
                      ],
                      "properties": {
                        "name": {
                          "description": "The qualified parameter or buffer name.",
                          "type": "string",
                          "pattern": "^[^.\\u0000-\\u001F\\u007F]+(?:\\.[^.\\u0000-\\u001F\\u007F]+)*(?![\\s\\S])",
                          "maxLength": 512
                        },
                        "when": {
                          "description": "The state value is present when each condition holds. Empty means always present.",
                          "type": "array",
                          "items": {
                            "description": "One constructor condition of a module state value.",
                            "type": "object",
                            "required": [
                              "constructor_parameter",
                              "equals",
                              "when_omitted"
                            ],
                            "properties": {
                              "constructor_parameter": {
                                "description": "The boolean constructor parameter that controls this state value.",
                                "type": "string",
                                "pattern": "^[A-Za-z_][A-Za-z0-9_]*(?![\\s\\S])"
                              },
                              "equals": {
                                "description": "The value for which this state value can be present.",
                                "type": "boolean"
                              },
                              "when_omitted": {
                                "description": "Whether the condition holds when the constructor parameter is omitted.",
                                "type": "boolean"
                              }
                            },
                            "additionalProperties": false
                          }
                        }
                      },
                      "additionalProperties": false
                    }
                  },
                  "buffers": {
                    "description": "The persistent module buffer names.",
                    "type": "array",
                    "items": {
                      "description": "One module parameter or persistent buffer of the public class.",
                      "type": "object",
                      "required": [
                        "name",
                        "when"
                      ],
                      "properties": {
                        "name": {
                          "description": "The qualified parameter or buffer name.",
                          "type": "string",
                          "pattern": "^[^.\\u0000-\\u001F\\u007F]+(?:\\.[^.\\u0000-\\u001F\\u007F]+)*(?![\\s\\S])",
                          "maxLength": 512
                        },
                        "when": {
                          "description": "The state value is present when each condition holds. Empty means always present.",
                          "type": "array",
                          "items": {
                            "description": "One constructor condition of a module state value.",
                            "type": "object",
                            "required": [
                              "constructor_parameter",
                              "equals",
                              "when_omitted"
                            ],
                            "properties": {
                              "constructor_parameter": {
                                "description": "The boolean constructor parameter that controls this state value.",
                                "type": "string",
                                "pattern": "^[A-Za-z_][A-Za-z0-9_]*(?![\\s\\S])"
                              },
                              "equals": {
                                "description": "The value for which this state value can be present.",
                                "type": "boolean"
                              },
                              "when_omitted": {
                                "description": "Whether the condition holds when the constructor parameter is omitted.",
                                "type": "boolean"
                              }
                            },
                            "additionalProperties": false
                          }
                        }
                      },
                      "additionalProperties": false
                    }
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false
      }
    }
  },
  "additionalProperties": false
}
