Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# _torch_module_interface.py
 
from collections import OrderedDict
from collections.abc import Callable, Iterator
from typing import Optional, TypeVar
 
import torch
from typing_extensions import Self
 
T = TypeVar("T", bound="torch.nn.Module")
 
 
class TorchModuleInterface:
    """Abstract class that provides the function signatures for the torch.nn.Module
 
    Concrete implementations should inherit from this class and provide necessary executions.
    """
 
    def __init__(self, module):
        self._original_module = module
 
    @property
    def module(self):
        """The original user provided module that this class manages.
 
        This property provides access to methods and properties on the original module.
        """
 
        raise NotImplementedError(f"module is not implemented for {type(self)}.")
 
    ###################################################
    # The methods below are part of torch.nn.Module API
    ###################################################
 
    def forward(self):
        """Executes the forward method for ORTModule
 
        This is an abstract method and must be overridden by a concrete implementation.
        """
 
        raise NotImplementedError(f"forward is not implemented for {type(self)}.")
 
    def _apply(self, fn):
        raise NotImplementedError(f"_apply is not implemented for {type(self)}.")
 
    def apply(self, fn: Callable[[Self], None]) -> Self:
        raise NotImplementedError(f"apply is not implemented for {type(self)}.")
 
    def is_training(self):
        raise NotImplementedError(f"is_training is not implemented for {type(self)}.")
 
    def train(self, mode: bool = True) -> Self:
        raise NotImplementedError(f"train is not implemented for {type(self)}.")
 
    def state_dict(self, destination=None, prefix="", keep_vars=False):
        raise NotImplementedError(f"state_dict is not implemented for {type(self)}.")
 
    def load_state_dict(self, state_dict: "OrderedDict[str, torch.Tensor]", strict: bool = True):
        raise NotImplementedError(f"load_state_dict is not implemented for {type(self)}.")
 
    def register_buffer(self, name: str, tensor: torch.Tensor | None, persistent: bool = True) -> None:
        raise NotImplementedError(f"register_buffer is not implemented for {type(self)}.")
 
    def register_parameter(self, name: str, param: torch.nn.Parameter | None) -> None:
        raise NotImplementedError(f"register_parameter is not implemented for {type(self)}.")
 
    def get_parameter(self, target: str) -> torch.nn.Parameter:
        raise NotImplementedError(f"get_parameter is not implemented for {type(self)}.")
 
    def get_buffer(self, target: str) -> torch.Tensor:
        raise NotImplementedError(f"get_buffer is not implemented for {type(self)}.")
 
    def parameters(self, recurse: bool = True) -> Iterator[torch.nn.Parameter]:
        raise NotImplementedError(f"parameters is not implemented for {type(self)}.")
 
    def named_parameters(self, prefix: str = "", recurse: bool = True) -> Iterator[tuple[str, torch.nn.Parameter]]:
        raise NotImplementedError(f"named_parameters is not implemented for {type(self)}.")
 
    def buffers(self, recurse: bool = True) -> Iterator[torch.Tensor]:
        raise NotImplementedError(f"buffers is not implemented for {type(self)}.")
 
    def named_buffers(self, prefix: str = "", recurse: bool = True) -> Iterator[tuple[str, torch.Tensor]]:
        raise NotImplementedError(f"named_buffers is not implemented for {type(self)}.")
 
    def _load_from_state_dict(
        self, state_dict, prefix, local_metadata, strict, missing_keys, unexpected_keys, error_msgs
    ):
        raise NotImplementedError(f"_load_from_state_dict is not implemented for {type(self)}.")
 
    def named_children(self) -> Iterator[tuple[str, T]]:
        raise NotImplementedError(f"named_children is not implemented for {type(self)}.")
 
    def modules(self) -> Iterator[T]:
        raise NotImplementedError(f"modules is not implemented for {type(self)}.")
 
    def named_modules(self, *args, **kwargs):
        raise NotImplementedError(f"named_modules is not implemented for {type(self)}.")
 
    def _replicate_for_data_parallel(self):
        raise NotImplementedError(f"_replicate_for_data_parallel is not implemented for {type(self)}.")
 
    def add_module(self, name: str, module: Optional["Module"]) -> None:  # noqa: F821
        raise NotImplementedError(f"add_module is not implemented for {type(self)}.")