code stringlengths 118 171k | apis list | extract_api stringlengths 145 164k |
|---|---|---|
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.FunctionConfig",
"oneflow.random_uniform_initializer",
"oneflow.train.CheckPoint",
"oneflow.onnx.export"
] | [((927, 950), 'oneflow.train.CheckPoint', 'flow.train.CheckPoint', ([], {}), '()\n', (948, 950), True, 'import oneflow as flow\n'), ((1396, 1425), 'tempfile.TemporaryDirectory', 'tempfile.TemporaryDirectory', ([], {}), '()\n', (1423, 1425), False, 'import tempfile\n'), ((1629, 1658), 'tempfile.TemporaryDirectory', 'tem... |
# coding=utf-8
# Copyright 2021 The OneFlow 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 require... | [
"oneflow.arange",
"oneflow.Generator",
"oneflow.randperm"
] | [((5675, 5691), 'oneflow.Generator', 'flow.Generator', ([], {}), '()\n', (5689, 5691), True, 'import oneflow as flow\n'), ((2821, 2837), 'oneflow.Generator', 'flow.Generator', ([], {}), '()\n', (2835, 2837), True, 'import oneflow as flow\n'), ((5762, 5809), 'oneflow.randperm', 'flow.randperm', (['bucket_size'], {'gener... |
"""
Modified from https://github.com/microsoft/Swin-Transformer/blob/main/main.py
"""
import os
import time
import argparse
import datetime
import numpy as np
import oneflow as flow
import oneflow.backends.cudnn as cudnn
from flowvision.loss.cross_entropy import (
LabelSmoothingCrossEntropy,
SoftTargetCrossEn... | [
"oneflow.env.get_rank",
"oneflow.nn.CrossEntropyLoss",
"oneflow.no_grad",
"oneflow.env.get_world_size",
"oneflow.manual_seed",
"oneflow.nn.parallel.DistributedDataParallel"
] | [((9189, 9203), 'oneflow.no_grad', 'flow.no_grad', ([], {}), '()\n', (9201, 9203), True, 'import oneflow as flow\n'), ((10709, 10723), 'oneflow.no_grad', 'flow.no_grad', ([], {}), '()\n', (10721, 10723), True, 'import oneflow as flow\n'), ((754, 868), 'argparse.ArgumentParser', 'argparse.ArgumentParser', (['"""Flowvisi... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.experimental.unittest.skip_unless_1n1d",
"oneflow.experimental.device"
] | [((2909, 2941), 'oneflow.experimental.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (2939, 2941), True, 'import oneflow.experimental as flow\n'), ((786, 829), 'numpy.array', 'np.array', (['[[1, 2, 3], [4, 5, 6], [7, 8, 9]]'], {}), '([[1, 2, 3], [4, 5, 6], [7, 8, 9]])\n', (794, 829), Tr... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.framework.c_api_util.CurrentResource",
"oneflow.framework.c_api_util.GetScopeConfigDef",
"oneflow.framework.c_api_util.GetFunctionConfigDef",
"oneflow.core.job.job_set_pb2.ConfigProto"
] | [((2346, 2374), 'oneflow.framework.c_api_util.CurrentResource', 'c_api_util.CurrentResource', ([], {}), '()\n', (2372, 2374), True, 'import oneflow.framework.c_api_util as c_api_util\n'), ((3399, 3425), 'oneflow.core.job.job_set_pb2.ConfigProto', 'job_set_util.ConfigProto', ([], {}), '()\n', (3423, 3425), True, 'import... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.python.framework.c_api_util.JobBuildAndInferCtx_MirroredBlobGetSubLbi",
"oneflow.python.framework.compile_context.CurJobAddMirroredOp",
"oneflow.python.framework.compile_context.CurJobAddConsistentOp",
"oneflow.current_scope",
"oneflow.python.framework.c_api_util.JobBuildAndInferCtx_MirroredBlobGet... | [((13187, 13219), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""FixedTensorDef"""'], {}), "('FixedTensorDef')\n", (13201, 13219), False, 'from oneflow.python.oneflow_export import oneflow_export\n'), ((13988, 14023), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""Mirro... |
import os
import time
import pickle
from tqdm import tqdm
import librosa
import soundfile as sf
import numpy as np
import oneflow as flow
import utils.data_utils as preprocess
from utils.dataset import trainingDataset
from model.model import Generator, Discriminator
class CycleGANTrainr(object):
def __init__(
... | [
"oneflow.optim.Adam",
"oneflow.tensor",
"oneflow.mean",
"oneflow.utils.data.DataLoader",
"oneflow.cuda.is_available",
"oneflow.abs",
"oneflow.nn.MSELoss"
] | [((969, 998), 'numpy.load', 'np.load', (['logf0s_normalization'], {}), '(logf0s_normalization)\n', (976, 998), True, 'import numpy as np\n'), ((1269, 1296), 'numpy.load', 'np.load', (['mcep_normalization'], {}), '(mcep_normalization)\n', (1276, 1296), True, 'import numpy as np\n'), ((1866, 1883), 'oneflow.nn.MSELoss', ... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.framework.docstr.utils.add_docstr"
] | [((660, 1959), 'oneflow.framework.docstr.utils.add_docstr', 'add_docstr', (['oneflow.tensor', '"""\n Constructs a tensor with data, return a consistent tensor if placement and sbp are in kwargs,\n otherwise return a local tensor. \n \n Arguments:\n data: Initial data for the tensor. Can be a li... |
import sys
import oneflow as flow
import oneflow.typing as tp
import argparse
import numpy as np
import os
import shutil
import json
from typing import Tuple
from textcnn import TextCNN
sys.path.append("../..")
from text_classification.utils import pad_sequences, load_imdb_data
parser = argparse.ArgumentParser()
par... | [
"oneflow.nn.sparse_softmax_cross_entropy_with_logits",
"oneflow.optimizer.Adam",
"oneflow.function_config",
"oneflow.optimizer.PiecewiseConstantScheduler",
"oneflow.train.CheckPoint",
"oneflow.scope.placement",
"oneflow.typing.Numpy.Placeholder"
] | [((188, 212), 'sys.path.append', 'sys.path.append', (['"""../.."""'], {}), "('../..')\n", (203, 212), False, 'import sys\n'), ((291, 316), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {}), '()\n', (314, 316), False, 'import argparse\n'), ((1447, 1469), 'oneflow.function_config', 'flow.function_config', ([... |
"""
@author: <NAME> <<EMAIL>>
"""
import os
import argparse
import pickle
import oneflow as flow
from Wav2Letter.model import Wav2Letter
from Wav2Letter.data import GoogleSpeechCommand
from Wav2Letter.decoder import GreedyDecoder
def get_args():
parser = argparse.ArgumentParser("""Wav2Letter train""")
parse... | [
"oneflow.Tensor",
"oneflow.tensor"
] | [((263, 306), 'argparse.ArgumentParser', 'argparse.ArgumentParser', (['"""Wav2Letter train"""'], {}), "('Wav2Letter train')\n", (286, 306), False, 'import argparse\n'), ((874, 895), 'Wav2Letter.data.GoogleSpeechCommand', 'GoogleSpeechCommand', ([], {}), '()\n', (893, 895), False, 'from Wav2Letter.data import GoogleSpee... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.framework.docstr.utils.add_docstr"
] | [((660, 1698), 'oneflow.framework.docstr.utils.add_docstr', 'add_docstr', (['oneflow.expand', '"""\n oneflow.expand(input, *sizes) -> Tensor,\n\n This operator expand the input tensor to a larger size.\n\n Passing -1 as the size for a dimension means not changing the size of that dimension.\n\n Tensor can b... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.framework.docstr.utils.add_docstr"
] | [((660, 1701), 'oneflow.framework.docstr.utils.add_docstr', 'add_docstr', (['oneflow.diag', '"""\n If input is a vector (1-D tensor), then returns a 2-D square tensor with the elements of input as the diagonal.\n If input is a matrix (2-D tensor), then returns a 1-D tensor with diagonal elements of input.\n\n ... |
import oneflow as flow
from utils.dataset import *
import random
# Find letter index from all_letters, e.g. "a" = 0
def letterToIndex(letter):
return all_letters.find(letter)
# Just for demonstration, turn a letter into a <1 x n_letters> Tensor
def letterToTensor(letter):
# NOTE(<NAME>): oneflow does not p... | [
"oneflow.nn.init.zeros_",
"oneflow.Tensor"
] | [((437, 459), 'oneflow.Tensor', 'flow.Tensor', (['n_letters'], {}), '(n_letters)\n', (448, 459), True, 'import oneflow as flow\n'), ((464, 491), 'oneflow.nn.init.zeros_', 'flow.nn.init.zeros_', (['tensor'], {}), '(tensor)\n', (483, 491), True, 'import oneflow as flow\n'), ((933, 960), 'oneflow.nn.init.zeros_', 'flow.nn... |
import argparse
import os
import numpy as np
import time
import pickle
import oneflow as flow
import oneflow.optim as optim
from tqdm import tqdm
from skimage.metrics import peak_signal_noise_ratio
from skimage.metrics import structural_similarity
from utils.of_data_utils import NumpyDataLoader, ValDatasetFromFolder
f... | [
"oneflow.mean",
"oneflow.no_grad",
"oneflow.load",
"oneflow.Tensor",
"oneflow.nn.BCEWithLogitsLoss"
] | [((422, 490), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {'description': '"""Train Super Resolution Models"""'}), "(description='Train Super Resolution Models')\n", (445, 490), False, 'import argparse\n'), ((2149, 2196), 'oneflow.Tensor', 'flow.Tensor', (['x'], {'requires_grad': 'grad', 'dtype': 'dtype'... |
"""
Copyright 2020 Tianshu AI Platform. 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... | [
"oneflow.data.OFRecordRawDecoder",
"oneflow.sync_default_session",
"oneflow.env.log_dir",
"oneflow.nn.sparse_softmax_cross_entropy_with_logits",
"oneflow.losses.add_loss",
"oneflow.train.CheckPoint",
"oneflow.scope.placement",
"oneflow.config.gpu_device_num",
"oneflow.data.ofrecord_reader"
] | [((1712, 1732), 'config.get_parser', 'configs.get_parser', ([], {}), '()\n', (1730, 1732), True, 'import config as configs\n'), ((5330, 5376), 'math.ceil', 'math.ceil', (['(args.train_example_num / batch_size)'], {}), '(args.train_example_num / batch_size)\n', (5339, 5376), False, 'import math\n'), ((5394, 5444), 'math... |
import errno
import hashlib
import os
import re
import shutil
import sys
import tempfile
import zipfile
import tarfile
import warnings
import logging
from urllib.parse import urlparse
from urllib.request import Request, urlopen
from tqdm import tqdm
from typing import Optional
import oneflow as flow
HASH_REGEX = re.c... | [
"oneflow.load"
] | [((316, 342), 're.compile', 're.compile', (['"""([a-f0-9]*)_"""'], {}), "('([a-f0-9]*)_')\n", (326, 342), False, 'import re\n'), ((1447, 1475), 'tarfile.is_tarfile', 'tarfile.is_tarfile', (['filename'], {}), '(filename)\n', (1465, 1475), False, 'import tarfile\n'), ((1896, 1921), 'oneflow.load', 'flow.load', (['extract... |
from typing import Callable
from overrides import overrides
import oneflow as flow
class Highway(flow.nn.Module):
def __init__(
self,
input_dim: int,
num_layers: int = 1,
activation: Callable[[flow.Tensor], flow.Tensor] = flow.nn.functional.relu,
) -> None:
super(Highw... | [
"oneflow.sigmoid",
"oneflow.nn.Linear"
] | [((1129, 1147), 'oneflow.sigmoid', 'flow.sigmoid', (['gate'], {}), '(gate)\n', (1141, 1147), True, 'import oneflow as flow\n'), ((433, 473), 'oneflow.nn.Linear', 'flow.nn.Linear', (['input_dim', '(input_dim * 2)'], {}), '(input_dim, input_dim * 2)\n', (447, 473), True, 'import oneflow as flow\n')] |
"""
The code refers to DeepLearningForFun(https://github.com/Ldpe2G/DeepLearningForFun/tree/master/Oneflow-Python/CycleGAN) by Ldpe2G
and pytorch-CycleGAN-and-pix2pix(https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix) by junyuanz for implementation.
"""
import time
import argparse
from numpy.lib.npyio import loa... | [
"oneflow.load",
"oneflow.Tensor"
] | [((523, 553), 'os.listdir', 'os.listdir', (['args.datasetA_path'], {}), '(args.datasetA_path)\n', (533, 553), False, 'import os\n'), ((569, 599), 'os.listdir', 'os.listdir', (['args.datasetB_path'], {}), '(args.datasetB_path)\n', (579, 599), False, 'import os\n'), ((2110, 2156), 'argparse.ArgumentParser', 'argparse.Arg... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.core.job.env_pb2.EnvProto",
"oneflow.python.oneflow_export.oneflow_export"
] | [((1006, 1046), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""deprecated.init_worker"""'], {}), "('deprecated.init_worker')\n", (1020, 1046), False, 'from oneflow.python.oneflow_export import oneflow_export\n'), ((3860, 3902), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.framework.tensor.register_tensor_op",
"oneflow.F.copy",
"oneflow.device",
"oneflow.F.cast",
"oneflow._oneflow_internal._ReplacePlacementDeviceTag"
] | [((4326, 4350), 'oneflow.framework.tensor.register_tensor_op', 'register_tensor_op', (['"""to"""'], {}), "('to')\n", (4344, 4350), False, 'from oneflow.framework.tensor import register_tensor_op\n'), ((2534, 2558), 'oneflow.device', 'flow.device', (['device_type'], {}), '(device_type)\n', (2545, 2558), True, 'import on... |
import unittest
from collections import OrderedDict
import math
import numpy as np
from numpy.lib.arraysetops import union1d
import oneflow as flow
from torch._C import dtype
from test_utils import GenArgDict, GenArgList
from flowvision.loss.cross_entropy import (
SoftTargetCrossEntropy,
LabelSmoothingCrossEnt... | [
"oneflow.device"
] | [((1333, 1355), 'numpy.swapaxes', 'np.swapaxes', (['x', '(0)', 'dim'], {}), '(x, 0, dim)\n', (1344, 1355), True, 'import numpy as np\n'), ((1375, 1401), 'numpy.swapaxes', 'np.swapaxes', (['index', '(0)', 'dim'], {}), '(index, 0, dim)\n', (1386, 1401), True, 'import numpy as np\n'), ((1417, 1453), 'numpy.choose', 'np.ch... |
import os
import numpy as np
import argparse
from datetime import datetime
import cv2
import random
import math
import oneflow as flow
import oneflow.typing as tp
import networks
import image_pool
def random_crop(image, crop_height, crop_width):
max_x = image.shape[1] - crop_width
max_y = image.shape[0] - c... | [
"oneflow.FunctionConfig",
"oneflow.scope.consistent_view",
"oneflow.optimizer.PiecewiseConstantScheduler",
"oneflow.typing.Numpy.Placeholder",
"oneflow.train.CheckPoint",
"oneflow.scope.placement"
] | [((340, 367), 'numpy.random.randint', 'np.random.randint', (['(0)', 'max_x'], {}), '(0, max_x)\n', (357, 367), True, 'import numpy as np\n'), ((376, 403), 'numpy.random.randint', 'np.random.randint', (['(0)', 'max_y'], {}), '(0, max_y)\n', (393, 403), True, 'import numpy as np\n'), ((652, 674), 'cv2.imread', 'cv2.imrea... |
"""
Modified from https://github.com/FrancescoSaverioZuppichini/glasses/blob/master/glasses/nn/regularization/__init__.py
"""
import oneflow as flow
import oneflow.nn as nn
import oneflow.nn.functional as F
from oneflow import Tensor
class DropBlock(nn.Module):
def __init__(self, block_size: int = 7, p: float = ... | [
"oneflow.nn.functional.max_pool2d",
"oneflow.ones_like"
] | [((821, 961), 'oneflow.nn.functional.max_pool2d', 'F.max_pool2d', (['mask'], {'kernel_size': '(self.block_size, self.block_size)', 'stride': '(1, 1)', 'padding': '(self.block_size // 2, self.block_size // 2)'}), '(mask, kernel_size=(self.block_size, self.block_size), stride=(\n 1, 1), padding=(self.block_size // 2, ... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.experimental.equal",
"oneflow.experimental.eq",
"oneflow.experimental.unittest.env.eager_execution_enabled",
"oneflow.experimental.Tensor"
] | [((1735, 1750), 'unittest.main', 'unittest.main', ([], {}), '()\n', (1748, 1750), False, 'import unittest\n'), ((860, 882), 'numpy.array', 'np.array', (['[2, 3, 4, 5]'], {}), '([2, 3, 4, 5])\n', (868, 882), True, 'import numpy as np\n'), ((899, 921), 'numpy.array', 'np.array', (['[2, 3, 4, 1]'], {}), '([2, 3, 4, 1])\n'... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.FunctionConfig",
"oneflow.core.record.record_pb2.Int64List",
"oneflow.core.record.record_pb2.Int32List",
"oneflow.data.RawCodec",
"oneflow.data.ofrecord_raw_decoder",
"oneflow.data.ofrecord_reader",
"oneflow.global_function",
"oneflow.core.record.record_pb2.DoubleList",
"oneflow.core.record... | [((838, 856), 'tempfile.mkdtemp', 'tempfile.mkdtemp', ([], {}), '()\n', (854, 856), False, 'import tempfile\n'), ((5227, 5248), 'oneflow.FunctionConfig', 'flow.FunctionConfig', ([], {}), '()\n', (5246, 5248), True, 'import oneflow as flow\n'), ((4175, 4195), 'oneflow.data.RawCodec', 'flow.data.RawCodec', ([], {}), '()\... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.nn.init.constant_",
"oneflow.nn.Linear",
"oneflow.device",
"oneflow.unittest.skip_unless_1n1d",
"oneflow.tensor"
] | [((4084, 4116), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (4114, 4116), True, 'import oneflow as flow\n'), ((4024, 4058), 'os.getenv', 'os.getenv', (['"""ONEFLOW_TEST_CPU_ONLY"""'], {}), "('ONEFLOW_TEST_CPU_ONLY')\n", (4033, 4058), False, 'import os\n'), ((4431, 4446), 'un... |
import oneflow as flow
def get_transformer_decoder_mask(targets):
batch_size, steps = targets.size()
seq_mask = flow.ones([batch_size, steps, steps], device=targets.device)
seq_mask = flow.tril(seq_mask).to(flow.int8)
return seq_mask
| [
"oneflow.tril",
"oneflow.ones"
] | [((122, 182), 'oneflow.ones', 'flow.ones', (['[batch_size, steps, steps]'], {'device': 'targets.device'}), '([batch_size, steps, steps], device=targets.device)\n', (131, 182), True, 'import oneflow as flow\n'), ((198, 217), 'oneflow.tril', 'flow.tril', (['seq_mask'], {}), '(seq_mask)\n', (207, 217), True, 'import onefl... |
# coding=utf-8
# Copyright 2021 The OneFlow 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 require... | [
"oneflow.env.get_rank"
] | [((799, 826), 'logging.getLogger', 'logging.getLogger', (['__name__'], {}), '(__name__)\n', (816, 826), False, 'import logging\n'), ((2471, 2489), 'libai.utils.distributed.synchronize', 'dist.synchronize', ([], {}), '()\n', (2487, 2489), True, 'from libai.utils import distributed as dist\n'), ((2613, 2624), 'time.time'... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.nn.init.ones_",
"oneflow.unittest.env.eager_execution_enabled",
"oneflow.ones_initializer",
"oneflow.global_function",
"oneflow.Tensor",
"oneflow.unittest.skip_unless_1n1d"
] | [((877, 909), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (907, 909), True, 'import oneflow as flow\n'), ((779, 798), 'oneflow.Tensor', 'flow.Tensor', (['*shape'], {}), '(*shape)\n', (790, 798), True, 'import oneflow as flow\n'), ((1978, 1993), 'unittest.main', 'unittest.mai... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.Tensor"
] | [((5538, 5574), 'doctest.testmod', 'doctest.testmod', ([], {'raise_on_error': '(True)'}), '(raise_on_error=True)\n', (5553, 5574), False, 'import doctest\n'), ((4952, 4969), 'math.sqrt', 'math.sqrt', (['fan_in'], {}), '(fan_in)\n', (4961, 4969), False, 'import math\n'), ((2678, 2732), 'oneflow.Tensor', 'flow.Tensor', (... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.FunctionConfig",
"oneflow.global_function",
"oneflow.random_uniform_initializer"
] | [((672, 693), 'oneflow.FunctionConfig', 'flow.FunctionConfig', ([], {}), '()\n', (691, 693), True, 'import oneflow as flow\n'), ((810, 843), 'oneflow.global_function', 'flow.global_function', (['func_config'], {}), '(func_config)\n', (830, 843), True, 'import oneflow as flow\n'), ((1289, 1333), 'util.convert_to_onnx_an... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.matmul",
"oneflow.function_config",
"oneflow.config.enable_legacy_model_io",
"oneflow.typing.Numpy.Placeholder",
"oneflow.global_function",
"oneflow.scope.placement",
"oneflow.unittest.skip_unless_1n1d"
] | [((1787, 1819), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (1817, 1819), True, 'import oneflow as flow\n'), ((1396, 1419), 'numpy.transpose', 'np.transpose', (['b', '(1, 0)'], {}), '(b, (1, 0))\n', (1408, 1419), True, 'import numpy as np\n'), ((1431, 1446), 'numpy.matmul', ... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.experimental.nn.UpsamplingBilinear2d",
"oneflow.experimental.nn.Upsample",
"oneflow.experimental.unittest.env.eager_execution_enabled",
"oneflow.experimental.nn.UpsamplingNearest2d"
] | [((8628, 8643), 'unittest.main', 'unittest.main', ([], {}), '()\n', (8641, 8643), False, 'import unittest\n'), ((993, 1043), 'oneflow.experimental.nn.Upsample', 'flow.nn.Upsample', ([], {'scale_factor': '(2.0)', 'mode': '"""nearest"""'}), "(scale_factor=2.0, mode='nearest')\n", (1009, 1043), True, 'import oneflow.exper... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.experimental.nn.PixelShuffle",
"oneflow.experimental.unittest.env.eager_execution_enabled",
"oneflow.experimental.device"
] | [((1022, 1087), 'numpy.reshape', 'np.reshape', (['input', '[_batch, _new_c, factor ** 2, _height, _width]'], {}), '(input, [_batch, _new_c, factor ** 2, _height, _width])\n', (1032, 1087), True, 'import numpy as np\n'), ((1098, 1164), 'numpy.reshape', 'np.reshape', (['out', '[_batch, _new_c, factor, factor, _height, _w... |
# coding=utf-8
# Copyright 2021 The OneFlow 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 require... | [
"oneflow.save",
"oneflow.load",
"oneflow.tensor"
] | [((1006, 1033), 'logging.getLogger', 'logging.getLogger', (['__name__'], {}), '(__name__)\n', (1023, 1033), False, 'import logging\n'), ((1845, 2000), 'os.path.join', 'os.path.join', (['(cache_dir if cache_dir is not None else data_dir)', 'f"""cached_{mode.value}_{tokenizer.__class__.__name__}_{max_seq_length}_{task_na... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.builtin_op",
"oneflow.python.nn.modules.utils._pair",
"oneflow.python.ops.nn_ops.get_dhw_offset",
"oneflow.python.oneflow_export.oneflow_export"
] | [((939, 969), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""nn.AvgPool2d"""'], {}), "('nn.AvgPool2d')\n", (953, 969), False, 'from oneflow.python.oneflow_export import oneflow_export, experimental_api\n'), ((4104, 4134), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""n... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.compatible.single_client.F.transpose",
"oneflow.compatible.single_client.python.framework.tensor.register_tensor_op",
"oneflow.compatible.single_client.python.oneflow_export.oneflow_export"
] | [((1978, 2005), 'oneflow.compatible.single_client.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""transpose"""'], {}), "('transpose')\n", (1992, 2005), False, 'from oneflow.compatible.single_client.python.oneflow_export import oneflow_export, experimental_api\n'), ((2007, 2038), 'oneflow.compatible.singl... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.compatible.single_client.framework.id_util.UniqueStr"
] | [((2292, 2318), 'oneflow.compatible.single_client.framework.id_util.UniqueStr', 'id_util.UniqueStr', (['"""Diag_"""'], {}), "('Diag_')\n", (2309, 2318), True, 'from oneflow.compatible.single_client.framework import id_util as id_util\n')] |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.unittest.skip_unless_1n1d",
"oneflow.tensor"
] | [((658, 690), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (688, 690), True, 'import oneflow as flow\n'), ((1164, 1179), 'unittest.main', 'unittest.main', ([], {}), '()\n', (1177, 1179), False, 'import unittest\n'), ((928, 947), 'oneflow.tensor', 'flow.tensor', (['(2, 2)'], {... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.nn.ReLU",
"oneflow.tanh",
"oneflow.nn.Tanh",
"oneflow.nn.Dropout",
"oneflow.sigmoid",
"oneflow.zeros",
"oneflow.Tensor",
"oneflow.cat"
] | [((46403, 46439), 'doctest.testmod', 'doctest.testmod', ([], {'raise_on_error': '(True)'}), '(raise_on_error=True)\n', (46418, 46439), False, 'import doctest\n'), ((6098, 6122), 'oneflow.nn.Dropout', 'nn.Dropout', (['self.dropout'], {}), '(self.dropout)\n', (6108, 6122), False, 'from oneflow import nn\n'), ((13311, 133... |
import cv2
import numpy as np
import os
import sys
import time
from PIL import Image
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtPrintSupport import QPrintDialog, QPrinter
import oneflow as flow
import oneflow.typing as tp
from data.base_dataset import load_label2nd... | [
"oneflow.env.init",
"oneflow.FunctionConfig",
"oneflow.scope.consistent_view",
"oneflow.global_function",
"oneflow.scope.placement",
"oneflow.config.gpu_device_num",
"oneflow.typing.Numpy.Placeholder",
"oneflow.checkpoint.get"
] | [((1058, 1098), 'oneflow.config.gpu_device_num', 'flow.config.gpu_device_num', (['opt.gpu_nums'], {}), '(opt.gpu_nums)\n', (1084, 1098), True, 'import oneflow as flow\n'), ((1099, 1114), 'oneflow.env.init', 'flow.env.init', ([], {}), '()\n', (1112, 1114), True, 'import oneflow as flow\n'), ((1129, 1150), 'oneflow.Funct... |
import os
import oneflow as flow
import oneflow.nn as nn
from oneflow.utils.data import DataLoader
from oneflow.utils.vision import transforms
from torchvision.datasets.folder import ImageFolder
from tqdm import tqdm
import numpy as np
class ImageNetDataLoader(DataLoader):
def __init__(self, data_dir, split='train... | [
"oneflow.utils.vision.transforms.CenterCrop",
"oneflow.utils.vision.transforms.Resize",
"oneflow.utils.vision.transforms.ToTensor",
"oneflow.load",
"oneflow.no_grad",
"oneflow.utils.vision.transforms.RandomHorizontalFlip",
"oneflow.utils.vision.transforms.Normalize"
] | [((1926, 1952), 'oneflow.load', 'flow.load', (['pretrained_path'], {}), '(pretrained_path)\n', (1935, 1952), True, 'import oneflow as flow\n'), ((2409, 2423), 'oneflow.no_grad', 'flow.no_grad', ([], {}), '()\n', (2421, 2423), True, 'import oneflow as flow\n'), ((3044, 3058), 'numpy.mean', 'np.mean', (['acc1s'], {}), '(... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.nn.init.constant_",
"oneflow.nn.Linear",
"oneflow.no_grad",
"oneflow.unittest.skip_unless_1n1d",
"oneflow.tensor",
"oneflow.nn.utils.weight_norm"
] | [((842, 984), 'numpy.array', 'np.array', (['[[-0.16046895, -1.03667831], [-0.34974465, 0.26505867], [-1.24111986, -\n 0.53806001], [1.72426331, 0.43572459]]'], {'dtype': 'np.float64'}), '([[-0.16046895, -1.03667831], [-0.34974465, 0.26505867], [-\n 1.24111986, -0.53806001], [1.72426331, 0.43572459]], dtype=np.flo... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.ones"
] | [((2973, 2988), 'unittest.main', 'unittest.main', ([], {}), '()\n', (2986, 2988), False, 'import unittest\n'), ((916, 973), 'oneflow.ones', 'flow.ones', (['(4, 4)'], {'dtype': 'flow.float32', 'requires_grad': '(True)'}), '((4, 4), dtype=flow.float32, requires_grad=True)\n', (925, 973), True, 'import oneflow as flow\n')... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.unittest.skip_unless_1n1d"
] | [((757, 789), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (787, 789), True, 'import oneflow as flow\n'), ((1565, 1580), 'unittest.main', 'unittest.main', ([], {}), '()\n', (1578, 1580), False, 'import unittest\n')] |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.framework.docstr.utils.add_docstr"
] | [((660, 2399), 'oneflow.framework.docstr.utils.add_docstr', 'add_docstr', (['oneflow.arange', '"""\n oneflow.arange(start: int = 0, end, step: int = 1, dtype: Optional[oneflow._oneflow_internal.dtype] = None, device: Optional[Union[oneflow._oneflow_internal.device, str]] = None, placement: Optional[oneflow._oneflow_... |
# coding=utf-8
# Copyright 2021 The OneFlow 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 require... | [
"oneflow.nn.Dropout",
"oneflow.ones"
] | [((7148, 7180), 'libai.layers.LMLogits', 'LMLogits', (['vocab_size'], {'bias': '(False)'}), '(vocab_size, bias=False)\n', (7156, 7180), False, 'from libai.layers import Embedding, LayerNorm, LMLogits, ParallelCrossEntropyLoss, TransformerLayer, VocabEmbedding\n'), ((9158, 9251), 'libai.layers.VocabEmbedding', 'VocabEmb... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.experimental.unittest.env.eager_execution_enabled",
"oneflow.experimental.nn.NLLLoss",
"oneflow.experimental.device"
] | [((1374, 1391), 'oneflow.experimental.nn.NLLLoss', 'flow.nn.NLLLoss', ([], {}), '()\n', (1389, 1391), True, 'import oneflow.experimental as flow\n'), ((2107, 2140), 'oneflow.experimental.nn.NLLLoss', 'flow.nn.NLLLoss', ([], {'reduction': '"""mean"""'}), "(reduction='mean')\n", (2122, 2140), True, 'import oneflow.experi... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.compatible.single_client.clear_default_session",
"oneflow.compatible.single_client.watch_diff",
"oneflow.compatible.single_client.nn.MarginRankingLoss",
"oneflow.compatible.single_client.constant_initializer",
"oneflow.compatible.single_client.FunctionConfig",
"oneflow.compatible.single_client.un... | [((5632, 5664), 'oneflow.compatible.single_client.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (5662, 5664), True, 'from oneflow.compatible import single_client as flow\n'), ((6525, 6557), 'oneflow.compatible.single_client.unittest.skip_unless_1n2d', 'flow.unittest.skip_unless_1n2d', ... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.image.crop_mirror_normalize",
"oneflow.config.train.primary_lr",
"oneflow.math.relu",
"oneflow.get_variable",
"oneflow.data.ofrecord_image_decoder",
"oneflow.random_uniform_initializer",
"oneflow.nn.bias_add",
"oneflow.reshape",
"oneflow.config.default_data_type",
"oneflow.image.resize",
... | [((1131, 1203), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {'description': '"""flags for multi-node and resource"""'}), "(description='flags for multi-node and resource')\n", (1154, 1203), False, 'import argparse\n'), ((2025, 2112), 'oneflow.data.ofrecord_reader', 'flow.data.ofrecord_reader', (['data_di... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.global_function",
"oneflow.data.OFRecordRawDecoder",
"oneflow.nn.sparse_cross_entropy",
"oneflow.reshape",
"oneflow.nn.softmax",
"oneflow.env.log_dir",
"oneflow.losses.add_loss",
"oneflow.scope.placement",
"oneflow.config.gpu_device_num",
"oneflow.data.ofrecord_reader"
] | [((917, 937), 'config.get_parser', 'configs.get_parser', ([], {}), '()\n', (935, 937), True, 'import config as configs\n'), ((3513, 3559), 'math.ceil', 'math.ceil', (['(args.train_example_num / batch_size)'], {}), '(args.train_example_num / batch_size)\n', (3522, 3559), False, 'import math\n'), ((3577, 3627), 'math.cei... |
import oneflow as flow
import oneflow.nn as nn
import sys, os
sys.path.append(
os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
)
from vgg.models.vgg import vgg19_bn, vgg16_bn, vgg19, vgg16
model_dict = {
"vgg16": vgg16,
"vgg19": vgg19,
"vgg16_bn": vgg16_bn,
"vgg19_bn"... | [
"oneflow.mean",
"oneflow.sum",
"oneflow.load",
"oneflow.log",
"oneflow.nn.MSELoss",
"oneflow.pow"
] | [((664, 679), 'oneflow.load', 'flow.load', (['path'], {}), '(path)\n', (673, 679), True, 'import oneflow as flow\n'), ((986, 998), 'oneflow.nn.MSELoss', 'nn.MSELoss', ([], {}), '()\n', (996, 998), True, 'import oneflow.nn as nn\n'), ((1148, 1173), 'oneflow.mean', 'flow.mean', (['(1 - out_labels)'], {}), '(1 - out_label... |
# import tensorflow as tf
import oneflow as flow
import numpy as np
class JointsMSELoss(object):
def __init__(self):
super(JointsMSELoss, self).__init__()
def call(self, y_pred, target, target_weight):
batch_size = y_pred.shape[0]
num_of_joints = y_pred.shape[-1]
pred = flow.r... | [
"oneflow.nn.MSELoss",
"oneflow.reshape",
"oneflow.slice",
"oneflow.squeeze"
] | [((314, 375), 'oneflow.reshape', 'flow.reshape', ([], {'x': 'y_pred', 'shape': '(batch_size, -1, num_of_joints)'}), '(x=y_pred, shape=(batch_size, -1, num_of_joints))\n', (326, 375), True, 'import oneflow as flow\n'), ((596, 657), 'oneflow.reshape', 'flow.reshape', ([], {'x': 'target', 'shape': '(batch_size, -1, num_of... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.core.record.record_pb2.OFRecord"
] | [((3155, 3229), 'os.path.join', 'os.path.join', (['self.data_dir_', 'self.data_part_seq_[self.cur_data_part_idx_]'], {}), '(self.data_dir_, self.data_part_seq_[self.cur_data_part_idx_])\n', (3167, 3229), False, 'import os\n'), ((4949, 4994), 'numpy.stack', 'np.stack', (['[data[0] for data in batch]'], {'axis': '(0)'}),... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.nn.Linear",
"oneflow.env.get_rank",
"oneflow.unittest.skip_unless_1n4d"
] | [((703, 722), 'oneflow.env.get_rank', 'flow.env.get_rank', ([], {}), '()\n', (720, 722), True, 'import oneflow as flow\n'), ((1764, 1796), 'oneflow.unittest.skip_unless_1n4d', 'flow.unittest.skip_unless_1n4d', ([], {}), '()\n', (1794, 1796), True, 'import oneflow as flow\n'), ((1704, 1738), 'os.getenv', 'os.getenv', ([... |
import os
import shutil
import sys
from time import time
import oneflow as flow
import oneflow.nn as nn
import flowvision
MODEL_ROOT = os.path.join(os.getcwd(), "repos")
CONFIG_FILE = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.pbtxt")
DEVICE = "cuda:0"
class MyGraph(nn.Graph):
def __init_... | [
"oneflow.save",
"oneflow.randn"
] | [((150, 161), 'os.getcwd', 'os.getcwd', ([], {}), '()\n', (159, 161), False, 'import os\n'), ((215, 241), 'os.path.realpath', 'os.path.realpath', (['__file__'], {}), '(__file__)\n', (231, 241), False, 'import os\n'), ((804, 810), 'time.time', 'time', ([], {}), '()\n', (808, 810), False, 'from time import time\n'), ((88... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.experimental.Tensor"
] | [((820, 843), 'numpy.random.default_rng', 'np.random.default_rng', ([], {}), '()\n', (841, 843), True, 'import numpy as np\n'), ((1098, 1131), 'random.choice', 'random_util.choice', (['[True, False]'], {}), '([True, False])\n', (1116, 1131), True, 'import random as random_util\n'), ((4522, 4564), 'inspect.getfullargspe... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.compatible.single_client.clear_default_session",
"oneflow.compatible.single_client.random_uniform_initializer",
"oneflow.compatible.single_client.identity",
"oneflow.compatible.single_client.unittest.skip_unless_1n4d",
"oneflow.compatible.single_client.FunctionConfig",
"oneflow.compatible.single_... | [((5278, 5306), 'oneflow.compatible.single_client.clear_default_session', 'flow.clear_default_session', ([], {}), '()\n', (5304, 5306), True, 'from oneflow.compatible import single_client as flow\n'), ((5310, 5342), 'oneflow.compatible.single_client.unittest.skip_unless_1n4d', 'flow.unittest.skip_unless_1n4d', ([], {})... |
import oneflow as flow
def multi_scale_discriminator(input, trainable=True):
num_d = 2
get_intermediate_featuers = True
results = []
for i in range(num_d):
with flow.scope.namespace('multi_scale_discriminator'+str(i)):
out = n_layer_discriminator(input, trainable=trainable)
... | [
"oneflow.xavier_uniform_initializer",
"oneflow.layers.conv2d",
"oneflow.nn.leaky_relu",
"oneflow.nn.InstanceNorm2d",
"oneflow.nn.avg_pool2d"
] | [((585, 618), 'oneflow.xavier_uniform_initializer', 'flow.xavier_uniform_initializer', ([], {}), '()\n', (616, 618), True, 'import oneflow as flow\n'), ((747, 882), 'oneflow.layers.conv2d', 'flow.layers.conv2d', (['input', 'nf'], {'kernel_size': '(4)', 'strides': '(2)', 'padding': '"""SAME"""', 'trainable': 'trainable'... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.framework.docstr.utils.add_docstr"
] | [((660, 1784), 'oneflow.framework.docstr.utils.add_docstr', 'add_docstr', (['oneflow.to_consistent', '"""\n to_consistent(input, placement=None, sbp=None, grad_sbp=None) -> Tensor\n\n Cast a local tensor to consistent tensor or cast a\n consistent tensor to another consistent tensor with\n different sbp or ... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.sbp.split",
"oneflow.env.get_rank",
"oneflow.device",
"oneflow.unittest.skip_unless_1n4d",
"oneflow.Tensor",
"oneflow.unittest.skip_unless_1n2d",
"oneflow.env.get_world_size",
"oneflow.tensor",
"oneflow.env.all_device_placement",
"oneflow.placement"
] | [((96537, 96569), 'oneflow.unittest.skip_unless_1n4d', 'flow.unittest.skip_unless_1n4d', ([], {}), '()\n', (96567, 96569), True, 'import oneflow as flow\n'), ((99084, 99116), 'oneflow.unittest.skip_unless_1n4d', 'flow.unittest.skip_unless_1n4d', ([], {}), '()\n', (99114, 99116), True, 'import oneflow as flow\n'), ((101... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.consistent_user_op_module_builder",
"oneflow.user_op_builder",
"oneflow.python.framework.id_util.UniqueStr",
"oneflow.python.framework.module.Module.__init__",
"oneflow.python.oneflow_export.oneflow_export"
] | [((998, 1068), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""data.OFRecordRawDecoder"""', '"""data.ofrecord_raw_decoder"""'], {}), "('data.OFRecordRawDecoder', 'data.ofrecord_raw_decoder')\n", (1012, 1068), False, 'from oneflow.python.oneflow_export import oneflow_export\n'), ((1824, 1924), 'o... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.nn.LSTM",
"oneflow.nn.GRU",
"oneflow.nn.RNN",
"oneflow.unittest.skip_unless_1n1d",
"oneflow.tensor",
"oneflow.test_utils.test_util.GenArgList"
] | [((6668, 6700), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (6698, 6700), True, 'import oneflow as flow\n'), ((923, 947), 'random.randint', 'random.randint', (['(10)', '(1000)'], {}), '(10, 1000)\n', (937, 947), False, 'import random\n'), ((966, 990), 'random.randint', 'rand... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.cat",
"oneflow.framework.tensor.register_tensor_op"
] | [((712, 739), 'oneflow.framework.tensor.register_tensor_op', 'register_tensor_op', (['"""stack"""'], {}), "('stack')\n", (730, 739), False, 'from oneflow.framework.tensor import Tensor, register_tensor_op\n'), ((2305, 2330), 'oneflow.cat', 'flow.cat', (['unsqueezed', 'dim'], {}), '(unsqueezed, dim)\n', (2313, 2330), Tr... |
import numpy as np
import oneflow as flow
import oneflow.core.operator.op_conf_pb2 as op_conf_util
from flow_utils import *
from resnet import resnet50
class Yolov3_tiny:
def __init__(self, cfg, trainable, data_format='NCHW'):
self.class_num = cfg.YOLO.CLASS_NUM
self.anchor_per_scale = cfg.YOLO.ANC... | [
"oneflow.transpose",
"oneflow.zeros_like",
"oneflow.math.abs",
"oneflow.math.reduce_max",
"oneflow.range",
"oneflow.math.minimum",
"oneflow.slice",
"oneflow.constant_like",
"oneflow.reshape",
"oneflow.concat",
"oneflow.math.maximum",
"oneflow.math.sigmoid",
"oneflow.expand_dims",
"oneflow.... | [((5093, 5158), 'oneflow.concat', 'flow.concat', (['[blob, blobs[0]]'], {'name': '"""yolo-detect2-concat"""', 'axis': '(1)'}), "([blob, blobs[0]], name='yolo-detect2-concat', axis=1)\n", (5104, 5158), True, 'import oneflow as flow\n'), ((6373, 6503), 'oneflow.reshape', 'flow.reshape', (['feature_map'], {'shape': '(feat... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.compatible.single_client.Generator",
"oneflow.compatible.single_client.F.dropout",
"oneflow.compatible.single_client.python.oneflow_export.oneflow_export"
] | [((1452, 1480), 'oneflow.compatible.single_client.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""nn.Dropout"""'], {}), "('nn.Dropout')\n", (1466, 1480), False, 'from oneflow.compatible.single_client.python.oneflow_export import oneflow_export, experimental_api\n'), ((3653, 3689), 'doctest.testmod', 'doc... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.FunctionConfig",
"oneflow.random_uniform_initializer",
"oneflow.global_function",
"oneflow.user_op_builder",
"oneflow.scope.placement",
"oneflow.unittest.skip_unless_1n1d",
"oneflow.clear_default_session",
"oneflow.cast"
] | [((862, 913), 'tensorflow.config.experimental.list_physical_devices', 'tf.config.experimental.list_physical_devices', (['"""GPU"""'], {}), "('GPU')\n", (906, 913), True, 'import tensorflow as tf\n'), ((3584, 3616), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (3614, 3616), Tr... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.matmul",
"oneflow.FunctionConfig",
"oneflow.unittest.env.eager_execution_enabled",
"oneflow.optimizer.PiecewiseConstantScheduler",
"oneflow.optimizer.SGD",
"oneflow.nn.bias_add",
"oneflow.ones_initializer",
"oneflow.global_function",
"oneflow.distribute.split",
"oneflow.distribute.broadca... | [((2474, 2506), 'oneflow.unittest.skip_unless_1n2d', 'flow.unittest.skip_unless_1n2d', ([], {}), '()\n', (2504, 2506), True, 'import oneflow as flow\n'), ((782, 820), 'oneflow.config.gpu_device_num', 'flow.config.gpu_device_num', (['device_num'], {}), '(device_num)\n', (808, 820), True, 'import oneflow as flow\n'), ((8... |
import oneflow as flow
import oneflow.nn as nn
import oneflow.distribute as distribute_util
def _batch_norm(inputs, name, trainable=True, training=True):
params_shape = [inputs.shape[1]]
# Float32 required to avoid precision-loss when using fp16 input/output
params_dtype = flow.float32 if inputs.d... | [
"oneflow.zeros_initializer",
"oneflow.nn.max_pool2d",
"oneflow.ones_initializer",
"oneflow.user_op_builder",
"oneflow.distribute.broadcast",
"oneflow.scope.namespace",
"oneflow.current_global_function_desc"
] | [((2616, 2727), 'oneflow.nn.max_pool2d', 'flow.nn.max_pool2d', (['input'], {'ksize': 'size', 'strides': 'strides', 'padding': 'padding', 'data_format': 'data_format', 'name': 'name'}), '(input, ksize=size, strides=strides, padding=padding,\n data_format=data_format, name=name)\n', (2634, 2727), True, 'import oneflow... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.unittest.skip_unless_1n1d",
"oneflow.tensor",
"oneflow.repeat_interleave"
] | [((703, 735), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (733, 735), True, 'import oneflow as flow\n'), ((3110, 3125), 'unittest.main', 'unittest.main', ([], {}), '()\n', (3123, 3125), False, 'import unittest\n'), ((918, 947), 'oneflow.tensor', 'flow.tensor', (['[[1, 2], [3... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.framework.docstr.utils.add_docstr"
] | [((660, 1875), 'oneflow.framework.docstr.utils.add_docstr', 'add_docstr', (['oneflow.tensor', '"""\n Constructs a tensor with data, return a global tensor if placement and sbp are in kwargs,\n otherwise return a local tensor.\n\n Arguments:\n data: Initial data for the tensor. Can be a list, tuple, N... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.support.enable_if.unique",
"oneflow.support.enable_if.condition",
"oneflow.eager.op_executor.Interpret",
"oneflow.eager.op_executor.OpKernelCall",
"oneflow.eager.gradient_util.GetDefaultBackwardBlobRegister",
"oneflow.current_scope",
"oneflow.eager.gradient_util.TrySetBackwardUsedBlobObject",
... | [((845, 895), 'oneflow._oneflow_internal.GetDefaultBlobRegister', 'oneflow._oneflow_internal.GetDefaultBlobRegister', ([], {}), '()\n', (893, 895), False, 'import oneflow\n'), ((1789, 1859), 'oneflow.support.enable_if.condition', 'enable_if.condition', (['(hob.in_global_mode & ~hob.eager_execution_enabled)'], {}), '(ho... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.advanced.distribute_split",
"oneflow.scope.consistent_view_enabled",
"oneflow.scope.placement",
"oneflow.core.operator.op_conf_pb2.OperatorConf",
"oneflow.python.framework.remote_blob.RemoteBlob",
"oneflow.python.lib.core.enable_if.unqiue",
"oneflow.python.lib.core.enable_if.condition",
"onef... | [((1199, 1242), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""advanced.distribute_clone"""'], {}), "('advanced.distribute_clone')\n", (1213, 1242), False, 'from oneflow.python.oneflow_export import oneflow_export\n'), ((1440, 1479), 'oneflow.python.lib.core.enable_if.condition', 'enable_if.con... |
# coding=utf-8
import numpy as np
from numpy import random
import oneflow as flow
import oneflow.nn as nn
import resnet50_model
# resnet50 bs 32, use_disjoint_set=False: threshold ~800MB
# memory policy:
# 1: only reuse the memory block with exactly the same size
# 2: reuse the memory block with the same size or la... | [
"oneflow._oneflow_internal.dtr.display",
"oneflow.nn.CrossEntropyLoss",
"oneflow._oneflow_internal.eager.multi_client.Sync",
"oneflow.manual_seed",
"oneflow.device",
"oneflow.enable_dtr"
] | [((584, 673), 'oneflow.enable_dtr', 'flow.enable_dtr', (['dtr_enabled', 'threshold', 'debug_level', 'memory_policy', 'use_disjoint_set'], {}), '(dtr_enabled, threshold, debug_level, memory_policy,\n use_disjoint_set)\n', (599, 673), True, 'import oneflow as flow\n'), ((681, 703), 'oneflow.manual_seed', 'flow.manual_... |
import oneflow as flow
import oneflow.nn as nn
class SEModule(nn.Module):
def __init__(
self,
channels,
reduction=16,
rd_channels=None,
act_layer=nn.ReLU,
gate_layer=nn.Sigmoid,
mlp_bias=False,
):
super(SEModule, self).__init__()
rd_chann... | [
"oneflow.nn.Conv2d"
] | [((407, 457), 'oneflow.nn.Conv2d', 'nn.Conv2d', (['channels', 'rd_channels', '(1)'], {'bias': 'mlp_bias'}), '(channels, rd_channels, 1, bias=mlp_bias)\n', (416, 457), True, 'import oneflow.nn as nn\n'), ((520, 570), 'oneflow.nn.Conv2d', 'nn.Conv2d', (['rd_channels', 'channels', '(1)'], {'bias': 'mlp_bias'}), '(rd_chann... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.framework.graph_build_util.make_new_block_scope",
"oneflow.nn.graph.util.add_indent",
"oneflow.env.get_rank",
"oneflow.nn.graph.util.seq_to_func_return",
"oneflow.framework.graph_build_util.lazy_mode.is_enabled",
"oneflow.nn.graph.block_config.BlockConfig",
"oneflow.framework.graph_build_util.B... | [((2167, 2180), 'oneflow.nn.graph.block_config.BlockConfig', 'BlockConfig', ([], {}), '()\n', (2178, 2180), False, 'from oneflow.nn.graph.block_config import BlockConfig\n'), ((2790, 2853), 'oneflow.framework.graph_build_util.BlockScopeContext', 'graph_build_util.BlockScopeContext', (['self.prev_scope', 'self.scope'], ... |
"""
Copyright 2020 The OneFlow 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... | [
"oneflow.FunctionConfig",
"oneflow.optimizer.AdamW",
"oneflow.math.multiply",
"oneflow.optimizer.warmup.linear",
"oneflow.train.CheckPoint",
"oneflow.global_function",
"oneflow.typing.Numpy.Placeholder",
"oneflow.optimizer.PiecewiseScalingScheduler"
] | [((1017, 1090), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {'description': '"""flags for person re-identification"""'}), "(description='flags for person re-identification')\n", (1040, 1090), False, 'import argparse\n'), ((3321, 3342), 'oneflow.FunctionConfig', 'flow.FunctionConfig', ([], {}), '()\n', (3... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.Tensor",
"oneflow.tensor"
] | [((7879, 7931), 'oneflow.tensor', 'flow.tensor', (['mean'], {'dtype': 'dtype', 'device': 'tensor.device'}), '(mean, dtype=dtype, device=tensor.device)\n', (7890, 7931), True, 'import oneflow as flow\n'), ((7942, 7993), 'oneflow.tensor', 'flow.tensor', (['std'], {'dtype': 'dtype', 'device': 'tensor.device'}), '(std, dty... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.sbp.split",
"oneflow.device",
"oneflow.unittest.skip_unless_1n2d",
"oneflow.placement"
] | [((776, 808), 'oneflow.unittest.skip_unless_1n2d', 'flow.unittest.skip_unless_1n2d', ([], {}), '()\n', (806, 808), True, 'import oneflow as flow\n'), ((826, 860), 'os.getenv', 'os.getenv', (['"""ONEFLOW_TEST_CPU_ONLY"""'], {}), "('ONEFLOW_TEST_CPU_ONLY')\n", (835, 860), False, 'import os\n'), ((1500, 1515), 'unittest.m... |
import oneflow as flow
from flowvision.layers.attention import SEModule
def test_se():
x = flow.randn(1, 48, 16, 16)
se = SEModule(48)
assert se(x).shape == x.shape
if __name__ == "__main__":
test_se()
| [
"oneflow.randn"
] | [((97, 122), 'oneflow.randn', 'flow.randn', (['(1)', '(48)', '(16)', '(16)'], {}), '(1, 48, 16, 16)\n', (107, 122), True, 'import oneflow as flow\n'), ((132, 144), 'flowvision.layers.attention.SEModule', 'SEModule', (['(48)'], {}), '(48)\n', (140, 144), False, 'from flowvision.layers.attention import SEModule\n')] |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.env.init",
"oneflow.scope.placement",
"oneflow.config.enable_legacy_model_io",
"oneflow.function_config",
"oneflow.typing.Numpy.Placeholder",
"oneflow.global_function",
"oneflow.train.CheckPoint"
] | [((1235, 1275), 'oneflow.config.enable_legacy_model_io', 'flow.config.enable_legacy_model_io', (['(True)'], {}), '(True)\n', (1269, 1275), True, 'import oneflow as flow\n'), ((809, 831), 'cv2.imread', 'cv2.imread', (['image_path'], {}), '(image_path)\n', (819, 831), False, 'import cv2\n'), ((841, 876), 'cv2.cvtColor', ... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.nms",
"oneflow.tensor",
"oneflow.env.all_device_placement"
] | [((877, 910), 'test_nms.create_tensors_with_iou', 'create_tensors_with_iou', (['(800)', 'iou'], {}), '(800, iou)\n', (900, 910), False, 'from test_nms import create_tensors_with_iou\n'), ((1458, 1490), 'test_nms.nms_np', 'nms_np', (['np_boxes', 'np_scores', 'iou'], {}), '(np_boxes, np_scores, iou)\n', (1464, 1490), Fal... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.compatible.single_client.unittest.skip_unless_1n1d",
"oneflow.compatible.single_client.FunctionConfig",
"oneflow.compatible.single_client.math.add_n",
"oneflow.compatible.single_client.typing.Numpy.Placeholder",
"oneflow.compatible.single_client.global_function"
] | [((777, 798), 'oneflow.compatible.single_client.FunctionConfig', 'flow.FunctionConfig', ([], {}), '()\n', (796, 798), True, 'from oneflow.compatible import single_client as flow\n'), ((1238, 1270), 'oneflow.compatible.single_client.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (1268, 1... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.F.broadcast_like",
"oneflow.python.oneflow_export.oneflow_export"
] | [((1848, 1880), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""broadcast_like"""'], {}), "('broadcast_like')\n", (1862, 1880), False, 'from oneflow.python.oneflow_export import oneflow_export, experimental_api\n'), ((1776, 1844), 'oneflow.F.broadcast_like', 'flow.F.broadcast_like', (['x', 'like... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.FunctionConfig",
"oneflow.optimizer.PiecewiseConstantScheduler",
"oneflow.global_function",
"oneflow.typing.Numpy.Placeholder",
"oneflow.nn.InstanceNorm2d",
"oneflow.unittest.skip_unless_1n2d",
"oneflow.constant_initializer",
"oneflow.nn.InstanceNorm1d",
"oneflow.scope.placement",
"oneflo... | [((4337, 4369), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (4367, 4369), True, 'import oneflow as flow\n'), ((4866, 4898), 'oneflow.unittest.skip_unless_1n2d', 'flow.unittest.skip_unless_1n2d', ([], {}), '()\n', (4896, 4898), True, 'import oneflow as flow\n'), ((944, 999), ... |
import oneflow as flow
import oneflow as flow_exp
from oneflow import Tensor
def nms(boxes: Tensor, scores: Tensor, iou_threshold: float) -> Tensor:
scores_inds = flow_exp.argsort(scores, dim=0, descending=True)
boxes = flow._C.gather(boxes, scores_inds, axis=0)
_nms_op = (
flow_exp.builtin_op("nm... | [
"oneflow.builtin_op",
"oneflow.argwhere",
"oneflow.argsort",
"oneflow._C.gather"
] | [((169, 217), 'oneflow.argsort', 'flow_exp.argsort', (['scores'], {'dim': '(0)', 'descending': '(True)'}), '(scores, dim=0, descending=True)\n', (185, 217), True, 'import oneflow as flow_exp\n'), ((230, 272), 'oneflow._C.gather', 'flow._C.gather', (['boxes', 'scores_inds'], {'axis': '(0)'}), '(boxes, scores_inds, axis=... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.experimental.std",
"oneflow.experimental.arcsinh",
"oneflow.experimental.topk",
"oneflow.experimental.unittest.env.eager_execution_enabled",
"oneflow.experimental.log",
"oneflow.experimental.sin",
"oneflow.experimental.device",
"oneflow.experimental.pow",
"oneflow.experimental.arcsin",
"o... | [((881, 904), 'numpy.random.randn', 'np.random.randn', (['*shape'], {}), '(*shape)\n', (896, 904), True, 'import numpy as np\n'), ((992, 1024), 'numpy.var', 'np.var', (['np_arr', '(0)'], {'keepdims': '(True)'}), '(np_arr, 0, keepdims=True)\n', (998, 1024), True, 'import numpy as np\n'), ((1160, 1183), 'numpy.random.ran... |
#-*- coding:utf-8 -*-
"""
@author: scorpio.lu
@datetime:2020-06-24 10:20
@software: PyCharm
@contact: <EMAIL>
----------
路有敬亭山
----------
"""
import oneflow as flow
import numpy as np
import cv2
import os
from .reid_model import resreid
func_config = flow.FunctionConfig()
fu... | [
"oneflow.FunctionConfig",
"oneflow.train.CheckPoint",
"oneflow.global_function",
"oneflow.FixedTensorDef"
] | [((296, 317), 'oneflow.FunctionConfig', 'flow.FunctionConfig', ([], {}), '()\n', (315, 317), True, 'import oneflow as flow\n'), ((562, 626), 'oneflow.FixedTensorDef', 'flow.FixedTensorDef', (['(batch_size, 3, 256, 128)'], {'dtype': 'flow.float'}), '((batch_size, 3, 256, 128), dtype=flow.float)\n', (581, 626), True, 'im... |
import oneflow as flow
import numpy as np
def spectral_norm(w, iteration=1):
w_shape = w.shape
w = np.reshape(w, [-1, w_shape[0]])
# u = flow.get_variable('u', shape=[1, w_shape[0]], initializer=flow.random_normal_initializer(), trainable=False)
u = np.random.random([1, w_shape[0]])
u_hat = u
... | [
"oneflow.load_variables",
"oneflow.get_all_variables"
] | [((108, 139), 'numpy.reshape', 'np.reshape', (['w', '[-1, w_shape[0]]'], {}), '(w, [-1, w_shape[0]])\n', (118, 139), True, 'import numpy as np\n'), ((268, 301), 'numpy.random.random', 'np.random.random', (['[1, w_shape[0]]'], {}), '([1, w_shape[0]])\n', (284, 301), True, 'import numpy as np\n'), ((622, 649), 'numpy.res... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.nn.Conv2d",
"oneflow.nn.functional.pad",
"oneflow.randn",
"oneflow.unittest.skip_unless_1n1d"
] | [((1785, 1817), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (1815, 1817), True, 'import oneflow as flow\n'), ((978, 1020), 'oneflow.nn.Conv2d', 'flow.nn.Conv2d', (['(3)', '(3)', '(2)', '(1)'], {'bias': 'with_bias'}), '(3, 3, 2, 1, bias=with_bias)\n', (992, 1020), True, 'impo... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.save",
"oneflow.optim.LAMB",
"oneflow.sum",
"oneflow.device",
"oneflow.load",
"oneflow.unittest.skip_unless_1n1d",
"oneflow.test_utils.test_util.GenArgList"
] | [((4563, 4595), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (4593, 4595), True, 'import oneflow as flow\n'), ((1105, 1125), 'numpy.random.seed', 'np.random.seed', (['(1000)'], {}), '(1000)\n', (1119, 1125), True, 'import numpy as np\n'), ((5603, 5618), 'unittest.main', 'unit... |
from __future__ import absolute_import
from __future__ import division
import oneflow.experimental as flow
import numpy as np
class TripletLoss(flow.nn.Module):
"""Triplet loss with hard positive/negative mining.
Reference:
Hermans et al. In Defense of the Triplet Loss for Person Re-Identification.... | [
"oneflow.experimental.add",
"oneflow.experimental.slice",
"oneflow.experimental.pow",
"oneflow.experimental.nn.LogSoftmax",
"oneflow.experimental.nn.MarginRankingLoss",
"oneflow.experimental.ones_like",
"oneflow.experimental.cat",
"oneflow.experimental.clamp",
"oneflow.experimental.zeros",
"oneflo... | [((658, 698), 'oneflow.experimental.nn.MarginRankingLoss', 'flow.nn.MarginRankingLoss', ([], {'margin': 'margin'}), '(margin=margin)\n', (683, 698), True, 'import oneflow.experimental as flow\n'), ((1264, 1285), 'oneflow.experimental.add', 'flow.add', (['dist', 'temp1'], {}), '(dist, temp1)\n', (1272, 1285), True, 'imp... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.python.eager.blob_cache.TryDisableBlobCache"
] | [((3300, 3369), 'oneflow.python.eager.blob_cache.TryDisableBlobCache', 'blob_cache_util.TryDisableBlobCache', (['self.blob_name2object[blob_name]'], {}), '(self.blob_name2object[blob_name])\n', (3335, 3369), True, 'import oneflow.python.eager.blob_cache as blob_cache_util\n')] |
"""
Copyright 2020 The OneFlow 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 l... | [
"oneflow.experimental.atan2",
"oneflow.experimental.unittest.env.eager_execution_enabled",
"oneflow.experimental.device"
] | [((1104, 1138), 'oneflow.experimental.atan2', 'flow.atan2', (['of_input_x', 'of_input_y'], {}), '(of_input_x, of_input_y)\n', (1114, 1138), True, 'import oneflow.experimental as flow\n'), ((1153, 1187), 'numpy.arctan2', 'np.arctan2', (['np_input_x', 'np_input_y'], {}), '(np_input_x, np_input_y)\n', (1163, 1187), True, ... |
import oneflow as flow
import oneflow.nn as nn
import math
# Reference: https://github.com/piEsposito/pytorch-lstm-by-hand
class LSTM(nn.Module):
def __init__(self, input_dim, hidden_dim, output_dim, batch_size=1, num_layers=1):
super(LSTM, self).__init__()
self.input_dim = input_dim
self.h... | [
"oneflow.matmul",
"oneflow.nn.Linear",
"oneflow.tanh",
"oneflow.sigmoid",
"oneflow.zeros",
"oneflow.Tensor",
"oneflow.cat"
] | [((571, 609), 'oneflow.nn.Linear', 'nn.Linear', (['self.hidden_dim', 'output_dim'], {}), '(self.hidden_dim, output_dim)\n', (580, 609), True, 'import oneflow.nn as nn\n'), ((3044, 3071), 'oneflow.cat', 'flow.cat', (['hidden_seq'], {'dim': '(0)'}), '(hidden_seq, dim=0)\n', (3052, 3071), True, 'import oneflow as flow\n')... |
import oneflow as flow
def make_optimizer(args, model):
param_group = {"params": [p for p in model.parameters() if p is not None]}
if args.grad_clipping > 0.0:
assert args.grad_clipping == 1.0, "ONLY support grad_clipping == 1.0"
param_group["clip_grad_max_norm"] = (1.0,)
param_group[... | [
"oneflow.amp.GradScaler",
"oneflow.optim.lr_scheduler.WarmUpLR",
"oneflow.nn.CrossEntropyLoss",
"oneflow.optim.SGD",
"oneflow.optim.lr_scheduler.CosineDecayLR",
"oneflow.env.get_world_size",
"oneflow._C.one_hot"
] | [((369, 481), 'oneflow.optim.SGD', 'flow.optim.SGD', (['[param_group]'], {'lr': 'args.learning_rate', 'momentum': 'args.momentum', 'weight_decay': 'args.weight_decay'}), '([param_group], lr=args.learning_rate, momentum=args.momentum,\n weight_decay=args.weight_decay)\n', (383, 481), True, 'import oneflow as flow\n')... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.sbp.split",
"oneflow.unittest.skip_unless_2n4d"
] | [((2969, 3001), 'oneflow.unittest.skip_unless_2n4d', 'flow.unittest.skip_unless_2n4d', ([], {}), '()\n', (2999, 3001), True, 'import oneflow as flow\n'), ((3019, 3053), 'os.getenv', 'os.getenv', (['"""ONEFLOW_TEST_CPU_ONLY"""'], {}), "('ONEFLOW_TEST_CPU_ONLY')\n", (3028, 3053), False, 'import os\n'), ((3790, 3805), 'un... |
import random
import numpy as np
from functools import partial
import oneflow
import oneflow as flow
import oneflow.nn as nn
import oneflow.F as F
from utils.drop import DropPath
from layers.mlp import Mlp
from layers.layer_norm import LayerNorm
from layers.helpers import to_2tuple
from layers.patch_embed import Patch... | [
"oneflow.nn.Linear",
"oneflow.nn.Identity",
"oneflow.load",
"oneflow.ones"
] | [((3832, 3879), 'oneflow.ones', 'flow.ones', (['(1, 3, 224, 224)'], {'dtype': 'flow.float32'}), '((1, 3, 224, 224), dtype=flow.float32)\n', (3841, 3879), True, 'import oneflow as flow\n'), ((4414, 4501), 'oneflow.load', 'flow.load', (['"""/data/rentianhe/code/vision-mlp-oneflow/weights/flow/mixer_b16_224.of"""'], {}), ... |
import oneflow as flow
from quantization_ops.q_module import QModule, QParam
__all__ = ["QConv2d"]
class QConv2d(QModule):
def __init__(self, conv_module, qi=True, qo=True, quantization_bit=8, quantization_scheme='symmetric', quantization_formula='google', per_layer_quantization=True):
super(QConv2d, se... | [
"oneflow.Tensor",
"oneflow.nn.FakeQuantization",
"oneflow.nn.Quantization"
] | [((845, 992), 'oneflow.nn.FakeQuantization', 'flow.nn.FakeQuantization', ([], {'quantization_formula': 'quantization_formula', 'quantization_bit': 'quantization_bit', 'quantization_scheme': 'quantization_scheme'}), '(quantization_formula=quantization_formula,\n quantization_bit=quantization_bit, quantization_scheme=... |
"""
Copyright 2020 The OneFlow 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 agr... | [
"oneflow.cat",
"oneflow.gather"
] | [((1616, 1653), 'oneflow.gather', 'flow.gather', (['input', 'dim', 'index_gather'], {}), '(input, dim, index_gather)\n', (1627, 1653), True, 'import oneflow as flow\n'), ((1707, 1743), 'doctest.testmod', 'doctest.testmod', ([], {'raise_on_error': '(True)'}), '(raise_on_error=True)\n', (1722, 1743), False, 'import docte... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.