mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
turn on -Werror=unused-variable in our Bazel CPU build
Summary: We also fix any existing issues. Note that we only do this for the CPU build because nvcc is considered a C++ toolchain but it does not have the same flag support. Adding flags to the GPU build will cause nvcc errors. Test Plan: Built locally, rely on CI to confirm. Reviewers: malfet Subscribers: Tasks: Tags: Pull Request resolved: https://github.com/pytorch/pytorch/pull/79156 Approved by: https://github.com/seemethere, https://github.com/osalpekar, https://github.com/albanD
This commit is contained in:
committed by
PyTorch MergeBot
parent
e727539c29
commit
ab2ca95dd1
4
.bazelrc
4
.bazelrc
@ -52,7 +52,9 @@ build \
|
|||||||
--per_file_copt='^//.*\.(cpp|cc)$'@-Werror=type-limits \
|
--per_file_copt='^//.*\.(cpp|cc)$'@-Werror=type-limits \
|
||||||
--per_file_copt=^//.*\.cu$@--compiler-options=-Werror=type-limits \
|
--per_file_copt=^//.*\.cu$@--compiler-options=-Werror=type-limits \
|
||||||
--per_file_copt='^//.*\.(cpp|cc)$'@-Werror=unused-function \
|
--per_file_copt='^//.*\.(cpp|cc)$'@-Werror=unused-function \
|
||||||
--per_file_copt=^//.*\.cu$@--compiler-options=-Werror=unused-function
|
--per_file_copt=^//.*\.cu$@--compiler-options=-Werror=unused-function \
|
||||||
|
--per_file_copt='^//.*\.(cpp|cc)$'@-Werror=unused-variable \
|
||||||
|
--per_file_copt=^//.*\.cu$@--compiler-options=-Werror=unused-variable
|
||||||
|
|
||||||
build \
|
build \
|
||||||
--per_file_copt=//:aten/src/ATen/RegisterCompositeExplicitAutograd.cpp@-Wno-error=unused-function \
|
--per_file_copt=//:aten/src/ATen/RegisterCompositeExplicitAutograd.cpp@-Wno-error=unused-function \
|
||||||
|
@ -504,6 +504,8 @@ class DispatchKeySet final {
|
|||||||
using iterator_category = std::input_iterator_tag;
|
using iterator_category = std::input_iterator_tag;
|
||||||
using value_type = DispatchKey;
|
using value_type = DispatchKey;
|
||||||
using difference_type = ptrdiff_t;
|
using difference_type = ptrdiff_t;
|
||||||
|
using reference = value_type&;
|
||||||
|
using pointer = value_type*;
|
||||||
// final mask value should mask out the entire keyset
|
// final mask value should mask out the entire keyset
|
||||||
static const uint8_t end_iter_mask_val =
|
static const uint8_t end_iter_mask_val =
|
||||||
num_backends + num_functionality_keys;
|
num_backends + num_functionality_keys;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <iterator>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
#include <c10/core/DispatchKeySet.h>
|
#include <c10/core/DispatchKeySet.h>
|
||||||
@ -14,7 +16,6 @@ TEST(DispatchKeySet, ShowSemantics) {
|
|||||||
// It corresponds to "dense" functionality, "CPU" backend.
|
// It corresponds to "dense" functionality, "CPU" backend.
|
||||||
// This means that it gets a dense functionality bit, and a cpu backend bit
|
// This means that it gets a dense functionality bit, and a cpu backend bit
|
||||||
// set.
|
// set.
|
||||||
auto undefined_set = DispatchKeySet();
|
|
||||||
auto dense_cpu_set = DispatchKeySet(DispatchKey::CPU);
|
auto dense_cpu_set = DispatchKeySet(DispatchKey::CPU);
|
||||||
ASSERT_TRUE(dense_cpu_set.has(DispatchKey::Dense));
|
ASSERT_TRUE(dense_cpu_set.has(DispatchKey::Dense));
|
||||||
ASSERT_TRUE(dense_cpu_set.has_backend(BackendComponent::CPUBit));
|
ASSERT_TRUE(dense_cpu_set.has_backend(BackendComponent::CPUBit));
|
||||||
@ -48,8 +49,6 @@ TEST(DispatchKeySet, ShowSemantics) {
|
|||||||
DispatchKey::Dense,
|
DispatchKey::Dense,
|
||||||
DispatchKey::CUDA,
|
DispatchKey::CUDA,
|
||||||
DispatchKey::CPU});
|
DispatchKey::CPU});
|
||||||
auto fpga = DispatchKeySet(DispatchKey::FPGA);
|
|
||||||
auto fpga_and_cpu = DispatchKeySet({DispatchKey::FPGA, DispatchKey::CPU});
|
|
||||||
// this keyset has all of the building block keys:
|
// this keyset has all of the building block keys:
|
||||||
ASSERT_TRUE(autograd_dense_cpu_cuda.has(DispatchKey::AutogradFunctionality));
|
ASSERT_TRUE(autograd_dense_cpu_cuda.has(DispatchKey::AutogradFunctionality));
|
||||||
ASSERT_TRUE(autograd_dense_cpu_cuda.has(DispatchKey::Dense));
|
ASSERT_TRUE(autograd_dense_cpu_cuda.has(DispatchKey::Dense));
|
||||||
@ -86,8 +85,6 @@ TEST(DispatchKeySet, ShowSemantics) {
|
|||||||
// Iterators allow you to iterate individually through the DispatchKey's in a
|
// Iterators allow you to iterate individually through the DispatchKey's in a
|
||||||
// DispatchKeySet
|
// DispatchKeySet
|
||||||
auto empty_set = DispatchKeySet();
|
auto empty_set = DispatchKeySet();
|
||||||
auto t1 = empty_set.begin();
|
|
||||||
auto t2 = empty_set.end();
|
|
||||||
ASSERT_EQ(*empty_set.begin(), *empty_set.end());
|
ASSERT_EQ(*empty_set.begin(), *empty_set.end());
|
||||||
|
|
||||||
// However, only keys that correspond to actual runtime indices of kernels in
|
// However, only keys that correspond to actual runtime indices of kernels in
|
||||||
@ -370,29 +367,12 @@ TEST(DispatchKeySet, IteratorCrossProduct) {
|
|||||||
|
|
||||||
TEST(DispatchKeySet, IteratorFull) {
|
TEST(DispatchKeySet, IteratorFull) {
|
||||||
DispatchKeySet full_set(DispatchKeySet::FULL);
|
DispatchKeySet full_set(DispatchKeySet::FULL);
|
||||||
uint8_t i = 0;
|
std::ptrdiff_t count = std::distance(full_set.begin(), full_set.end());
|
||||||
|
|
||||||
for (const auto& it : full_set) {
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
// Total # of runtime entries includes an entry for DispatchKey::Undefined,
|
|
||||||
// which is not included when iterating through the DispatchKeySet.
|
|
||||||
ASSERT_EQ(i, num_runtime_entries - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(DispatchKeySet, IteratorRangeFull) {
|
|
||||||
DispatchKeySet full_set(DispatchKeySet::FULL);
|
|
||||||
uint8_t i = 0;
|
|
||||||
|
|
||||||
for (DispatchKey dispatch_key : full_set) {
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Total # of runtime entries includes an entry for DispatchKey::Undefined,
|
// Total # of runtime entries includes an entry for DispatchKey::Undefined,
|
||||||
// which is not included when iterating through the DispatchKeySet.
|
// which is not included when iterating through the DispatchKeySet.
|
||||||
ASSERT_EQ(i, num_runtime_entries - 1);
|
ASSERT_EQ(count, std::ptrdiff_t{num_runtime_entries} - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(DispatchKeySet, FailAtEndIterator) {
|
TEST(DispatchKeySet, FailAtEndIterator) {
|
||||||
DispatchKeySet full_set(DispatchKeySet::FULL);
|
DispatchKeySet full_set(DispatchKeySet::FULL);
|
||||||
uint64_t raw_repr = full_set.raw_repr();
|
uint64_t raw_repr = full_set.raw_repr();
|
||||||
|
@ -219,8 +219,6 @@ TEST(
|
|||||||
givenInvalidPtr_whenMoveAssigning_thenNewInstanceIsValid) {
|
givenInvalidPtr_whenMoveAssigning_thenNewInstanceIsValid) {
|
||||||
intrusive_ptr<SomeClass> obj1 = make_intrusive<SomeClass>();
|
intrusive_ptr<SomeClass> obj1 = make_intrusive<SomeClass>();
|
||||||
intrusive_ptr<SomeClass> obj2;
|
intrusive_ptr<SomeClass> obj2;
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
|
||||||
SomeClass* obj1ptr = obj1.get();
|
|
||||||
obj2 = std::move(obj1);
|
obj2 = std::move(obj1);
|
||||||
EXPECT_TRUE(obj2.defined());
|
EXPECT_TRUE(obj2.defined());
|
||||||
}
|
}
|
||||||
@ -271,8 +269,6 @@ TEST(
|
|||||||
givenInvalidPtr_whenMoveAssigningToBaseClass_thenNewInstanceIsValid) {
|
givenInvalidPtr_whenMoveAssigningToBaseClass_thenNewInstanceIsValid) {
|
||||||
intrusive_ptr<SomeChildClass> obj1 = make_intrusive<SomeChildClass>(5);
|
intrusive_ptr<SomeChildClass> obj1 = make_intrusive<SomeChildClass>(5);
|
||||||
intrusive_ptr<SomeBaseClass> obj2;
|
intrusive_ptr<SomeBaseClass> obj2;
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
|
||||||
SomeBaseClass* obj1ptr = obj1.get();
|
|
||||||
obj2 = std::move(obj1);
|
obj2 = std::move(obj1);
|
||||||
EXPECT_TRUE(obj2.defined());
|
EXPECT_TRUE(obj2.defined());
|
||||||
}
|
}
|
||||||
@ -358,8 +354,6 @@ TEST(
|
|||||||
givenInvalidPtr_whenCopyAssigning_thenNewInstanceIsValid) {
|
givenInvalidPtr_whenCopyAssigning_thenNewInstanceIsValid) {
|
||||||
intrusive_ptr<SomeClass> obj1 = make_intrusive<SomeClass>();
|
intrusive_ptr<SomeClass> obj1 = make_intrusive<SomeClass>();
|
||||||
intrusive_ptr<SomeClass> obj2;
|
intrusive_ptr<SomeClass> obj2;
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
|
||||||
SomeClass* obj1ptr = obj1.get();
|
|
||||||
obj2 = obj1;
|
obj2 = obj1;
|
||||||
EXPECT_TRUE(obj2.defined());
|
EXPECT_TRUE(obj2.defined());
|
||||||
}
|
}
|
||||||
@ -387,8 +381,6 @@ TEST(
|
|||||||
givenInvalidPtr_whenCopyAssigningToBaseClass_thenNewInstanceIsValid) {
|
givenInvalidPtr_whenCopyAssigningToBaseClass_thenNewInstanceIsValid) {
|
||||||
intrusive_ptr<SomeChildClass> obj1 = make_intrusive<SomeChildClass>(5);
|
intrusive_ptr<SomeChildClass> obj1 = make_intrusive<SomeChildClass>(5);
|
||||||
intrusive_ptr<SomeBaseClass> obj2;
|
intrusive_ptr<SomeBaseClass> obj2;
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
|
||||||
SomeBaseClass* obj1ptr = obj1.get();
|
|
||||||
obj2 = obj1;
|
obj2 = obj1;
|
||||||
EXPECT_TRUE(obj2.defined());
|
EXPECT_TRUE(obj2.defined());
|
||||||
}
|
}
|
||||||
@ -1779,8 +1771,7 @@ TEST(
|
|||||||
givenInvalidPtr_whenMoveAssigning_thenNewInstanceIsValid) {
|
givenInvalidPtr_whenMoveAssigning_thenNewInstanceIsValid) {
|
||||||
IntrusiveAndWeak<SomeClass> obj1 = make_weak_intrusive<SomeClass>();
|
IntrusiveAndWeak<SomeClass> obj1 = make_weak_intrusive<SomeClass>();
|
||||||
weak_intrusive_ptr<SomeClass> obj2 = make_invalid_weak<SomeClass>();
|
weak_intrusive_ptr<SomeClass> obj2 = make_invalid_weak<SomeClass>();
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
obj1.weak.lock().get();
|
||||||
SomeClass* obj1ptr = obj1.weak.lock().get();
|
|
||||||
obj2 = std::move(obj1.weak);
|
obj2 = std::move(obj1.weak);
|
||||||
EXPECT_FALSE(obj2.expired());
|
EXPECT_FALSE(obj2.expired());
|
||||||
}
|
}
|
||||||
@ -1826,8 +1817,7 @@ TEST(
|
|||||||
givenWeakOnlyPtr_whenMoveAssigning_thenNewInstanceIsValid) {
|
givenWeakOnlyPtr_whenMoveAssigning_thenNewInstanceIsValid) {
|
||||||
IntrusiveAndWeak<SomeClass> obj1 = make_weak_intrusive<SomeClass>();
|
IntrusiveAndWeak<SomeClass> obj1 = make_weak_intrusive<SomeClass>();
|
||||||
weak_intrusive_ptr<SomeClass> obj2 = make_weak_only<SomeClass>();
|
weak_intrusive_ptr<SomeClass> obj2 = make_weak_only<SomeClass>();
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
obj1.weak.lock().get();
|
||||||
SomeClass* obj1ptr = obj1.weak.lock().get();
|
|
||||||
obj2 = std::move(obj1.weak);
|
obj2 = std::move(obj1.weak);
|
||||||
EXPECT_FALSE(obj2.expired());
|
EXPECT_FALSE(obj2.expired());
|
||||||
}
|
}
|
||||||
@ -1846,8 +1836,7 @@ TEST(
|
|||||||
WeakIntrusivePtrTest,
|
WeakIntrusivePtrTest,
|
||||||
givenWeakOnlyPtr_whenMoveAssigningToSelf_thenStaysInvalid) {
|
givenWeakOnlyPtr_whenMoveAssigningToSelf_thenStaysInvalid) {
|
||||||
weak_intrusive_ptr<SomeClass> obj1 = make_weak_only<SomeClass>();
|
weak_intrusive_ptr<SomeClass> obj1 = make_weak_only<SomeClass>();
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
obj1.lock().get();
|
||||||
SomeClass* obj1ptr = obj1.lock().get();
|
|
||||||
obj1 = std::move(obj1);
|
obj1 = std::move(obj1);
|
||||||
// NOLINTNEXTLINE(bugprone-use-after-move)
|
// NOLINTNEXTLINE(bugprone-use-after-move)
|
||||||
EXPECT_TRUE(obj1.expired());
|
EXPECT_TRUE(obj1.expired());
|
||||||
@ -1911,8 +1900,7 @@ TEST(
|
|||||||
IntrusiveAndWeak<SomeChildClass> obj1 =
|
IntrusiveAndWeak<SomeChildClass> obj1 =
|
||||||
make_weak_intrusive<SomeChildClass>(5);
|
make_weak_intrusive<SomeChildClass>(5);
|
||||||
weak_intrusive_ptr<SomeBaseClass> obj2 = make_invalid_weak<SomeBaseClass>();
|
weak_intrusive_ptr<SomeBaseClass> obj2 = make_invalid_weak<SomeBaseClass>();
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
obj1.weak.lock().get();
|
||||||
SomeBaseClass* obj1ptr = obj1.weak.lock().get();
|
|
||||||
obj2 = std::move(obj1.weak);
|
obj2 = std::move(obj1.weak);
|
||||||
EXPECT_FALSE(obj2.expired());
|
EXPECT_FALSE(obj2.expired());
|
||||||
}
|
}
|
||||||
@ -1945,8 +1933,7 @@ TEST(
|
|||||||
IntrusiveAndWeak<SomeChildClass> obj1 =
|
IntrusiveAndWeak<SomeChildClass> obj1 =
|
||||||
make_weak_intrusive<SomeChildClass>(5);
|
make_weak_intrusive<SomeChildClass>(5);
|
||||||
weak_intrusive_ptr<SomeBaseClass> obj2 = make_weak_only<SomeBaseClass>(2);
|
weak_intrusive_ptr<SomeBaseClass> obj2 = make_weak_only<SomeBaseClass>(2);
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
obj1.weak.lock().get();
|
||||||
SomeBaseClass* obj1ptr = obj1.weak.lock().get();
|
|
||||||
obj2 = std::move(obj1.weak);
|
obj2 = std::move(obj1.weak);
|
||||||
EXPECT_FALSE(obj2.expired());
|
EXPECT_FALSE(obj2.expired());
|
||||||
}
|
}
|
||||||
@ -2028,8 +2015,7 @@ TEST(
|
|||||||
givenInvalidPtr_whenCopyAssigning_thenNewInstanceIsValid) {
|
givenInvalidPtr_whenCopyAssigning_thenNewInstanceIsValid) {
|
||||||
IntrusiveAndWeak<SomeClass> obj1 = make_weak_intrusive<SomeClass>();
|
IntrusiveAndWeak<SomeClass> obj1 = make_weak_intrusive<SomeClass>();
|
||||||
weak_intrusive_ptr<SomeClass> obj2 = make_invalid_weak<SomeClass>();
|
weak_intrusive_ptr<SomeClass> obj2 = make_invalid_weak<SomeClass>();
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
obj1.weak.lock().get();
|
||||||
SomeClass* obj1ptr = obj1.weak.lock().get();
|
|
||||||
obj2 = obj1.weak;
|
obj2 = obj1.weak;
|
||||||
EXPECT_FALSE(obj2.expired());
|
EXPECT_FALSE(obj2.expired());
|
||||||
}
|
}
|
||||||
@ -2048,8 +2034,7 @@ TEST(
|
|||||||
givenWeakOnlyPtr_whenCopyAssigning_thenNewInstanceIsValid) {
|
givenWeakOnlyPtr_whenCopyAssigning_thenNewInstanceIsValid) {
|
||||||
IntrusiveAndWeak<SomeClass> obj1 = make_weak_intrusive<SomeClass>();
|
IntrusiveAndWeak<SomeClass> obj1 = make_weak_intrusive<SomeClass>();
|
||||||
weak_intrusive_ptr<SomeClass> obj2 = make_weak_only<SomeClass>();
|
weak_intrusive_ptr<SomeClass> obj2 = make_weak_only<SomeClass>();
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
obj1.weak.lock().get();
|
||||||
SomeClass* obj1ptr = obj1.weak.lock().get();
|
|
||||||
obj2 = obj1.weak;
|
obj2 = obj1.weak;
|
||||||
EXPECT_FALSE(obj2.expired());
|
EXPECT_FALSE(obj2.expired());
|
||||||
}
|
}
|
||||||
@ -2068,8 +2053,7 @@ TEST(
|
|||||||
WeakIntrusivePtrTest,
|
WeakIntrusivePtrTest,
|
||||||
givenWeakOnlyPtr_whenCopyAssigningToSelf_thenStaysInvalid) {
|
givenWeakOnlyPtr_whenCopyAssigningToSelf_thenStaysInvalid) {
|
||||||
weak_intrusive_ptr<SomeClass> obj1 = make_weak_only<SomeClass>();
|
weak_intrusive_ptr<SomeClass> obj1 = make_weak_only<SomeClass>();
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
obj1.lock().get();
|
||||||
SomeClass* obj1ptr = obj1.lock().get();
|
|
||||||
// NOLINTNEXTLINE(clang-diagnostic-self-assign-overloaded)
|
// NOLINTNEXTLINE(clang-diagnostic-self-assign-overloaded)
|
||||||
obj1 = obj1;
|
obj1 = obj1;
|
||||||
EXPECT_TRUE(obj1.expired());
|
EXPECT_TRUE(obj1.expired());
|
||||||
@ -2111,8 +2095,7 @@ TEST(
|
|||||||
IntrusiveAndWeak<SomeChildClass> obj1 =
|
IntrusiveAndWeak<SomeChildClass> obj1 =
|
||||||
make_weak_intrusive<SomeChildClass>(5);
|
make_weak_intrusive<SomeChildClass>(5);
|
||||||
weak_intrusive_ptr<SomeBaseClass> obj2 = make_invalid_weak<SomeBaseClass>();
|
weak_intrusive_ptr<SomeBaseClass> obj2 = make_invalid_weak<SomeBaseClass>();
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
obj1.weak.lock().get();
|
||||||
SomeBaseClass* obj1ptr = obj1.weak.lock().get();
|
|
||||||
obj2 = obj1.weak;
|
obj2 = obj1.weak;
|
||||||
EXPECT_FALSE(obj2.expired());
|
EXPECT_FALSE(obj2.expired());
|
||||||
}
|
}
|
||||||
@ -2145,8 +2128,7 @@ TEST(
|
|||||||
IntrusiveAndWeak<SomeChildClass> obj1 =
|
IntrusiveAndWeak<SomeChildClass> obj1 =
|
||||||
make_weak_intrusive<SomeChildClass>(5);
|
make_weak_intrusive<SomeChildClass>(5);
|
||||||
weak_intrusive_ptr<SomeBaseClass> obj2 = make_weak_only<SomeBaseClass>(2);
|
weak_intrusive_ptr<SomeBaseClass> obj2 = make_weak_only<SomeBaseClass>(2);
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
obj1.weak.lock().get();
|
||||||
SomeBaseClass* obj1ptr = obj1.weak.lock().get();
|
|
||||||
obj2 = obj1.weak;
|
obj2 = obj1.weak;
|
||||||
EXPECT_FALSE(obj2.expired());
|
EXPECT_FALSE(obj2.expired());
|
||||||
}
|
}
|
||||||
|
@ -1900,8 +1900,6 @@ TEST(DataLoaderTest, ChunkDatasetDoesNotHang) {
|
|||||||
datasets::ChunkDatasetOptions(
|
datasets::ChunkDatasetOptions(
|
||||||
prefetch_count, batch_size, cache_size));
|
prefetch_count, batch_size, cache_size));
|
||||||
|
|
||||||
samplers::SequentialSampler& chunk_sampler = dataset->chunk_sampler();
|
|
||||||
|
|
||||||
auto data_loader = torch::data::make_data_loader(
|
auto data_loader = torch::data::make_data_loader(
|
||||||
dataset.map(transforms::BatchLambda<DummyChunkDataReader::BatchType, DummyChunkDataReader::DataType>(
|
dataset.map(transforms::BatchLambda<DummyChunkDataReader::BatchType, DummyChunkDataReader::DataType>(
|
||||||
[](DummyChunkDataReader::BatchType batch) {
|
[](DummyChunkDataReader::BatchType batch) {
|
||||||
@ -2043,7 +2041,6 @@ TEST(DataLoaderTest, ChunkDatasetLoad) {
|
|||||||
const size_t prefetch_count = 1;
|
const size_t prefetch_count = 1;
|
||||||
const size_t batch_size = 10;
|
const size_t batch_size = 10;
|
||||||
const size_t dataloader_worker_count = 0;
|
const size_t dataloader_worker_count = 0;
|
||||||
const size_t save_interval = 2;
|
|
||||||
|
|
||||||
DummyChunkDataReader data_reader;
|
DummyChunkDataReader data_reader;
|
||||||
samplers::SequentialSampler sampler(0);
|
samplers::SequentialSampler sampler(0);
|
||||||
@ -2223,8 +2220,6 @@ TEST(DataLoaderTest, ChunkDatasetCrossChunkShuffle) {
|
|||||||
std::vector<int> expected_result;
|
std::vector<int> expected_result;
|
||||||
{
|
{
|
||||||
// construct expected result
|
// construct expected result
|
||||||
int offset = 0;
|
|
||||||
|
|
||||||
for (const auto i : c10::irange((chunk_count + cross_chunk_shuffle_count - 1) /
|
for (const auto i : c10::irange((chunk_count + cross_chunk_shuffle_count - 1) /
|
||||||
cross_chunk_shuffle_count)) {
|
cross_chunk_shuffle_count)) {
|
||||||
for (const auto j : c10::irange(chunk_size)) {
|
for (const auto j : c10::irange(chunk_size)) {
|
||||||
|
@ -1940,7 +1940,6 @@ TEST_F(FunctionalTest, InstanceNorm2d) {
|
|||||||
|
|
||||||
TEST_F(FunctionalTest, InstanceNorm2dDefaultOptions) {
|
TEST_F(FunctionalTest, InstanceNorm2dDefaultOptions) {
|
||||||
int num_features = 5;
|
int num_features = 5;
|
||||||
double eps = 1e-05;
|
|
||||||
|
|
||||||
auto input = torch::arange(2. * num_features * 2 * 2).view({2, num_features, 2, 2});
|
auto input = torch::arange(2. * num_features * 2 * 2).view({2, num_features, 2, 2});
|
||||||
auto output = F::instance_norm(input);
|
auto output = F::instance_norm(input);
|
||||||
@ -2031,7 +2030,6 @@ TEST_F(FunctionalTest, InstanceNorm3d) {
|
|||||||
|
|
||||||
TEST_F(FunctionalTest, InstanceNorm3dDefaultOptions) {
|
TEST_F(FunctionalTest, InstanceNorm3dDefaultOptions) {
|
||||||
int num_features = 5;
|
int num_features = 5;
|
||||||
double eps = 1e-05;
|
|
||||||
|
|
||||||
auto input = torch::arange(2. * num_features * 2 * 2 * 2).view({2, num_features, 2, 2, 2});
|
auto input = torch::arange(2. * num_features * 2 * 2 * 2).view({2, num_features, 2, 2, 2});
|
||||||
auto output = F::instance_norm(input);
|
auto output = F::instance_norm(input);
|
||||||
|
@ -613,7 +613,6 @@ TEST_F(NNUtilsTest, PackPaddedSequence) {
|
|||||||
}
|
}
|
||||||
batch_sizes[i-1] = total;
|
batch_sizes[i-1] = total;
|
||||||
}
|
}
|
||||||
int64_t offset = 0;
|
|
||||||
std::vector<torch::Tensor> tensors_to_be_cat;
|
std::vector<torch::Tensor> tensors_to_be_cat;
|
||||||
for (int64_t i = 1; i < static_cast<int64_t>(sorted_lengths.size() + 1); i++) {
|
for (int64_t i = 1; i < static_cast<int64_t>(sorted_lengths.size() + 1); i++) {
|
||||||
int64_t l = sorted_lengths.at(i-1);
|
int64_t l = sorted_lengths.at(i-1);
|
||||||
|
@ -173,7 +173,7 @@ TEST(OptimTest, OptimizerAccessors) {
|
|||||||
const auto& optimizer_ = Adagrad(params, options);
|
const auto& optimizer_ = Adagrad(params, options);
|
||||||
optimizer_.defaults();
|
optimizer_.defaults();
|
||||||
// test for param_groups() with const reference return
|
// test for param_groups() with const reference return
|
||||||
const auto& params_2 = optimizer_.param_groups();
|
(void)optimizer_.param_groups();
|
||||||
// test for state() with const reference return
|
// test for state() with const reference return
|
||||||
optimizer_.state();
|
optimizer_.state();
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,6 @@ class BackendWithCompiler : public PyTorchBackendInterface {
|
|||||||
IValue val = token;
|
IValue val = token;
|
||||||
auto instruction = val.toTupleRef().elements()[0].toStringRef();
|
auto instruction = val.toTupleRef().elements()[0].toStringRef();
|
||||||
auto debug_handle = val.toTupleRef().elements()[1].toInt();
|
auto debug_handle = val.toTupleRef().elements()[1].toInt();
|
||||||
double const_val = 1.0;
|
|
||||||
#ifndef NO_PROFILING
|
#ifndef NO_PROFILING
|
||||||
auto start_time_us = torch::profiler::impl::getTime() / 1000;
|
auto start_time_us = torch::profiler::impl::getTime() / 1000;
|
||||||
#endif
|
#endif
|
||||||
@ -132,8 +131,6 @@ class BackendWithCompiler : public PyTorchBackendInterface {
|
|||||||
instruction);
|
instruction);
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
|
||||||
auto sub = instruction.substr(15);
|
auto sub = instruction.substr(15);
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
|
||||||
const_val = stod(sub);
|
|
||||||
} else if (instruction == "aten::add" || instruction == "aten::sub") {
|
} else if (instruction == "aten::add" || instruction == "aten::sub") {
|
||||||
TORCH_CHECK(x.sizes() == h.sizes());
|
TORCH_CHECK(x.sizes() == h.sizes());
|
||||||
if (x.dim() > 1 || (x.dim() == 1 && x.size(0) > 1)) {
|
if (x.dim() > 1 || (x.dim() == 1 && x.size(0) > 1)) {
|
||||||
|
@ -122,11 +122,12 @@ TEST_F(FuserTest, TestOne_CUDA) {
|
|||||||
// with different internal strides. To do this, we generate a tensor
|
// with different internal strides. To do this, we generate a tensor
|
||||||
// with the "wrong" dimensions, and then use transpose to get an
|
// with the "wrong" dimensions, and then use transpose to get an
|
||||||
// appropriately sized view.
|
// appropriately sized view.
|
||||||
for (const auto i : c10::irange(graph.inputs().size())) {
|
std::generate_n(
|
||||||
std::vector<int64_t> dims = {128, 128, 32};
|
std::back_inserter(inputs), graph.inputs().size(), [ti, tj] {
|
||||||
std::swap(dims[ti], dims[tj]);
|
std::array<int64_t, 3> dims = {128, 128, 32};
|
||||||
inputs.push_back(at::rand(dims, at::kCUDA).transpose(ti, tj));
|
std::swap(dims[ti], dims[tj]);
|
||||||
}
|
return at::rand(dims, at::kCUDA).transpose(ti, tj);
|
||||||
|
});
|
||||||
|
|
||||||
auto t22 = inputs[4].sigmoid();
|
auto t22 = inputs[4].sigmoid();
|
||||||
auto t20 = inputs[3].sigmoid();
|
auto t20 = inputs[3].sigmoid();
|
||||||
|
@ -301,7 +301,6 @@ graph(%a : Float(4, 5),
|
|||||||
TEST(IRParserTest, MalformedStrides) {
|
TEST(IRParserTest, MalformedStrides) {
|
||||||
auto graph = std::make_shared<Graph>();
|
auto graph = std::make_shared<Graph>();
|
||||||
std::unordered_map<std::string, Value*> vmap;
|
std::unordered_map<std::string, Value*> vmap;
|
||||||
bool error_thrown = false;
|
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-goto,hicpp-avoid-goto)
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-goto,hicpp-avoid-goto)
|
||||||
EXPECT_ANY_THROW(parseIR(
|
EXPECT_ANY_THROW(parseIR(
|
||||||
R"IR(
|
R"IR(
|
||||||
|
@ -1182,7 +1182,6 @@ TEST(RunTimeTest, ParseOperator) {
|
|||||||
std::vector<IValue> constants{
|
std::vector<IValue> constants{
|
||||||
to_tuple({1}),
|
to_tuple({1}),
|
||||||
};
|
};
|
||||||
int64_t model_version = caffe2::serialize::kProducedBytecodeVersion;
|
|
||||||
// 2. Parse the function
|
// 2. Parse the function
|
||||||
std::string function_name("test_function");
|
std::string function_name("test_function");
|
||||||
auto function = std::unique_ptr<mobile::Function>(
|
auto function = std::unique_ptr<mobile::Function>(
|
||||||
@ -1566,7 +1565,6 @@ TEST(RunTimeTest, RuntimeCall) {
|
|||||||
std::vector<IValue> constantsCall{
|
std::vector<IValue> constantsCall{
|
||||||
1,
|
1,
|
||||||
};
|
};
|
||||||
int64_t model_version = caffe2::serialize::kProducedBytecodeVersion;
|
|
||||||
|
|
||||||
auto foo = std::make_unique<mobile::Function>(c10::QualifiedName("foo"));
|
auto foo = std::make_unique<mobile::Function>(c10::QualifiedName("foo"));
|
||||||
c10::ivalue::TupleElements debug_handles_m_tuple;
|
c10::ivalue::TupleElements debug_handles_m_tuple;
|
||||||
|
@ -1049,8 +1049,7 @@ TEST(RecordFunctionTest, Callbacks) {
|
|||||||
GraphOptimizerEnabledGuard opt_guard(false);
|
GraphOptimizerEnabledGuard opt_guard(false);
|
||||||
|
|
||||||
auto h1 = add_remove_test_add_cb<1>();
|
auto h1 = add_remove_test_add_cb<1>();
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
add_remove_test_add_cb<2>();
|
||||||
auto h2 = add_remove_test_add_cb<2>();
|
|
||||||
auto h3 = add_remove_test_add_cb<3>();
|
auto h3 = add_remove_test_add_cb<3>();
|
||||||
|
|
||||||
{ RECORD_USER_SCOPE("test"); }
|
{ RECORD_USER_SCOPE("test"); }
|
||||||
@ -1144,7 +1143,6 @@ TEST(RecordFunctionTest, Callbacks) {
|
|||||||
} // END: global test
|
} // END: global test
|
||||||
{ // START: thread local test
|
{ // START: thread local test
|
||||||
auto ctx_th = std::thread([]() {
|
auto ctx_th = std::thread([]() {
|
||||||
const int test_val = 234;
|
|
||||||
const std::string test_str = "test thread str";
|
const std::string test_str = "test thread str";
|
||||||
addThreadLocalCallback(RecordFunctionCallback(
|
addThreadLocalCallback(RecordFunctionCallback(
|
||||||
[](const RecordFunction&
|
[](const RecordFunction&
|
||||||
@ -1417,22 +1415,6 @@ TEST(TestSymInt, AddSymbolicInt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(FallbackGraphsTest, Basic) {
|
TEST(FallbackGraphsTest, Basic) {
|
||||||
static const auto nestGraphIntoFallbackGraph =
|
|
||||||
[](const std::shared_ptr<Graph>& graph) {
|
|
||||||
ProfilingRecord::removeProfileCounter(graph->block());
|
|
||||||
auto fallback =
|
|
||||||
replaceBlockWithFallbackGraph(graph->block(), graph->inputs());
|
|
||||||
for (size_t i = 0; i < graph->outputs().size(); i++) {
|
|
||||||
graph->outputs()[i]->replaceAllUsesWith(fallback->output(i));
|
|
||||||
fallback->output(i)->copyMetadata(graph->outputs()[i]);
|
|
||||||
}
|
|
||||||
for (auto it = graph->block()->nodes().rbegin();
|
|
||||||
it != fallback->iterator();
|
|
||||||
it++) {
|
|
||||||
it.destroyCurrent();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
auto x = at::randn({1}, at::kCPU);
|
auto x = at::randn({1}, at::kCPU);
|
||||||
auto y = at::randn({1}, at::kCPU);
|
auto y = at::randn({1}, at::kCPU);
|
||||||
auto stack = createStack({x.clone(), y.clone()});
|
auto stack = createStack({x.clone(), y.clone()});
|
||||||
@ -2656,11 +2638,13 @@ TEST(RecordDebugHandles, Basic) {
|
|||||||
RECORD_EDGE_SCOPE_WITH_DEBUG_HANDLE_AND_INPUTS("my_function", 42, {});
|
RECORD_EDGE_SCOPE_WITH_DEBUG_HANDLE_AND_INPUTS("my_function", 42, {});
|
||||||
float x{5.9999}, y{2.1212};
|
float x{5.9999}, y{2.1212};
|
||||||
float z = x / y;
|
float z = x / y;
|
||||||
|
(void)z;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
RECORD_USER_SCOPE_WITH_INPUTS("not_my_function", {});
|
RECORD_USER_SCOPE_WITH_INPUTS("not_my_function", {});
|
||||||
float x{5.9999}, y{2.1212};
|
float x{5.9999}, y{2.1212};
|
||||||
float z = x / y;
|
float z = x / y;
|
||||||
|
(void)z;
|
||||||
}
|
}
|
||||||
auto profiler_results_ptr = torch::autograd::profiler::disableProfiler();
|
auto profiler_results_ptr = torch::autograd::profiler::disableProfiler();
|
||||||
const auto& kineto_events = profiler_results_ptr->events();
|
const auto& kineto_events = profiler_results_ptr->events();
|
||||||
|
@ -69,8 +69,6 @@ TEST_F(Kernel, InliningIntermediates) {
|
|||||||
const auto graph_string = format(graph_template, env);
|
const auto graph_string = format(graph_template, env);
|
||||||
auto graph = std::make_shared<Graph>();
|
auto graph = std::make_shared<Graph>();
|
||||||
parseIR(graph_string, &*graph);
|
parseIR(graph_string, &*graph);
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
|
||||||
auto device = use_cuda ? kCUDA : kCPU;
|
|
||||||
TensorExprKernel k(graph);
|
TensorExprKernel k(graph);
|
||||||
auto stmt = k.getCodeGenStmt();
|
auto stmt = k.getCodeGenStmt();
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@ -80,8 +78,6 @@ TEST_F(Kernel, InliningIntermediates) {
|
|||||||
|
|
||||||
// aten_sub should be removed by the CUDA backend by metavar rewriting
|
// aten_sub should be removed by the CUDA backend by metavar rewriting
|
||||||
// and by the CPU backend by horizontal fusion.
|
// and by the CPU backend by horizontal fusion.
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores,cppcoreguidelines-avoid-magic-numbers)
|
|
||||||
size_t num_out1_uses = use_cuda ? 0 : 5;
|
|
||||||
torch::jit::testing::FileCheck().check_not("aten_sub")->run(oss.str());
|
torch::jit::testing::FileCheck().check_not("aten_sub")->run(oss.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,6 @@ TEST(Reductions, ReduceSum0D_1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Reductions, ReduceSum0D_2) {
|
TEST(Reductions, ReduceSum0D_2) {
|
||||||
const int M = 10;
|
|
||||||
|
|
||||||
BufHandle b("b", {}, kFloat);
|
BufHandle b("b", {}, kFloat);
|
||||||
std::vector<float> in(1);
|
std::vector<float> in(1);
|
||||||
in[0] = 77.7;
|
in[0] = 77.7;
|
||||||
|
@ -68,15 +68,14 @@ TEST(Type, BitCasting) {
|
|||||||
ASSERT_EQ(y.dtype(), kShort);
|
ASSERT_EQ(y.dtype(), kShort);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr int16_t ref16 = 1337;
|
|
||||||
constexpr int32_t ref32 = 1337;
|
constexpr int32_t ref32 = 1337;
|
||||||
constexpr int64_t ref64 = 1337;
|
constexpr int64_t ref64 = 1337;
|
||||||
at::Half reff16 = 1337.0f;
|
|
||||||
constexpr float reff32 = 1337.0f;
|
constexpr float reff32 = 1337.0f;
|
||||||
constexpr double reff64 = 1337.0f;
|
constexpr double reff64 = 1337.0f;
|
||||||
using SimpleIRExprEval = ExprEval<SimpleIREvaluator>;
|
using SimpleIRExprEval = ExprEval<SimpleIREvaluator>;
|
||||||
// this is broken
|
// this is broken
|
||||||
/*{
|
/*{
|
||||||
|
constexpr int16_t ref16 = 1337;
|
||||||
at::Half k_;
|
at::Half k_;
|
||||||
at::Half* k = &k_;
|
at::Half* k = &k_;
|
||||||
*reinterpret_cast<int16_t*>(k) = ref16;
|
*reinterpret_cast<int16_t*>(k) = ref16;
|
||||||
|
@ -82,8 +82,8 @@ static PyObject * THPStorage_copy_(PyObject *self, PyObject *args, PyObject *kwa
|
|||||||
static PyObject * THPStorage_isPinned(PyObject *_self, PyObject *noargs)
|
static PyObject * THPStorage_isPinned(PyObject *_self, PyObject *noargs)
|
||||||
{
|
{
|
||||||
HANDLE_TH_ERRORS
|
HANDLE_TH_ERRORS
|
||||||
auto self = (THPStorage*)_self;
|
|
||||||
#if defined(USE_CUDA)
|
#if defined(USE_CUDA)
|
||||||
|
auto self = (THPStorage*)_self;
|
||||||
return PyBool_FromLong(at::globalContext().isPinnedPtr(self->cdata->data<uint8_t>()));
|
return PyBool_FromLong(at::globalContext().isPinnedPtr(self->cdata->data<uint8_t>()));
|
||||||
#else
|
#else
|
||||||
Py_RETURN_FALSE;
|
Py_RETURN_FALSE;
|
||||||
@ -94,7 +94,6 @@ static PyObject * THPStorage_isPinned(PyObject *_self, PyObject *noargs)
|
|||||||
static PyObject * THPStorage_elementSize(PyObject *_self, PyObject *noargs)
|
static PyObject * THPStorage_elementSize(PyObject *_self, PyObject *noargs)
|
||||||
{
|
{
|
||||||
HANDLE_TH_ERRORS
|
HANDLE_TH_ERRORS
|
||||||
auto self = (THPStorage*)_self;
|
|
||||||
return THPUtils_packInt64(sizeof(uint8_t));
|
return THPUtils_packInt64(sizeof(uint8_t));
|
||||||
END_HANDLE_TH_ERRORS
|
END_HANDLE_TH_ERRORS
|
||||||
}
|
}
|
||||||
@ -364,7 +363,6 @@ PyObject * THPStorage_newWithFile(PyObject *_unused, PyObject *args)
|
|||||||
HANDLE_TH_ERRORS
|
HANDLE_TH_ERRORS
|
||||||
TORCH_CHECK(PyTuple_Size(args) == 2,
|
TORCH_CHECK(PyTuple_Size(args) == 2,
|
||||||
"_new_with_file takes exactly two arguments");
|
"_new_with_file takes exactly two arguments");
|
||||||
PyObject *fd_obj = PyTuple_GetItem(args, 0);
|
|
||||||
int fd = PyObject_AsFileDescriptor(PyTuple_GetItem(args, 0));
|
int fd = PyObject_AsFileDescriptor(PyTuple_GetItem(args, 0));
|
||||||
THPUtils_assert(fd != -1, "_new_with_file couldn't retrieve a file "
|
THPUtils_assert(fd != -1, "_new_with_file couldn't retrieve a file "
|
||||||
"descriptor from given object");
|
"descriptor from given object");
|
||||||
|
@ -221,7 +221,6 @@ void autogradNotImplementedInplaceOrViewFallbackImpl(const c10::OperatorHandle&
|
|||||||
const auto num_arguments = arguments.size();
|
const auto num_arguments = arguments.size();
|
||||||
const auto num_returns = returns.size();
|
const auto num_returns = returns.size();
|
||||||
const auto stack_start = stack->size() - num_arguments;
|
const auto stack_start = stack->size() - num_arguments;
|
||||||
bool any_is_inplace = false;
|
|
||||||
|
|
||||||
at::Tensor aliased_input;
|
at::Tensor aliased_input;
|
||||||
|
|
||||||
@ -254,8 +253,6 @@ void autogradNotImplementedInplaceOrViewFallbackImpl(const c10::OperatorHandle&
|
|||||||
const c10::IValue& aliased_input_iv = (*stack)[stack_start + i]; // get a reference to an ivalue on the stack
|
const c10::IValue& aliased_input_iv = (*stack)[stack_start + i]; // get a reference to an ivalue on the stack
|
||||||
TORCH_CHECK(aliased_input_iv.isTensor());
|
TORCH_CHECK(aliased_input_iv.isTensor());
|
||||||
aliased_input = aliased_input_iv.toTensor(); // TODO: Can we avoid saving this tensor and incurring the refcount bump?
|
aliased_input = aliased_input_iv.toTensor(); // TODO: Can we avoid saving this tensor and incurring the refcount bump?
|
||||||
} else {
|
|
||||||
any_is_inplace = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -553,7 +553,6 @@ Node* FunctionExtractor::CreateFunctionNode(
|
|||||||
const std::string& domain_name,
|
const std::string& domain_name,
|
||||||
const std::string& func_name) {
|
const std::string& func_name) {
|
||||||
const auto& func_scope = func_ctx.scope_key_;
|
const auto& func_scope = func_ctx.scope_key_;
|
||||||
const auto& func_scope_ctx = func_ctx.scope_ctxs_[func_scope];
|
|
||||||
GRAPH_DEBUG(
|
GRAPH_DEBUG(
|
||||||
"Create and insert local function for scope: ",
|
"Create and insert local function for scope: ",
|
||||||
func_scope->namesFromRoot());
|
func_scope->namesFromRoot());
|
||||||
@ -671,8 +670,7 @@ void FunctionExtractor::ConvertScopeToFunction(
|
|||||||
const auto func_name =
|
const auto func_name =
|
||||||
construct_unique_module_name(module_class_name.substr(pos + 1));
|
construct_unique_module_name(module_class_name.substr(pos + 1));
|
||||||
|
|
||||||
auto func_def_n =
|
CreateFunctionDefNode(func_ctx, graph, domain_name, func_name);
|
||||||
CreateFunctionDefNode(func_ctx, graph, domain_name, func_name);
|
|
||||||
|
|
||||||
// create and insert local function node to graph.
|
// create and insert local function node to graph.
|
||||||
for (const auto& it : func_ctx.scope_ctxs_) {
|
for (const auto& it : func_ctx.scope_ctxs_) {
|
||||||
|
@ -97,8 +97,7 @@ c10::optional<at::ScalarType> ONNXTypeToATenType(int32_t onnx_type) {
|
|||||||
Node* addNodeToBlock(Block* block, Symbol kind, ArrayRef<Value*> inputs) {
|
Node* addNodeToBlock(Block* block, Symbol kind, ArrayRef<Value*> inputs) {
|
||||||
auto new_node = block->appendNode(block->owningGraph()->create(kind));
|
auto new_node = block->appendNode(block->owningGraph()->create(kind));
|
||||||
for (auto input : inputs) {
|
for (auto input : inputs) {
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
new_node->addInput(input);
|
||||||
auto new_input = new_node->addInput(input);
|
|
||||||
}
|
}
|
||||||
return new_node;
|
return new_node;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <onnx/shape_inference/implementation.h>
|
#include <onnx/shape_inference/implementation.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <iterator>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -684,9 +685,8 @@ std::vector<::c10::ShapeSymbol> Broadcast(
|
|||||||
size_t rank_min = std::min(rank_0, rank_1);
|
size_t rank_min = std::min(rank_0, rank_1);
|
||||||
std::vector<::c10::ShapeSymbol> final_shape;
|
std::vector<::c10::ShapeSymbol> final_shape;
|
||||||
final_shape.reserve(rank_max);
|
final_shape.reserve(rank_max);
|
||||||
for (auto idx : c10::irange(rank_max)) {
|
std::generate_n(
|
||||||
final_shape.emplace_back(::c10::ShapeSymbol::newSymbol());
|
std::back_inserter(final_shape), rank_max, ::c10::ShapeSymbol::newSymbol);
|
||||||
}
|
|
||||||
for (auto idx : c10::irange(rank_min)) {
|
for (auto idx : c10::irange(rank_min)) {
|
||||||
const c10::ShapeSymbol& ss_shape_0 = input_shape_value_0[rank_0 - 1 - idx];
|
const c10::ShapeSymbol& ss_shape_0 = input_shape_value_0[rank_0 - 1 - idx];
|
||||||
const c10::ShapeSymbol& ss_shape_1 = input_shape_value_1[rank_1 - 1 - idx];
|
const c10::ShapeSymbol& ss_shape_1 = input_shape_value_1[rank_1 - 1 - idx];
|
||||||
@ -1366,9 +1366,10 @@ void ComputeConstant(Node* n, int opset_version) {
|
|||||||
expand_shape.value().size());
|
expand_shape.value().size());
|
||||||
if (expand_shape.value()[0] > 0) {
|
if (expand_shape.value()[0] > 0) {
|
||||||
std::vector<c10::ShapeSymbol> final_shape;
|
std::vector<c10::ShapeSymbol> final_shape;
|
||||||
for (const auto i : c10::irange(expand_shape.value()[0])) {
|
std::generate_n(
|
||||||
final_shape.emplace_back(c10::ShapeSymbol::newSymbol());
|
std::back_inserter(final_shape),
|
||||||
}
|
expand_shape.value()[0],
|
||||||
|
::c10::ShapeSymbol::newSymbol);
|
||||||
UpdateShape(n->output(), c10::SymbolicShape(final_shape));
|
UpdateShape(n->output(), c10::SymbolicShape(final_shape));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1607,7 +1608,6 @@ void SpecialPostProcess(Node* n) {
|
|||||||
// onnx Sequence type requires element type to be set.
|
// onnx Sequence type requires element type to be set.
|
||||||
// If the list to insert is empty, we set the elem type by
|
// If the list to insert is empty, we set the elem type by
|
||||||
// looking at the tensor being inserted.
|
// looking at the tensor being inserted.
|
||||||
auto list_node = n->input(0)->node();
|
|
||||||
auto seq_node = n->input(0)->node();
|
auto seq_node = n->input(0)->node();
|
||||||
auto t_type = n->input(1)->type()->cast<TensorType>();
|
auto t_type = n->input(1)->type()->cast<TensorType>();
|
||||||
|
|
||||||
|
@ -608,7 +608,7 @@ void initPythonIRBindings(PyObject* module_) {
|
|||||||
"schema",
|
"schema",
|
||||||
[](Node& n) {
|
[](Node& n) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
if (auto sch = n.maybeSchema()) {
|
if (n.maybeSchema()) {
|
||||||
ss << n.schema();
|
ss << n.schema();
|
||||||
} else {
|
} else {
|
||||||
ss << "(no schema)";
|
ss << "(no schema)";
|
||||||
|
@ -1191,8 +1191,10 @@ std::shared_ptr<SugaredValue> toSugaredValue(
|
|||||||
obj = py::getattr(obj, "op");
|
obj = py::getattr(obj, "op");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_RPC
|
||||||
bool isRpcAvailable = py::cast<bool>(
|
bool isRpcAvailable = py::cast<bool>(
|
||||||
py::module::import("torch.distributed.rpc").attr("is_available")());
|
py::module::import("torch.distributed.rpc").attr("is_available")());
|
||||||
|
#endif
|
||||||
|
|
||||||
if (auto callee = as_function(obj)) {
|
if (auto callee = as_function(obj)) {
|
||||||
return std::make_shared<FunctionValue>(callee->function_);
|
return std::make_shared<FunctionValue>(callee->function_);
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#include <c10/util/irange.h>
|
|
||||||
#include <torch/csrc/python_headers.h>
|
#include <torch/csrc/python_headers.h>
|
||||||
#include <torch/csrc/THP.h>
|
#include <torch/csrc/THP.h>
|
||||||
#include <torch/csrc/utils/python_strings.h>
|
#include <torch/csrc/utils/python_strings.h>
|
||||||
@ -10,6 +9,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
|
#include <iterator>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@ -129,9 +129,9 @@ void THPUtils_invalidArguments(PyObject *given_args, PyObject *given_kwargs,
|
|||||||
std::vector<std::string> option_strings;
|
std::vector<std::string> option_strings;
|
||||||
va_list option_list;
|
va_list option_list;
|
||||||
va_start(option_list, num_options);
|
va_start(option_list, num_options);
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
std::generate_n(std::back_inserter(option_strings), num_options, [&option_list] {
|
||||||
for(const auto i : c10::irange(num_options))
|
return va_arg(option_list, const char*);
|
||||||
option_strings.emplace_back(va_arg(option_list, const char*));
|
});
|
||||||
va_end(option_list);
|
va_end(option_list);
|
||||||
|
|
||||||
PyErr_SetString(PyExc_TypeError, torch::format_invalid_args(
|
PyErr_SetString(PyExc_TypeError, torch::format_invalid_args(
|
||||||
|
@ -55,12 +55,8 @@ void unregister_fd(int fd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void print_init_message(const char* message) {
|
void print_init_message(const char* message) {
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
|
write(1, message, strlen(message));
|
||||||
size_t unused;
|
write(1, "\n", 1);
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
|
||||||
unused = write(1, message, strlen(message));
|
|
||||||
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
|
|
||||||
unused = write(1, "\n", 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool object_exists(const char* name) {
|
bool object_exists(const char* name) {
|
||||||
|
Reference in New Issue
Block a user