code stringlengths 118 171k | apis list | extract_api stringlengths 145 164k |
|---|---|---|
import os
import numpy as np
import time
import argparse
import oneflow as flow
from models.networks import Generator, Discriminator
from utils.data_utils import load_facades
from utils.utils import init_logger, to_tensor, to_numpy, save_images, mkdirs
class Pix2Pix:
def __init__(self, args) -> None:
self... | [
"oneflow.no_grad",
"oneflow.cat",
"oneflow.nn.BCEWithLogitsLoss",
"oneflow.nn.L1Loss"
] | [((7251, 7305), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {'description': '"""oneflow PIX2PIX"""'}), "(description='oneflow PIX2PIX')\n", (7274, 7305), False, 'import argparse\n'), ((1026, 1053), 'oneflow.nn.BCEWithLogitsLoss', 'flow.nn.BCEWithLogitsLoss', ([], {}), '()\n', (1051, 1053), True, 'import ... |
"""
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.config.collective_boxing.nccl_fusion_threshold_mb",
"oneflow.sync_default_session",
"oneflow.config.collective_boxing.nccl_fusion_all_reduce_use_buffer",
"oneflow.one_hot",
"oneflow.env.log_dir",
"oneflow.config.enable_debug_mode",
"oneflow.nn.softmax_cross_entropy_with_logits",
"oneflow.nn.s... | [((1192, 1212), 'util.config.get_parser', 'configs.get_parser', ([], {}), '()\n', (1210, 1212), True, 'import util.config as configs\n'), ((1240, 1264), 'util.config.print_args', 'configs.print_args', (['args'], {}), '(args)\n', (1258, 1264), True, 'import util.config as configs\n'), ((1499, 1546), 'math.ceil', 'math.c... |
"""
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.unsqueeze",
"oneflow.experimental.abs",
"oneflow.python.framework.tensor.register_tensor_op",
"oneflow.experimental.argwhere",
"oneflow.python.oneflow_export.oneflow_export",
"oneflow.experimental.square"
] | [((5214, 5243), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""linalg.norm"""'], {}), "('linalg.norm')\n", (5228, 5243), False, 'from oneflow.python.oneflow_export import oneflow_export, experimental_api\n'), ((10663, 10689), 'oneflow.python.framework.tensor.register_tensor_op', 'register_tenso... |
"""
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.typing.Numpy.Placeholder",
"oneflow.constant_initializer",
"oneflow.config.enable_debug_mode",
"oneflow.losses.add_loss",
"oneflow.config.gpu_device_num",
"oneflow.FunctionConfig",
"oneflow.scope.consistent_view"
] | [((713, 742), 'oneflow.config.gpu_device_num', 'flow.config.gpu_device_num', (['(2)'], {}), '(2)\n', (739, 742), True, 'import oneflow as flow\n'), ((747, 782), 'oneflow.config.enable_debug_mode', 'flow.config.enable_debug_mode', (['(True)'], {}), '(True)\n', (776, 782), True, 'import oneflow as flow\n'), ((801, 822), ... |
"""
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_1n4d",
"oneflow.tensor",
"oneflow.env.get_rank",
"oneflow.env.all_device_placement",
"oneflow.unittest.skip_unless_1n2d",
"oneflow.rsqrt",
"oneflow.unittest.env.eager_execution_enabled",
"oneflow.placement",
"oneflow.sbp.split",
"oneflow.Tensor",
"oneflow.unittest.s... | [((864, 896), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (894, 896), True, 'import oneflow as flow\n'), ((7967, 7999), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (7997, 7999), True, 'import oneflow as flow\n'), ((23502, 23541), ... |
from models.pix2pix_model import Pix2PixModel
import oneflow as flow
import oneflow.typing as tp
import numpy as np
from options import BaseOptions
from pre_process import preprocess_input
import cv2
from data.base_method.what_name import Dataset_Help
import util.util as util
opt = BaseOptions().parse()
opt.phase = 't... | [
"oneflow.env.init",
"oneflow.global_function",
"oneflow.typing.Numpy.Placeholder",
"oneflow.checkpoint.get",
"oneflow.config.gpu_device_num",
"oneflow.FunctionConfig"
] | [((469, 484), 'oneflow.env.init', 'flow.env.init', ([], {}), '()\n', (482, 484), True, 'import oneflow as flow\n'), ((499, 520), 'oneflow.FunctionConfig', 'flow.FunctionConfig', ([], {}), '()\n', (518, 520), True, 'import oneflow as flow\n'), ((889, 906), 'models.pix2pix_model.Pix2PixModel', 'Pix2PixModel', (['opt'], {... |
r"""
reference to PyTorch
MultiheadAttention in torch.nn.activation
multi_head_attention_forward in torch.nn.functional
"""
from typing import Optional, Tuple
import oneflow as flow
from oneflow import Tensor
from oneflow.nn import Module, Parameter, Linear
from oneflow.nn.init import xavier_uniform_,... | [
"oneflow.nn.init.xavier_normal_",
"oneflow.nn.Linear",
"oneflow.logical_or",
"oneflow.zeros",
"oneflow.nn.init.constant_",
"oneflow.zeros_like",
"oneflow.nn.init.xavier_uniform_"
] | [((2387, 2426), 'oneflow.nn.Linear', 'Linear', (['embed_dim', 'embed_dim'], {'bias': 'bias'}), '(embed_dim, embed_dim, bias=bias)\n', (2393, 2426), False, 'from oneflow.nn import Module, Parameter, Linear\n'), ((2806, 2842), 'oneflow.nn.init.xavier_uniform_', 'xavier_uniform_', (['self.in_proj_weight'], {}), '(self.in_... |
"""
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.scope.namespace",
"oneflow.nn.conv2d",
"oneflow.gather",
"oneflow.constant_initializer",
"oneflow.random_uniform_initializer",
"oneflow.FixedTensorDef",
"oneflow.nn.bias_add",
"oneflow.reshape",
"oneflow.matmul"
] | [((686, 717), 'oneflow.FixedTensorDef', 'of.FixedTensorDef', (['(1, 3, 6, 6)'], {}), '((1, 3, 6, 6))\n', (703, 717), True, 'import oneflow as of\n'), ((2333, 2358), 'oneflow.FixedTensorDef', 'of.FixedTensorDef', (['(2, 5)'], {}), '((2, 5))\n', (2350, 2358), True, 'import oneflow as of\n'), ((729, 762), 'oneflow.scope.n... |
import argparse
import oneflow as flow
from classifier_flow import ClueAFQMCCPT
from tokenizer.tokenization_bert import BertTokenizer
def inference_afqmc(args):
tokenizer = BertTokenizer.from_pretrained("hfl/chinese-roberta-wwm-ext")
model = ClueAFQMCCPT(args.pretrain_dir, args.n_classes, args.is_train).to... | [
"oneflow.argmax",
"oneflow.tensor",
"oneflow.softmax",
"oneflow.load"
] | [((182, 242), 'tokenizer.tokenization_bert.BertTokenizer.from_pretrained', 'BertTokenizer.from_pretrained', (['"""hfl/chinese-roberta-wwm-ext"""'], {}), "('hfl/chinese-roberta-wwm-ext')\n", (211, 242), False, 'from tokenizer.tokenization_bert import BertTokenizer\n'), ((806, 826), 'oneflow.softmax', 'flow.softmax', (['... |
# !/usr/bin/env python
# -*- coding:utf-8 -*-
"""
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/LICEN... | [
"oneflow.core.record.record_pb2.Int32List",
"oneflow.core.record.record_pb2.BytesList"
] | [((939, 977), 'sched.scheduler', 'sched.scheduler', (['time.time', 'time.sleep'], {}), '(time.time, time.sleep)\n', (954, 977), False, 'import sched\n'), ((3577, 3612), 'numpy.zeros', 'np.zeros', (['(num_labels, num_classes)'], {}), '((num_labels, num_classes))\n', (3585, 3612), True, 'import numpy as np\n'), ((4082, 4... |
"""
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.clear_default_session",
"oneflow.global_function",
"oneflow.train.CheckPoint",
"oneflow.python.test.ops.test_util.GenArgList",
"oneflow.scope.placement",
"oneflow.concat",
"oneflow.typing.Numpy.Placeholder",
"oneflow.constant_initializer",
"oneflow.con... | [((2818, 2850), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (2848, 2850), True, 'import oneflow as flow\n'), ((1502, 1530), 'oneflow.clear_default_session', 'flow.clear_default_session', ([], {}), '()\n', (1528, 1530), True, 'import oneflow as flow\n'), ((1549, 1570), 'onefl... |
"""
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.operator.op_conf_pb2.OperatorConf",
"oneflow.python.framework.remote_blob.EagerLogicalBlob",
"oneflow.python.experimental.name_scope.GetJobNameScopePrefix",
"oneflow.python.framework.c_api_util.CheckAndCompleteUserOpConf",
"oneflow.python.framework.remote_blob.RemoteBlob",
"oneflow.python.on... | [((1811, 1847), 'oneflow_api.GetDefaultBlobRegister', 'oneflow_api.GetDefaultBlobRegister', ([], {}), '()\n', (1845, 1847), False, 'import oneflow_api\n'), ((5090, 5123), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""user_op_builder"""'], {}), "('user_op_builder')\n", (5104, 5123), False, 'fro... |
"""
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.initializer_conf_pb2.InitializerConf",
"oneflow.core.job.initializer_conf_pb2.EmptyInitializerConf",
"oneflow.python.oneflow_export.oneflow_export",
"oneflow.random_uniform_initializer",
"oneflow.random_normal_initializer"
] | [((935, 970), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""empty_initializer"""'], {}), "('empty_initializer')\n", (949, 970), False, 'from oneflow.python.oneflow_export import oneflow_export\n'), ((1268, 1306), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""constant_... |
"""
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_1n4d"
] | [((786, 818), 'oneflow.unittest.skip_unless_1n4d', 'flow.unittest.skip_unless_1n4d', ([], {}), '()\n', (816, 818), True, 'import oneflow as flow\n'), ((2778, 2793), 'unittest.main', 'unittest.main', ([], {}), '()\n', (2791, 2793), False, 'import unittest\n'), ((906, 919), 'collections.OrderedDict', 'OrderedDict', ([], ... |
import argparse
import math
import oneflow as flow
_GLOBAL_ARGS = None
def get_args():
global _GLOBAL_ARGS
if _GLOBAL_ARGS is None:
_GLOBAL_ARGS = parse_args()
return _GLOBAL_ARGS
def str2bool(v):
if v.lower() in ("yes", "true", "t", "y", "1"):
return True
elif v.lower() in ("n... | [
"oneflow.env.get_world_size",
"oneflow.env.get_rank"
] | [((513, 602), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {'description': '"""OneFlow ResNet50 Arguments"""', 'allow_abbrev': '(False)'}), "(description='OneFlow ResNet50 Arguments',\n allow_abbrev=False)\n", (536, 602), False, 'import argparse\n'), ((8042, 8067), 'oneflow.env.get_world_size', 'flow.e... |
"""
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.squeeze",
"oneflow.experimental.unittest.env.eager_execution_enabled"
] | [((1639, 1654), 'unittest.main', 'unittest.main', ([], {}), '()\n', (1652, 1654), False, 'import unittest\n'), ((690, 733), 'oneflow.experimental.unittest.env.eager_execution_enabled', 'flow.unittest.env.eager_execution_enabled', ([], {}), '()\n', (731, 733), True, 'import oneflow.experimental as flow\n'), ((1047, 1081... |
# -*- coding:utf-8 -*-
import sys
import argparse
from data_loader import Market1501, RandomIdentitySampler, ImageDataset
import oneflow as flow
from bisect import bisect_right
import os
import os.path as osp
import numpy as np
from utils.loggers import Logger
from utils.distance import compute_distance_matrix
from lo... | [
"oneflow.load",
"oneflow.no_grad"
] | [((465, 544), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {'formatter_class': 'argparse.ArgumentDefaultsHelpFormatter'}), '(formatter_class=argparse.ArgumentDefaultsHelpFormatter)\n', (488, 544), False, 'import argparse\n'), ((3899, 3924), 'model.ResReid', 'ResReid', (['args.num_classes'], {}), '(args.nu... |
"""
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.clear_default_session",
"oneflow.global_function",
"oneflow.train.CheckPoint",
"oneflow.scope.placement",
"oneflow.nn.conv1d",
"oneflow.optimizer.PiecewiseConstantScheduler",
"oneflow.random_uniform_initializer",
"oneflow.FunctionConfig",
"oneflow.scope.consistent_view"
] | [((771, 822), 'tensorflow.config.experimental.list_physical_devices', 'tf.config.experimental.list_physical_devices', (['"""GPU"""'], {}), "('GPU')\n", (815, 822), True, 'import tensorflow as tf\n'), ((844, 895), 'tensorflow.config.experimental.set_memory_growth', 'tf.config.experimental.set_memory_growth', (['gpu', '(... |
import json
import os
import shutil
import sys
import oneflow as flow
import numpy as np
import torch
import transformers
from base_weight_utils import colored_string
from roberta_weight_utils import (
Roberta_trans,
RobertaForMaskedLM_trans,
RobertaForSequenceClassification_trans
)
sys.path.append("../")... | [
"oneflow.tensor",
"oneflow.load"
] | [((298, 320), 'sys.path.append', 'sys.path.append', (['"""../"""'], {}), "('../')\n", (313, 320), False, 'import sys\n'), ((695, 728), 'os.path.join', 'os.path.join', (['save_dir', 'model_dir'], {}), '(save_dir, model_dir)\n', (707, 728), False, 'import os\n'), ((756, 794), 'os.path.join', 'os.path.join', (['self.save_... |
"""
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, 4095), 'oneflow.framework.docstr.utils.add_docstr', 'add_docstr', (['oneflow.index_select', '"""\n input.index_select(dim, index) -> Tensor\n\n The interface is consistent with PyTorch. \n The documentation is referenced from: https://pytorch.org/docs/1.11/generated/torch.index_select.html#torch.ind... |
"""
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.Size"
] | [((1203, 1235), 'oneflow.compatible.single_client.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (1233, 1235), True, 'from oneflow.compatible import single_client as flow\n'), ((1092, 1110), 'oneflow.compatible.single_client.Size', 'flow.Size', (['x_shape'], {}), '(x_shape)\n', (1101, 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.scope.placement",
"oneflow.cast",
"oneflow.unittest.skip_unless_1n2d",
"oneflow.scope.consistent_view",
"oneflow.clear_default_session",
"oneflow.global_function",
"oneflow.typing.Numpy.Placeholder",
"oneflow.math.reduce_sum",
"oneflow.config.gpu_device_num",
"oneflow.FunctionConfig"
] | [((822, 873), 'tensorflow.config.experimental.list_physical_devices', 'tf.config.experimental.list_physical_devices', (['"""GPU"""'], {}), "('GPU')\n", (866, 873), True, 'import tensorflow as tf\n'), ((2442, 2474), 'oneflow.unittest.skip_unless_1n2d', 'flow.unittest.skip_unless_1n2d', ([], {}), '()\n', (2472, 2474), 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.experimental.sort",
"oneflow.experimental.unittest.env.eager_execution_enabled",
"oneflow.experimental.device"
] | [((1018, 1067), 'oneflow.experimental.sort', 'flow.sort', (['input'], {'dim': 'axis', 'descending': 'descending'}), '(input, dim=axis, descending=descending)\n', (1027, 1067), True, 'import oneflow.experimental as flow\n'), ((1148, 1179), 'numpy.argsort', 'np.argsort', (['np_input'], {'axis': 'axis'}), '(np_input, 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.compatible.single_client.zeros_initializer",
"oneflow.compatible.single_client.nn.elu",
"oneflow.compatible.single_client.scope.placement",
"oneflow.compatible.single_client.FunctionConfig",
"oneflow.compatible.single_client.watch_diff",
"oneflow.compatible.single_client.unittest.skip_unless_1n1d... | [((5855, 5887), 'oneflow.compatible.single_client.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (5885, 5887), True, 'from oneflow.compatible import single_client as flow\n'), ((6673, 6705), '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.unittest.skip_unless_1n1d",
"oneflow.Generator",
"oneflow.test_utils.test_util.GenArgList",
"oneflow.device"
] | [((2038, 2070), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (2068, 2070), True, 'import oneflow as flow\n'), ((1359, 1375), 'oneflow.Generator', 'flow.Generator', ([], {}), '()\n', (1373, 1375), True, 'import oneflow as flow\n'), ((2605, 2620), '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._C.to_consistent",
"oneflow._C.to_local",
"oneflow.support.blocking.BlockingInfoContext",
"oneflow.framework.tensor.register_tensor_op"
] | [((1258, 1293), 'oneflow.framework.tensor.register_tensor_op', 'register_tensor_op', (['"""to_consistent"""'], {}), "('to_consistent')\n", (1276, 1293), False, 'from oneflow.framework.tensor import register_tensor_op, Tensor\n'), ((3940, 3970), 'oneflow.framework.tensor.register_tensor_op', 'register_tensor_op', (['"""... |
from oneflow.compatible import single_client as flow
from oneflow.compatible.single_client import typing as tp
import numpy as np
import os
BATCH_SIZE = 100
flow.config.enable_legacy_model_io(True)
flow.config.enable_model_io_v2(True)
flow.enable_eager_execution(False)
print(os.getpid())
def mlp_model(images, labels... | [
"oneflow.compatible.single_client.random_uniform_initializer",
"oneflow.compatible.single_client.config.enable_legacy_model_io",
"oneflow.compatible.single_client.checkpoint.save",
"oneflow.compatible.single_client.config.enable_model_io_v2",
"oneflow.compatible.single_client.enable_eager_execution",
"one... | [((158, 198), 'oneflow.compatible.single_client.config.enable_legacy_model_io', 'flow.config.enable_legacy_model_io', (['(True)'], {}), '(True)\n', (192, 198), True, 'from oneflow.compatible import single_client as flow\n'), ((199, 235), 'oneflow.compatible.single_client.config.enable_model_io_v2', 'flow.config.enable_... |
"""
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.randn",
"oneflow.nn.Linear"
] | [((709, 741), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (739, 741), True, 'import oneflow as flow\n'), ((1143, 1158), 'unittest.main', 'unittest.main', ([], {}), '()\n', (1156, 1158), False, 'import unittest\n'), ((926, 944), 'oneflow.randn', 'flow.randn', (['(10)', '(10)'... |
"""
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.argsort",
"oneflow._C.nms",
"oneflow.argwhere",
"oneflow._C.gather"
] | [((774, 818), 'oneflow.argsort', 'flow.argsort', (['scores'], {'dim': '(0)', 'descending': '(True)'}), '(scores, dim=0, descending=True)\n', (786, 818), True, 'import oneflow as flow\n'), ((831, 872), 'oneflow._C.gather', 'flow._C.gather', (['boxes', 'score_inds'], {'axis': '(0)'}), '(boxes, score_inds, axis=0)\n', (84... |
"""
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.randn",
"oneflow.env.all_device_placement",
"oneflow.sbp.split",
"oneflow.nn.BatchNorm1d"
] | [((1117, 1149), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (1147, 1149), True, 'import oneflow as flow\n'), ((731, 748), 'oneflow.nn.BatchNorm1d', 'nn.BatchNorm1d', (['(6)'], {}), '(6)\n', (745, 748), True, 'import oneflow.nn as nn\n'), ((1501, 1516), 'unittest.main', 'unit... |
"""
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.distribute.broadcast",
"oneflow.scope.namespace",
"oneflow.constant_initializer",
"oneflow.get_variable",
"oneflow.user_op_builder",
"oneflow.python.oneflow_export.oneflow_export"
] | [((934, 964), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""layers.prelu"""'], {}), "('layers.prelu')\n", (948, 964), False, 'from oneflow.python.oneflow_export import oneflow_export\n'), ((1307, 1334), 'oneflow.python.framework.distribute.broadcast', 'distribute_util.broadcast', ([], {}), '()... |
"""
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, 6844), 'oneflow.framework.docstr.utils.add_docstr', 'add_docstr', (['oneflow.tensordot', '"""\n tensordot(a, b, dims=Union[int, Tensor, Tuple[List[int], List[int]], List[List[int]]], out=None) -> Tensor\n \n Compute tensor dot along given dimensions.\n \n Given two tensors a and b, and dims which... |
import math
from numpy.lib.arraysetops import isin
# import torch
# import torch.nn as nn
# import torch.nn.functional as F
import oneflow as of
import oneflow.nn as nn
import oneflow.nn.functional as F
# from libs.components.scores import CosineScore
# class GE2ELoss(nn.Module):
#
# def __init__(self, ini... | [
"oneflow.Tensor",
"oneflow.nn.init.kaiming_normal_",
"oneflow.nn.functional.softmax",
"oneflow.nn.functional.cosine_similarity",
"oneflow.nn.functional.relu",
"oneflow.nn.CrossEntropyLoss",
"oneflow.zeros_like",
"oneflow.nn.functional.l2_normalize",
"oneflow.nn.Linear",
"oneflow.nn.functional.cros... | [((13298, 13336), 'oneflow.nn.Linear', 'nn.Linear', (['embedding_size', 'num_classes'], {}), '(embedding_size, num_classes)\n', (13307, 13336), True, 'import oneflow.nn as nn\n'), ((13420, 13444), 'oneflow.nn.functional.softmax', 'F.softmax', (['logits'], {'dim': '(1)'}), '(logits, dim=1)\n', (13429, 13444), True, 'imp... |
import oneflow.experimental as flow
import os
class OFRecordDataLoader(object):
def __init__(self,data_dir, batch_size, data_part_num, seq_length, part_name_prefix, dataset_size, shuffle=True):
self.train_record_reader= flow.nn.OfrecordReader(data_dir,
batch_size... | [
"oneflow.experimental.nn.OfrecordReader",
"oneflow.experimental.enable_eager_execution",
"oneflow.experimental.InitEagerGlobalSession",
"oneflow.experimental.nn.OfrecordRawDecoder"
] | [((2172, 2201), 'oneflow.experimental.enable_eager_execution', 'flow.enable_eager_execution', ([], {}), '()\n', (2199, 2201), True, 'import oneflow.experimental as flow\n'), ((2206, 2235), 'oneflow.experimental.InitEagerGlobalSession', 'flow.InitEagerGlobalSession', ([], {}), '()\n', (2233, 2235), 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.experimental.unittest.skip_unless_1n1d",
"oneflow.experimental.tensor_to_tensor_buffer",
"oneflow.experimental.nn.image.decode",
"oneflow.experimental.device"
] | [((677, 709), 'oneflow.experimental.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (707, 709), True, 'import oneflow.experimental as flow\n'), ((2390, 2405), 'unittest.main', 'unittest.main', ([], {}), '()\n', (2403, 2405), False, 'import unittest\n'), ((1226, 1265), 'oneflow.experiment... |
"""
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.test_utils.test_util.GenArgDict",
"oneflow._C.one_embedding_id_shuffle",
"oneflow.unittest.skip_unless_1n1d",
"oneflow.tensor",
"oneflow.cast",
"oneflow._C.one_embedding_embedding_shuffle",
"oneflow._C.one_embedding_embedding_gradient_shuffle",
"oneflow._C.gather"
] | [((8070, 8102), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (8100, 8102), True, 'import oneflow as flow\n'), ((909, 978), 'numpy.random.randint', 'np.random.randint', (['(0)', '(1000)', '(batch_size, num_columns)'], {'dtype': 'np.int64'}), '(0, 1000, (batch_size, num_columns... |
import oneflow as flow
from oneflow import nn
class OfRecordDataLoader(nn.Module):
def __init__(
self,
ofrecord_dir: str,
mode: str,
dataset_size: int,
batch_size: int,
data_part_num: int,
seq_length: int,
max_predictions_per_seq: int,
consis... | [
"oneflow.nn.OfrecordReader",
"oneflow.env.get_world_size",
"oneflow.placement",
"oneflow.nn.OfrecordRawDecoder",
"oneflow.sbp.split"
] | [((940, 1184), 'oneflow.nn.OfrecordReader', 'nn.OfrecordReader', (['ofrecord_dir'], {'batch_size': 'batch_size', 'data_part_num': 'data_part_num', 'random_shuffle': "(True if mode == 'train' else False)", 'shuffle_after_epoch': "(True if mode == 'train' else False)", 'placement': 'self.placement', 'sbp': 'self.sbp'}), ... |
"""
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._C.negative",
"oneflow.framework.tensor.register_tensor_op"
] | [((698, 728), 'oneflow.framework.tensor.register_tensor_op', 'register_tensor_op', (['"""negative"""'], {}), "('negative')\n", (716, 728), False, 'from oneflow.framework.tensor import register_tensor_op\n'), ((1340, 1369), 'oneflow.framework.tensor.register_tensor_op', 'register_tensor_op', (['"""type_as"""'], {}), "('... |
import os,time
import numpy as np
import cv2
import oneflow as flow
from .reid_model import resreid
from .restrack_reid import *
## todo:
# 将bbox_tlwh, ori_img转化为numpy矩阵,批量处理,提取特征
class Extractor():
def __init__(self, model_name, load_path, gpu_ids='0', use_gpu=True, height=256, width=128, seed=1, cl... | [
"oneflow.train.CheckPoint"
] | [((732, 799), 'cv2.HOGDescriptor', 'cv2.HOGDescriptor', (['winSize', 'blockSize', 'blockStride', 'cellSize', 'nbins'], {}), '(winSize, blockSize, blockStride, cellSize, nbins)\n', (749, 799), False, 'import cv2\n'), ((835, 859), 'os.path.isdir', 'os.path.isdir', (['load_path'], {}), '(load_path)\n', (848, 859), False, ... |
"""
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.user_op_builder",
"oneflow.python.oneflow_export.oneflow_export",
"oneflow.python.framework.id_util.UniqueStr"
] | [((832, 881), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""experimental.ssp_variable_proxy"""'], {}), "('experimental.ssp_variable_proxy')\n", (846, 881), False, 'from oneflow.python.oneflow_export import oneflow_export\n'), ((1102, 1140), 'oneflow.python.framework.id_util.UniqueStr', 'id_uti... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import numpy as np
import unittest
import oneflow.experimental as flow
from zhusuan_of.distributions.base import *
flow.enable_eager_execution()
class Dist(Dist... | [
"oneflow.experimental.zeros_like",
"oneflow.experimental.Tensor",
"oneflow.experimental.enable_eager_execution",
"oneflow.experimental.ones"
] | [((274, 303), 'oneflow.experimental.enable_eager_execution', 'flow.enable_eager_execution', ([], {}), '()\n', (301, 303), True, 'import oneflow.experimental as flow\n'), ((1291, 1325), 'oneflow.experimental.ones', 'flow.ones', (['(n_samples, 2, 3, 4, 5)'], {}), '((n_samples, 2, 3, 4, 5))\n', (1300, 1325), 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 agreed... | [
"oneflow.distribute.broadcast",
"oneflow.current_global_function_desc",
"oneflow.nn.conv2d",
"oneflow.scope.namespace",
"oneflow.ones_initializer",
"oneflow.nn.conv2d_transpose",
"oneflow.random_normal_initializer",
"oneflow.constant_initializer",
"oneflow.get_variable",
"oneflow.zeros_initializer... | [((664, 707), 'oneflow.random_normal_initializer', 'flow.random_normal_initializer', ([], {'stddev': '(0.02)'}), '(stddev=0.02)\n', (694, 707), True, 'import oneflow as flow\n'), ((1061, 1191), 'oneflow.get_variable', 'flow.get_variable', (["(name + '-weight')"], {'shape': 'weight_shape', 'dtype': 'input.dtype', 'initi... |
"""
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.enable_eager_execution",
"oneflow.saved_model.ModelBuilder",
"oneflow.typing.Numpy.Placeholder",
"oneflow.scope.placement",
"oneflow.function_config",
"oneflow.env.init",
"oneflow.config.enable_legacy_model_io",
"oneflow.train.CheckPoint"
] | [((714, 729), 'oneflow.env.init', 'flow.env.init', ([], {}), '()\n', (727, 729), True, 'import oneflow as flow\n'), ((734, 768), 'oneflow.enable_eager_execution', 'flow.enable_eager_execution', (['(False)'], {}), '(False)\n', (761, 768), True, 'import oneflow as flow\n'), ((773, 813), 'oneflow.config.enable_legacy_mode... |
"""
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.batch_matmul",
"oneflow.python.oneflow_export.oneflow_export",
"oneflow.python.framework.tensor.register_tensor_op"
] | [((1129, 1150), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""bmm"""'], {}), "('bmm')\n", (1143, 1150), False, 'from oneflow.python.oneflow_export import oneflow_export, experimental_api\n'), ((2099, 2124), 'oneflow.python.framework.tensor.register_tensor_op', 'register_tensor_op', (['"""bmm""... |
"""
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.meshgrid",
"oneflow.unittest.skip_unless_1n1d",
"oneflow.device"
] | [((2428, 2460), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (2458, 2460), True, 'import oneflow as flow\n'), ((1173, 1221), 'oneflow.meshgrid', 'flow.meshgrid', (['input1', 'input2'], {'indexing': 'indexing'}), '(input1, input2, indexing=indexing)\n', (1186, 1221), True, 'im... |
import oneflow as flow
def conv_encoder(input, trainable=True):
crop_size = 512
if input.shape[2]!=256 or input.shape[3]!=256:
input = flow.experimental.nn.UpsamplingBilinear2d(size=(256, 256))(input)
input = flow.layers.conv2d(input, 64, kernel_size=3, strides=2, padding=1, trainable=trainable)
... | [
"oneflow.nn.InstanceNorm2d",
"oneflow.layers.dense",
"oneflow.reshape",
"oneflow.nn.leaky_relu",
"oneflow.layers.conv2d",
"oneflow.experimental.nn.UpsamplingBilinear2d"
] | [((232, 323), 'oneflow.layers.conv2d', 'flow.layers.conv2d', (['input', '(64)'], {'kernel_size': '(3)', 'strides': '(2)', 'padding': '(1)', 'trainable': 'trainable'}), '(input, 64, kernel_size=3, strides=2, padding=1,\n trainable=trainable)\n', (250, 323), True, 'import oneflow as flow\n'), ((332, 379), 'oneflow.nn.... |
"""
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.from_numpy",
"oneflow.tensor",
"oneflow.nn.parameter.Parameter",
"oneflow.multiprocessing.shared_memory.SharedMemory"
] | [((1294, 1322), 'oneflow.tensor', 'flow.tensor', (['[]'], {'dtype': 'dtype'}), '([], dtype=dtype)\n', (1305, 1322), True, 'import oneflow as flow\n'), ((1572, 1618), 'numpy.ndarray', 'np.ndarray', (['shape'], {'dtype': 'dtype', 'buffer': 'shm.buf'}), '(shape, dtype=dtype, buffer=shm.buf)\n', (1582, 1618), 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.logical_slice",
"oneflow.zeros",
"oneflow.slice"
] | [((1437, 1489), 'oneflow.slice', 'flow.slice', (['x.oneflow'], {'slice_tup_list': 'slice_tup_list'}), '(x.oneflow, slice_tup_list=slice_tup_list)\n', (1447, 1489), True, 'import oneflow as flow\n'), ((1852, 1904), 'oneflow.slice', 'flow.slice', (['x.oneflow'], {'slice_tup_list': 'slice_tup_list'}), '(x.oneflow, slice_t... |
"""
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.eager_execution_enabled",
"oneflow.clear_default_session",
"oneflow.unittest.skip_unless_1n1d",
"oneflow.optimizer.PiecewiseConstantScheduler",
"oneflow.nn.softmax",
"oneflow.FunctionConfig",
"oneflow.random_uniform_initializer",
"oneflow.global_function",
"oneflow.identity",
"oneflow.sco... | [((811, 862), 'tensorflow.config.experimental.list_physical_devices', 'tf.config.experimental.list_physical_devices', (['"""GPU"""'], {}), "('GPU')\n", (855, 862), True, 'import tensorflow as tf\n'), ((3162, 3194), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (3192, 3194), 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.global_function",
"oneflow.typing.Numpy.Placeholder",
"oneflow.FunctionConfig",
"oneflow.math.squared_difference"
] | [((801, 822), 'oneflow.FunctionConfig', 'flow.FunctionConfig', ([], {}), '()\n', (820, 822), True, 'import oneflow as flow\n'), ((899, 948), 'oneflow.global_function', 'flow.global_function', ([], {'function_config': 'func_config'}), '(function_config=func_config)\n', (919, 948), True, 'import oneflow as flow\n'), ((13... |
import numpy as np
import cv2
import oneflow as flow
import oneflow.typing as tp
def gram_matrix(y):
(b, ch, h, w) = y.shape
features = y.reshape((b, ch, w * h))
features_t = features.transpose(1, 2)
gram = flow.matmul(features, features_t) / (ch * h * w)
return gram
def normalize_batch(batch):... | [
"oneflow.Tensor",
"oneflow.matmul"
] | [((650, 672), 'cv2.imread', 'cv2.imread', (['image_path'], {}), '(image_path)\n', (660, 672), False, 'import cv2\n'), ((682, 717), 'cv2.cvtColor', 'cv2.cvtColor', (['im', 'cv2.COLOR_BGR2RGB'], {}), '(im, cv2.COLOR_BGR2RGB)\n', (694, 717), False, 'import cv2\n'), ((727, 753), 'cv2.resize', 'cv2.resize', (['im', '(256, 2... |
import argparse
import cv2
import numpy as np
import oneflow as flow
from flowvision.models import ModelCreator
def load_image(image_path):
im = cv2.imread(image_path)
im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
im = np.transpose(im, (2, 0, 1))
im = np.expand_dims(im, axis=0)
return np.ascontiguousa... | [
"oneflow.Tensor",
"oneflow.no_grad"
] | [((152, 174), 'cv2.imread', 'cv2.imread', (['image_path'], {}), '(image_path)\n', (162, 174), False, 'import cv2\n'), ((184, 219), 'cv2.cvtColor', 'cv2.cvtColor', (['im', 'cv2.COLOR_BGR2RGB'], {}), '(im, cv2.COLOR_BGR2RGB)\n', (196, 219), False, 'import cv2\n'), ((229, 256), 'numpy.transpose', 'np.transpose', (['im', '... |
"""
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._C.nll_loss",
"oneflow._C.cross_entropy",
"oneflow._C.mse_loss",
"oneflow._C.margin_ranking_loss",
"oneflow._C.combined_margin_loss",
"oneflow._C.kl_div_loss",
"oneflow._C.smooth_l1_loss",
"oneflow._C.triplet_margin_loss",
"oneflow._C.binary_cross_entropy_loss",
"oneflow._C.ctc_loss",
"... | [((40404, 40440), 'doctest.testmod', 'doctest.testmod', ([], {'raise_on_error': '(True)'}), '(raise_on_error=True)\n', (40419, 40440), False, 'import doctest\n'), ((2902, 2948), 'oneflow._C.l1_loss', 'flow._C.l1_loss', (['input', 'target', 'self.reduction'], {}), '(input, target, self.reduction)\n', (2917, 2948), True,... |
"""
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.typing.Numpy.Placeholder",
"oneflow.FunctionConfig",
"oneflow.watch",
"oneflow.typing.ListListNumpy.Placeholder",
"oneflow.config.gpu_device_num",
"oneflow.typing.ListNumpy.Placeholder",
"oneflow.scope.mirrored_view"
] | [((742, 771), 'oneflow.config.gpu_device_num', 'flow.config.gpu_device_num', (['(1)'], {}), '(1)\n', (768, 771), True, 'import oneflow as flow\n'), ((778, 800), 'oneflow.global_function', 'flow.global_function', ([], {}), '()\n', (798, 800), True, 'import oneflow as flow\n'), ((880, 912), 'numpy.ones', 'np.ones', (['(1... |
"""
Modified from https://github.com/pytorch/vision/blob/main/torchvision/models/detection/transform.py
"""
import math
import oneflow as flow
import random
from oneflow import nn, Tensor
from typing import List, Tuple, Dict, Optional
from .image_list import ImageList
from .roi_heads import paste_masks_in_image
def... | [
"oneflow.as_tensor",
"oneflow.concat",
"oneflow.minimum",
"oneflow.tensor",
"oneflow.max",
"oneflow.nn.functional.interpolate",
"oneflow.full",
"oneflow.min"
] | [((579, 608), 'oneflow.tensor', 'flow.tensor', (['image.shape[-2:]'], {}), '(image.shape[-2:])\n', (590, 608), True, 'import oneflow as flow\n'), ((2801, 2845), 'oneflow.concat', 'flow.concat', (['(xmin, ymin, xmax, ymax)'], {'dim': '(1)'}), '((xmin, ymin, xmax, ymax), dim=1)\n', (2812, 2845), True, 'import oneflow as ... |
"""
Modified from https://github.com/rwightman/pytorch-image-models/blob/master/timm/models/layers/cbam.py
"""
import oneflow as flow
import oneflow.nn as nn
import oneflow.nn.functional as F
from flowvision.layers.blocks import ConvBnAct
from flowvision.layers.helpers import make_divisible
class ChannelAttn(nn.Mod... | [
"oneflow.nn.Conv2d",
"oneflow.max"
] | [((848, 898), 'oneflow.nn.Conv2d', 'nn.Conv2d', (['channels', 'rd_channels', '(1)'], {'bias': 'mlp_bias'}), '(channels, rd_channels, 1, bias=mlp_bias)\n', (857, 898), True, 'import oneflow.nn as nn\n'), ((961, 1011), 'oneflow.nn.Conv2d', 'nn.Conv2d', (['rd_channels', 'channels', '(1)'], {'bias': 'mlp_bias'}), '(rd_chan... |
"""
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, 1960), 'oneflow.framework.docstr.utils.add_docstr', 'add_docstr', (['oneflow._C.cosine_similarity', '"""\n cosine_similarity(x1, x2, dim=1, eps=1e-8) -> Tensor\n\n The documentation is referenced from: https://pytorch.org/docs/stable/generated/torch.nn.functional.cosine_similarity.html#torch.nn.functional... |
"""
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, 1493), 'oneflow.framework.docstr.utils.add_docstr', 'add_docstr', (['oneflow.F.adaptive_avg_pool1d', '"""\n adaptive_avg_pool1d(input, output_size) -> Tensor\n\n Applies a 1D adaptive average pooling over an input signal composed of\n several input planes.\n\n See :class:`~oneflow.nn.AdaptiveAvgPool... |
"""
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.utils.vision.transforms.Resize",
"oneflow.nn.Linear",
"oneflow.utils.vision.transforms.ToTensor",
"oneflow.no_grad",
"oneflow.nn.ReLU",
"oneflow.utils.vision.datasets.FashionMNIST",
"oneflow.utils.vision.transforms.Compose",
"oneflow.nn.CrossEntropyLoss",
"oneflow.nn.Conv2d",
"oneflow.uni... | [((4915, 4947), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (4945, 4947), True, 'import oneflow as flow\n'), ((1861, 1885), 'os.path.expanduser', 'os.path.expanduser', (['root'], {}), '(root)\n', (1879, 1885), False, 'import os\n'), ((2020, 2045), 'oneflow.utils.vision.trans... |
import oneflow as flow
import oneflow.typing as tp
from typing import Tuple
import numpy as np
import time
import os
from yolov3_tiny import Yolov3_tiny
from dataset import Dataset
from config import cfg
np.set_printoptions(threshold=np.inf)
train_label_sbbox_input_size = int(cfg.TRAIN.INPUT_SIZE[0]/cfg.YOLO.STRIDES[... | [
"oneflow.global_function",
"oneflow.optimizer.warmup.linear",
"oneflow.optimizer.CosineScheduler",
"oneflow.typing.Numpy.Placeholder",
"oneflow.FunctionConfig",
"oneflow.optimizer.Adam",
"oneflow.train.CheckPoint"
] | [((205, 242), 'numpy.set_printoptions', 'np.set_printoptions', ([], {'threshold': 'np.inf'}), '(threshold=np.inf)\n', (224, 242), True, 'import numpy as np\n'), ((487, 503), 'dataset.Dataset', 'Dataset', (['"""train"""'], {}), "('train')\n", (494, 503), False, 'from dataset import Dataset\n'), ((571, 673), 'oneflow.typ... |
from utils.dataset import *
from utils.utils_oneflow import *
from models.GRU_oneflow import *
import oneflow.experimental.F as F
class EncoderRNN_oneflow(nn.Module):
def __init__(self, input_size, hidden_size):
super().__init__()
self.hidden_size = hidden_size
self.embedding = nn.Embeddi... | [
"oneflow.experimental.F.relu"
] | [((2016, 2030), 'oneflow.experimental.F.relu', 'F.relu', (['output'], {}), '(output)\n', (2022, 2030), True, 'import oneflow.experimental.F as F\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.typing.Numpy.Placeholder",
"oneflow.clear_default_session",
"oneflow.unittest.skip_unless_1n1d",
"oneflow.optimizer.PiecewiseConstantScheduler",
"oneflow.FunctionConfig",
"oneflow.zeros_initializer",
"oneflow.global_function",
"oneflow.scope.placement",
"oneflow.train.CheckPoint"
] | [((895, 946), 'tensorflow.config.experimental.list_physical_devices', 'tf.config.experimental.list_physical_devices', (['"""GPU"""'], {}), "('GPU')\n", (939, 946), True, 'import tensorflow as tf\n'), ((5568, 5600), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (5598, 5600), 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.nn.modules.min_max_observer",
"oneflow.device",
"oneflow.nn.MinMaxObserver"
] | [((1226, 1240), 'numpy.max', 'np.max', (['weight'], {}), '(weight)\n', (1232, 1240), True, 'import numpy as np\n'), ((1258, 1272), 'numpy.min', 'np.min', (['weight'], {}), '(weight)\n', (1264, 1272), True, 'import numpy as np\n'), ((2157, 2179), 'numpy.zeros', 'np.zeros', (['(outer_num,)'], {}), '((outer_num,))\n', (21... |
"""
Modified from https://github.com/pytorch/vision/blob/main/torchvision/utils.py
"""
from typing import Union, Optional, List, Tuple, Text, BinaryIO
import pathlib
import oneflow as flow
import math
irange = range
def make_grid(
tensor: Union[flow.Tensor, List[flow.Tensor]],
nrow: int = 8,
padding: in... | [
"oneflow.cat",
"oneflow.stack",
"oneflow.zeros"
] | [((5584, 5606), 'PIL.Image.fromarray', 'Image.fromarray', (['ndarr'], {}), '(ndarr)\n', (5599, 5606), False, 'from PIL import Image\n'), ((2030, 2055), 'oneflow.stack', 'flow.stack', (['tensor'], {'dim': '(0)'}), '(tensor, dim=0)\n', (2040, 2055), True, 'import oneflow as flow\n'), ((2448, 2485), 'oneflow.cat', 'flow.c... |
"""
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.typing.Numpy.Placeholder",
"oneflow.clear_default_session",
"oneflow.config.cpu_device_num",
"oneflow.unittest.skip_unless_1n1d",
"oneflow.nn.hardswish",
"oneflow.unittest.skip_unless_1n2d",
"oneflow.config.gpu_device_num",
"oneflow.watch_diff",
"oneflow.optimizer.PiecewiseConstantScheduler... | [((6703, 6735), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (6733, 6735), True, 'import oneflow as flow\n'), ((7508, 7540), 'oneflow.unittest.skip_unless_1n2d', 'flow.unittest.skip_unless_1n2d', ([], {}), '()\n', (7538, 7540), True, 'import oneflow as flow\n'), ((913, 935), ... |
"""
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.user_op_builder",
"oneflow.compatible.single_client.scope.namespace",
"oneflow.compatible.single_client.python.oneflow_export.oneflow_export",
"oneflow.compatible.single_client.current_global_function_desc",
"oneflow.compatible.single_client.python.framework.id_util.UniqueS... | [((1020, 1067), 'oneflow.compatible.single_client.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""quantization.min_max_observer"""'], {}), "('quantization.min_max_observer')\n", (1034, 1067), False, 'from oneflow.compatible.single_client.python.oneflow_export import oneflow_export\n'), ((4683, 4745), 'on... |
"""
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.oneflow_export.oneflow_export",
"oneflow.python.framework.id_util.UniqueStr"
] | [((857, 879), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""sort"""'], {}), "('sort')\n", (871, 879), False, 'from oneflow.python.oneflow_export import oneflow_export\n'), ((1368, 1393), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""argsort"""'], {}), "('argsort')\n",... |
import oneflow as flow
from oneflow_gpt.config import get_args
_DIST_UTIL = None
def _merge_devices(devices):
node_devices = dict()
for node_id, device_id in devices:
if node_id not in node_devices:
node_devices[node_id] = []
node_devices[node_id].append(device_id)
return n... | [
"oneflow.sbp.split"
] | [((404, 414), 'oneflow_gpt.config.get_args', 'get_args', ([], {}), '()\n', (412, 414), False, 'from oneflow_gpt.config import get_args\n'), ((4916, 4933), 'oneflow.sbp.split', 'flow.sbp.split', (['(0)'], {}), '(0)\n', (4930, 4933), 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.roi_align",
"oneflow.tensor",
"oneflow.env.all_device_placement"
] | [((1406, 1424), 'numpy.array', 'np.array', (['concated'], {}), '(concated)\n', (1414, 1424), True, 'import numpy as np\n'), ((2354, 2377), 'torch.tensor', 'pytorch.tensor', (['np_rois'], {}), '(np_rois)\n', (2368, 2377), True, 'import torch as pytorch\n'), ((2392, 2448), 'oneflow.roi_align', 'flow.roi_align', (['x.onef... |
"""
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.scope.consistent_view",
"oneflow.typing.Numpy.Placeholder",
"oneflow.is_valid_device_tag",
"oneflow.clear_default_session",
"oneflow.unittest.skip_unless_1n1d",
"oneflow.config.cpu_device_num",
"oneflow.unittest.skip_unless_1n2d",
"oneflow.config.gpu_device_num",
"oneflow.watch_diff",
"on... | [((10850, 10882), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (10880, 10882), True, 'import oneflow as flow\n'), ((11042, 11074), 'oneflow.unittest.skip_unless_1n2d', 'flow.unittest.skip_unless_1n2d', ([], {}), '()\n', (11072, 11074), True, 'import oneflow as flow\n'), ((113... |
# 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.tensor"
] | [((2035, 2071), 'libai.data.structures.DistTensorData', 'DistTensorData', (['img'], {'placement_idx': '(0)'}), '(img, placement_idx=0)\n', (2049, 2071), False, 'from libai.data.structures import DistTensorData, Instance\n'), ((3560, 3596), 'libai.data.structures.DistTensorData', 'DistTensorData', (['img'], {'placement_... |
"""
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.batch_gather",
"oneflow.test_utils.automated_test_util.util.broadcast",
"oneflow.tensor"
] | [((1348, 1402), 'numpy.random.choice', 'np.random.choice', (['dims[indices_ndim - 1]', 'indices_dims'], {}), '(dims[indices_ndim - 1], indices_dims)\n', (1364, 1402), True, 'import numpy as np\n'), ((1417, 1435), 'oneflow.test_utils.automated_test_util.util.broadcast', 'broadcast', (['indices'], {}), '(indices)\n', (14... |
import oneflow as flow
def load_checkpoint(
model, path_to_checkpoint,
):
"""
Load the checkpoint from the given file. If inflation is True, inflate the
2D Conv weights from the checkpoint to 3D Conv.
Args:
path_to_checkpoint (string): path to the checkpoint to load.
model (model):... | [
"oneflow.load"
] | [((393, 422), 'oneflow.load', 'flow.load', (['path_to_checkpoint'], {}), '(path_to_checkpoint)\n', (402, 422), True, 'import oneflow as flow\n')] |
import oneflow as flow
import os
class OFRecordDataLoader(object):
def __init__(
self,
ofrecord_root: str = "./ofrecord",
mode: str = "train", # "val"
dataset_size: int = 9469,
batch_size: int = 1,
):
channel_last = False
output_layout = "NHWC" if chan... | [
"oneflow.nn.OFRecordImageDecoder",
"oneflow.nn.OfrecordRawDecoder",
"oneflow.nn.OFRecordImageDecoderRandomCrop",
"oneflow.nn.CropMirrorNormalize",
"oneflow.nn.image.Resize",
"oneflow.nn.CoinFlip"
] | [((727, 796), 'oneflow.nn.OfrecordRawDecoder', 'flow.nn.OfrecordRawDecoder', (['"""class/label"""'], {'shape': '()', 'dtype': 'flow.int32'}), "('class/label', shape=(), dtype=flow.int32)\n", (753, 796), True, 'import oneflow as flow\n'), ((412, 445), 'os.path.join', 'os.path.join', (['ofrecord_root', 'mode'], {}), '(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.global_function",
"oneflow.math.add_n",
"oneflow.experimental.set_interface_blob_value",
"oneflow.scope.placement",
"oneflow.config.gpu_device_num",
"oneflow.random_uniform_initializer",
"oneflow.experimental.get_interface_blob_value",
"oneflow.train.CheckPoint"
] | [((791, 820), 'oneflow.config.gpu_device_num', 'flow.config.gpu_device_num', (['(2)'], {}), '(2)\n', (817, 820), True, 'import oneflow as flow\n'), ((827, 849), 'oneflow.global_function', 'flow.global_function', ([], {}), '()\n', (847, 849), True, 'import oneflow as flow\n'), ((1262, 1285), 'oneflow.train.CheckPoint', ... |
"""
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.id_util.UniqueStr"
] | [((3972, 4007), 'oneflow.python.framework.id_util.UniqueStr', 'id_util.UniqueStr', (['"""const_fold_opt"""'], {}), "('const_fold_opt')\n", (3989, 4007), False, 'from oneflow.python.framework import 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.nn.conv2d",
"oneflow.scope.namespace",
"oneflow.matmul",
"oneflow.math.sigmoid",
"oneflow.truncated_normal",
"oneflow.concat",
"oneflow.constant_initializer",
"oneflow.get_variable",
"oneflow.reshape",
"oneflow.random_uniform_initializer",
"oneflow.nn.avg_pool2d",
"oneflow.nn.bias_add... | [((990, 1023), 'oneflow.random_uniform_initializer', 'flow.random_uniform_initializer', ([], {}), '()\n', (1021, 1023), True, 'import oneflow as flow\n'), ((1046, 1073), 'oneflow.constant_initializer', 'flow.constant_initializer', ([], {}), '()\n', (1071, 1073), True, 'import oneflow as flow\n'), ((1287, 1397), 'oneflo... |
"""
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.variance_scaling_initializer",
"oneflow.nn.InstanceNorm2d",
"oneflow.nn.conv2d",
"oneflow.scope.namespace",
"oneflow.nn.relu",
"oneflow.ones_initializer",
"oneflow.zeros_initializer",
"oneflow.get_variable",
"oneflow.nn.moments",
"oneflow.math.square",
"oneflow.nn.bias_add",
"oneflow.... | [((701, 748), 'oneflow.nn.InstanceNorm2d', 'flow.nn.InstanceNorm2d', (['input'], {'name': 'name_prefix'}), '(input, name=name_prefix)\n', (723, 748), True, 'import oneflow as flow\n'), ((849, 894), 'oneflow.nn.moments', 'flow.nn.moments', (['input', '[1, 2]'], {'keepdims': '(True)'}), '(input, [1, 2], keepdims=True)\n'... |
#!/usr/bin/python3
import argparse
import os
import time
from functools import partial
import numpy as np
import oneflow as flow
from oneflow import nn
from modeling import BertForPreTraining
from utils.ofrecord_data_utils import OfRecordDataLoader
def save_model(module: nn.Module, checkpoint_path: str, epoch: int,... | [
"oneflow.optim.lr_scheduler.CosineDecayLR",
"oneflow.no_grad",
"oneflow.nn.CrossEntropyLoss",
"oneflow.nn.GELU",
"oneflow.reshape",
"oneflow.sum",
"oneflow.device"
] | [((2661, 2686), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {}), '()\n', (2684, 2686), False, 'import argparse\n'), ((5546, 5776), 'utils.ofrecord_data_utils.OfRecordDataLoader', 'OfRecordDataLoader', ([], {'ofrecord_dir': 'args.ofrecord_path', 'mode': '"""train"""', 'dataset_size': '(1024)', 'batch_size... |
import math
import numpy as np
import oneflow as flow
import oneflow.nn as nn
def gelu(x):
"""
Implementation of the GELU activation function currently in Google BERT repo (identical to OpenAI GPT). Also see
the Gaussian Error Linear Units paper: https://arxiv.org/abs/1606.08415
"""
return 0.5 * x... | [
"oneflow.Tensor",
"oneflow.arange",
"oneflow.nn.init.normal_",
"oneflow.cat",
"oneflow.pow",
"oneflow.matmul",
"oneflow.sqrt",
"oneflow.zeros",
"oneflow.nn.CrossEntropyLoss",
"oneflow.ones",
"oneflow.nn.Dropout",
"oneflow.chunk",
"oneflow.nn.Embedding",
"oneflow.tensor",
"oneflow.nn.Soft... | [((1444, 1490), 'oneflow.nn.init.normal_', 'nn.init.normal_', (['self.weight'], {'mean': '(0)', 'std': '(0.02)'}), '(self.weight, mean=0, std=0.02)\n', (1459, 1490), True, 'import oneflow.nn as nn\n'), ((2667, 2696), 'oneflow.nn.Dropout', 'nn.Dropout', (['config.attn_pdrop'], {}), '(config.attn_pdrop)\n', (2677, 2696),... |
"""
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._C.gather_nd",
"oneflow._C.mul",
"oneflow.framework.tensor.register_tensor_op",
"oneflow.argwhere"
] | [((2766, 2801), 'oneflow.framework.tensor.register_tensor_op', 'register_tensor_op', (['"""masked_select"""'], {}), "('masked_select')\n", (2784, 2801), False, 'from oneflow.framework.tensor import register_tensor_op\n'), ((2624, 2648), 'oneflow._C.mul', 'flow._C.mul', (['input', 'mask'], {}), '(input, mask)\n', (2635,... |
"""
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.unittest.skip_unless_1n2d",
"oneflow.env.get_rank",
"oneflow.device",
"oneflow.placement"
] | [((775, 807), 'oneflow.unittest.skip_unless_1n2d', 'flow.unittest.skip_unless_1n2d', ([], {}), '()\n', (805, 807), True, 'import oneflow as flow\n'), ((825, 859), 'os.getenv', 'os.getenv', (['"""ONEFLOW_TEST_CPU_ONLY"""'], {}), "('ONEFLOW_TEST_CPU_ONLY')\n", (834, 859), False, 'import os\n'), ((2322, 2337), 'unittest.m... |
"""
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.typing.Numpy.Placeholder",
"oneflow.FunctionConfig",
"oneflow.typing.ListListNumpy.Placeholder",
"oneflow.config.gpu_device_num",
"oneflow.typing.ListNumpy.Placeholder",
"oneflow.scope.mirrored_view"
] | [((729, 751), 'oneflow.global_function', 'flow.global_function', ([], {}), '()\n', (749, 751), True, 'import oneflow as flow\n'), ((828, 861), 'numpy.ones', 'np.ones', (['(2, 5)'], {'dtype': 'np.float32'}), '((2, 5), dtype=np.float32)\n', (835, 861), True, 'import numpy as np\n'), ((1107, 1129), 'oneflow.global_functio... |
"""
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.losses.add_loss",
"oneflow.python.framework.c_api_util.CurJobBuildAndInferCtx_SetTrainConf",
"oneflow.core.operator.op_conf_pb2.WarmupConf",
"oneflow.core.operator.op_conf_pb2.LearningRateDecayConf",
"oneflow.core.operator.op_conf_pb2.ClipConf",
"oneflow.core.job.job_conf_pb2.TrainConf",
"onefl... | [((1303, 1359), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""optimizer.grad_clipping.by_global_norm"""'], {}), "('optimizer.grad_clipping.by_global_norm')\n", (1317, 1359), False, 'from oneflow.python.oneflow_export import oneflow_export\n'), ((1769, 1812), 'oneflow.python.oneflow_export.onef... |
"""
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"
] | [((1716, 1748), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (1746, 1748), True, 'import oneflow as flow\n'), ((1138, 1173), 'oneflow.tensor', 'flow.tensor', (['data'], {'dtype': 'flow.int64'}), '(data, dtype=flow.int64)\n', (1149, 1173), 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.framework.docstr.utils.add_docstr"
] | [((660, 1481), 'oneflow.framework.docstr.utils.add_docstr', 'add_docstr', (['oneflow._C.swapdims', '"""\n swapdims(input, dim0, dim1) -> Tensor\n\n This function is equivalent to torch’s swapdims function.\n\n For example:\n\n .. code-block:: python\n \n >>> import oneflow as flow\n\n >>> x... |
import oneflow as flow
import oneflow.typing as tp
@flow.global_function(type="train")
def train_job(
images: tp.Numpy.Placeholder((BATCH_SIZE, 1, 28, 28), dtype=flow.float),
labels: tp.Numpy.Placeholder((BATCH_SIZE,), dtype=flow.int32),
) -> tp.Numpy:
with flow.scope.placement("gpu", "0:0"):
logit... | [
"oneflow.global_function",
"oneflow.optimizer.PiecewiseConstantScheduler",
"oneflow.typing.Numpy.Placeholder",
"oneflow.optimizer.Adam",
"oneflow.scope.placement",
"oneflow.nn.sparse_softmax_cross_entropy_with_logits"
] | [((53, 87), 'oneflow.global_function', 'flow.global_function', ([], {'type': '"""train"""'}), "(type='train')\n", (73, 87), True, 'import oneflow as flow\n'), ((526, 580), 'oneflow.optimizer.PiecewiseConstantScheduler', 'flow.optimizer.PiecewiseConstantScheduler', (['[]', '[0.001]'], {}), '([], [0.001])\n', (567, 580),... |
"""
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.OFRecordImageDecoder",
"oneflow.nn.COCOReader",
"oneflow.nn.OFRecordBytesDecoder",
"oneflow.unittest.skip_unless_1n1d",
"oneflow.nn.OfrecordRawDecoder",
"oneflow.nn.CropMirrorNormalize",
"oneflow.nn.OfrecordReader",
"oneflow.nn.image.decode",
"oneflow.nn.image.Resize"
] | [((711, 743), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (741, 743), True, 'import oneflow as flow\n'), ((8335, 8367), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (8365, 8367), True, 'import oneflow as flow\n'), ((10366, 10398), ... |
"""
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.eager.op_executor.Interpret",
"oneflow.eager.gradient_util.GetDefaultBackwardBlobRegister",
"oneflow.core.operator.op_attribute_pb2.OpAttribute",
"oneflow.eager.op_executor.MirroredCast",
"oneflow.eager.gradient_util.ReleaseUnusedBlobObject",
"oneflow.eager.gradient_util.TrySetBackwardUsedBlobObj... | [((2308, 2354), 'oneflow.eager.gradient_util.GetDefaultBackwardBlobRegister', 'gradient_util.GetDefaultBackwardBlobRegister', ([], {}), '()\n', (2352, 2354), True, 'import oneflow.eager.gradient_util as gradient_util\n'), ((2359, 2452), 'oneflow.eager.gradient_util.TrySetBackwardUsedBlobObject', 'gradient_util.TrySetBa... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import oneflow.experimental as flow
def log_mean_exp(x, dim=None, keepdims=False):
"""
Oneflow numerically stable log mean of exps across the `dim`.
:param x: A Tensor.
:param dim: An int or list or tuple. The dimensions to reduce.
If `None` (the d... | [
"oneflow.experimental.mean",
"oneflow.experimental.max",
"oneflow.experimental.exp"
] | [((571, 605), 'oneflow.experimental.max', 'flow.max', (['x'], {'dim': 'dim', 'keepdim': '(True)'}), '(x, dim=dim, keepdim=True)\n', (579, 605), True, 'import oneflow.experimental as flow\n'), ((755, 778), 'oneflow.experimental.mean', 'flow.mean', (['ret'], {'dim': 'dim'}), '(ret, dim=dim)\n', (764, 778), True, 'import ... |
import numpy as np
import oneflow as flow
import oneflow.nn as nn
class GLU(nn.Module):
def __init__(self):
super(GLU, self).__init__()
def forward(self, x):
return x * flow.sigmoid(x)
class PixelShuffle(nn.Module):
"""Custom implementation pf Pixel Shuffle since PyTorch's PixelShuffle
... | [
"oneflow.nn.InstanceNorm2d",
"oneflow.nn.InstanceNorm1d",
"oneflow.nn.Conv1d",
"oneflow.sigmoid",
"oneflow.stack",
"oneflow.nn.PixelShuffle",
"oneflow.nn.Conv2d"
] | [((3504, 3624), 'oneflow.nn.Conv2d', 'nn.Conv2d', ([], {'in_channels': '(2)', 'out_channels': '(residual_in_channels // 2)', 'kernel_size': '(5, 15)', 'stride': '(1, 1)', 'padding': '(2, 7)'}), '(in_channels=2, out_channels=residual_in_channels // 2,\n kernel_size=(5, 15), stride=(1, 1), padding=(2, 7))\n', (3513, 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.unittest.skip_unless_1n1d",
"oneflow.Tensor"
] | [((968, 1000), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (998, 1000), True, 'import oneflow as flow\n'), ((1498, 1513), 'unittest.main', 'unittest.main', ([], {}), '()\n', (1511, 1513), False, 'import unittest\n'), ((1107, 1125), 'oneflow.Tensor', 'flow.Tensor', (['(8)', '... |
"""
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._oneflow_internal._C.dispatch_coin_flip",
"oneflow._oneflow_internal._C.dispatch_ofrecord_reader",
"oneflow._oneflow_internal._C.dispatch_crop_mirror_normalize_from_uint8",
"oneflow._oneflow_internal._C.dispatch_ofrecord_image_decoder",
"oneflow._oneflow_internal._C.dispatch_tensor_buffer_to_list_o... | [((40022, 40058), 'doctest.testmod', 'doctest.testmod', ([], {'raise_on_error': '(True)'}), '(raise_on_error=True)\n', (40037, 40058), False, 'import doctest\n'), ((5422, 5637), 'oneflow._oneflow_internal._C.dispatch_ofrecord_raw_decoder', '_C.dispatch_ofrecord_raw_decoder', (['self._op', 'input'], {'name': 'self.blob_... |
"""
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"
] | [((661, 3311), 'oneflow.framework.docstr.utils.add_docstr', 'add_docstr', (['oneflow.linalg.vector_norm', '"""linalg.vector_norm(input, ord=2, dim=None, keepdim=False, *, dtype=None, out=None) -> Tensor\n\n Computes a vector norm.\n\n Supports input of float, double dtypes.\n\n This function does not necessari... |
"""
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.tensor.register_tensor_op",
"oneflow.experimental.exp",
"oneflow.builtin_op",
"oneflow.experimental.sigmoid",
"oneflow.python.oneflow_export.oneflow_export",
"oneflow.experimental.log"
] | [((1286, 1311), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""nn.ReLU"""'], {}), "('nn.ReLU')\n", (1300, 1311), False, 'from oneflow.python.oneflow_export import oneflow_export, experimental_api\n'), ((2308, 2334), 'oneflow.python.oneflow_export.oneflow_export', 'oneflow_export', (['"""nn.ReLU... |
"""
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._C.sparse_softmax_cross_entropy",
"oneflow.env.get_world_size",
"oneflow.sbp.broadcast",
"oneflow.unittest.skip_unless_1n4d",
"oneflow.sbp.split",
"oneflow.optim.SGD",
"oneflow.unittest.skip_unless_1n2d",
"oneflow.nn.CrossEntropyLoss",
"oneflow.zeros",
"oneflow.randn",
"oneflow.unittest... | [((2066, 2092), 'oneflow.nn.CrossEntropyLoss', 'flow.nn.CrossEntropyLoss', ([], {}), '()\n', (2090, 2092), True, 'import oneflow as flow\n'), ((3335, 3367), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (3365, 3367), True, 'import oneflow as flow\n'), ((3570, 3602), 'oneflow.u... |
import math
# import torch
# import torch.nn as nn
# import torch.nn.functional as F
import oneflow as of
import oneflow.nn as nn
import oneflow.nn.functional as F
# from libs.components import attention
class TAP(nn.Module):
def __init__(self):
super(TAP, self).__init__()
def forward(self, feat... | [
"oneflow.Tensor",
"oneflow.cat",
"oneflow.std",
"oneflow.nn.init.kaiming_normal_",
"oneflow.nn.ReLU",
"oneflow.nn.AdaptiveAvgPool2d",
"oneflow.randn",
"oneflow.mean",
"oneflow.tanh"
] | [((18635, 18656), 'oneflow.randn', 'of.randn', (['(4)', '(512)', '(300)'], {}), '(4, 512, 300)\n', (18643, 18656), True, 'import oneflow as of\n'), ((470, 497), 'oneflow.mean', 'of.mean', (['feature_map'], {'dim': '(2)'}), '(feature_map, dim=2)\n', (477, 497), True, 'import oneflow as of\n'), ((769, 802), 'oneflow.nn.A... |
"""
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._oneflow_internal.test_api.divide",
"oneflow._oneflow_internal.test_api.get_singleton_a",
"oneflow.unittest.skip_unless_1n1d",
"oneflow._oneflow_internal.test_api.increase_x_of_a_if_not_none",
"oneflow._oneflow_internal.test_api.increase_if_not_none",
"oneflow._oneflow_internal.test_api.throw_if_... | [((656, 688), 'oneflow.unittest.skip_unless_1n1d', 'flow.unittest.skip_unless_1n1d', ([], {}), '()\n', (686, 688), True, 'import oneflow as flow\n'), ((2300, 2315), 'unittest.main', 'unittest.main', ([], {}), '()\n', (2313, 2315), False, 'import unittest\n'), ((1346, 1394), 'oneflow._oneflow_internal.test_api.throw_if_... |
import oneflow as flow
import oneflow.nn as nn
import oneflow.nn.functional as F
class ConformerConvolutionModule(nn.Module):
def __init__(self, channels, kernel_size, bias=True, dropout=0.0):
super(ConformerConvolutionModule, self).__init__()
assert kernel_size % 2 == 1
self.pointwise_c... | [
"oneflow.nn.Conv1d",
"oneflow.sigmoid",
"oneflow.nn.Dropout",
"oneflow.nn.BatchNorm1d",
"oneflow.nn.functional.glu",
"oneflow.masked_fill",
"oneflow.nn.Linear"
] | [((327, 371), 'oneflow.nn.Linear', 'nn.Linear', (['channels', '(2 * channels)'], {'bias': 'bias'}), '(channels, 2 * channels, bias=bias)\n', (336, 371), True, 'import oneflow.nn as nn\n'), ((403, 519), 'oneflow.nn.Conv1d', 'nn.Conv1d', (['channels', 'channels', 'kernel_size'], {'stride': '(1)', 'padding': '((kernel_siz... |
"""
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.argmax",
"oneflow.experimental.unittest.env.eager_execution_enabled"
] | [((2712, 2727), 'unittest.main', 'unittest.main', ([], {}), '()\n', (2725, 2727), False, 'import unittest\n'), ((997, 1025), 'oneflow.experimental.argmax', 'flow.argmax', (['input'], {'dim': 'axis'}), '(input, dim=axis)\n', (1008, 1025), True, 'import oneflow.experimental as flow\n'), ((1727, 1755), 'oneflow.experiment... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.