Skip to content

Commit

Permalink
Merge branch 'master' into destribution
Browse files Browse the repository at this point in the history
  • Loading branch information
decade-afk authored Oct 2, 2024
2 parents 7f7045f + 3dd8372 commit 08e5490
Show file tree
Hide file tree
Showing 33 changed files with 1,781 additions and 130 deletions.
4 changes: 2 additions & 2 deletions paconvert/api_alias_mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"torch.nn.modules.Dropout": "torch.nn.Dropout",
"torch.nn.modules.GroupNorm": "torch.nn.GroupNorm",
"torch.nn.modules.LSTM": "torch.nn.LSTM",
"torch.nn.modules.Linear": "torch.nn.linear",
"torch.nn.modules.Linear": "torch.nn.Linear",
"torch.nn.modules.Module": "torch.nn.Module",
"torch.nn.modules.RNN": "torch.nn.RNN",
"torch.nn.modules.RNNBase": "torch.nn.RNNBase",
Expand All @@ -141,7 +141,7 @@
"torch.nn.modules.batchnorm.SyncBatchNorm": "torch.nn.SyncBatchNorm",
"torch.nn.modules.conv.Conv2d": "torch.nn.Conv2d",
"torch.nn.modules.distance.CosineSimilarity": "torch.nn.CosineSimilarity",
"torch.nn.modules.linear.Linear": "torch.nn.linear",
"torch.nn.modules.linear.Linear": "torch.nn.Linear",
"torch.nn.modules.module.Module": "torch.nn.Module",
"torch.nn.modules.pooling.AvgPool1d": "torch.nn.AvgPool1d",
"torch.nn.modules.pooling.AvgPool2d": "torch.nn.AvgPool2d",
Expand Down
164 changes: 147 additions & 17 deletions paconvert/api_mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
},
"fairscale.nn.model_parallel.layers.ParallelEmbedding": {
"Matcher": "FSParallelEmbeddingMatcher",
"paddle_api": "paddle.distributed.fleet.meta_parallel.VocabParallelEmbedding",
"args_list": [
"num_embeddings",
"embedding_dim",
Expand Down Expand Up @@ -1732,6 +1733,7 @@
},
"torch.Tensor.histogram": {
"Matcher": "HistogramMatcher",
"paddle_api": "paddle.Tensor.histogram",
"min_input_args": 1,
"args_list": [
"bins",
Expand Down Expand Up @@ -2760,9 +2762,7 @@
"*",
"dtype",
"device",
"requires_grad",
"layout",
"pin_memory"
"requires_grad"
],
"kwargs_change": {
"device": "place",
Expand Down Expand Up @@ -3815,7 +3815,8 @@
"args_list": [
"dtype",
"non_blocking",
"dst_type"
"dst_type",
"**kwargs"
]
},
"torch.Tensor.type_as": {
Expand Down Expand Up @@ -4226,6 +4227,22 @@
"out"
]
},
"torch.amp.autocast": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.amp.auto_cast",
"args_list": [
"device_type",
"dtype",
"enabled",
"cache_enabled"
],
"kwargs_change": {
"device_type": "",
"dtype": "dtype",
"enabled": "enable",
"cache_enabled": ""
}
},
"torch.angle": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.angle",
Expand Down Expand Up @@ -5913,6 +5930,9 @@
"torch.distributed.get_rank": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.distributed.get_rank",
"args_list": [
"group"
],
"min_input_args": 0
},
"torch.distributed.init_process_group": {
Expand Down Expand Up @@ -6185,6 +6205,26 @@
"validate_args": ""
}
},
"torch.distributions.Binomial": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.distribution.Binomial",
"args_list": [
"total_count",
"probs",
"logits",
"validate_args"
],
"kwargs_change": {
"validate_args": ""
},
"unsupport_args": [
"logits"
],
"paddle_default_kwargs": {
"total_count": "1"

}
},
"torch.distributions.Categorical": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.distribution.Categorical",
Expand Down Expand Up @@ -6227,6 +6267,22 @@
"cache_size": ""
}
},
"torch.distributions.ContinuousBernoulli": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.distribution.ContinuousBernoulli",
"args_list": [
"probs",
"logits",
"lims",
"validate_args"
],
"kwargs_change": {
"validate_args": ""
},
"unsupport_args": [
"logits"
]
},
"torch.distributions.Dirichlet": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.distribution.Dirichlet",
Expand Down Expand Up @@ -6271,6 +6327,9 @@
},
"torch.distributions.Distribution.log_prob": {
"Matcher": "UnchangeMatcher",
"args_list": [
"value"
],
"min_input_args": 1
},
"torch.distributions.Distribution.logits": {},
Expand Down Expand Up @@ -6318,6 +6377,17 @@
"cache_size": ""
}
},
"torch.distributions.Exponential": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.distribution.Exponential",
"args_list": [
"rate",
"validate_args"
],
"kwargs_change": {
"validate_args": ""
}
},
"torch.distributions.ExponentialFamily": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.distribution.ExponentialFamily",
Expand Down Expand Up @@ -6433,6 +6503,20 @@
"logits"
]
},
"torch.distributions.MultivariateNormal": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.distribution.MultivariateNormal",
"args_list": [
"loc",
"covariance_matrix",
"precision_matrix",
"scale_tril",
"validate_args"
],
"kwargs_change": {
"validate_args": ""
}
},
"torch.distributions.Normal": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.distribution.Normal",
Expand Down Expand Up @@ -6656,6 +6740,10 @@
"torch.einsum": {
"Matcher": "UnchangeMatcher",
"paddle_api": "paddle.einsum",
"args_list": [
"equation",
"*operands"
],
"min_input_args": 0
},
"torch.embedding": {},
Expand Down Expand Up @@ -7497,6 +7585,7 @@
},
"torch.histogram": {
"Matcher": "HistogramMatcher",
"paddle_api": "paddle.histogram",
"min_input_args": 2,
"args_list": [
"input",
Expand Down Expand Up @@ -10441,8 +10530,7 @@
"remove_duplicate"
],
"kwargs_change": {
"recurse": "include_sublayers",
"remove_duplicate": ""
"recurse": "include_sublayers"
},
"min_input_args": 0
},
Expand All @@ -10459,10 +10547,12 @@
"prefix",
"remove_duplicate"
],
"unsupport_args": [
"memo",
"remove_duplicate"
],
"kwargs_change": {
"memo": "layers_set"
},
"paddle_default_kwargs": {
"include_self": "True"
},
"min_input_args": 0
},
"torch.nn.Module.named_parameters": {
Expand All @@ -10475,8 +10565,7 @@
"remove_duplicate"
],
"kwargs_change": {
"recurse": "include_sublayers",
"remove_duplicate": ""
"recurse": "include_sublayers"
}
},
"torch.nn.Module.parameters": {
Expand Down Expand Up @@ -11582,6 +11671,17 @@
"input": "x"
}
},
"torch.nn.functional.channel_shuffle": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.nn.functional.channel_shuffle",
"args_list": [
"input",
"groups"
],
"kwargs_change": {
"input": "x"
}
},
"torch.nn.functional.conv1d": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.nn.functional.conv1d",
Expand Down Expand Up @@ -12299,7 +12399,7 @@
"min_input_args": 0
},
"torch.nn.functional.max_unpool1d": {
"Matcher": "UnpoolMatcher",
"Matcher": "GenericMatcher",
"paddle_api": "paddle.nn.functional.max_unpool1d",
"args_list": [
"input",
Expand All @@ -12315,7 +12415,7 @@
"min_input_args": 3
},
"torch.nn.functional.max_unpool2d": {
"Matcher": "UnpoolMatcher",
"Matcher": "GenericMatcher",
"paddle_api": "paddle.nn.functional.max_unpool2d",
"args_list": [
"input",
Expand All @@ -12331,7 +12431,7 @@
"min_input_args": 3
},
"torch.nn.functional.max_unpool3d": {
"Matcher": "UnpoolMatcher",
"Matcher": "GenericMatcher",
"paddle_api": "paddle.nn.functional.max_unpool3d",
"args_list": [
"input",
Expand Down Expand Up @@ -14916,8 +15016,34 @@
"input": "x"
}
},
"torch.special.gammainc": {},
"torch.special.gammaincc": {},
"torch.special.gammainc": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.gammainc",
"args_list": [
"input",
"other",
"*",
"out"
],
"kwargs_change": {
"input": "x",
"other": "y"
}
},
"torch.special.gammaincc": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.gammaincc",
"args_list": [
"input",
"other",
"*",
"out"
],
"kwargs_change": {
"input": "x",
"other": "y"
}
},
"torch.special.gammaln": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.lgamma",
Expand Down Expand Up @@ -16249,7 +16375,11 @@
"single_word",
"lstrip",
"rstrip",
"special",
"normalized"
],
"unsupport_args": [
"special"
]
},
"transformers.GenerationConfig": {
Expand Down
7 changes: 0 additions & 7 deletions paconvert/api_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3878,13 +3878,6 @@ def generate_code(self, kwargs):
return code


class UnpoolMatcher(BaseMatcher):
def generate_code(self, kwargs):
kwargs["indices"] = "{}.astype('int32')".format(kwargs["indices"])

return GenericMatcher.generate_code(self, kwargs)


class SoftmaxMatcher(BaseMatcher):
def generate_aux_code(self):
CODE_TEMPLATE = textwrap.dedent(
Expand Down
23 changes: 21 additions & 2 deletions tests/distributed/load_lib.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#


import ctypes
import os


def load_cusparse_library():
# 获取当前脚本文件的绝对路径
script_dir = os.path.dirname(os.path.abspath(__file__))
# 构建完整的库文件路径
cusparse_lib_path = os.path.join(script_dir, 'libcusparse.so.12')
cusparse_lib_path = os.path.join(script_dir, "libcusparse.so.12")

# 检查库文件是否存在
if not os.path.exists(cusparse_lib_path):
Expand All @@ -23,6 +40,7 @@ def load_cusparse_library():

return libcusparse


def main():
try:
libcusparse = load_cusparse_library()
Expand All @@ -33,5 +51,6 @@ def main():
# print(f"Error occurred: {e}")
pass


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

0 comments on commit 08e5490

Please sign in to comment.