code stringlengths 208 42.9k | apis list | extract_api stringlengths 129 69.9k |
|---|---|---|
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.core.tensor"
] | [((582, 590), 'megengine.core.tensor', 'tensor', ([], {}), '()\n', (588, 590), False, 'from megengine.core import tensor\n'), ((599, 607), 'megengine.core.tensor', 'tensor', ([], {}), '()\n', (605, 607), False, 'from megengine.core import tensor\n'), ((868, 900), 'pytest.raises', 'pytest.raises', (['mgb.MegBrainError']... |
import pytest
import megengine as mge
import megengine.functional as F
from megengine.core._imperative_rt.core2 import config_async_level, get_async_level
def test_basic():
config_async_level(2)
assert get_async_level() == 2
with pytest.raises(RuntimeError):
config_async_level(3)
def test_level... | [
"megengine.core._imperative_rt.core2.get_async_level",
"megengine.core._imperative_rt.core2.config_async_level",
"megengine.tensor",
"megengine.functional.matmul",
"megengine.functional.reshape"
] | [((180, 201), 'megengine.core._imperative_rt.core2.config_async_level', 'config_async_level', (['(2)'], {}), '(2)\n', (198, 201), False, 'from megengine.core._imperative_rt.core2 import config_async_level, get_async_level\n'), ((341, 362), 'megengine.core._imperative_rt.core2.config_async_level', 'config_async_level', ... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.is_cuda_available",
"megengine.Tensor",
"megengine.load",
"megengine.get_default_device",
"megengine.set_default_device",
"megengine.save"
] | [((705, 720), 'tempfile.TemporaryFile', 'TemporaryFile', ([], {}), '()\n', (718, 720), False, 'from tempfile import TemporaryFile\n'), ((742, 786), 'numpy.random.randint', 'np.random.randint', ([], {'low': '(0)', 'high': '(7)', 'size': '[233]'}), '(low=0, high=7, size=[233])\n', (759, 786), True, 'import numpy as np\n'... |
# -*- coding: utf-8 -*-
# This repo is licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.data.transform.ToMode",
"megengine.device.set_prealloc_config",
"megengine.distributed.get_rank",
"megengine.distributed.get_world_size",
"megengine.dtr.enable",
"megengine.get_logger",
"megengine.distributed.make_allreduce_cb",
"megengine.data.transform.RandomHorizontalFlip",
"megengine.... | [((767, 784), 'megengine.core._imperative_rt.utils._set_defrag', '_set_defrag', (['(True)'], {}), '(True)\n', (778, 784), False, 'from megengine.core._imperative_rt.utils import _set_defrag\n'), ((992, 1016), 'megengine.get_logger', 'mge.get_logger', (['__name__'], {}), '(__name__)\n', (1006, 1016), True, 'import megen... |
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY ... | [
"megengine.functional.sigmoid",
"megengine.jit.trace",
"megengine.functional.exp",
"megengine.core.tensor",
"megengine.functional.maximum",
"megengine.functional.grad",
"megengine.functional.round"
] | [((715, 725), 'megengine.core.tensor', 'tensor', (['av'], {}), '(av)\n', (721, 725), False, 'from megengine.core import Function, tensor\n'), ((734, 744), 'megengine.core.tensor', 'tensor', (['bv'], {}), '(bv)\n', (740, 744), False, 'from megengine.core import Function, tensor\n'), ((1339, 1349), 'megengine.core.tensor... |
#!/usr/bin/env python3
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
import copy
import time
from typing import Iterable
import megengine as mge
import megengine.amp as amp
import megengine.distributed as dist
import megengine.functional as F
import megengine.module as M
import megengine.optimizer as opti... | [
"megengine.jit.trace",
"megengine.distributed.get_world_size",
"megengine.optimizer.clip_grad_value",
"megengine.amp.autocast",
"megengine.optimizer.clip_grad_norm",
"megengine.functional.argmax",
"megengine._full_sync",
"megengine.functional.metric.topk_accuracy"
] | [((666, 695), 'basecls.utils.registers.trainers.register', 'registers.trainers.register', ([], {}), '()\n', (693, 695), False, 'from basecls.utils import registers\n'), ((1698, 1757), 'basecls.layers.Preprocess', 'Preprocess', (['cfg.preprocess.img_mean', 'cfg.preprocess.img_std'], {}), '(cfg.preprocess.img_mean, cfg.p... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.module.Linear",
"megengine.quantization.quantize.quantize_qat",
"megengine.module.QuantStub",
"megengine.Parameter",
"megengine.functional.relu",
"megengine.module.DequantStub",
"megengine.jit.tracing.trace",
"megengine.core.tensor.megbrain_graph.load_graph",
"megengine.utils.naming.AutoN... | [((1296, 1346), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""symbolic"""', '[False, True]'], {}), "('symbolic', [False, True])\n", (1319, 1346), False, 'import pytest\n'), ((1708, 1758), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""symbolic"""', '[False, True]'], {}), "('symbolic', [False,... |
import megengine
import megengine.module as M
import megengine.functional as F
def default_init_weights(module, scale=1, nonlinearity="relu"):
"""
nonlinearity: leaky_relu
"""
for m in module.modules():
if isinstance(m, M.Conv2d):
M.init.msra_normal_(m.weight, mode="fan_in", non... | [
"megengine.module.init.zeros_",
"megengine.module.init.msra_normal_"
] | [((272, 343), 'megengine.module.init.msra_normal_', 'M.init.msra_normal_', (['m.weight'], {'mode': '"""fan_in"""', 'nonlinearity': 'nonlinearity'}), "(m.weight, mode='fan_in', nonlinearity=nonlinearity)\n", (291, 343), True, 'import megengine.module as M\n'), ((425, 446), 'megengine.module.init.zeros_', 'M.init.zeros_'... |
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY ... | [
"megengine.functional.sqrt"
] | [((1634, 1656), 'megengine.functional.sqrt', 'F.sqrt', (['(var + self.eps)'], {}), '(var + self.eps)\n', (1640, 1656), True, 'import megengine.functional as F\n'), ((3137, 3159), 'megengine.functional.sqrt', 'F.sqrt', (['(var + self.eps)'], {}), '(var + self.eps)\n', (3143, 3159), True, 'import megengine.functional as ... |
import io
import pickle
import numpy as np
import megengine as mge
import megengine.functional as F
import megengine.module as M
import megengine.utils.comp_graph_tools as cgtools
from megengine.core._trace_option import set_symbolic_shape
from megengine.jit import trace
from megengine.traced_module import trace_modu... | [
"megengine.jit.trace",
"megengine.functional.repeat",
"megengine.functional.zeros",
"megengine.functional.broadcast_to",
"megengine.functional.ones",
"megengine.functional.matinv",
"megengine.functional.warp_perspective",
"megengine.core._trace_option.set_symbolic_shape",
"megengine.traced_module.tr... | [((324, 348), 'megengine.core._trace_option.set_symbolic_shape', 'set_symbolic_shape', (['(True)'], {}), '(True)\n', (342, 348), False, 'from megengine.core._trace_option import set_symbolic_shape\n'), ((2000, 2036), 'megengine.traced_module.trace_module', 'trace_module', (['module', "{'data': data}"], {}), "(module, {... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.functional.sign",
"megengine.functional.elemwise.Elemwise",
"megengine.core.tensor.dtype.qint8",
"megengine.functional.logical_not",
"megengine.jit.trace",
"megengine.tensor",
"megengine.functional.logical_xor",
"megengine.functional.logical_or",
"megengine.functional.mul",
"megengine.f... | [((6757, 6807), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""is_trace"""', '[True, False]'], {}), "('is_trace', [True, False])\n", (6780, 6807), False, 'import pytest\n'), ((2580, 2615), 'numpy.linspace', 'np.linspace', (['(-6)', '(6)'], {'dtype': '"""float32"""'}), "(-6, 6, dtype='float32')\n", (2591, 2... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.functional.nn.cross_entropy",
"megengine.functional.nn.ctc_loss",
"megengine.tensor"
] | [((627, 658), 'megengine.functional.nn.cross_entropy', 'F.nn.cross_entropy', (['data', 'label'], {}), '(data, label)\n', (645, 658), True, 'import megengine.functional as F\n'), ((764, 795), 'megengine.functional.nn.cross_entropy', 'F.nn.cross_entropy', (['data', 'label'], {}), '(data, label)\n', (782, 795), True, 'imp... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.core.TensorDict",
"megengine.load",
"megengine.core.tensor"
] | [((1024, 1053), 'helpers.graph_mode', 'graph_mode', (['"""eager"""', '"""static"""'], {}), "('eager', 'static')\n", (1034, 1053), False, 'from helpers import MLP, graph_mode\n'), ((1155, 1160), 'helpers.MLP', 'MLP', ([], {}), '()\n', (1158, 1160), False, 'from helpers import MLP, graph_mode\n'), ((1238, 1250), 'megengi... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.tensor",
"megengine.utils.profiler.scope",
"megengine.Parameter",
"megengine.utils.profiler.Profiler"
] | [((1165, 1188), 'os.remove', 'os.remove', (['profile_path'], {}), '(profile_path)\n', (1174, 1188), False, 'import os\n'), ((669, 703), 'megengine.Parameter', 'Parameter', (['[1.23]'], {'dtype': '"""float32"""'}), "([1.23], dtype='float32')\n", (678, 703), False, 'from megengine import Parameter, tensor\n'), ((951, 998... |
#! /usr/bin/env python3
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.utils.profiler.merge_trace_events",
"megengine.logger.get_logger",
"megengine.utils.profiler.Profiler"
] | [((575, 679), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {'prog': '"""megengine.tools.profiler"""', 'description': '"""Profiling megengine program"""'}), "(prog='megengine.tools.profiler', description=\n 'Profiling megengine program')\n", (598, 679), False, 'import argparse\n'), ((2719, 2771), 'runpy... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.jit.trace",
"megengine.tensor",
"megengine.load",
"megengine.utils.http_download.download_from_url"
] | [((829, 854), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {}), '()\n', (852, 854), False, 'import argparse\n'), ((1343, 1371), 'cv2.imwrite', 'cv2.imwrite', (['"""out.jpg"""', 'pred'], {}), "('out.jpg', pred)\n", (1354, 1371), False, 'import cv2\n'), ((1419, 1439), 'megengine.load', 'mge.load', (['model_... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.random.normal",
"megengine.functional.adaptive_max_pool2d",
"megengine.functional.avg_pool2d",
"megengine.module.Conv2d",
"megengine.functional.repeat",
"megengine.functional.max_pool2d",
"megengine.functional.squeeze",
"megengine.module.BatchNorm2d",
"megengine.functional.leaky_relu",
... | [((10595, 10609), 'numpy.mean', 'np.mean', (['times'], {}), '(times)\n', (10602, 10609), True, 'import numpy as np\n'), ((629, 655), 'megengine.module.Conv2d', 'MM.Conv2d', (['(32)', '(32)', '(3)', '(1)', '(0)'], {}), '(32, 32, 3, 1, 0)\n', (638, 655), True, 'import megengine.module as MM\n'), ((720, 757), 'megengine.m... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.functional.distributed.all_reduce_sum",
"megengine.functional.distributed.all_reduce_max",
"megengine.functional.distributed.broadcast",
"megengine.distributed.get_rank",
"megengine.device.get_default_device",
"megengine.functional.distributed.gather",
"megengine.functional.distributed.all_to... | [((1418, 1445), 'pytest.mark.require_ngpu', 'pytest.mark.require_ngpu', (['(2)'], {}), '(2)\n', (1442, 1445), False, 'import pytest\n'), ((1447, 1532), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""shape"""', '[(), (1,), (2, 3), (8, 10), (99, 77)]'], {'ids': 'str'}), "('shape', [(), (1,), (2, 3), (8, 10),... |
import math
import numpy as np
import megengine as mge
import megengine.functional as F
import megengine.module as M
def bias_act(x, b=None, dim=1, act='linear', alpha=None, gain=None, clamp=None):
assert clamp is None or clamp >= 0
def_gain = 1.0
if act in ['relu', 'lrelu', 'swish']: # 除了这些激活函数的def_... | [
"megengine.functional.sigmoid",
"megengine.functional.softplus",
"megengine.functional.matmul",
"megengine.functional.expand_dims",
"megengine.functional.relu",
"megengine.functional.leaky_relu",
"megengine.functional.elu",
"megengine.functional.clip",
"megengine.functional.selu",
"megengine.funct... | [((379, 389), 'numpy.sqrt', 'np.sqrt', (['(2)'], {}), '(2)\n', (386, 389), True, 'import numpy as np\n'), ((797, 820), 'megengine.functional.reshape', 'F.reshape', (['b', 'new_shape'], {}), '(b, new_shape)\n', (806, 820), True, 'import megengine.functional as F\n'), ((1597, 1621), 'megengine.functional.clip', 'F.clip',... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.distributed.is_distributed",
"megengine.data.transform.ToMode",
"megengine.data.transform.CenterCrop",
"megengine.data.transform.Normalize",
"megengine.data.SequentialSampler",
"megengine.distributed.get_rank",
"megengine.distributed.get_world_size",
"megengine.get_logger",
"megengine.dat... | [((950, 974), 'megengine.get_logger', 'mge.get_logger', (['__name__'], {}), '(__name__)\n', (964, 974), True, 'import megengine as mge\n'), ((1002, 1027), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {}), '()\n', (1025, 1027), False, 'import argparse\n'), ((2354, 2369), 'megengine.distributed.get_rank', '... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.data.transform.Normalize",
"megengine.data.SequentialSampler",
"megengine.jit.trace",
"megengine.tensor",
"megengine.load",
"megengine.data.dataset.PascalVOC"
] | [((1066, 1091), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {}), '()\n', (1089, 1091), False, 'import argparse\n'), ((1465, 1505), 'official.vision.segmentation.deeplabv3plus.DeepLabV3Plus', 'DeepLabV3Plus', ([], {'class_num': 'cfg.NUM_CLASSES'}), '(class_num=cfg.NUM_CLASSES)\n', (1478, 1505), False, 'fr... |
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY ... | [
"megengine.quantization.quantize.propagate_qconfig",
"megengine.module.Elemwise",
"megengine.module.quantized.Elemwise.from_qat_module",
"megengine.module.qat.Linear",
"megengine.core.tensor.dtype.qint8",
"megengine.module.DequantStub",
"megengine.module.qat.Linear.from_float_module",
"megengine.modul... | [((1778, 1818), 'functools.partial', 'partial', (['fake_quant'], {'qmin': '(-128)', 'qmax': '(127)'}), '(fake_quant, qmin=-128, qmax=127)\n', (1785, 1818), False, 'from functools import partial\n'), ((1839, 1879), 'functools.partial', 'partial', (['fake_quant'], {'qmin': '(-127)', 'qmax': '(127)'}), '(fake_quant, qmin=... |
#!/usr/bin/env python3
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
import argparse
import importlib
import multiprocessing as mp
import os
import sys
import megengine as mge
import megengine.distributed as dist
from basecore.config import ConfigDict
from loguru import logger
from basecls.engine import ... | [
"megengine.distributed.get_rank",
"megengine.functional.debug_param.set_execution_strategy",
"megengine.device.get_device_count",
"megengine.distributed.group_barrier",
"megengine.distributed.launcher"
] | [((632, 657), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {}), '()\n', (655, 657), False, 'import argparse\n'), ((1220, 1256), 'importlib.import_module', 'importlib.import_module', (['module_name'], {}), '(module_name)\n', (1243, 1256), False, 'import importlib\n'), ((1390, 1421), 'os.path.abspath', 'os.... |
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
import megengine as mge
import megengine.functional as F
import megengine.module as M
__all__ = ["fuse_conv_and_bn", "fuse_model", "replace_module"]
def fuse_conv_and_bn(conv, bn):
# Fuse convolution and bat... | [
"megengine.functional.zeros",
"megengine.Parameter",
"megengine.functional.sqrt",
"megengine.module.Conv2d"
] | [((403, 555), 'megengine.module.Conv2d', 'M.Conv2d', (['conv.in_channels', 'conv.out_channels'], {'kernel_size': 'conv.kernel_size', 'stride': 'conv.stride', 'padding': 'conv.padding', 'groups': 'conv.groups', 'bias': '(True)'}), '(conv.in_channels, conv.out_channels, kernel_size=conv.kernel_size,\n stride=conv.stri... |
#!/usr/bin/env python3
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
import megengine as mge
import megengine.module as M
import numpy as np
import pytest
from basecls.layers import ClsHead, MBV3Head, VGGHead, build_head
@pytest.mark.parametrize("w_in", [4])
@pytest.mark.parametrize(
"head_args",
... | [
"megengine.Tensor"
] | [((238, 274), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""w_in"""', '[4]'], {}), "('w_in', [4])\n", (261, 274), False, 'import pytest\n'), ((1128, 1172), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""norm_name"""', "['BN']"], {}), "('norm_name', ['BN'])\n", (1151, 1172), False, 'import pyt... |
import os
import os.path as osp
import bisect
import argparse
import multiprocessing as mp
import numpy as np
from tqdm import tqdm
import megengine as mge
from megengine import distributed as dist
from megengine import optimizer as optim
import megengine.autodiff as autodiff
from megengine import jit
import dataset, n... | [
"megengine.set_log_file",
"megengine.get_device_count",
"megengine.save",
"megengine.get_logger",
"megengine.optimizer.SGD",
"megengine.distributed.functional.all_reduce_sum",
"megengine.distributed.init_process_group",
"megengine.autodiff.GradManager",
"megengine.distributed.Server",
"megengine.l... | [((420, 446), 'misc_utils.ensure_dir', 'ensure_dir', (['cfg.output_dir'], {}), '(cfg.output_dir)\n', (430, 446), False, 'from misc_utils import ensure_dir\n'), ((456, 480), 'megengine.get_logger', 'mge.get_logger', (['__name__'], {}), '(__name__)\n', (470, 480), True, 'import megengine as mge\n'), ((492, 530), 'os.path... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.distributed.is_distributed",
"megengine.data.transform.ToMode",
"megengine.data.transform.CenterCrop",
"megengine.data.transform.Normalize",
"megengine.data.SequentialSampler",
"megengine.distributed.get_rank",
"megengine.distributed.get_world_size",
"megengine.get_logger",
"megengine.dat... | [((866, 890), 'megengine.get_logger', 'mge.get_logger', (['__name__'], {}), '(__name__)\n', (880, 890), True, 'import megengine as mge\n'), ((918, 943), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {}), '()\n', (941, 943), False, 'import argparse\n'), ((2188, 2217), 'collections.defaultdict', 'collections... |
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY ... | [
"megengine.module.Linear",
"megengine.tensor",
"megengine.module.AvgPool2d",
"megengine.module.BatchNorm2d",
"megengine.functional.avg_pool2d",
"megengine.functional.relu",
"megengine.autodiff.GradManager",
"megengine.module.Conv2d",
"megengine.functional.flatten"
] | [((623, 686), 'megengine.module.Conv2d', 'M.Conv2d', (['(3)', '(64)'], {'kernel_size': '(7)', 'stride': '(2)', 'padding': '(3)', 'bias': '(False)'}), '(3, 64, kernel_size=7, stride=2, padding=3, bias=False)\n', (631, 686), True, 'import megengine.module as M\n'), ((706, 723), 'megengine.module.BatchNorm2d', 'M.BatchNor... |
# -*- coding: utf-8 -*-
import megengine.module as M
import megengine.functional as F
class LeNet32x32(M.Module):
def __init__(self):
super().__init__()
# single channel image, two 5x5 Conv + ReLU + Pool
# Conv2d(1, 6, kernel_size=(5, 5))
self.conv1 = M.Conv2d(1, 6, 5)
self.... | [
"megengine.module.MaxPool2d",
"megengine.module.Linear",
"megengine.module.ReLU",
"megengine.module.Conv2d",
"megengine.functional.flatten"
] | [((289, 306), 'megengine.module.Conv2d', 'M.Conv2d', (['(1)', '(6)', '(5)'], {}), '(1, 6, 5)\n', (297, 306), True, 'import megengine.module as M\n'), ((328, 336), 'megengine.module.ReLU', 'M.ReLU', ([], {}), '()\n', (334, 336), True, 'import megengine.module as M\n'), ((414, 431), 'megengine.module.MaxPool2d', 'M.MaxPo... |
import megengine as mge
import megengine.functional as F
from megengine.core import Tensor
def softmax_loss(pred, label, ignore_label=-1):
max_pred = F.zero_grad(pred.max(axis=1, keepdims=True))
pred -= max_pred
log_prob = pred - F.log(F.exp(pred).sum(axis=1, keepdims=True))
mask = 1 - F.equal(label, i... | [
"megengine.functional.abs",
"megengine.functional.equal",
"megengine.functional.exp",
"megengine.functional.indexing_one_hot"
] | [((496, 516), 'megengine.functional.abs', 'F.abs', (['(pred - target)'], {}), '(pred - target)\n', (501, 516), True, 'import megengine.functional as F\n'), ((304, 332), 'megengine.functional.equal', 'F.equal', (['label', 'ignore_label'], {}), '(label, ignore_label)\n', (311, 332), True, 'import megengine.functional as ... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.tensor",
"megengine.core.tensor.utils.make_shape_tuple",
"megengine.quantization.utils.fake_quant_tensor",
"megengine.quantization.fake_quant.TQT_Function",
"megengine.core.autodiff.grad.Grad"
] | [((2261, 2284), 'megengine.quantization.fake_quant.TQT_Function', 'TQT_Function', (['(-127)', '(127)'], {}), '(-127, 127)\n', (2273, 2284), False, 'from megengine.quantization.fake_quant import TQT_Function\n'), ((2906, 2918), 'megengine.tensor', 'tensor', (['a_np'], {}), '(a_np)\n', (2912, 2918), False, 'from megengin... |
# -*- coding: utf-8 -*-
# This repo is licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.functional.zeros",
"megengine.functional.broadcast_to",
"megengine.functional.stack",
"megengine.functional.concat",
"megengine.functional.exp",
"megengine.functional.sigmoid",
"megengine.functional.maximum",
"megengine.functional.cond_take",
"megengine.functional.topk",
"megengine.func... | [((740, 906), 'layers.AnchorBoxGenerator', 'layers.AnchorBoxGenerator', ([], {'anchor_scales': 'self.cfg.anchor_scales', 'anchor_ratios': 'self.cfg.anchor_ratios', 'strides': 'self.cfg.stride', 'offset': 'self.cfg.anchor_offset'}), '(anchor_scales=self.cfg.anchor_scales,\n anchor_ratios=self.cfg.anchor_ratios, strid... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.module.init.zeros_",
"megengine.module.init.normal_",
"megengine.tensor",
"megengine.module.ReLU",
"megengine.module.Conv2d",
"megengine.module.init.ones_",
"megengine.module.ConvTranspose2d",
"megengine.functional.square_loss",
"megengine.module.Sequential",
"megengine.hub.pretrained"
... | [((3431, 3543), 'megengine.hub.pretrained', 'hub.pretrained', (['"""https://data.megengine.org.cn/models/weights/simplebaseline50_256x192_0_255_71_2.pkl"""'], {}), "(\n 'https://data.megengine.org.cn/models/weights/simplebaseline50_256x192_0_255_71_2.pkl'\n )\n", (3445, 3543), True, 'import megengine.hub as hub\n... |
# -*- coding: utf-8 -*-
# MIT License
#
# Copyright (c) 2019 Megvii Technology
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
#... | [
"megengine.get_device_count",
"megengine.distributed.is_distributed",
"megengine.data.transform.ToMode",
"megengine.data.transform.CenterCrop",
"megengine.data.SequentialSampler",
"megengine.distributed.get_rank",
"megengine.distributed.get_world_size",
"megengine.get_logger",
"megengine.data.datase... | [((2178, 2202), 'megengine.get_logger', 'mge.get_logger', (['__name__'], {}), '(__name__)\n', (2192, 2202), True, 'import megengine as mge\n'), ((2230, 2255), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {}), '()\n', (2253, 2255), False, 'import argparse\n'), ((5245, 5279), 'os.path.join', 'os.path.join',... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.module.Dropout",
"megengine.jit.trace",
"megengine.functional.dropout",
"megengine.random.uniform",
"megengine.ones",
"megengine.random.gaussian",
"megengine.random.manual_seed"
] | [((585, 609), 'megengine.jit.trace', 'jit.trace', ([], {'symbolic': '(True)'}), '(symbolic=True)\n', (594, 609), True, 'import megengine.jit as jit\n'), ((679, 703), 'megengine.jit.trace', 'jit.trace', ([], {'symbolic': '(True)'}), '(symbolic=True)\n', (688, 703), True, 'import megengine.jit as jit\n'), ((891, 915), 'm... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.data.transform.ToMode",
"megengine.amp.autocast",
"megengine.device.set_prealloc_config",
"megengine.distributed.get_rank",
"megengine.distributed.get_world_size",
"megengine.get_logger",
"megengine.distributed.make_allreduce_cb",
"megengine.data.transform.RandomHorizontalFlip",
"megengin... | [((942, 966), 'megengine.get_logger', 'mge.get_logger', (['__name__'], {}), '(__name__)\n', (956, 966), True, 'import megengine as mge\n'), ((991, 1057), 'megengine.device.set_prealloc_config', 'mge.device.set_prealloc_config', (['(1024)', '(1024)', '(512 * 1024 * 1024)', '(2.0)'], {}), '(1024, 1024, 512 * 1024 * 1024,... |
import logging
from megengine.distributed.group import get_rank
from megengine.distributed import is_distributed
logger_initialized = {}
def get_logger(name, log_file=None, log_level=logging.INFO):
"""Initialize and get a logger by name.
If the logger has not been initialized, this method will initialize the... | [
"megengine.distributed.is_distributed",
"megengine.distributed.group.get_rank"
] | [((1026, 1049), 'logging.getLogger', 'logging.getLogger', (['name'], {}), '(name)\n', (1043, 1049), False, 'import logging\n'), ((1494, 1517), 'logging.StreamHandler', 'logging.StreamHandler', ([], {}), '()\n', (1515, 1517), False, 'import logging\n'), ((1558, 1574), 'megengine.distributed.is_distributed', 'is_distribu... |
import argparse
import logging
import os
import dataset.data_loader as data_loader
import model.net as net
from common import utils
from loss.losses import compute_losses, compute_metrics
from common.manager import Manager
import megengine.distributed as dist
import megengine.functional as F
parser = argparse.Argum... | [
"megengine.functional.distributed.all_reduce_sum",
"megengine.distributed.get_world_size",
"megengine.distributed.get_rank"
] | [((306, 331), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {}), '()\n', (329, 331), False, 'import argparse\n'), ((606, 621), 'megengine.distributed.get_rank', 'dist.get_rank', ([], {}), '()\n', (619, 621), True, 'import megengine.distributed as dist\n'), ((639, 660), 'megengine.distributed.get_world_size... |
import sys
sys.path.append('.')
import cv2
import megengine as mge
import megengine.functional as F
import numpy as np
from model.RIFE import Model
model = Model()
model.load_model('train_log')
model.eval()
name = ['Beanbags', 'Dimetrodon', 'DogDance', 'Grove2', 'Grove3', 'Hydrangea', 'MiniCooper', 'RubberWhale', 'Ur... | [
"megengine.functional.zeros",
"megengine.Tensor"
] | [((11, 31), 'sys.path.append', 'sys.path.append', (['"""."""'], {}), "('.')\n", (26, 31), False, 'import sys\n'), ((157, 164), 'model.RIFE.Model', 'Model', ([], {}), '()\n', (162, 164), False, 'from model.RIFE import Model\n'), ((670, 695), 'megengine.functional.zeros', 'F.zeros', (['[1, 6, 480, 640]'], {}), '([1, 6, 4... |
# Copyright (c) 2014-2022 Megvii Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
#
# 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, eithe... | [
"megengine.module.Dropout",
"megengine.module.Linear",
"megengine.functional.pad",
"megengine.functional.sqrt",
"megengine.module.BatchNorm2d",
"megengine.functional.conv2d",
"megengine.module.AdaptiveAvgPool2d",
"megengine.module.Identity",
"megengine.functional.flatten"
] | [((9027, 9054), 'basecls.utils.registers.models.register', 'registers.models.register', ([], {}), '()\n', (9052, 9054), False, 'from basecls.utils import registers\n'), ((9190, 9217), 'basecls.utils.registers.models.register', 'registers.models.register', ([], {}), '()\n', (9215, 9217), False, 'from basecls.utils impor... |
#!/usr/bin/env python3
import megengine as mge
import megengine.module as nn
import megengine.functional as F
def conv3x3(in_chn, out_chn, bias=True):
layer = nn.Conv2d(in_chn, out_chn, kernel_size=3, stride=1, padding=1, bias=bias)
return layer
def conv_down(in_chn, out_chn, bias=False):
layer = nn.Conv... | [
"megengine.module.init.calculate_gain",
"megengine.functional.matmul",
"megengine.module.init.zeros_",
"megengine.functional.concat",
"megengine.functional.matinv",
"megengine.module.ConvTranspose2d",
"megengine.module.init.xavier_uniform_",
"megengine.module.Conv2d",
"megengine.functional.abs",
"... | [((164, 237), 'megengine.module.Conv2d', 'nn.Conv2d', (['in_chn', 'out_chn'], {'kernel_size': '(3)', 'stride': '(1)', 'padding': '(1)', 'bias': 'bias'}), '(in_chn, out_chn, kernel_size=3, stride=1, padding=1, bias=bias)\n', (173, 237), True, 'import megengine.module as nn\n'), ((313, 386), 'megengine.module.Conv2d', 'n... |
# -*- coding: utf-8 -*-
# This repo is licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ... | [
"megengine.save",
"megengine.load"
] | [((1472, 1503), 'collections.defaultdict', 'defaultdict', (['utils.AverageMeter'], {}), '(utils.AverageMeter)\n', (1483, 1503), False, 'from collections import defaultdict\n'), ((1555, 1586), 'collections.defaultdict', 'defaultdict', (['utils.AverageMeter'], {}), '(utils.AverageMeter)\n', (1566, 1586), False, 'from col... |
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY ... | [
"megengine._internal.dtype.qint32",
"megengine._internal.dtype.qint8",
"megengine._internal.dtype.get_scale"
] | [((3763, 3794), 'functools.partial', 'partial', (['to_quantized', 'ConvBn2d'], {}), '(to_quantized, ConvBn2d)\n', (3770, 3794), False, 'from functools import partial\n'), ((3841, 3876), 'functools.partial', 'partial', (['to_quantized', 'ConvBnRelu2d'], {}), '(to_quantized, ConvBnRelu2d)\n', (3848, 3876), False, 'from f... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.tensor"
] | [((2620, 2668), 'numpy.array', 'np.array', (['[[100, 101, 102, 103]]'], {'dtype': 'np.int32'}), '([[100, 101, 102, 103]], dtype=np.int32)\n', (2628, 2668), True, 'import numpy as np\n'), ((2680, 2705), 'numpy.repeat', 'np.repeat', (['tmp', '(4)'], {'axis': '(0)'}), '(tmp, 4, axis=0)\n', (2689, 2705), True, 'import nump... |
import sys
sys.path.append('.')
import time
import megengine as mge
from model.RIFE import Model
model = Model()
model.eval()
I0 = mge.random(1, 3, 480, 640)
I1 = mge.random(1, 3, 480, 640)
for i in range(100):
pred = model.inference(I0, I1)
mge._full_sync()
time_stamp = time.time()
for i in range(100):
pred ... | [
"megengine.random",
"megengine._full_sync"
] | [((11, 31), 'sys.path.append', 'sys.path.append', (['"""."""'], {}), "('.')\n", (26, 31), False, 'import sys\n'), ((106, 113), 'model.RIFE.Model', 'Model', ([], {}), '()\n', (111, 113), False, 'from model.RIFE import Model\n'), ((133, 159), 'megengine.random', 'mge.random', (['(1)', '(3)', '(480)', '(640)'], {}), '(1, ... |
# Copyright (c) Megvii, Inc. and its affiliates.
import megengine.functional as F
import megengine.module as M
from .head import get_head
from .loss import get_loss
from .resnet import get_backbone
from .stn import STN
class FaceRecognitionModel(M.Module):
"""combination of all building blocks, including backbo... | [
"megengine.functional.normalize"
] | [((2314, 2344), 'megengine.functional.normalize', 'F.normalize', (['embedding'], {'axis': '(1)'}), '(embedding, axis=1)\n', (2325, 2344), True, 'import megengine.functional as F\n')] |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.quantization.utils.fake_quant_tensor",
"megengine.functional.maximum",
"megengine.quantization.utils.lsq_forward",
"megengine.functional.full",
"megengine.core.tensor.utils.make_shape_tuple",
"megengine.quantization.utils.create_qparams",
"megengine.functional.ones_like",
"megengine.core.au... | [((2467, 2511), 'numpy.ones', 'np.ones', ([], {'shape': '(1, 2, 3, 4)', 'dtype': '"""float32"""'}), "(shape=(1, 2, 3, 4), dtype='float32')\n", (2474, 2511), True, 'import numpy as np\n'), ((2615, 2645), 'megengine.tensor', 'mge.tensor', (['x'], {'dtype': '"""float32"""'}), "(x, dtype='float32')\n", (2625, 2645), True, ... |
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY ... | [
"megengine._internal.dtype.get_scale",
"megengine._internal.dtype.qint32"
] | [((1670, 1700), 'megengine._internal.dtype.get_scale', 'mgb.dtype.get_scale', (['inp.dtype'], {}), '(inp.dtype)\n', (1689, 1700), True, 'import megengine._internal as mgb\n'), ((1719, 1757), 'megengine._internal.dtype.get_scale', 'mgb.dtype.get_scale', (['self.weight.dtype'], {}), '(self.weight.dtype)\n', (1738, 1757),... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.core.Graph",
"megengine.core.Parameter"
] | [((703, 716), 'megengine.core.Parameter', 'Parameter', (['v0'], {}), '(v0)\n', (712, 716), False, 'from megengine.core import Buffer, Graph, Parameter\n'), ((1080, 1114), 'numpy.zeros', 'np.zeros', (['(2, 3)'], {'dtype': 'np.float32'}), '((2, 3), dtype=np.float32)\n', (1088, 1114), True, 'import numpy as np\n'), ((1163... |
#!/usr/bin/env python3
import argparse
import math
import megengine.functional as F
import megengine.module as M
import numpy as np
from megengine import jit, tensor
class ConvNet(M.Module):
def __init__(self):
super().__init__()
self.conv1 = M.Conv2d(in_channels=3, out_channels=1, kernel_size=... | [
"megengine.module.Conv2d",
"megengine.jit.trace"
] | [((457, 583), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {'description': '"""dump mge model for add_demo"""', 'formatter_class': 'argparse.ArgumentDefaultsHelpFormatter'}), "(description='dump mge model for add_demo',\n formatter_class=argparse.ArgumentDefaultsHelpFormatter)\n", (480, 583), False, 'i... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine._internal.cgtools.get_dep_vars",
"megengine._internal.opr.callback_injector",
"megengine._internal.make_arg",
"megengine._internal.plugin.CompGraphProfiler",
"megengine._internal.serialize_comp_graph_to_file",
"megengine._internal.optimize_for_inference",
"megengine._internal.comp_graph_tools... | [((865, 883), 'functools.wraps', 'functools.wraps', (['f'], {}), '(f)\n', (880, 883), False, 'import functools\n'), ((3018, 3048), 'os.getenv', 'os.getenv', (['"""MGE_DISABLE_TRACE"""'], {}), "('MGE_DISABLE_TRACE')\n", (3027, 3048), False, 'import os\n'), ((5194, 5236), 'megengine._internal.opr.virtual_dep', 'mgb.opr.v... |
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY ... | [
"megengine.core.tensor",
"megengine.distributed.functional.all_reduce_min",
"megengine.distributed.get_master_port",
"megengine.distributed.functional.all_gather",
"megengine.distributed.init_process_group",
"megengine.distributed.functional.all_to_all",
"megengine.get_device_count",
"megengine.distri... | [((636, 707), 'megengine.distributed.init_process_group', 'dist.init_process_group', (['"""localhost"""', '(0)', 'world_size', 'rank', 'dev', 'backend'], {}), "('localhost', 0, world_size, rank, dev, backend)\n", (659, 707), True, 'import megengine.distributed as dist\n'), ((787, 861), 'megengine.distributed.init_proce... |
import os
import sys
import time
from collections import OrderedDict
from time import strftime, gmtime
from tensorboardX import SummaryWriter
from dataset import AsrDataset, DataLoader, AsrCollator
from models.transformer import Model
import hparams as hp
import argparse
import megengine as mge
import megengine.module ... | [
"megengine.core._imperative_rt.core2.push_scope",
"megengine.autodiff.GradManager",
"megengine.logger.get_logger",
"megengine.functional.minimum",
"megengine.random.uniform",
"megengine.distributed.init_process_group",
"megengine.distributed.make_allreduce_cb",
"megengine.functional.concat",
"megeng... | [((902, 931), 'megengine.logger.get_logger', 'megengine.logger.get_logger', ([], {}), '()\n', (929, 931), False, 'import megengine\n'), ((1050, 1078), 'megengine.core._imperative_rt.core2.push_scope', 'push_scope', (['"""clip_grad_norm"""'], {}), "('clip_grad_norm')\n", (1060, 1078), False, 'from megengine.core._impera... |
# Copyright (c) 2020 <NAME>
# This code is licensed under MIT license
# (https://github.com/kwotsin/mimicry/blob/master/LICENSE)
# ------------------------------------------------------------------------------
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megv... | [
"megengine.functional.sqrt",
"megengine.functional.mean",
"megengine.jit.trace",
"megengine.functional.clamp",
"megengine.functional.avg_pool2d"
] | [((2715, 2747), 'megengine.functional.mean', 'F.mean', (['x'], {'axis': '(1)', 'keepdims': '(True)'}), '(x, axis=1, keepdims=True)\n', (2721, 2747), True, 'import megengine.functional as F\n'), ((2756, 2799), 'megengine.functional.mean', 'F.mean', (['((x - m) ** 2)'], {'axis': '(1)', 'keepdims': '(True)'}), '((x - m) *... |
import megengine as mge
import megengine.module as M
import megengine.functional as F
from megengine.core import Parameter
from utils import *
def addLeakyRelu(x):
return M.Sequential(x, M.LeakyReLU(0.1))
def addSig(x):
return M.Sequential(x, M.Sigmoid())
def up_block(x, ic, oc):
return M.ConvTranspose2d... | [
"megengine.module.ConvTranspose2d",
"megengine.functional.maximum",
"megengine.module.LeakyReLU",
"megengine.module.Conv2d",
"megengine.module.AvgPool2d",
"megengine.module.Sigmoid",
"megengine.module.Identity",
"megengine.functional.dimshuffle",
"megengine.functional.concat"
] | [((303, 352), 'megengine.module.ConvTranspose2d', 'M.ConvTranspose2d', (['ic', 'oc', '(4)'], {'stride': '(2)', 'padding': '(1)'}), '(ic, oc, 4, stride=2, padding=1)\n', (320, 352), True, 'import megengine.module as M\n'), ((392, 432), 'megengine.module.Conv2d', 'M.Conv2d', (['ic', 'oc', '(3)'], {'padding': '(1)', 'stri... |
# MegFlow is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2019-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KI... | [
"megengine.load"
] | [((778, 799), 'megengine.load', 'mge.load', (['sys.argv[1]'], {}), '(sys.argv[1])\n', (786, 799), True, 'import megengine as mge\n'), ((918, 941), 'loguru.logger.info', 'logger.info', (['f"""{feat1}"""'], {}), "(f'{feat1}')\n", (929, 941), False, 'from loguru import logger\n'), ((999, 1022), 'loguru.logger.info', 'logg... |
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY ... | [
"megengine.tensor.Tensor"
] | [((2414, 2472), 'numpy.arange', 'np.arange', (['min_value', '(max_value + 2)', '(2)'], {'dtype': 'low_bit_type'}), '(min_value, max_value + 2, 2, dtype=low_bit_type)\n', (2423, 2472), True, 'import numpy as np\n'), ((2483, 2530), 'megengine.tensor.Tensor', 'Tensor', (['data'], {'dtype': 'low_bit_type', 'device': '"""xp... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.functional.div",
"megengine.functional.broadcast_to",
"megengine.jit.trace",
"megengine.functional.sub",
"megengine.functional.vision.warp_perspective",
"megengine.functional.concat",
"megengine.functional.transpose"
] | [((795, 827), 'megengine.jit.trace', 'jit.trace', ([], {'capture_as_const': '(True)'}), '(capture_as_const=True)\n', (804, 827), False, 'from megengine import jit\n'), ((1815, 1888), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {'description': '"""MegEngine Classification Dump .mge"""'}), "(description='M... |
# -*- coding:utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIE... | [
"megengine.functional.argmax",
"megengine.functional.flatten",
"megengine.module.init.fill_",
"megengine.functional.indexing_one_hot",
"megengine.functional.softmax",
"megengine.functional.minimum",
"megengine.module.init.normal_",
"megengine.functional.add_axis",
"megengine.module.Linear",
"megen... | [((636, 688), 'official.vision.detection.layers.BoxCoder', 'layers.BoxCoder', (['cfg.rcnn_reg_mean', 'cfg.rcnn_reg_std'], {}), '(cfg.rcnn_reg_mean, cfg.rcnn_reg_std)\n', (651, 688), False, 'from official.vision.detection import layers\n'), ((909, 974), 'megengine.module.Linear', 'M.Linear', (['(256 * self.pooling_size[... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.module.init.normal_",
"megengine.module.init.fill_",
"megengine.module.ReLU",
"megengine.module.Sequential",
"megengine.module.Conv2d"
] | [((1556, 1581), 'megengine.module.Sequential', 'M.Sequential', (['*cls_subnet'], {}), '(*cls_subnet)\n', (1568, 1581), True, 'import megengine.module as M\n'), ((1609, 1635), 'megengine.module.Sequential', 'M.Sequential', (['*bbox_subnet'], {}), '(*bbox_subnet)\n', (1621, 1635), True, 'import megengine.module as M\n'),... |
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY ... | [
"megengine.functional.conv2d",
"megengine.functional.reshape",
"megengine.core.tensor.dtype.convert_to_qint4",
"megengine.functional.transpose",
"megengine.core.tensor.dtype.qint32",
"megengine.functional.clip",
"megengine.Tensor",
"megengine.core.tensor.dtype.qint4",
"megengine.device.get_device_co... | [((966, 1044), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""kind"""', "['abs', 'sin', 'sub', 'mul', 'fuse_add_tanh']"], {}), "('kind', ['abs', 'sin', 'sub', 'mul', 'fuse_add_tanh'])\n", (989, 1044), False, 'import pytest\n'), ((5797, 5887), 'pytest.mark.skip', 'pytest.mark.skip', ([], {'reason': '"""does... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine._internal.config.create_mm_server",
"megengine._internal.config.group_barrier"
] | [((3376, 3446), 'megengine._internal.config.group_barrier', 'mgb.config.group_barrier', (['_master_ip', '_master_port', '_world_size', '_rank'], {}), '(_master_ip, _master_port, _world_size, _rank)\n', (3400, 3446), True, 'import megengine._internal as mgb\n'), ((3628, 3649), 'functools.wraps', 'functools.wraps', (['fu... |
import functools
import numpy as np
import pytest
import megengine
from megengine.autodiff.grad_manager import GradManager
from megengine.core.ops.builtin import GetVarShape, Reduce, TypeCvt
from megengine.core.tensor.utils import subgraph_fn
from megengine.device import CompNode, get_default_device
from megengine.ji... | [
"megengine.core.ops.builtin.GetVarShape",
"megengine.tensor",
"megengine.device.CompNode",
"megengine.Tensor",
"megengine.device.get_default_device",
"megengine.jit.trace",
"megengine.core.tensor.utils.subgraph_fn",
"megengine.autodiff.grad_manager.GradManager",
"megengine.core.ops.builtin.Reduce",
... | [((355, 424), 'functools.partial', 'functools.partial', (['np.testing.assert_allclose'], {'atol': '(5e-06)', 'rtol': '(5e-06)'}), '(np.testing.assert_allclose, atol=5e-06, rtol=5e-06)\n', (372, 424), False, 'import functools\n'), ((426, 459), 'functools.lru_cache', 'functools.lru_cache', ([], {'maxsize': 'None'}), '(ma... |
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# Copyright (c) Megvii, Inc. and its affiliates.
import random
import megengine as mge
import megengine.distributed as dist
import megengine.functional as F
class DataPrefetcher:
"""
DataPrefetcher is inspired by code of following file:
https://github.com/NV... | [
"megengine.functional.distributed.broadcast",
"megengine.tensor",
"megengine.distributed.group_barrier"
] | [((1025, 1040), 'megengine.tensor', 'mge.tensor', (['[1]'], {}), '([1])\n', (1035, 1040), True, 'import megengine as mge\n'), ((1297, 1328), 'megengine.functional.distributed.broadcast', 'F.distributed.broadcast', (['tensor'], {}), '(tensor)\n', (1320, 1328), True, 'import megengine.functional as F\n'), ((1337, 1357), ... |
import megengine as mge
import megengine.functional as F
import numpy as np
from megengine import Tensor
import pdb
def softmax_loss(pred, label, ignore_label=-1):
max_pred = pred.max(axis=1, keepdims=True).detach()
pred -= max_pred
log_prob = pred - F.log(F.exp(pred).sum(axis=1, keepdims=True))
mask =... | [
"megengine.functional.exp",
"megengine.functional.pow",
"megengine.functional.equal",
"megengine.functional.zeros",
"megengine.functional.log",
"megengine.functional.ones",
"megengine.functional.expand_dims",
"megengine.functional.abs"
] | [((1072, 1080), 'megengine.functional.abs', 'F.abs', (['x'], {}), '(x)\n', (1077, 1080), True, 'import megengine.functional as F\n'), ((3251, 3271), 'megengine.functional.abs', 'F.abs', (['(pred - target)'], {}), '(pred - target)\n', (3256, 3271), True, 'import megengine.functional as F\n'), ((4722, 4748), 'megengine.f... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.functional.arange",
"megengine.utils.comp_graph_tools.GraphInference",
"megengine.utils.naming.AutoNaming.clear",
"megengine.optimizer.SGD",
"megengine.autodiff.GradManager",
"megengine.jit.trace",
"megengine.functional.clip",
"megengine.functional.sum",
"megengine.core.tensor.utils.issca... | [((1162, 1214), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""trace_mode"""', '[False, True]'], {}), "('trace_mode', [False, True])\n", (1185, 1214), False, 'import pytest\n'), ((1216, 1290), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""return_mode"""', "['Value', 'Tuple', 'List', 'Dict']"]... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.test.assertTensorClose",
"megengine.save",
"megengine.tensor",
"megengine.functional.relu",
"megengine.functional.flatten",
"megengine.functional.debug_param.set_conv_execution_strategy",
"megengine.module.Conv2d",
"megengine.module.AvgPool2d",
"megengine.functional.cross_entropy_with_sof... | [((1407, 1430), 'megengine.is_cuda_available', 'mge.is_cuda_available', ([], {}), '()\n', (1428, 1430), True, 'import megengine as mge\n'), ((2486, 2527), 'megengine.functional.cross_entropy_with_softmax', 'F.cross_entropy_with_softmax', (['pred', 'label'], {}), '(pred, label)\n', (2514, 2527), True, 'import megengine.... |
import math
import megengine.module as M
import megengine.functional as F
import megengine as mge
class PositionalEncoding(M.Module):
"""Positional encoding.
:param int d_model: embedding dim
:param float dropout_rate: dropout rate
:param int max_len: maximum input length
"""
def __init__(s... | [
"megengine.functional.arange",
"megengine.module.dropout.Dropout",
"megengine.functional.cos",
"megengine.Tensor",
"megengine.functional.tensor.zeros",
"megengine.functional.sin"
] | [((521, 544), 'math.sqrt', 'math.sqrt', (['self.d_model'], {}), '(self.d_model)\n', (530, 544), False, 'import math\n'), ((568, 599), 'megengine.module.dropout.Dropout', 'M.dropout.Dropout', (['dropout_rate'], {}), '(dropout_rate)\n', (585, 599), True, 'import megengine.module as M\n'), ((618, 633), 'megengine.Tensor',... |
#!/usr/bin/env python3
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
import copy
from typing import Any, Mapping
import megengine as mge
import megengine.functional as F
import megengine.module as M
from .modules import SE, activation, conv2d, gap2d, linear, norm2d
__all__ = ["build_head", "ClsHead", "M... | [
"megengine.module.Dropout",
"megengine.functional.flatten"
] | [((1112, 1136), 'copy.deepcopy', 'copy.deepcopy', (['head_args'], {}), '(head_args)\n', (1125, 1136), False, 'import copy\n'), ((3120, 3135), 'megengine.functional.flatten', 'F.flatten', (['x', '(1)'], {}), '(x, 1)\n', (3129, 3135), True, 'import megengine.functional as F\n'), ((4881, 4896), 'megengine.functional.flatt... |
import numpy as np
from megengine import Tensor
import megengine.functional as F
import pdb
class AnchorGenerator():
"""default anchor generator for fpn.
This class generate anchors by feature map in level.
"""
def __init__(self, base_size=16, ratios=[0.5, 1, 2],
base_scale=2):
self.base... | [
"megengine.functional.linspace",
"megengine.Tensor",
"megengine.functional.stack",
"megengine.functional.sqrt",
"megengine.functional.expand_dims",
"megengine.functional.concat"
] | [((364, 384), 'numpy.array', 'np.array', (['base_scale'], {}), '(base_scale)\n', (372, 384), True, 'import numpy as np\n'), ((939, 993), 'megengine.Tensor', 'Tensor', (['[0, 0, self.base_size - 1, self.base_size - 1]'], {}), '([0, 0, self.base_size - 1, self.base_size - 1])\n', (945, 993), False, 'from megengine import... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.get_logger",
"megengine.distributed.get_rank",
"megengine.data.DataLoader",
"megengine.tensor",
"megengine.distributed.launcher",
"megengine.load"
] | [((691, 715), 'megengine.get_logger', 'mge.get_logger', (['__name__'], {}), '(__name__)\n', (705, 715), True, 'import megengine as mge\n'), ((774, 799), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {}), '()\n', (797, 799), False, 'import argparse\n'), ((1656, 1683), 'official.vision.detection.tools.utils.... |
#!/usr/bin/env python3
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
import megengine as mge
import megengine.module as M
import numpy as np
import pytest
from basecls.layers import SE, DropPath, conv2d, gap2d, linear, norm2d, pool2d
@pytest.mark.parametrize("w_in", [4])
@pytest.mark.parametrize("w_out"... | [
"megengine.random.normal",
"megengine.Tensor"
] | [((251, 287), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""w_in"""', '[4]'], {}), "('w_in', [4])\n", (274, 287), False, 'import pytest\n'), ((289, 326), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""w_out"""', '[8]'], {}), "('w_out', [8])\n", (312, 326), False, 'import pytest\n'), ((328, 36... |
import platform
import numpy as np
import pytest
import megengine as mge
import megengine.distributed as dist
from megengine.distributed.helper import get_device_count_by_fork
from megengine.quantization.observer import (
ExponentialMovingAverageObserver,
MinMaxObserver,
Observer,
PassiveObserver,
... | [
"megengine.quantization.observer.Observer",
"megengine.tensor",
"megengine.distributed.get_rank",
"megengine.quantization.observer.SyncMinMaxObserver",
"megengine.distributed.helper.get_device_count_by_fork",
"megengine.quantization.observer.PassiveObserver",
"megengine.quantization.observer.Exponential... | [((599, 612), 'megengine.tensor', 'mge.tensor', (['x'], {}), '(x)\n', (609, 612), True, 'import megengine as mge\n'), ((621, 637), 'megengine.quantization.observer.MinMaxObserver', 'MinMaxObserver', ([], {}), '()\n', (635, 637), False, 'from megengine.quantization.observer import ExponentialMovingAverageObserver, MinMa... |
import random
from megengine.data.transform import RandomResizedCrop as mge_RRC
from megengine.data.transform import Resize as mge_resize
from ..registry import PIPELINES
from edit.utils import interp_codes
@PIPELINES.register_module()
class Resize(object):
"""
Args:
size (int|list|tuple): Desired ... | [
"megengine.data.transform.Resize",
"megengine.data.transform.RandomResizedCrop"
] | [((935, 1011), 'megengine.data.transform.Resize', 'mge_resize', ([], {'output_size': 'self.size', 'interpolation': 'interp_codes[interpolation]'}), '(output_size=self.size, interpolation=interp_codes[interpolation])\n', (945, 1011), True, 'from megengine.data.transform import Resize as mge_resize\n'), ((3160, 3277), 'm... |
#!/usr/bin/env python3
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
import bisect
import datetime
import math
import os
import pickle
import time
from typing import Optional
import megengine as mge
import megengine.distributed as dist
import megengine.module as M
from basecore.config import ConfigDict
fr... | [
"megengine.distributed.get_rank",
"megengine.distributed.get_world_size"
] | [((1244, 1353), 'basecore.utils.Checkpoint', 'Checkpoint', (['save_dir', 'model'], {'tag_file': 'None', 'optimizer': 'optim', 'scaler': 'scaler', 'progress': 'progress'}), '(save_dir, model, tag_file=None, optimizer=optim, scaler=scaler,\n progress=progress, **ckpt_kws)\n', (1254, 1353), False, 'from basecore.utils ... |
import numpy as np
import megengine as mge
import megengine.functional as F
import megengine.module as M
import math
from config import config
from backbone.resnet50 import ResNet50
from module.generate_anchors import generate_anchors
from det_opr.bbox_opr import bbox_transform_inv_opr, box_overlap_opr
from det_opr.uti... | [
"megengine.module.init.fill_",
"megengine.module.ReLU",
"megengine.functional.sigmoid",
"megengine.functional.ones",
"megengine.module.Conv2d",
"megengine.functional.expand_dims",
"megengine.functional.nn.interpolate",
"megengine.functional.stack",
"megengine.functional.concat",
"megengine.functio... | [((1393, 1470), 'megengine.functional.stack', 'F.stack', (['[broad_shift_x, broad_shift_y, broad_shift_x, broad_shift_y]'], {'axis': '(1)'}), '([broad_shift_x, broad_shift_y, broad_shift_x, broad_shift_y], axis=1)\n', (1400, 1470), True, 'import megengine.functional as F\n'), ((2352, 2362), 'backbone.resnet50.ResNet50'... |
import os
import time
import numpy as np
import megengine.distributed as dist
import megengine as mge
import megengine.functional as F
from megengine.autodiff import GradManager
from edit.core.hook.evaluation import psnr, ssim
from edit.utils import imwrite, tensor2img, bgr2ycbcr, img_multi_padding, img_de_multi_paddin... | [
"megengine.tensor",
"megengine.functional.nn.interpolate",
"megengine.distributed.functional.all_reduce_sum",
"megengine.functional.zeros",
"megengine.functional.stack",
"megengine.functional.expand_dims",
"megengine.distributed.is_distributed",
"megengine.distributed.get_world_size",
"megengine.fun... | [((2104, 2148), 'megengine.functional.zeros', 'F.zeros', (['(2 * B, netG.hidden_channels, h, w)'], {}), '((2 * B, netG.hidden_channels, h, w))\n', (2111, 2148), True, 'import megengine.functional as F\n'), ((2722, 2742), 'megengine.functional.stack', 'F.stack', (['res'], {'axis': '(1)'}), '(res, axis=1)\n', (2729, 2742... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.module.ReLU",
"megengine.module.init.ones_",
"megengine.module.init.msra_normal_",
"megengine.functional.nn.interpolate",
"megengine.module.init.zeros_",
"megengine.module.Conv2d",
"megengine.functional.mean",
"megengine.module.Dropout",
"megengine.module.BatchNorm2d",
"megengine.functi... | [((2386, 2409), 'megengine.functional.mean', 'F.mean', (['x', '[2, 3]', '(True)'], {}), '(x, [2, 3], True)\n', (2392, 2409), True, 'import megengine.functional as F\n'), ((2453, 2499), 'megengine.functional.nn.interpolate', 'F.nn.interpolate', (['gp', '(x.shape[2], x.shape[3])'], {}), '(gp, (x.shape[2], x.shape[3]))\n'... |
import math
import megengine as mge
import megengine.functional as F
import numpy as np
from megengine import Tensor
import pdb
def restore_bbox(rois, deltas, unnormalize=True, config = None):
assert deltas.ndim == 3
if unnormalize:
std_opr = mge.tensor(config.bbox_normalize_stds.reshape(1, 1, -1))
... | [
"megengine.functional.exp",
"megengine.functional.maximum",
"megengine.functional.equal",
"megengine.functional.stack",
"megengine.functional.expand_dims",
"megengine.functional.minimum",
"megengine.functional.prod",
"megengine.functional.log"
] | [((1566, 1587), 'math.log', 'math.log', (['(1000.0 / 16)'], {}), '(1000.0 / 16)\n', (1574, 1587), False, 'import math\n'), ((2027, 2051), 'megengine.functional.minimum', 'F.minimum', (['dw', 'max_delta'], {}), '(dw, max_delta)\n', (2036, 2051), True, 'import megengine.functional as F\n'), ((2061, 2085), 'megengine.func... |
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY ... | [
"megengine.Tensor",
"megengine.functional.sqrt"
] | [((5519, 5532), 'collections.OrderedDict', 'OrderedDict', ([], {}), '()\n', (5530, 5532), False, 'from collections import OrderedDict\n'), ((18529, 18542), 'collections.OrderedDict', 'OrderedDict', ([], {}), '()\n', (18540, 18542), False, 'from collections import OrderedDict\n'), ((8433, 8532), 'numpy.array', 'np.array... |
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY ... | [
"megengine.functional.relu",
"megengine.traced_module.trace_module",
"megengine.traced_module.node.Node._set_next_id",
"megengine.functional.zeros",
"megengine.functional.ones",
"megengine.functional.neg",
"megengine.module.Conv2d",
"megengine.module.qat.Concat",
"megengine.traced_module.expr.Expr._... | [((2316, 2333), 'collections.defaultdict', 'defaultdict', (['list'], {}), '(list)\n', (2327, 2333), False, 'from collections import defaultdict\n'), ((2686, 2706), 'megengine.functional.ones', 'F.ones', (['(1, 3, 3, 3)'], {}), '((1, 3, 3, 3))\n', (2692, 2706), True, 'import megengine.functional as F\n'), ((2745, 2768),... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.core._imperative_rt.imperative.make_backward_graph",
"megengine.functional.distributed.remote_send",
"megengine.functional.expand_dims",
"megengine.functional.distributed.remote_recv",
"megengine.core._imperative_rt.imperative.sync",
"megengine.distributed.init_process_group",
"megengine.func... | [((3488, 3558), 'pytest.mark.skip', 'pytest.mark.skip', ([], {'reason': '"""high order gradient was not implemented yet"""'}), "(reason='high order gradient was not implemented yet')\n", (3504, 3558), False, 'import pytest\n'), ((1041, 1055), 'megengine.core.ops.builtin.Elemwise', 'Elemwise', (['mode'], {}), '(mode)\n'... |
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY ... | [
"megengine.distributed.group_barrier",
"megengine.distributed.get_backend",
"megengine.distributed.get_master_ip",
"megengine.distributed.get_master_port",
"megengine.distributed.get_rank",
"megengine.distributed.init_process_group",
"megengine.distributed.is_distributed",
"megengine.distributed.get_w... | [((1564, 1589), 'multiprocessing.Process', 'mp.Process', ([], {'target': 'worker'}), '(target=worker)\n', (1574, 1589), True, 'import multiprocessing as mp\n'), ((3314, 3324), 'multiprocessing.Queue', 'mp.Queue', ([], {}), '()\n', (3322, 3324), True, 'import multiprocessing as mp\n'), ((3334, 3372), 'multiprocessing.Pr... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.utils.comp_graph_tools.load_and_inference",
"megengine.functional.arange",
"megengine.autodiff.GradManager",
"megengine.jit.trace",
"megengine.functional.clip",
"megengine.core.tensor.utils.isscalar",
"megengine.utils.comp_graph_tools.get_owner_opr_inputs",
"megengine.tensor",
"megengine.... | [((5110, 5174), 'pytest.mark.skip', 'pytest.mark.skip', ([], {'reason': '"""force opt_level=0 when building graph"""'}), "(reason='force opt_level=0 when building graph')\n", (5126, 5174), False, 'import pytest\n'), ((5666, 5730), 'pytest.mark.skip', 'pytest.mark.skip', ([], {'reason': '"""force opt_level=0 when buildi... |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# Copyright (c) 2020 <NAME>
# This file has been modified by Megvii ("Megvii Modifications").
# All Megvii Modifications are Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
"""EfficientNet Series
EfficientNet: `"EfficientNet: Rethinking... | [
"megengine.hub.pretrained"
] | [((3301, 3328), 'basecls.utils.registers.models.register', 'registers.models.register', ([], {}), '()\n', (3326, 3328), False, 'from basecls.utils import recursive_update, registers\n'), ((8976, 9003), 'basecls.utils.registers.models.register', 'registers.models.register', ([], {}), '()\n', (9001, 9003), False, 'from b... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.module.init.fill_",
"megengine.module.Conv3d",
"megengine.module.Conv1d",
"megengine.module.init.calculate_fan_in_and_fan_out",
"megengine.module.Conv2d",
"megengine.module.Linear"
] | [((648, 661), 'megengine.module.init.fill_', 'fill_', (['x', '(5.0)'], {}), '(x, 5.0)\n', (653, 661), False, 'from megengine.module.init import calculate_fan_in_and_fan_out, fill_\n'), ((833, 870), 'megengine.module.Linear', 'Linear', ([], {'in_features': '(3)', 'out_features': '(8)'}), '(in_features=3, out_features=8)... |
import io
import numpy as np
import megengine.core.tensor.megbrain_graph as G
import megengine.functional as F
import megengine.module as M
import megengine.utils.network_node as N
from megengine.jit.tracing import trace
from megengine.tensor import Tensor
from megengine.utils.comp_graph_tools import GraphInference
f... | [
"megengine.utils.comp_graph_tools.GraphInference",
"megengine.functional.ones",
"megengine.functional.sigmoid",
"megengine.module.Conv2d",
"megengine.functional.cond_take",
"megengine.utils.network.Network.load",
"megengine.functional.add",
"megengine.jit.tracing.trace",
"megengine.functional.mul",
... | [((534, 543), 'megengine.tensor.Tensor', 'Tensor', (['(0)'], {}), '(0)\n', (540, 543), False, 'from megengine.tensor import Tensor\n'), ((550, 593), 'megengine.jit.tracing.trace', 'trace', ([], {'symbolic': '(True)', 'capture_as_const': '(True)'}), '(symbolic=True, capture_as_const=True)\n', (555, 593), False, 'from me... |
import math
import megengine.module as M
import megengine.functional as F
class PositionEncodingSine(M.Module):
"""
This is a sinusoidal position encoding that generalized to 2-dimensional images
"""
def __init__(self, d_model, max_shape=(256, 256)):
"""
Args:
max_shape (t... | [
"megengine.functional.arange",
"megengine.functional.cos",
"megengine.functional.zeros",
"megengine.functional.ones",
"megengine.functional.expand_dims",
"megengine.functional.sin"
] | [((446, 476), 'megengine.functional.zeros', 'F.zeros', (['(d_model, *max_shape)'], {}), '((d_model, *max_shape))\n', (453, 476), True, 'import megengine.functional as F\n'), ((751, 782), 'megengine.functional.expand_dims', 'F.expand_dims', (['div_term', '(1, 2)'], {}), '(div_term, (1, 2))\n', (764, 782), True, 'import ... |
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
import cv2
import megengine.functional as F
import numpy as np
__all__ = [
"preprocess",
"postprocess",
]
def preprocess(image, input_size, mean, std, swap=(2, 0, 1)):
if len(image.sha... | [
"megengine.functional.vision.nms",
"megengine.functional.argmax",
"megengine.functional.squeeze",
"megengine.functional.zeros_like",
"megengine.functional.concat",
"megengine.functional.max"
] | [((475, 490), 'numpy.array', 'np.array', (['image'], {}), '(image)\n', (483, 490), True, 'import numpy as np\n'), ((1072, 1117), 'numpy.ascontiguousarray', 'np.ascontiguousarray', (['image'], {'dtype': 'np.float32'}), '(image, dtype=np.float32)\n', (1092, 1117), True, 'import numpy as np\n'), ((1234, 1258), 'megengine.... |
import argparse
import megengine.core.tensor.megbrain_graph as G
import megengine.utils.comp_graph_tools as cgtools
from megengine.core._imperative_rt import make_h2d
def change_batch_and_dump(inp_file, oup_file):
cg, _, outputs = G.load_graph(inp_file)
inputs = cgtools.get_dep_vars(outputs[0], "Host2DeviceC... | [
"megengine.core._imperative_rt.make_h2d",
"megengine.utils.comp_graph_tools.replace_vars",
"megengine.utils.comp_graph_tools.get_dep_vars",
"megengine.core.tensor.megbrain_graph.load_graph"
] | [((238, 260), 'megengine.core.tensor.megbrain_graph.load_graph', 'G.load_graph', (['inp_file'], {}), '(inp_file)\n', (250, 260), True, 'import megengine.core.tensor.megbrain_graph as G\n'), ((274, 325), 'megengine.utils.comp_graph_tools.get_dep_vars', 'cgtools.get_dep_vars', (['outputs[0]', '"""Host2DeviceCopy"""'], {}... |
import os
import math
import numpy as np
import six
import megengine._internal as mgb
from enum import Enum
from py_proto import mace_pb2
from transform import base_converter
from transform.base_converter import PoolingType
from transform.base_converter import ActivationType
from transform.base_converter import Eltwis... | [
"megengine._internal.cgtools.graph_traversal",
"megengine._internal.cgtools.get_opr_type",
"megengine._internal.cgtools.get_oprs_seq",
"megengine._internal.load_comp_graph_from_file"
] | [((1313, 1378), 'enum.Enum', 'Enum', (['"""MGEOpType"""', '[(op, op) for op in MGESupportedOps]'], {'type': 'str'}), "('MGEOpType', [(op, op) for op in MGESupportedOps], type=str)\n", (1317, 1378), False, 'from enum import Enum\n'), ((4473, 4490), 'py_proto.mace_pb2.NetDef', 'mace_pb2.NetDef', ([], {}), '()\n', (4488, ... |
# Copyright (c) Megvii, Inc. and its affiliates.
import megengine as mge
import megengine.functional as F
import megengine.module as M
from .resnet import BasicBlock
class STN(M.Module):
"""spatial transformer networks from
`"Spatial Transformer Networks" <https://arxiv.org/pdf/1506.02025.pdf>`_
some de... | [
"megengine.functional.broadcast_to",
"megengine.functional.flatten",
"megengine.module.ReLU",
"megengine.tensor",
"megengine.module.MaxPool2d",
"megengine.functional.matmul",
"megengine.module.Conv2d",
"megengine.functional.warp_perspective",
"megengine.module.Linear",
"megengine.module.BatchNorm2... | [((944, 959), 'megengine.module.Linear', 'M.Linear', (['(64)', '(9)'], {}), '(64, 9)\n', (952, 959), True, 'import megengine.module as M\n'), ((1452, 1493), 'megengine.functional.warp_perspective', 'F.warp_perspective', (['image', 'mat3x3', '[s, s]'], {}), '(image, mat3x3, [s, s])\n', (1470, 1493), True, 'import megeng... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.functional.sum",
"megengine.functional.grad",
"megengine.module.BatchNorm2d"
] | [((542, 559), 'numpy.random.seed', 'np.random.seed', (['(0)'], {}), '(0)\n', (556, 559), True, 'import numpy as np\n'), ((846, 854), 'megengine.functional.sum', 'F.sum', (['b'], {}), '(b)\n', (851, 854), True, 'import megengine.functional as F\n'), ((868, 904), 'megengine.functional.grad', 'F.grad', (['c', 'x'], {'use_... |
# -*- coding: utf-8 -*-
# MIT License
#
# Copyright (c) 2020 <NAME>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, ... | [
"megengine.module.init.calculate_fan_in_and_fan_out",
"megengine.functional.vision.interpolate",
"megengine.functional.sigmoid",
"megengine.module.Conv2d",
"megengine.functional.nn.pad",
"megengine.functional.var",
"megengine.functional.stack",
"megengine.functional.ones_like",
"megengine.functional... | [((3076, 3175), 'megengine.functional.nn.pad', 'F.nn.pad', (['x2', '((0, 0), (0, 0), (self.pad_size, self.pad_size), (self.pad_size, self.pad_size)\n )'], {}), '(x2, ((0, 0), (0, 0), (self.pad_size, self.pad_size), (self.\n pad_size, self.pad_size)))\n', (3084, 3175), True, 'import megengine.functional as F\n'), ... |
#!/usr/bin/env python3
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
import argparse
import importlib
import os
import sys
import megengine as mge
import megengine.distributed as dist
from basecore.config import ConfigDict
from loguru import logger
from basecls.models import build_model, load_model, sync... | [
"megengine.functional.debug_param.set_execution_strategy",
"megengine.device.get_device_count",
"megengine.distributed.group_barrier",
"megengine.dtr.enable",
"megengine.distributed.get_rank"
] | [((565, 590), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {}), '()\n', (588, 590), False, 'import argparse\n'), ((1353, 1389), 'importlib.import_module', 'importlib.import_module', (['module_name'], {}), '(module_name)\n', (1376, 1389), False, 'import importlib\n'), ((1577, 1608), 'os.path.abspath', 'os.... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.module.BatchNorm2d",
"megengine.autodiff.GradManager"
] | [((630, 664), 'megengine.module.BatchNorm2d', 'BatchNorm2d', (['nchannel'], {'freeze': '(True)'}), '(nchannel, freeze=True)\n', (641, 664), False, 'from megengine.module import BatchNorm2d\n'), ((1445, 1493), 'megengine.module.BatchNorm2d', 'BatchNorm2d', (['nchannel'], {'track_running_stats': '(False)'}), '(nchannel, ... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.functional.loss.cross_entropy",
"megengine._full_sync",
"megengine.autodiff.GradManager",
"megengine.functional.debug_param.set_execution_strategy",
"megengine.jit.trace",
"megengine.amp.autocast",
"megengine.distributed.make_allreduce_cb",
"megengine.distributed.launcher",
"megengine.dtr... | [((941, 966), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {}), '()\n', (964, 966), False, 'import argparse\n'), ((1927, 1955), 'multiprocessing.set_start_method', 'mp.set_start_method', (['"""spawn"""'], {}), "('spawn')\n", (1946, 1955), True, 'import multiprocessing as mp\n'), ((1961, 1975), 'basecls.ut... |
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTI... | [
"megengine.Graph",
"megengine.functional.relu",
"megengine.jit.trace",
"megengine.module.Linear"
] | [((1156, 1178), 'numpy.random.random', 'np.random.random', (['args'], {}), '(args)\n', (1172, 1178), True, 'import numpy as np\n'), ((747, 761), 'megengine.module.Linear', 'Linear', (['(28)', '(50)'], {}), '(28, 50)\n', (753, 761), False, 'from megengine.module import Linear, Module\n'), ((784, 798), 'megengine.module.... |
# -*- coding: utf-8 -*-
# Copyright 2018-2019 Open-MMLab.
#
# 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 ... | [
"megengine.functional.linspace",
"megengine.core.tensor",
"megengine.functional.add_axis",
"megengine.functional.concat"
] | [((2161, 2180), 'numpy.array', 'np.array', (['[2, 3, 4]'], {}), '([2, 3, 4])\n', (2169, 2180), True, 'import numpy as np\n'), ((2218, 2239), 'numpy.array', 'np.array', (['[0.5, 1, 2]'], {}), '([0.5, 1, 2])\n', (2226, 2239), True, 'import numpy as np\n'), ((2971, 3025), 'megengine.core.tensor', 'tensor', (['[0, 0, self.... |
import os
import sys
import pytest
from megengine.core._imperative_rt.imperative import sync
sys.path.append(os.path.join(os.path.dirname(__file__), "helpers"))
def pytest_runtest_teardown():
sync()
| [
"megengine.core._imperative_rt.imperative.sync"
] | [((201, 207), 'megengine.core._imperative_rt.imperative.sync', 'sync', ([], {}), '()\n', (205, 207), False, 'from megengine.core._imperative_rt.imperative import sync\n'), ((125, 150), 'os.path.dirname', 'os.path.dirname', (['__file__'], {}), '(__file__)\n', (140, 150), False, 'import os\n')] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.