The following issues were found
caffe2/python/ideep/sigmoid_op_test.py
10 issues
Line: 7
Column: 1
import unittest
import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
Reported by Pylint.
Line: 8
Column: 1
import unittest
import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np
from caffe2.python import core, workspace
import caffe2.python.hypothesis_test_util as hu
Reported by Pylint.
Line: 14
Column: 22
import caffe2.python.hypothesis_test_util as hu
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
class SigmoidTest(hu.HypothesisTestCase):
@given(X=hu.tensor(dtype=np.float32),
inplace=st.booleans(),
**hu.gcs)
@settings(deadline=1000)
Reported by Pylint.
Line: 1
Column: 1
import unittest
import hypothesis.strategies as st
from hypothesis import given, settings
import numpy as np
Reported by Pylint.
Line: 15
Column: 1
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
class SigmoidTest(hu.HypothesisTestCase):
@given(X=hu.tensor(dtype=np.float32),
inplace=st.booleans(),
**hu.gcs)
@settings(deadline=1000)
def test_sigmoid(self, X, inplace, gc, dc):
Reported by Pylint.
Line: 20
Column: 5
inplace=st.booleans(),
**hu.gcs)
@settings(deadline=1000)
def test_sigmoid(self, X, inplace, gc, dc):
op = core.CreateOperator(
"Sigmoid",
["X"],
["Y"] if not inplace else ["X"],
)
Reported by Pylint.
Line: 20
Column: 5
inplace=st.booleans(),
**hu.gcs)
@settings(deadline=1000)
def test_sigmoid(self, X, inplace, gc, dc):
op = core.CreateOperator(
"Sigmoid",
["X"],
["Y"] if not inplace else ["X"],
)
Reported by Pylint.
Line: 20
Column: 5
inplace=st.booleans(),
**hu.gcs)
@settings(deadline=1000)
def test_sigmoid(self, X, inplace, gc, dc):
op = core.CreateOperator(
"Sigmoid",
["X"],
["Y"] if not inplace else ["X"],
)
Reported by Pylint.
Line: 20
Column: 5
inplace=st.booleans(),
**hu.gcs)
@settings(deadline=1000)
def test_sigmoid(self, X, inplace, gc, dc):
op = core.CreateOperator(
"Sigmoid",
["X"],
["Y"] if not inplace else ["X"],
)
Reported by Pylint.
Line: 21
Column: 9
**hu.gcs)
@settings(deadline=1000)
def test_sigmoid(self, X, inplace, gc, dc):
op = core.CreateOperator(
"Sigmoid",
["X"],
["Y"] if not inplace else ["X"],
)
Reported by Pylint.
caffe2/contrib/playground/resnetdemo/gfs_IN1k.py
10 issues
Line: 8
Column: 40
# # example1 using gfs as input source.
def gen_input_builder_fun(self, model, dataset, is_train):
if is_train:
input_path = self.opts['input']['train_input_path']
else:
input_path = self.opts['input']['test_input_path']
Reported by Pylint.
Line: 25
Column: 15
Image input operator that loads data from reader and
applies certain transformations to the images.
'''
data, label = model.ImageInput(
reader,
["data", "label"],
batch_size=batch_size,
use_caffe_datum=True,
mean=128.,
Reported by Pylint.
Line: 49
Column: 23
return add_image_input
def get_input_dataset(opts):
return []
def get_model_input_fun(self):
pass
Reported by Pylint.
Line: 53
Column: 25
return []
def get_model_input_fun(self):
pass
Reported by Pylint.
Line: 1
Column: 1
# # example1 using gfs as input source.
def gen_input_builder_fun(self, model, dataset, is_train):
if is_train:
Reported by Pylint.
Line: 1
Column: 1
# # example1 using gfs as input source.
def gen_input_builder_fun(self, model, dataset, is_train):
if is_train:
Reported by Pylint.
Line: 8
Column: 1
# # example1 using gfs as input source.
def gen_input_builder_fun(self, model, dataset, is_train):
if is_train:
input_path = self.opts['input']['train_input_path']
else:
input_path = self.opts['input']['test_input_path']
Reported by Pylint.
Line: 20
Column: 5
shard_id=self.shard_id,
num_shards=self.opts['distributed']['num_shards'],)
def AddImageInput(model, reader, batch_size, img_size):
'''
Image input operator that loads data from reader and
applies certain transformations to the images.
'''
data, label = model.ImageInput(
Reported by Pylint.
Line: 49
Column: 1
return add_image_input
def get_input_dataset(opts):
return []
def get_model_input_fun(self):
pass
Reported by Pylint.
Line: 53
Column: 1
return []
def get_model_input_fun(self):
pass
Reported by Pylint.
caffe2/python/ideep/blobs_queue_db_test.py
10 issues
Line: 9
Column: 1
import unittest
import numpy as np
import caffe2.proto.caffe2_pb2 as caffe2_pb2
from caffe2.python import core, workspace, timeout_guard
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
class BlobsQueueDBTest(unittest.TestCase):
Reported by Pylint.
Line: 13
Column: 22
from caffe2.python import core, workspace, timeout_guard
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
class BlobsQueueDBTest(unittest.TestCase):
def test_create_blobs_queue_db_string(self):
device_opt = core.DeviceOption(caffe2_pb2.IDEEP, 0)
with core.DeviceScope(device_opt):
def add_blobs(queue, num_samples):
Reported by Pylint.
Line: 108
Column: 5
return item.SerializeToString()
if __name__ == "__main__":
import unittest
unittest.main()
Reported by Pylint.
Line: 1
Column: 1
import unittest
import numpy as np
import caffe2.proto.caffe2_pb2 as caffe2_pb2
Reported by Pylint.
Line: 14
Column: 1
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
class BlobsQueueDBTest(unittest.TestCase):
def test_create_blobs_queue_db_string(self):
device_opt = core.DeviceOption(caffe2_pb2.IDEEP, 0)
with core.DeviceScope(device_opt):
def add_blobs(queue, num_samples):
blob = core.BlobReference("blob")
Reported by Pylint.
Line: 15
Column: 5
@unittest.skipIf(not workspace.C.use_mkldnn, "No MKLDNN support.")
class BlobsQueueDBTest(unittest.TestCase):
def test_create_blobs_queue_db_string(self):
device_opt = core.DeviceOption(caffe2_pb2.IDEEP, 0)
with core.DeviceScope(device_opt):
def add_blobs(queue, num_samples):
blob = core.BlobReference("blob")
status = core.BlobReference("blob_status")
Reported by Pylint.
Line: 27
Column: 5
)
self._test_create_blobs_queue_db(add_blobs)
def test_create_blobs_queue_db_tensor(self):
device_opt = core.DeviceOption(caffe2_pb2.IDEEP, 0)
with core.DeviceScope(device_opt):
def add_blobs(queue, num_samples):
blob = core.BlobReference("blob")
status = core.BlobReference("blob_status")
Reported by Pylint.
Line: 84
Column: 5
self.assertEqual(1, item)
workspace.RunNetOnce(close_net)
def _add_blob_to_queue(self, queue, data, blob, status):
device_opt = core.DeviceOption(caffe2_pb2.IDEEP, 0)
with core.DeviceScope(device_opt):
workspace.FeedBlob(blob, data, core.DeviceOption(caffe2_pb2.CPU, 0))
op = core.CreateOperator(
"SafeEnqueueBlobs",
Reported by Pylint.
Line: 88
Column: 13
device_opt = core.DeviceOption(caffe2_pb2.IDEEP, 0)
with core.DeviceScope(device_opt):
workspace.FeedBlob(blob, data, core.DeviceOption(caffe2_pb2.CPU, 0))
op = core.CreateOperator(
"SafeEnqueueBlobs",
[queue, blob],
[blob, status],
)
Reported by Pylint.
Line: 96
Column: 5
workspace.RunOperatorOnce(op)
def _create_test_tensor_protos(self, idx):
item = caffe2_pb2.TensorProtos()
data = item.protos.add()
data.data_type = core.DataType.STRING
data.string_data.append("foo{}".format(idx).encode('utf-8'))
label = item.protos.add()
Reported by Pylint.
caffe2/quantization/server/relu_dnnlowp_op_test.py
10 issues
Line: 6
Column: 1
import collections
import caffe2.python.hypothesis_test_util as hu
import hypothesis.strategies as st
import numpy as np
from caffe2.python import core, dyndep, workspace
from caffe2.quantization.server.dnnlowp_test_utils import check_quantized_results_close
from hypothesis import given
Reported by Pylint.
Line: 10
Column: 1
import numpy as np
from caffe2.python import core, dyndep, workspace
from caffe2.quantization.server.dnnlowp_test_utils import check_quantized_results_close
from hypothesis import given
dyndep.InitOpsLibrary("//caffe2/caffe2/quantization/server:dnnlowp_ops")
workspace.GlobalInit(["caffe2", "--caffe2_omp_num_threads=11"])
Reported by Pylint.
Line: 19
Column: 53
class DNNLowPReluOpTest(hu.HypothesisTestCase):
@given(size=st.integers(1024, 2048), is_empty=st.booleans(), **hu.gcs_cpu_only)
def test_dnnlowp_relu(self, size, is_empty, gc, dc):
if is_empty:
size = 0
min_ = -10.0
max_ = 10.0
scale = (max_ - min_) / 255
Reported by Pylint.
Line: 1
Column: 1
import collections
import caffe2.python.hypothesis_test_util as hu
import hypothesis.strategies as st
import numpy as np
from caffe2.python import core, dyndep, workspace
from caffe2.quantization.server.dnnlowp_test_utils import check_quantized_results_close
Reported by Pylint.
Line: 17
Column: 1
workspace.GlobalInit(["caffe2", "--caffe2_omp_num_threads=11"])
class DNNLowPReluOpTest(hu.HypothesisTestCase):
@given(size=st.integers(1024, 2048), is_empty=st.booleans(), **hu.gcs_cpu_only)
def test_dnnlowp_relu(self, size, is_empty, gc, dc):
if is_empty:
size = 0
min_ = -10.0
Reported by Pylint.
Line: 19
Column: 5
class DNNLowPReluOpTest(hu.HypothesisTestCase):
@given(size=st.integers(1024, 2048), is_empty=st.booleans(), **hu.gcs_cpu_only)
def test_dnnlowp_relu(self, size, is_empty, gc, dc):
if is_empty:
size = 0
min_ = -10.0
max_ = 10.0
scale = (max_ - min_) / 255
Reported by Pylint.
Line: 19
Column: 5
class DNNLowPReluOpTest(hu.HypothesisTestCase):
@given(size=st.integers(1024, 2048), is_empty=st.booleans(), **hu.gcs_cpu_only)
def test_dnnlowp_relu(self, size, is_empty, gc, dc):
if is_empty:
size = 0
min_ = -10.0
max_ = 10.0
scale = (max_ - min_) / 255
Reported by Pylint.
Line: 19
Column: 5
class DNNLowPReluOpTest(hu.HypothesisTestCase):
@given(size=st.integers(1024, 2048), is_empty=st.booleans(), **hu.gcs_cpu_only)
def test_dnnlowp_relu(self, size, is_empty, gc, dc):
if is_empty:
size = 0
min_ = -10.0
max_ = 10.0
scale = (max_ - min_) / 255
Reported by Pylint.
Line: 19
Column: 5
class DNNLowPReluOpTest(hu.HypothesisTestCase):
@given(size=st.integers(1024, 2048), is_empty=st.booleans(), **hu.gcs_cpu_only)
def test_dnnlowp_relu(self, size, is_empty, gc, dc):
if is_empty:
size = 0
min_ = -10.0
max_ = 10.0
scale = (max_ - min_) / 255
Reported by Pylint.
Line: 26
Column: 9
max_ = 10.0
scale = (max_ - min_) / 255
zero_point = int(np.round(-min_ / scale))
X = (np.random.rand(size) * (max_ - min_) + min_).astype(np.float32)
Output = collections.namedtuple("Output", ["Y", "op_type", "engine"])
outputs = []
op_engine_list = [("Relu", ""), ("Relu", "DNNLOWP"), ("Int8Relu", "DNNLOWP")]
Reported by Pylint.
caffe2/python/operator_test/lengths_pad_op_test.py
10 issues
Line: 9
Column: 1
from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st
import numpy as np
class TestLengthsPadOp(serial.SerializedTestCase):
Reported by Pylint.
Line: 26
Column: 73
padding_value=st.floats(-10.0, 10.0),
**hu.gcs
)
def test_lengths_pad(self, inputs, delta_length, padding_value, gc, dc):
data, lengths = inputs
max_length = np.max(lengths) if len(lengths) > 0 else 0
target_length = max(max_length + delta_length, 1)
def lengths_pad_op(data, lengths):
Reported by Pylint.
Line: 1
Column: 1
from caffe2.python import core
import caffe2.python.hypothesis_test_util as hu
import caffe2.python.serialized_test.serialized_test_util as serial
import hypothesis.strategies as st
Reported by Pylint.
Line: 13
Column: 1
import numpy as np
class TestLengthsPadOp(serial.SerializedTestCase):
@serial.given(
inputs=hu.lengths_tensor(
dtype=np.float32,
min_value=1,
Reported by Pylint.
Line: 25
Column: 5
delta_length=st.integers(0, 10),
padding_value=st.floats(-10.0, 10.0),
**hu.gcs
)
def test_lengths_pad(self, inputs, delta_length, padding_value, gc, dc):
data, lengths = inputs
max_length = np.max(lengths) if len(lengths) > 0 else 0
target_length = max(max_length + delta_length, 1)
Reported by Pylint.
Line: 25
Column: 5
delta_length=st.integers(0, 10),
padding_value=st.floats(-10.0, 10.0),
**hu.gcs
)
def test_lengths_pad(self, inputs, delta_length, padding_value, gc, dc):
data, lengths = inputs
max_length = np.max(lengths) if len(lengths) > 0 else 0
target_length = max(max_length + delta_length, 1)
Reported by Pylint.
Line: 25
Column: 5
delta_length=st.integers(0, 10),
padding_value=st.floats(-10.0, 10.0),
**hu.gcs
)
def test_lengths_pad(self, inputs, delta_length, padding_value, gc, dc):
data, lengths = inputs
max_length = np.max(lengths) if len(lengths) > 0 else 0
target_length = max(max_length + delta_length, 1)
Reported by Pylint.
Line: 25
Column: 5
delta_length=st.integers(0, 10),
padding_value=st.floats(-10.0, 10.0),
**hu.gcs
)
def test_lengths_pad(self, inputs, delta_length, padding_value, gc, dc):
data, lengths = inputs
max_length = np.max(lengths) if len(lengths) > 0 else 0
target_length = max(max_length + delta_length, 1)
Reported by Pylint.
Line: 32
Column: 13
target_length = max(max_length + delta_length, 1)
def lengths_pad_op(data, lengths):
N = len(lengths)
output = np.ndarray(
shape=(target_length * N, ) + data.shape[1:], dtype=np.float32)
output.fill(padding_value)
ptr1, ptr2 = 0, 0
for i in range(N):
Reported by Pylint.
Line: 44
Column: 9
return [output]
op = core.CreateOperator(
"LengthsPad",
["data", "lengths"],
["data_padded"],
target_length=target_length,
padding_value=padding_value,
Reported by Pylint.
test/bottleneck_test/test_cuda.py
10 issues
Line: 1
Column: 1
import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self):
super(Model, self).__init__()
self.linear = nn.Linear(20, 20)
Reported by Pylint.
Line: 2
Column: 1
import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self):
super(Model, self).__init__()
self.linear = nn.Linear(20, 20)
Reported by Pylint.
Line: 10
Column: 23
super(Model, self).__init__()
self.linear = nn.Linear(20, 20)
def forward(self, input):
out = self.linear(input[:, 10:30])
return out.sum()
def main():
Reported by Pylint.
Line: 19
Column: 9
data = torch.randn(10, 50).cuda()
model = Model().cuda()
optimizer = torch.optim.SGD(model.parameters(), lr=0.0001)
for i in range(10):
optimizer.zero_grad()
loss = model(data)
loss.backward()
optimizer.step()
Reported by Pylint.
Line: 1
Column: 1
import torch
import torch.nn as nn
class Model(nn.Module):
def __init__(self):
super(Model, self).__init__()
self.linear = nn.Linear(20, 20)
Reported by Pylint.
Line: 5
Column: 1
import torch.nn as nn
class Model(nn.Module):
def __init__(self):
super(Model, self).__init__()
self.linear = nn.Linear(20, 20)
def forward(self, input):
Reported by Pylint.
Line: 5
Column: 1
import torch.nn as nn
class Model(nn.Module):
def __init__(self):
super(Model, self).__init__()
self.linear = nn.Linear(20, 20)
def forward(self, input):
Reported by Pylint.
Line: 7
Column: 9
class Model(nn.Module):
def __init__(self):
super(Model, self).__init__()
self.linear = nn.Linear(20, 20)
def forward(self, input):
out = self.linear(input[:, 10:30])
return out.sum()
Reported by Pylint.
Line: 10
Column: 5
super(Model, self).__init__()
self.linear = nn.Linear(20, 20)
def forward(self, input):
out = self.linear(input[:, 10:30])
return out.sum()
def main():
Reported by Pylint.
Line: 15
Column: 1
return out.sum()
def main():
data = torch.randn(10, 50).cuda()
model = Model().cuda()
optimizer = torch.optim.SGD(model.parameters(), lr=0.0001)
for i in range(10):
optimizer.zero_grad()
Reported by Pylint.
test/distributed/launcher/launch_test.py
10 issues
Line: 14
Column: 1
import unittest
from contextlib import closing
import torch.distributed.launch as launch
from torch.distributed.elastic.utils import get_socket_with_port
from torch.testing._internal.common_utils import (
TEST_WITH_DEV_DBG_ASAN,
TEST_WITH_TSAN,
sandcastle_skip_if,
Reported by Pylint.
Line: 15
Column: 1
from contextlib import closing
import torch.distributed.launch as launch
from torch.distributed.elastic.utils import get_socket_with_port
from torch.testing._internal.common_utils import (
TEST_WITH_DEV_DBG_ASAN,
TEST_WITH_TSAN,
sandcastle_skip_if,
)
Reported by Pylint.
Line: 16
Column: 1
import torch.distributed.launch as launch
from torch.distributed.elastic.utils import get_socket_with_port
from torch.testing._internal.common_utils import (
TEST_WITH_DEV_DBG_ASAN,
TEST_WITH_TSAN,
sandcastle_skip_if,
)
Reported by Pylint.
Line: 44
Column: 9
def test_launch_without_env(self):
nnodes = 1
nproc_per_node = 4
world_size = nnodes * nproc_per_node
sock = get_socket_with_port()
with closing(sock):
master_port = sock.getsockname()[1]
args = [
f"--nnodes={nnodes}",
Reported by Pylint.
Line: 1
Column: 1
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import os
import shutil
Reported by Pylint.
Line: 23
Column: 1
)
def path(script):
return os.path.join(os.path.dirname(__file__), script)
class LaunchTest(unittest.TestCase):
def setUp(self):
Reported by Pylint.
Line: 27
Column: 1
return os.path.join(os.path.dirname(__file__), script)
class LaunchTest(unittest.TestCase):
def setUp(self):
self.test_dir = tempfile.mkdtemp()
# set a sentinel env var on the parent proc
# this should be present on the child and gets
# asserted in ``bin/test_script.py``
Reported by Pylint.
Line: 40
Column: 5
@sandcastle_skip_if(
TEST_WITH_DEV_DBG_ASAN or TEST_WITH_TSAN, "tests incompatible with tsan and dev/dbg asan"
)
def test_launch_without_env(self):
nnodes = 1
nproc_per_node = 4
world_size = nnodes * nproc_per_node
sock = get_socket_with_port()
Reported by Pylint.
Line: 40
Column: 5
@sandcastle_skip_if(
TEST_WITH_DEV_DBG_ASAN or TEST_WITH_TSAN, "tests incompatible with tsan and dev/dbg asan"
)
def test_launch_without_env(self):
nnodes = 1
nproc_per_node = 4
world_size = nnodes * nproc_per_node
sock = get_socket_with_port()
Reported by Pylint.
Line: 62
Column: 5
@sandcastle_skip_if(
TEST_WITH_DEV_DBG_ASAN or TEST_WITH_TSAN, "tests incompatible with tsan and dev/dbg asan"
)
def test_launch_with_env(self):
nnodes = 1
nproc_per_node = 4
world_size = nnodes * nproc_per_node
sock = get_socket_with_port()
Reported by Pylint.
caffe2/python/operator_test/weighted_sample_test.py
10 issues
Line: 8
Column: 1
import numpy as np
from hypothesis import given
import hypothesis.strategies as st
from caffe2.python import core
from caffe2.python import workspace
import caffe2.python.hypothesis_test_util as hu
Reported by Pylint.
Line: 9
Column: 1
import numpy as np
from hypothesis import given
import hypothesis.strategies as st
from caffe2.python import core
from caffe2.python import workspace
import caffe2.python.hypothesis_test_util as hu
Reported by Pylint.
Line: 22
Column: 56
weights_len=st.integers(min_value=0, max_value=128),
**hu.gcs
)
def test_weighted_sample(self, batch, weights_len, gc, dc):
weights = np.zeros((batch, weights_len))
values = np.zeros((batch, weights_len))
rand_indices = []
rand_values = []
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
from hypothesis import given
import hypothesis.strategies as st
Reported by Pylint.
Line: 16
Column: 1
import caffe2.python.hypothesis_test_util as hu
class TestWeightedSample(hu.HypothesisTestCase):
@given(
batch=st.integers(min_value=0, max_value=128),
weights_len=st.integers(min_value=0, max_value=128),
**hu.gcs
)
Reported by Pylint.
Line: 21
Column: 5
batch=st.integers(min_value=0, max_value=128),
weights_len=st.integers(min_value=0, max_value=128),
**hu.gcs
)
def test_weighted_sample(self, batch, weights_len, gc, dc):
weights = np.zeros((batch, weights_len))
values = np.zeros((batch, weights_len))
rand_indices = []
Reported by Pylint.
Line: 21
Column: 5
batch=st.integers(min_value=0, max_value=128),
weights_len=st.integers(min_value=0, max_value=128),
**hu.gcs
)
def test_weighted_sample(self, batch, weights_len, gc, dc):
weights = np.zeros((batch, weights_len))
values = np.zeros((batch, weights_len))
rand_indices = []
Reported by Pylint.
Line: 21
Column: 5
batch=st.integers(min_value=0, max_value=128),
weights_len=st.integers(min_value=0, max_value=128),
**hu.gcs
)
def test_weighted_sample(self, batch, weights_len, gc, dc):
weights = np.zeros((batch, weights_len))
values = np.zeros((batch, weights_len))
rand_indices = []
Reported by Pylint.
Line: 21
Column: 5
batch=st.integers(min_value=0, max_value=128),
weights_len=st.integers(min_value=0, max_value=128),
**hu.gcs
)
def test_weighted_sample(self, batch, weights_len, gc, dc):
weights = np.zeros((batch, weights_len))
values = np.zeros((batch, weights_len))
rand_indices = []
Reported by Pylint.
Line: 43
Column: 9
workspace.FeedBlob("values", values.astype(np.float32))
# output both indices and values
op = core.CreateOperator(
"WeightedSample", ["weights", "values"],
["sample_indices", "sample_values"]
)
workspace.RunOperatorOnce(op)
result_indices = workspace.FetchBlob("sample_indices")
Reported by Pylint.
test/jit/test_modules.py
10 issues
Line: 1
Column: 1
import torch
import os
import sys
from torch.testing._internal.jit_utils import JitTestCase
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
Reported by Pylint.
Line: 4
Column: 1
import torch
import os
import sys
from torch.testing._internal.jit_utils import JitTestCase
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
Reported by Pylint.
Line: 1
Column: 1
import torch
import os
import sys
from torch.testing._internal.jit_utils import JitTestCase
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
Reported by Pylint.
Line: 2
Column: 1
import torch
import os
import sys
from torch.testing._internal.jit_utils import JitTestCase
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
Reported by Pylint.
Line: 3
Column: 1
import torch
import os
import sys
from torch.testing._internal.jit_utils import JitTestCase
# Make the helper files in test/ importable
pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(pytorch_test_dir)
Reported by Pylint.
Line: 15
Column: 1
"\tpython test/test_jit.py TESTNAME\n\n"
"instead.")
class TestModules(JitTestCase):
def test_script_module_with_constants_list(self):
"""
Test that a module that has __constants__ set to something
that is not a set can be scripted.
"""
Reported by Pylint.
Line: 15
Column: 1
"\tpython test/test_jit.py TESTNAME\n\n"
"instead.")
class TestModules(JitTestCase):
def test_script_module_with_constants_list(self):
"""
Test that a module that has __constants__ set to something
that is not a set can be scripted.
"""
Reported by Pylint.
Line: 24
Column: 9
# torch.nn.Linear has a __constants__ attribute defined
# and intialized to a list.
class Net(torch.nn.Linear):
x: torch.jit.Final[int]
def __init__(self):
super().__init__(5, 10)
self.x = 0
Reported by Pylint.
Line: 24
Column: 9
# torch.nn.Linear has a __constants__ attribute defined
# and intialized to a list.
class Net(torch.nn.Linear):
x: torch.jit.Final[int]
def __init__(self):
super().__init__(5, 10)
self.x = 0
Reported by Pylint.
Line: 29
Column: 17
def __init__(self):
super().__init__(5, 10)
self.x = 0
self.checkModule(Net(), (torch.randn(5),))
Reported by Pylint.
test/cpp/c10d/TestUtils.hpp
10 issues
Line: 56
Column: 25
CWE codes:
807
20
Suggestion:
Check environment variables carefully before using them
}
std::string tmppath() {
const char* tmpfile = getenv("TMPFILE");
if (tmpfile) {
return std::string(tmpfile);
}
else {
return autoGenerateTmpFilePath();
Reported by FlawFinder.
Line: 68
Column: 25
CWE codes:
807
20
Suggestion:
Check environment variables carefully before using them
std::string tmppath() {
// TMPFILE is for manual test execution during which the user will specify
// the full temp file path using the environmental variable TMPFILE
const char* tmpfile = getenv("TMPFILE");
if (tmpfile) {
return std::string(tmpfile);
}
const char* tmpdir = getenv("TMPDIR");
Reported by FlawFinder.
Line: 73
Column: 24
CWE codes:
807
20
Suggestion:
Check environment variables carefully before using them
return std::string(tmpfile);
}
const char* tmpdir = getenv("TMPDIR");
if (tmpdir == nullptr) {
tmpdir = "/tmp";
}
// Create template
Reported by FlawFinder.
Line: 94
Column: 17
CWE codes:
807
20
Suggestion:
Check environment variables carefully before using them
#endif
bool isTSANEnabled() {
auto s = std::getenv("PYTORCH_TEST_WITH_TSAN");
return s && strcmp(s, "1") == 0;
}
struct TemporaryFile {
std::string path;
Reported by FlawFinder.
Line: 45
Column: 3
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
#ifdef _WIN32
std::string autoGenerateTmpFilePath() {
char tmp[L_tmpnam_s];
errno_t err;
err = tmpnam_s(tmp, L_tmpnam_s);
if (err != 0)
{
throw std::system_error(errno, std::system_category());
Reported by FlawFinder.
Line: 57
Column: 7
CWE codes:
377
std::string tmppath() {
const char* tmpfile = getenv("TMPFILE");
if (tmpfile) {
return std::string(tmpfile);
}
else {
return autoGenerateTmpFilePath();
}
Reported by FlawFinder.
Line: 58
Column: 24
CWE codes:
377
std::string tmppath() {
const char* tmpfile = getenv("TMPFILE");
if (tmpfile) {
return std::string(tmpfile);
}
else {
return autoGenerateTmpFilePath();
}
}
Reported by FlawFinder.
Line: 69
Column: 7
CWE codes:
377
// TMPFILE is for manual test execution during which the user will specify
// the full temp file path using the environmental variable TMPFILE
const char* tmpfile = getenv("TMPFILE");
if (tmpfile) {
return std::string(tmpfile);
}
const char* tmpdir = getenv("TMPDIR");
if (tmpdir == nullptr) {
Reported by FlawFinder.
Line: 70
Column: 24
CWE codes:
377
// the full temp file path using the environmental variable TMPFILE
const char* tmpfile = getenv("TMPFILE");
if (tmpfile) {
return std::string(tmpfile);
}
const char* tmpdir = getenv("TMPDIR");
if (tmpdir == nullptr) {
tmpdir = "/tmp";
Reported by FlawFinder.
Line: 84
Column: 13
CWE codes:
377
tmp.resize(len);
// Create temporary file
auto fd = mkstemp(&tmp[0]);
if (fd == -1) {
throw std::system_error(errno, std::system_category());
}
close(fd);
return std::string(tmp.data(), tmp.size());
Reported by FlawFinder.