Skip to content

Commit 8b1a63b

Browse files
authored
Update and fix copyright headers (#1589)
Updates the header according to https://docs.opensource.microsoft.com/releasing/general-guidance/copyright-headers/ and enforce it with ruff. Ref: https://docs.opensource.microsoft.com/news/2019-07-02-cela-all-rights-reserved/ Fix additional ruff lint errors due to enabling `--preview` rules for the copyright header lint check.
1 parent b007b12 commit 8b1a63b

File tree

215 files changed

+454
-347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+454
-347
lines changed

docs/conf.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
# Configuration file for the Sphinx documentation builder.
2-
# To run the documentation: python -m sphinx docs dist/html
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
"""Configuration file for the Sphinx documentation builder.
4+
5+
To run the documentation: python -m sphinx docs dist/html
6+
"""
37

48
import os
59
import re

docs/examples/01_plot_selu.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
"""
24
Generating a FunctionProto
35
==========================

docs/examples/02_plot_square_loss.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
"""
24
Generating a ModelProto
35
=======================

docs/examples/03_export_lib.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
"""
24
Generating a LibProto
35
=====================

docs/examples/04_plot_eager_mode_evaluation.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
"""
24
Eager mode evaluation
35
=====================

docs/examples/05_plot_model_props.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
"""
24
ModelProto Properties
35
=====================

docs/examples/06_plot_model_local_funs.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
"""
24
Model Local Functions
35
=====================

docs/test/test_documentation_examples.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# -------------------------------------------------------------------------
2-
# Copyright (c) Microsoft Corporation. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
32
# Licensed under the MIT License.
4-
# --------------------------------------------------------------------------
53

64
import os
75
import subprocess

docs/tutorial/examples/dropout.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
from onnxscript import opset15 as op
24
from onnxscript import script
35

docs/tutorial/examples/firstdim.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
from onnxscript import opset15 as op
24
from onnxscript import script
35

docs/tutorial/examples/forloop.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
from onnxscript import opset15 as op
24
from onnxscript import script
35

docs/tutorial/examples/forwhileloop.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
from onnxscript import opset15 as op
24
from onnxscript import script
35

docs/tutorial/examples/hardmax_end_to_end.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
import onnx
24

35
# We use ONNX opset 15 to define the function below.

docs/tutorial/examples/leaky_relu.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
from onnxscript import opset15 as op
24
from onnxscript import script
35

docs/tutorial/examples/leaky_relu_attr_promoted.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
from onnxscript import opset15 as op
24
from onnxscript import script
35

docs/tutorial/examples/omitted_input.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
from onnxscript import opset15 as op
24
from onnxscript import script
35

docs/tutorial/examples/outerscope_redef_error.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
from onnxscript import graph, script
24
from onnxscript import opset15 as op
35

@@ -13,7 +15,7 @@ def Sum(sum_in, next):
1315
return sum_out, sum_out
1416

1517
g = op.Constant(value=1)
16-
all_sum, cumulative_sum = op.Scan(0, X, body=Sum, num_scan_inputs=1)
18+
_all_sum, cumulative_sum = op.Scan(0, X, body=Sum, num_scan_inputs=1)
1719
return cumulative_sum
1820

1921
except Exception as e:

docs/tutorial/examples/scanloop.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
from onnxscript import graph, script
24
from onnxscript import opset15 as op
35

@@ -9,5 +11,5 @@ def Sum(sum_in, next):
911
sum_out = sum_in + next
1012
return sum_out, sum_out
1113

12-
all_sum, cumulative_sum = op.Scan(0, X, body=Sum, num_scan_inputs=1)
14+
_all_sum, cumulative_sum = op.Scan(0, X, body=Sum, num_scan_inputs=1)
1315
return cumulative_sum

docs/tutorial/examples/softplus.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
# We use ONNX opset 15 to define the function below.
24
from onnxscript import opset15 as op
35
from onnxscript import script

docs/tutorial/examples/tensor_attr.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
from onnx import TensorProto, helper
24

35
from onnxscript import opset15 as op

docs/tutorial/examples/tensor_attr2.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
from onnx import TensorProto, helper
24

35
from onnxscript import opset15 as op

docs/tutorial/examples/tensor_attr_short.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
from onnxscript import opset15 as op
24
from onnxscript import script
35

docs/tutorial/examples/whileloop.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
from onnx import TensorProto
24
from onnx.helper import make_tensor
35

docs/tutorial/rewriter/examples/broadcast_matmul.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
"""Onnx Pattern Rewriting with match condition parameter.
24
35
This script shows how to define a rewriting rule based on patterns while

docs/tutorial/rewriter/examples/erfgelu.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
"""Onnx Pattern Rewriting.
24
35
This script shows how to define a rewriting rule based on patterns.

docs/update_readme.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Script to update end-to-end example in README.md.
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
"""Script to update end-to-end example in README.md."""
24

35
updated_readme = []
46
with open("README.md", encoding="utf-8") as f:
@@ -12,7 +14,7 @@
1214
with open(
1315
"docs/tutorial/examples/hardmax_end_to_end.py", encoding="utf-8"
1416
) as example_f:
15-
example_code = example_f.readlines()
17+
example_code = example_f.readlines()[2:] # Skip the copyright header
1618
updated_readme += example_code
1719
if line == "```\n" and in_stub:
1820
updated_readme.append(line)

examples/pattern_rewriting.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
"""Onnx Pattern Rewriting.
24
35
This script shows how to define a rewriting rule based on patterns.
@@ -74,7 +76,9 @@ def rotary_match_pattern(op, x, pos_ids, axis):
7476

7577
matmul = op.MatMul(pos_ids, cast)
7678
transpose = op.Transpose(matmul)
77-
output, length = op.ConcatTraining(transpose, transpose, domain="com.microsoft", outputs=2)
79+
output, _length = op.ConcatTraining(
80+
transpose, transpose, domain="com.microsoft", outputs=2
81+
)
7882

7983
sin = op.Sin(output)
8084
cast1 = op.Cast(sin, to=onnx.TensorProto.FLOAT)

noxfile.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
"""Test with different environment configuration with nox.
24
35
Documentation:

onnxscript/__init__.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# -------------------------------------------------------------------------
2-
# Copyright (c) Microsoft Corporation. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
32
# Licensed under the MIT License.
4-
# --------------------------------------------------------------------------
53

64
__all__ = [
75
"script",

onnxscript/_internal/analysis.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# -------------------------------------------------------------------------
2-
# Copyright (c) Microsoft Corporation. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
32
# Licensed under the MIT License.
4-
# --------------------------------------------------------------------------
53
from __future__ import annotations
64

75
import ast

onnxscript/_internal/analysis_test.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
from __future__ import annotations
24

35
import ast

onnxscript/_internal/ast_utils.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
"""Utilities for working with Python ASTs."""
24

35
from __future__ import annotations

onnxscript/_internal/autocast.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# -------------------------------------------------------------------------
2-
# Copyright (c) Microsoft Corporation. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
32
# Licensed under the MIT License.
4-
# --------------------------------------------------------------------------
53

64
from __future__ import annotations
75

onnxscript/_internal/deprecation.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# -------------------------------------------------------------------------
2-
# Copyright (c) Microsoft Corporation. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
32
# Licensed under the MIT License.
4-
# --------------------------------------------------------------------------
53
"""Utility for deprecating APIs."""
64

75
# Reference: https://github.com/pytorch/pytorch/blob/aed9bee0413dac190452fbfa9ab2a44b6e6843f5/torch/onnx/_deprecation.py

onnxscript/_internal/param_manipulation.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
"""Function for manipulating input parameters of an Op or a OnnxFunction."""
24

35
from __future__ import annotations

onnxscript/_internal/param_manipulation_test.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
# mypy: disable-error-code=misc
24

35
import collections

onnxscript/_internal/runtime_typing.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
"""An internal wrapper for the beartype library.
24
35
Decorate a function with `@runtime_typing.checked` to enable runtime

onnxscript/_internal/utils.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# -------------------------------------------------------------------------
2-
# Copyright (c) Microsoft Corporation. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
32
# Licensed under the MIT License.
4-
# --------------------------------------------------------------------------
53
from __future__ import annotations
64

75
import numbers

onnxscript/_internal/version_utils.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
"""Version utils for testing."""
24

35
import packaging.version

onnxscript/_legacy_ir/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
from __future__ import annotations
24

35
import dataclasses

onnxscript/_legacy_ir/visitor.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
from __future__ import annotations
24

35
import dataclasses

onnxscript/_legacy_ir/visitor_test.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13
import unittest
24

35
import onnx

onnxscript/_thirdparty/asciichartpy.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# SPDX-License-Identifier: MIT
2-
# Modifications Copyright (c) Microsoft.
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
33
#
44
# Copyright © 2016 Igor Kroitor
55
#

onnxscript/backend/__init__.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
# -------------------------------------------------------------------------
2-
# Copyright (c) Microsoft Corporation. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
32
# Licensed under the MIT License.
4-
# --------------------------------------------------------------------------

onnxscript/backend/onnx_backend.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# -------------------------------------------------------------------------
2-
# Copyright (c) Microsoft Corporation. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
32
# Licensed under the MIT License.
4-
# --------------------------------------------------------------------------
53

64

75
import os
@@ -291,7 +289,7 @@ def enumerate_onnx_tests(series, fct_filter=None) -> Iterator[OnnxBackendTest]:
291289
sub = os.path.join(root, "data", series)
292290
if not os.path.exists(sub):
293291
raise FileNotFoundError(
294-
"Unable to find series of tests in {root!r}, subfolders:\n"
292+
f"Unable to find series of tests in {root!r}, subfolders:\n"
295293
+ "\n".join(os.listdir(root))
296294
)
297295
tests = os.listdir(sub)

onnxscript/backend/onnx_backend_test.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# -------------------------------------------------------------------------
2-
# Copyright (c) Microsoft Corporation. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
32
# Licensed under the MIT License.
4-
# --------------------------------------------------------------------------
53

64
import os
75
import unittest

onnxscript/backend/onnx_export.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# -------------------------------------------------------------------------
2-
# Copyright (c) Microsoft Corporation. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
32
# Licensed under the MIT License.
4-
# --------------------------------------------------------------------------
53
from __future__ import annotations
64

75
from typing import Any, Optional, Sequence
@@ -311,7 +309,7 @@ def _translate_onnx_var_ref(self, var):
311309

312310
def _rename_domain(self, domain: str) -> str:
313311
if domain in {"", "ai.onnx"}:
314-
return "opset" # TODO: Need checks to avoid name conflicts.
312+
return "opset" # TODO: Need checks to avoid name conflicts.
315313
return _cleanup_variable_name(domain) # type: ignore[return-value]
316314

317315
def _make_opset_name(self, domain, version):

onnxscript/backend/onnx_export_test.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# -------------------------------------------------------------------------
2-
# Copyright (c) Microsoft Corporation. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
32
# Licensed under the MIT License.
4-
# --------------------------------------------------------------------------
53
from __future__ import annotations
64

75
import dataclasses

0 commit comments

Comments
 (0)