pytorch/caffe2/onnx/torch_ops/defs.cc
Nikita Shulga 4cb534f92e Make PyTorch code-base clang-tidy compliant (#56892)
Summary:
This is an automatic change generated by the following script:
```
#!/usr/bin/env python3
from subprocess import check_output, check_call
import os

def get_compiled_files_list():
    import json
    with open("build/compile_commands.json") as f:
        data = json.load(f)
    files = [os.path.relpath(node['file']) for node in data]
    for idx, fname in enumerate(files):
        if fname.startswith('build/') and fname.endswith('.DEFAULT.cpp'):
            files[idx] = fname[len('build/'):-len('.DEFAULT.cpp')]
    return files

def run_clang_tidy(fname):
    check_call(["python3", "tools/clang_tidy.py", "-c", "build", "-x", fname,"-s"])
    changes = check_output(["git", "ls-files", "-m"])
    if len(changes) == 0:
        return
    check_call(["git", "commit","--all", "-m", f"NOLINT stubs for {fname}"])

def main():
    git_files = check_output(["git", "ls-files"]).decode("ascii").split("\n")
    compiled_files = get_compiled_files_list()
    for idx, fname in enumerate(git_files):
        if fname not in compiled_files:
            continue
        if fname.startswith("caffe2/contrib/aten/"):
            continue
        print(f"[{idx}/{len(git_files)}] Processing {fname}")
        run_clang_tidy(fname)

if __name__ == "__main__":
    main()
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/56892

Reviewed By: H-Huang

Differential Revision: D27991944

Pulled By: malfet

fbshipit-source-id: 5415e1eb2c1b34319a4f03024bfaa087007d7179
2021-04-28 14:10:25 -07:00

169 lines
6.1 KiB
C++

// Copyright (c) Facebook Inc. and Microsoft Corporation.
// Licensed under the MIT license.
#include "./schema.h"
namespace ONNX_NAMESPACE {
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables,bugprone-branch-clone)
ONNX_PYTORCH_OPERATOR_SET_SCHEMA(
SparseLengthsSumFused8BitRowwise,
1,
OpSchema()
.SetDoc("Mirror Caffe2 SparseLengthsSumFused8BitRowwise operator")
.Input(0, "DATA", "data tensor", "T1")
.Input(1, "INDICES", "indices tensor", "T2")
.Input(2, "LENGTHS", "lengths tensor", "T2")
.Output(0, "output", "Output tensor", "T2")
.TypeConstraint(
"T1",
{"tensor(uint8)"},
"Constrain input data to uint8 tensors.")
.TypeConstraint(
"T2",
{"tensor(int8)",
"tensor(int16)",
"tensor(int32)",
"tensor(int64)",
"tensor(uint8)",
"tensor(uint16)",
"tensor(uint32)",
"tensor(uint64)"},
"Constrain index and length to integral tensors."));
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables,bugprone-branch-clone)
ONNX_PYTORCH_OPERATOR_SET_SCHEMA(
SparseLengthsSum,
1,
OpSchema()
.SetDoc("Mirror Caffe2 SparseLengthsSum operator")
.Input(0, "DATA", "data tensor", "T1")
.Input(1, "INDICES", "indices tensor", "T2")
.Input(2, "LENGTHS", "lengths tensor", "T2")
.Output(0, "output", "Output tensor", "T1")
.TypeConstraint(
"T1",
{"tensor(float16)", "tensor(float)", "tensor(double)"},
"Constrain input and output types to float tensors.")
.TypeConstraint(
"T2",
{"tensor(int8)",
"tensor(int16)",
"tensor(int32)",
"tensor(int64)",
"tensor(uint8)",
"tensor(uint16)",
"tensor(uint32)",
"tensor(uint64)"},
"Constrain index and length to integral tensors."));
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables,bugprone-branch-clone)
ONNX_PYTORCH_OPERATOR_SET_SCHEMA(
SparseLengthsWeightedSum,
1,
OpSchema()
.SetDoc("Mirror Caffe2 SparseLengthsWeightedSum operator")
.Input(0, "DATA", "data tensor", "T1")
.Input(1, "WEIGHTS", "data tensor", "T1")
.Input(2, "INDICES", "indices tensor", "T2")
.Input(3, "LENGTHS", "lengths tensor", "T2")
.Output(0, "output", "Output tensor", "T1")
.TypeConstraint(
"T1",
{"tensor(float16)", "tensor(float)", "tensor(double)"},
"Constrain input and output types to float tensors.")
.TypeConstraint(
"T2",
{"tensor(int8)",
"tensor(int16)",
"tensor(int32)",
"tensor(int64)",
"tensor(uint8)",
"tensor(uint16)",
"tensor(uint32)",
"tensor(uint64)"},
"Constrain index and length to integral tensors."));
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables,bugprone-branch-clone)
ONNX_PYTORCH_OPERATOR_SET_SCHEMA(
BatchGather,
1,
OpSchema()
.SetDoc("Mirror Caffe2 BatchGather operator")
.Input(0, "DATA", "data tensor", "T1")
.Input(1, "INDICES", "indices tensor", "T2")
.Output(0, "output", "Output tensor", "T1")
.TypeConstraint(
"T1",
{"tensor(float16)", "tensor(float)", "tensor(double)"},
"Constrain input and output types to float tensors.")
.TypeConstraint(
"T2",
{"tensor(int8)",
"tensor(int16)",
"tensor(int32)",
"tensor(int64)",
"tensor(uint8)",
"tensor(uint16)",
"tensor(uint32)",
"tensor(uint64)"},
"Constrain index and length to integral tensors."));
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables,bugprone-branch-clone)
ONNX_PYTORCH_OPERATOR_SET_SCHEMA(
DotProduct,
1,
OpSchema()
.SetDoc("Mirror Caffe2 DotProduct operator")
.Input(0, "X", "Input 1 tensor", "T")
.Input(1, "Y", "Input 2 tensor", "T")
.Output(0, "Z", "Output tensor", "T")
.TypeConstraint(
"T",
{"tensor(float16)", "tensor(float)", "tensor(double)"},
"Constrain input and output types to float tensors."));
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables,bugprone-branch-clone)
ONNX_PYTORCH_OPERATOR_SET_SCHEMA(
FCTransposed,
1,
OpSchema()
.SetDoc("Mirror Caffe2 FCTransposed operator")
.Input(0, "X", "Input tensor", "T")
.Input(1, "W", "Weight tensor", "T")
.Input(2, "B", "Bias tensor", "T")
.Output(0, "Z", "Output tensor", "T")
.TypeConstraint(
"T",
{"tensor(float16)", "tensor(float)", "tensor(double)"},
"Constrain input and output types to float tensors."));
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables,bugprone-branch-clone)
ONNX_PYTORCH_OPERATOR_SET_SCHEMA(
BatchMatMul,
1,
OpSchema()
.SetDoc("Mirror Caffe2 BatchMatMul operator")
.Input(0, "X", "tensor of shape (dim0, dim1 ... M, K)", "T")
.Input(1, "Y", "tensor of shape (dim0, dim2 ... K, N)", "T")
.Output(0, "Z", "tensor of shape (dim0, dim1 ... M, N)", "T")
.TypeConstraint(
"T",
{"tensor(float16)", "tensor(float)", "tensor(double)"},
"Constrain input and output types to float tensors."));
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables,bugprone-branch-clone)
ONNX_PYTORCH_OPERATOR_SET_SCHEMA(
ExpandDims,
1,
OpSchema()
.SetDoc("Mirror Caffe2 ExpandDims operator")
.Input(0, "X", "Input tensor", "T")
.Output(0, "Y", "Output tensor", "T")
.TypeConstraint(
"T",
{"tensor(float16)", "tensor(float)", "tensor(double)"},
"Constrain input and output types to float tensors."));
} // namespace ONNX_NAMESPACE