Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/common/cuda_buffer.h +29 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/common/device.h +69 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/common/error.h +132 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/common/optional.h +16 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/core/context.h +101 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/core/error.h +53 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/core/listener.h +101 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/core/message.h +109 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/core/pipe.h +103 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/transport/context.h +83 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/transport/error.h +52 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/transport/ibv/error.h +53 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/transport/ibv/factory.h +28 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/transport/ibv/utility.h +31 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/transport/shm/factory.h +28 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/transport/uv/error.h +43 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/transport/uv/factory.h +28 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/transport/uv/utility.h +41 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/CudaIPCTypes.h +148 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/DataLoader.h +11 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Device.h +27 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/DeviceAccelerator.h +13 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Dtype.h +37 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/DynamicTypes.h +42 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Event.h +28 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Exceptions.h +405 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Export.h +14 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Generator.h +36 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Layout.h +31 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/MemoryFormat.h +34 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Module.h +11 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/PyInterpreter.h +18 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/PyInterpreterHooks.h +20 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/QScheme.h +32 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Size.h +21 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Storage.h +62 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/StorageMethods.h +13 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/StorageSharing.h +13 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Stream.h +33 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/THConcat.h +24 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/THP.h +25 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/TypeInfo.h +33 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Types.h +18 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/acc/Module.h +13 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/all.h +28 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/arg.h +28 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/autograd.h +10 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/cuda.h +33 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/data.h +18 -0
- miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h +59 -0
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/common/cuda_buffer.h
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*
|
| 3 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 4 |
+
* All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the BSD-style license found in the
|
| 7 |
+
* LICENSE file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#pragma once
|
| 11 |
+
|
| 12 |
+
#include <cuda_runtime.h>
|
| 13 |
+
|
| 14 |
+
#include <tensorpipe/common/device.h>
|
| 15 |
+
|
| 16 |
+
namespace tensorpipe {
|
| 17 |
+
|
| 18 |
+
struct CudaBuffer {
|
| 19 |
+
void* ptr{nullptr};
|
| 20 |
+
cudaStream_t stream{cudaStreamDefault};
|
| 21 |
+
|
| 22 |
+
Device getDevice() const;
|
| 23 |
+
};
|
| 24 |
+
|
| 25 |
+
} // namespace tensorpipe
|
| 26 |
+
|
| 27 |
+
#else
|
| 28 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 29 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/common/device.h
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*
|
| 3 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 4 |
+
* All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the BSD-style license found in the
|
| 7 |
+
* LICENSE file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#pragma once
|
| 11 |
+
|
| 12 |
+
#include <sstream>
|
| 13 |
+
#include <stdexcept>
|
| 14 |
+
#include <string>
|
| 15 |
+
|
| 16 |
+
namespace tensorpipe {
|
| 17 |
+
|
| 18 |
+
const std::string kCpuDeviceType{"cpu"};
|
| 19 |
+
const std::string kCudaDeviceType{"cuda"};
|
| 20 |
+
|
| 21 |
+
struct Device {
|
| 22 |
+
std::string type;
|
| 23 |
+
int index;
|
| 24 |
+
|
| 25 |
+
// This pointless constructor is needed to work around a bug in GCC 5.5 (and
|
| 26 |
+
// possibly other versions). It appears to be needed in the nop types that
|
| 27 |
+
// are used inside nop::Optional.
|
| 28 |
+
Device() {}
|
| 29 |
+
|
| 30 |
+
Device(std::string type, int index) : type(std::move(type)), index(index) {}
|
| 31 |
+
|
| 32 |
+
std::string toString() const {
|
| 33 |
+
std::stringstream ss;
|
| 34 |
+
ss << type << ":" << index;
|
| 35 |
+
return ss.str();
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
bool operator==(const Device& other) const {
|
| 39 |
+
return type == other.type && index == other.index;
|
| 40 |
+
}
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
} // namespace tensorpipe
|
| 44 |
+
|
| 45 |
+
namespace std {
|
| 46 |
+
|
| 47 |
+
template <>
|
| 48 |
+
struct hash<::tensorpipe::Device> {
|
| 49 |
+
size_t operator()(const ::tensorpipe::Device& device) const noexcept {
|
| 50 |
+
return std::hash<std::string>{}(device.toString());
|
| 51 |
+
}
|
| 52 |
+
};
|
| 53 |
+
|
| 54 |
+
template <>
|
| 55 |
+
struct hash<std::pair<::tensorpipe::Device, ::tensorpipe::Device>> {
|
| 56 |
+
size_t operator()(const std::pair<::tensorpipe::Device, ::tensorpipe::Device>&
|
| 57 |
+
p) const noexcept {
|
| 58 |
+
size_t h1 = std::hash<::tensorpipe::Device>{}(p.first);
|
| 59 |
+
size_t h2 = std::hash<::tensorpipe::Device>{}(p.second);
|
| 60 |
+
// Shifting one hash to avoid collisions between (a, b) and (b, a).
|
| 61 |
+
return h1 ^ (h2 << 1);
|
| 62 |
+
}
|
| 63 |
+
};
|
| 64 |
+
|
| 65 |
+
} // namespace std
|
| 66 |
+
|
| 67 |
+
#else
|
| 68 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 69 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/common/error.h
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*
|
| 3 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 4 |
+
* All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the BSD-style license found in the
|
| 7 |
+
* LICENSE file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#pragma once
|
| 11 |
+
|
| 12 |
+
#include <memory>
|
| 13 |
+
#include <string>
|
| 14 |
+
|
| 15 |
+
namespace tensorpipe {
|
| 16 |
+
|
| 17 |
+
// Base class for actual errors.
|
| 18 |
+
class BaseError {
|
| 19 |
+
public:
|
| 20 |
+
virtual ~BaseError() = default;
|
| 21 |
+
|
| 22 |
+
// Returns an explanatory string.
|
| 23 |
+
// Like `std::exception` but returns a `std::string`.
|
| 24 |
+
virtual std::string what() const = 0;
|
| 25 |
+
};
|
| 26 |
+
|
| 27 |
+
// Wrapper class for errors.
|
| 28 |
+
//
|
| 29 |
+
// Background: we wish to not use exceptions yet need an error
|
| 30 |
+
// representation that can propagate across function and thread
|
| 31 |
+
// boundaries. This representation must be copyable (so we can store
|
| 32 |
+
// and return it at a later point in time) and retain downstream type
|
| 33 |
+
// information. This implies a heap allocation because it's the
|
| 34 |
+
// easiest way to deal with variable size objects (barring a union of
|
| 35 |
+
// all downstream error classes and a lot of custom code). Instead of
|
| 36 |
+
// passing a shared_ptr around directly, we use this wrapper class to
|
| 37 |
+
// keep implementation details hidden from calling code.
|
| 38 |
+
//
|
| 39 |
+
class Error final {
|
| 40 |
+
public:
|
| 41 |
+
// Constant instance that indicates success.
|
| 42 |
+
static const Error kSuccess;
|
| 43 |
+
|
| 44 |
+
// Default constructor for error that is not an error.
|
| 45 |
+
Error() {}
|
| 46 |
+
|
| 47 |
+
Error(std::shared_ptr<BaseError> error, std::string file, int line)
|
| 48 |
+
: error_(std::move(error)), file_(std::move(file)), line_(line) {}
|
| 49 |
+
|
| 50 |
+
~Error() = default;
|
| 51 |
+
|
| 52 |
+
// Converting to boolean means checking if there is an error. This
|
| 53 |
+
// means we don't need to use an `std::optional` and allows for a
|
| 54 |
+
// snippet like the following:
|
| 55 |
+
//
|
| 56 |
+
// if (error) {
|
| 57 |
+
// // Deal with it.
|
| 58 |
+
// }
|
| 59 |
+
//
|
| 60 |
+
operator bool() const {
|
| 61 |
+
return static_cast<bool>(error_);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
template <typename T>
|
| 65 |
+
std::shared_ptr<T> castToType() const {
|
| 66 |
+
return std::dynamic_pointer_cast<T>(error_);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
template <typename T>
|
| 70 |
+
bool isOfType() const {
|
| 71 |
+
return castToType<T>() != nullptr;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
// Like `std::exception` but returns a `std::string`.
|
| 75 |
+
std::string what() const;
|
| 76 |
+
|
| 77 |
+
private:
|
| 78 |
+
std::shared_ptr<BaseError> error_;
|
| 79 |
+
std::string file_;
|
| 80 |
+
int line_;
|
| 81 |
+
};
|
| 82 |
+
|
| 83 |
+
class SystemError final : public BaseError {
|
| 84 |
+
public:
|
| 85 |
+
explicit SystemError(const char* syscall, int error)
|
| 86 |
+
: syscall_(syscall), error_(error) {}
|
| 87 |
+
|
| 88 |
+
std::string what() const override;
|
| 89 |
+
|
| 90 |
+
int errorCode() const;
|
| 91 |
+
|
| 92 |
+
private:
|
| 93 |
+
const char* syscall_;
|
| 94 |
+
const int error_;
|
| 95 |
+
};
|
| 96 |
+
|
| 97 |
+
class ShortReadError final : public BaseError {
|
| 98 |
+
public:
|
| 99 |
+
ShortReadError(ssize_t expected, ssize_t actual)
|
| 100 |
+
: expected_(expected), actual_(actual) {}
|
| 101 |
+
|
| 102 |
+
std::string what() const override;
|
| 103 |
+
|
| 104 |
+
private:
|
| 105 |
+
const ssize_t expected_;
|
| 106 |
+
const ssize_t actual_;
|
| 107 |
+
};
|
| 108 |
+
|
| 109 |
+
class ShortWriteError final : public BaseError {
|
| 110 |
+
public:
|
| 111 |
+
ShortWriteError(ssize_t expected, ssize_t actual)
|
| 112 |
+
: expected_(expected), actual_(actual) {}
|
| 113 |
+
|
| 114 |
+
std::string what() const override;
|
| 115 |
+
|
| 116 |
+
private:
|
| 117 |
+
const ssize_t expected_;
|
| 118 |
+
const ssize_t actual_;
|
| 119 |
+
};
|
| 120 |
+
|
| 121 |
+
class EOFError final : public BaseError {
|
| 122 |
+
public:
|
| 123 |
+
EOFError() {}
|
| 124 |
+
|
| 125 |
+
std::string what() const override;
|
| 126 |
+
};
|
| 127 |
+
|
| 128 |
+
} // namespace tensorpipe
|
| 129 |
+
|
| 130 |
+
#else
|
| 131 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 132 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/common/optional.h
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <optional>
|
| 5 |
+
|
| 6 |
+
namespace tensorpipe {
|
| 7 |
+
|
| 8 |
+
using std::optional;
|
| 9 |
+
using std::nullopt;
|
| 10 |
+
|
| 11 |
+
} // namespace tensorpipe
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
#else
|
| 15 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 16 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/core/context.h
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*
|
| 3 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 4 |
+
* All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the BSD-style license found in the
|
| 7 |
+
* LICENSE file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#pragma once
|
| 11 |
+
|
| 12 |
+
#include <memory>
|
| 13 |
+
#include <string>
|
| 14 |
+
#include <utility>
|
| 15 |
+
#include <vector>
|
| 16 |
+
|
| 17 |
+
#include <tensorpipe/transport/context.h>
|
| 18 |
+
|
| 19 |
+
#include <tensorpipe/channel/context.h>
|
| 20 |
+
|
| 21 |
+
namespace tensorpipe {
|
| 22 |
+
|
| 23 |
+
class ContextImpl;
|
| 24 |
+
class Listener;
|
| 25 |
+
class Pipe;
|
| 26 |
+
|
| 27 |
+
class ContextOptions {
|
| 28 |
+
public:
|
| 29 |
+
// The name should be a semantically meaningful description of this context.
|
| 30 |
+
// It will only be used for logging and debugging purposes, to identify the
|
| 31 |
+
// endpoints of a pipe.
|
| 32 |
+
ContextOptions&& name(std::string name) && {
|
| 33 |
+
name_ = std::move(name);
|
| 34 |
+
return std::move(*this);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
private:
|
| 38 |
+
std::string name_;
|
| 39 |
+
|
| 40 |
+
friend ContextImpl;
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
class PipeOptions {
|
| 44 |
+
public:
|
| 45 |
+
// The name should be a semantically meaningful description of the context
|
| 46 |
+
// that the pipe is connecting to. It will only be used for logging and
|
| 47 |
+
// debugging purposes, to identify the endpoints of a pipe.
|
| 48 |
+
PipeOptions&& remoteName(std::string remoteName) && {
|
| 49 |
+
remoteName_ = std::move(remoteName);
|
| 50 |
+
return std::move(*this);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
private:
|
| 54 |
+
std::string remoteName_;
|
| 55 |
+
|
| 56 |
+
friend ContextImpl;
|
| 57 |
+
};
|
| 58 |
+
|
| 59 |
+
class Context final {
|
| 60 |
+
public:
|
| 61 |
+
explicit Context(ContextOptions opts = ContextOptions());
|
| 62 |
+
|
| 63 |
+
void registerTransport(
|
| 64 |
+
int64_t priority,
|
| 65 |
+
std::string transport,
|
| 66 |
+
std::shared_ptr<transport::Context> context);
|
| 67 |
+
|
| 68 |
+
void registerChannel(
|
| 69 |
+
int64_t priority,
|
| 70 |
+
std::string channel,
|
| 71 |
+
std::shared_ptr<channel::Context> context);
|
| 72 |
+
|
| 73 |
+
std::shared_ptr<Listener> listen(const std::vector<std::string>& urls);
|
| 74 |
+
|
| 75 |
+
std::shared_ptr<Pipe> connect(
|
| 76 |
+
const std::string& url,
|
| 77 |
+
PipeOptions opts = PipeOptions());
|
| 78 |
+
|
| 79 |
+
// Put the context in a terminal state, in turn closing all of its pipes and
|
| 80 |
+
// listeners, and release its resources. This may be done asynchronously, in
|
| 81 |
+
// background.
|
| 82 |
+
void close();
|
| 83 |
+
|
| 84 |
+
// Wait for all resources to be released and all background activity to stop.
|
| 85 |
+
void join();
|
| 86 |
+
|
| 87 |
+
~Context();
|
| 88 |
+
|
| 89 |
+
private:
|
| 90 |
+
// The implementation is managed by a shared_ptr because each child object
|
| 91 |
+
// will also hold a shared_ptr to it. However, its lifetime is tied to the one
|
| 92 |
+
// of this public object since when the latter is destroyed the implementation
|
| 93 |
+
// is closed and joined.
|
| 94 |
+
const std::shared_ptr<ContextImpl> impl_;
|
| 95 |
+
};
|
| 96 |
+
|
| 97 |
+
} // namespace tensorpipe
|
| 98 |
+
|
| 99 |
+
#else
|
| 100 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 101 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/core/error.h
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*
|
| 3 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 4 |
+
* All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the BSD-style license found in the
|
| 7 |
+
* LICENSE file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#pragma once
|
| 11 |
+
|
| 12 |
+
#include <string>
|
| 13 |
+
|
| 14 |
+
#include <tensorpipe/common/error.h>
|
| 15 |
+
|
| 16 |
+
namespace tensorpipe {
|
| 17 |
+
|
| 18 |
+
class LogicError final : public BaseError {
|
| 19 |
+
public:
|
| 20 |
+
explicit LogicError(std::string reason) : reason_(std::move(reason)) {}
|
| 21 |
+
|
| 22 |
+
std::string what() const override;
|
| 23 |
+
|
| 24 |
+
private:
|
| 25 |
+
const std::string reason_;
|
| 26 |
+
};
|
| 27 |
+
|
| 28 |
+
class ContextClosedError final : public BaseError {
|
| 29 |
+
public:
|
| 30 |
+
explicit ContextClosedError() {}
|
| 31 |
+
|
| 32 |
+
std::string what() const override;
|
| 33 |
+
};
|
| 34 |
+
|
| 35 |
+
class ListenerClosedError final : public BaseError {
|
| 36 |
+
public:
|
| 37 |
+
explicit ListenerClosedError() {}
|
| 38 |
+
|
| 39 |
+
std::string what() const override;
|
| 40 |
+
};
|
| 41 |
+
|
| 42 |
+
class PipeClosedError final : public BaseError {
|
| 43 |
+
public:
|
| 44 |
+
explicit PipeClosedError() {}
|
| 45 |
+
|
| 46 |
+
std::string what() const override;
|
| 47 |
+
};
|
| 48 |
+
|
| 49 |
+
} // namespace tensorpipe
|
| 50 |
+
|
| 51 |
+
#else
|
| 52 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 53 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/core/listener.h
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*
|
| 3 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 4 |
+
* All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the BSD-style license found in the
|
| 7 |
+
* LICENSE file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#pragma once
|
| 11 |
+
|
| 12 |
+
#include <functional>
|
| 13 |
+
#include <map>
|
| 14 |
+
#include <memory>
|
| 15 |
+
#include <string>
|
| 16 |
+
#include <vector>
|
| 17 |
+
|
| 18 |
+
#include <tensorpipe/common/error.h>
|
| 19 |
+
|
| 20 |
+
namespace tensorpipe {
|
| 21 |
+
|
| 22 |
+
class ContextImpl;
|
| 23 |
+
class ListenerImpl;
|
| 24 |
+
class Pipe;
|
| 25 |
+
|
| 26 |
+
// The listener.
|
| 27 |
+
//
|
| 28 |
+
// Listeners are used to produce pipes. Depending on the type of the
|
| 29 |
+
// context, listeners may use a variety of addresses to listen on. For
|
| 30 |
+
// example, for TCP/IP sockets they listen on an IPv4 or IPv6 address,
|
| 31 |
+
// for Unix domain sockets they listen on a path, etcetera.
|
| 32 |
+
//
|
| 33 |
+
// A pipe can only be accepted from this listener after it has been
|
| 34 |
+
// fully established. This means that both its connection and all its
|
| 35 |
+
// side channels have been established.
|
| 36 |
+
//
|
| 37 |
+
class Listener final {
|
| 38 |
+
// Use the passkey idiom to allow make_shared to call what should be a private
|
| 39 |
+
// constructor. See https://abseil.io/tips/134 for more information.
|
| 40 |
+
struct ConstructorToken {};
|
| 41 |
+
|
| 42 |
+
public:
|
| 43 |
+
Listener(
|
| 44 |
+
ConstructorToken token,
|
| 45 |
+
std::shared_ptr<ContextImpl> context,
|
| 46 |
+
std::string id,
|
| 47 |
+
const std::vector<std::string>& urls);
|
| 48 |
+
|
| 49 |
+
//
|
| 50 |
+
// Entry points for user code
|
| 51 |
+
//
|
| 52 |
+
|
| 53 |
+
using accept_callback_fn =
|
| 54 |
+
std::function<void(const Error&, std::shared_ptr<Pipe>)>;
|
| 55 |
+
|
| 56 |
+
void accept(accept_callback_fn fn);
|
| 57 |
+
|
| 58 |
+
// Returns map with the materialized address of listeners by transport.
|
| 59 |
+
//
|
| 60 |
+
// If you don't bind a transport listener to a specific port or address, it
|
| 61 |
+
// may generate its address automatically. Then, in order to connect to the
|
| 62 |
+
// listener, the user must use a separate mechanism to communicate the
|
| 63 |
+
// materialized address to whoever wants to connect.
|
| 64 |
+
//
|
| 65 |
+
const std::map<std::string, std::string>& addresses() const;
|
| 66 |
+
|
| 67 |
+
// Returns materialized address for specific transport.
|
| 68 |
+
//
|
| 69 |
+
// See `addresses()` for more information.
|
| 70 |
+
//
|
| 71 |
+
const std::string& address(const std::string& transport) const;
|
| 72 |
+
|
| 73 |
+
// Returns URL with materialized address for specific transport.
|
| 74 |
+
//
|
| 75 |
+
// See `addresses()` for more information.
|
| 76 |
+
//
|
| 77 |
+
std::string url(const std::string& transport) const;
|
| 78 |
+
|
| 79 |
+
// Put the listener in a terminal state, aborting its pending operations and
|
| 80 |
+
// rejecting future ones, and release its resrouces. This may be carried out
|
| 81 |
+
// asynchronously, in background. Since the pipes may occasionally use the
|
| 82 |
+
// listener to open new connections, closing a listener may trigger errors
|
| 83 |
+
// in the pipes.
|
| 84 |
+
void close();
|
| 85 |
+
|
| 86 |
+
~Listener();
|
| 87 |
+
|
| 88 |
+
private:
|
| 89 |
+
// Using a shared_ptr allows us to detach the lifetime of the implementation
|
| 90 |
+
// from the public object's one and perform the destruction asynchronously.
|
| 91 |
+
const std::shared_ptr<ListenerImpl> impl_;
|
| 92 |
+
|
| 93 |
+
// Allow context to access constructor token.
|
| 94 |
+
friend ContextImpl;
|
| 95 |
+
};
|
| 96 |
+
|
| 97 |
+
} // namespace tensorpipe
|
| 98 |
+
|
| 99 |
+
#else
|
| 100 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 101 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/core/message.h
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*
|
| 3 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 4 |
+
* All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the BSD-style license found in the
|
| 7 |
+
* LICENSE file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#pragma once
|
| 11 |
+
|
| 12 |
+
#include <cstddef>
|
| 13 |
+
#include <string>
|
| 14 |
+
#include <vector>
|
| 15 |
+
|
| 16 |
+
#include <tensorpipe/common/buffer.h>
|
| 17 |
+
#include <tensorpipe/common/optional.h>
|
| 18 |
+
|
| 19 |
+
namespace tensorpipe {
|
| 20 |
+
|
| 21 |
+
// Messages consist of a primary buffer and zero or more separate
|
| 22 |
+
// buffers. The primary buffer is always a host-side memory region that
|
| 23 |
+
// contains a serialized version of the message we're dealing with. This
|
| 24 |
+
// serialized message, in turn, may have references to the separate
|
| 25 |
+
// buffers that accompany the primary buffer. These separate buffers may
|
| 26 |
+
// point to any type of memory, host-side or device-side.
|
| 27 |
+
//
|
| 28 |
+
class Message final {
|
| 29 |
+
public:
|
| 30 |
+
std::string metadata;
|
| 31 |
+
|
| 32 |
+
struct Payload {
|
| 33 |
+
void* data{nullptr};
|
| 34 |
+
size_t length{0};
|
| 35 |
+
|
| 36 |
+
// Users may include arbitrary metadata in the following fields.
|
| 37 |
+
// This may contain allocation hints for the receiver, for example.
|
| 38 |
+
std::string metadata;
|
| 39 |
+
};
|
| 40 |
+
|
| 41 |
+
// Holds the payloads that are transferred over the primary connection.
|
| 42 |
+
std::vector<Payload> payloads;
|
| 43 |
+
|
| 44 |
+
struct Tensor {
|
| 45 |
+
tensorpipe::Buffer buffer;
|
| 46 |
+
size_t length{0};
|
| 47 |
+
|
| 48 |
+
// Users may optionally specify the target device, on which the receiver
|
| 49 |
+
// should allocate memory for this tensor. If left unset, the receiver will
|
| 50 |
+
// choose one at their convenience.
|
| 51 |
+
optional<Device> targetDevice;
|
| 52 |
+
|
| 53 |
+
// Users may include arbitrary metadata in the following field.
|
| 54 |
+
// This may contain allocation hints for the receiver, for example.
|
| 55 |
+
std::string metadata;
|
| 56 |
+
};
|
| 57 |
+
|
| 58 |
+
// Holds the tensors that are offered to the side channels.
|
| 59 |
+
std::vector<Tensor> tensors;
|
| 60 |
+
};
|
| 61 |
+
|
| 62 |
+
// Descriptors consist of metadata required by the receiver to allocate memory
|
| 63 |
+
// for an incoming message.
|
| 64 |
+
class Descriptor final {
|
| 65 |
+
public:
|
| 66 |
+
std::string metadata;
|
| 67 |
+
|
| 68 |
+
struct Payload {
|
| 69 |
+
size_t length{0};
|
| 70 |
+
std::string metadata;
|
| 71 |
+
};
|
| 72 |
+
std::vector<Payload> payloads;
|
| 73 |
+
|
| 74 |
+
struct Tensor {
|
| 75 |
+
size_t length{0};
|
| 76 |
+
|
| 77 |
+
// This is the sender-side device from which this tensor is being sent.
|
| 78 |
+
Device sourceDevice;
|
| 79 |
+
|
| 80 |
+
// The sender may optionally specify a target device, in which case the
|
| 81 |
+
// receiver must allocate memory for this tensor on the specified device.
|
| 82 |
+
optional<Device> targetDevice;
|
| 83 |
+
|
| 84 |
+
std::string metadata;
|
| 85 |
+
};
|
| 86 |
+
std::vector<Tensor> tensors;
|
| 87 |
+
};
|
| 88 |
+
|
| 89 |
+
// Allocations consist of actual memory allocations provided by the receiver for
|
| 90 |
+
// an incoming message. They must match the length and target devices specified
|
| 91 |
+
// in the corresponding Descriptor.
|
| 92 |
+
class Allocation final {
|
| 93 |
+
public:
|
| 94 |
+
struct Payload {
|
| 95 |
+
void* data{nullptr};
|
| 96 |
+
};
|
| 97 |
+
std::vector<Payload> payloads;
|
| 98 |
+
|
| 99 |
+
struct Tensor {
|
| 100 |
+
tensorpipe::Buffer buffer;
|
| 101 |
+
};
|
| 102 |
+
std::vector<Tensor> tensors;
|
| 103 |
+
};
|
| 104 |
+
|
| 105 |
+
} // namespace tensorpipe
|
| 106 |
+
|
| 107 |
+
#else
|
| 108 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 109 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/core/pipe.h
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*
|
| 3 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 4 |
+
* All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the BSD-style license found in the
|
| 7 |
+
* LICENSE file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#pragma once
|
| 11 |
+
|
| 12 |
+
#include <functional>
|
| 13 |
+
#include <memory>
|
| 14 |
+
#include <string>
|
| 15 |
+
|
| 16 |
+
#include <tensorpipe/common/error.h>
|
| 17 |
+
#include <tensorpipe/core/message.h>
|
| 18 |
+
#include <tensorpipe/transport/context.h>
|
| 19 |
+
|
| 20 |
+
namespace tensorpipe {
|
| 21 |
+
|
| 22 |
+
class ContextImpl;
|
| 23 |
+
class ListenerImpl;
|
| 24 |
+
class PipeImpl;
|
| 25 |
+
|
| 26 |
+
// The pipe.
|
| 27 |
+
//
|
| 28 |
+
// Pipes represent a set of connections between a pair of processes.
|
| 29 |
+
// Unlike POSIX pipes, they are message oriented instead of byte
|
| 30 |
+
// oriented. Messages that are sent through the pipe may use whatever
|
| 31 |
+
// channels are at their disposal to make it happen. If the pair of
|
| 32 |
+
// processes happen to be colocated on the same machine, they may
|
| 33 |
+
// leverage a region of shared memory to communicate the primary
|
| 34 |
+
// buffer of a message. Secondary buffers may use shared memory as
|
| 35 |
+
// well, if they're located in CPU memory, or use a CUDA device to
|
| 36 |
+
// device copy if they're located in NVIDIA GPU memory. If the pair is
|
| 37 |
+
// located across the world, they may simply use a set of TCP
|
| 38 |
+
// connections to communicate.
|
| 39 |
+
//
|
| 40 |
+
class Pipe final {
|
| 41 |
+
// Use the passkey idiom to allow make_shared to call what should be a private
|
| 42 |
+
// constructor. See https://abseil.io/tips/134 for more information.
|
| 43 |
+
struct ConstructorToken {};
|
| 44 |
+
|
| 45 |
+
public:
|
| 46 |
+
//
|
| 47 |
+
// Initialization
|
| 48 |
+
//
|
| 49 |
+
|
| 50 |
+
Pipe(
|
| 51 |
+
ConstructorToken token,
|
| 52 |
+
std::shared_ptr<ContextImpl> context,
|
| 53 |
+
std::string id,
|
| 54 |
+
std::string remoteName,
|
| 55 |
+
const std::string& url);
|
| 56 |
+
|
| 57 |
+
Pipe(ConstructorToken token, std::shared_ptr<PipeImpl> impl);
|
| 58 |
+
|
| 59 |
+
//
|
| 60 |
+
// Entry points for user code
|
| 61 |
+
//
|
| 62 |
+
|
| 63 |
+
using read_descriptor_callback_fn =
|
| 64 |
+
std::function<void(const Error&, Descriptor)>;
|
| 65 |
+
|
| 66 |
+
void readDescriptor(read_descriptor_callback_fn fn);
|
| 67 |
+
|
| 68 |
+
using read_callback_fn = std::function<void(const Error&)>;
|
| 69 |
+
|
| 70 |
+
void read(Allocation allocation, read_callback_fn fn);
|
| 71 |
+
|
| 72 |
+
using write_callback_fn = std::function<void(const Error&)>;
|
| 73 |
+
|
| 74 |
+
void write(Message message, write_callback_fn fn);
|
| 75 |
+
|
| 76 |
+
// Retrieve the user-defined name that was given to the constructor of the
|
| 77 |
+
// context on the remote side, if any (if not, this will be the empty string).
|
| 78 |
+
// This is intended to help in logging and debugging only.
|
| 79 |
+
const std::string& getRemoteName();
|
| 80 |
+
|
| 81 |
+
// Put the pipe in a terminal state, aborting its pending operations and
|
| 82 |
+
// rejecting future ones, and release its resrouces. This may be carried out
|
| 83 |
+
// asynchronously, in background.
|
| 84 |
+
void close();
|
| 85 |
+
|
| 86 |
+
~Pipe();
|
| 87 |
+
|
| 88 |
+
private:
|
| 89 |
+
// Using a shared_ptr allows us to detach the lifetime of the implementation
|
| 90 |
+
// from the public object's one and perform the destruction asynchronously.
|
| 91 |
+
const std::shared_ptr<PipeImpl> impl_;
|
| 92 |
+
|
| 93 |
+
// Allow context to access constructor token.
|
| 94 |
+
friend ContextImpl;
|
| 95 |
+
// Allow listener to access constructor token.
|
| 96 |
+
friend ListenerImpl;
|
| 97 |
+
};
|
| 98 |
+
|
| 99 |
+
} // namespace tensorpipe
|
| 100 |
+
|
| 101 |
+
#else
|
| 102 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 103 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/transport/context.h
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*
|
| 3 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 4 |
+
* All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the BSD-style license found in the
|
| 7 |
+
* LICENSE file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#pragma once
|
| 11 |
+
|
| 12 |
+
#include <memory>
|
| 13 |
+
#include <string>
|
| 14 |
+
|
| 15 |
+
namespace tensorpipe {
|
| 16 |
+
namespace transport {
|
| 17 |
+
|
| 18 |
+
class Connection;
|
| 19 |
+
class Listener;
|
| 20 |
+
|
| 21 |
+
class Context {
|
| 22 |
+
public:
|
| 23 |
+
virtual std::shared_ptr<Connection> connect(std::string addr) = 0;
|
| 24 |
+
|
| 25 |
+
virtual std::shared_ptr<Listener> listen(std::string addr) = 0;
|
| 26 |
+
|
| 27 |
+
// Return whether the context is able to operate correctly.
|
| 28 |
+
//
|
| 29 |
+
// Some transport types may be unable to perform as intended under
|
| 30 |
+
// some circumstances (e.g., specialized hardware unavailable, lack
|
| 31 |
+
// of permissions). They can report it through this method in order
|
| 32 |
+
// for the core context to avoid registering them in the first place.
|
| 33 |
+
//
|
| 34 |
+
virtual bool isViable() const = 0;
|
| 35 |
+
|
| 36 |
+
// Return string to describe the domain for this context.
|
| 37 |
+
//
|
| 38 |
+
// Two processes with a context of the same type can connect to each
|
| 39 |
+
// other if one side's domain descriptor is "accepted" by the other
|
| 40 |
+
// one, using the canCommunicateWithRemote method below. That method
|
| 41 |
+
// must be symmetric, and unless overridden defaults to string
|
| 42 |
+
// comparison.
|
| 43 |
+
//
|
| 44 |
+
// For example, for a transport that leverages TCP/IP, this may be
|
| 45 |
+
// as simple as the address family (assuming we can route between
|
| 46 |
+
// any two processes). For a transport that leverages shared memory,
|
| 47 |
+
// this descriptor must uniquely identify the machine, such that
|
| 48 |
+
// only co-located processes generate the same domain descriptor.
|
| 49 |
+
//
|
| 50 |
+
virtual const std::string& domainDescriptor() const = 0;
|
| 51 |
+
|
| 52 |
+
// Compare local and remote domain descriptor for compatibility.
|
| 53 |
+
//
|
| 54 |
+
// Determine whether a connection can be opened between this context
|
| 55 |
+
// and a remote one that has the given domain descriptor. This
|
| 56 |
+
// function needs to be symmetric: if we called this method on the
|
| 57 |
+
// remote context with the local descriptor we should get the same
|
| 58 |
+
// answer. Unless overridden it defaults to string comparison.
|
| 59 |
+
//
|
| 60 |
+
virtual bool canCommunicateWithRemote(
|
| 61 |
+
const std::string& remoteDomainDescriptor) const {
|
| 62 |
+
return domainDescriptor() == remoteDomainDescriptor;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
// Tell the context what its identifier is.
|
| 66 |
+
//
|
| 67 |
+
// This is only supposed to be called from the high-level context or from
|
| 68 |
+
// channel contexts. It will only used for logging and debugging purposes.
|
| 69 |
+
virtual void setId(std::string id) = 0;
|
| 70 |
+
|
| 71 |
+
virtual void close() = 0;
|
| 72 |
+
|
| 73 |
+
virtual void join() = 0;
|
| 74 |
+
|
| 75 |
+
virtual ~Context() = default;
|
| 76 |
+
};
|
| 77 |
+
|
| 78 |
+
} // namespace transport
|
| 79 |
+
} // namespace tensorpipe
|
| 80 |
+
|
| 81 |
+
#else
|
| 82 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 83 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/transport/error.h
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*
|
| 3 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 4 |
+
* All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the BSD-style license found in the
|
| 7 |
+
* LICENSE file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#pragma once
|
| 11 |
+
|
| 12 |
+
#include <string>
|
| 13 |
+
|
| 14 |
+
#include <tensorpipe/common/error.h>
|
| 15 |
+
|
| 16 |
+
namespace tensorpipe {
|
| 17 |
+
namespace transport {
|
| 18 |
+
|
| 19 |
+
class ContextClosedError final : public BaseError {
|
| 20 |
+
public:
|
| 21 |
+
ContextClosedError() {}
|
| 22 |
+
|
| 23 |
+
std::string what() const override;
|
| 24 |
+
};
|
| 25 |
+
|
| 26 |
+
class ListenerClosedError final : public BaseError {
|
| 27 |
+
public:
|
| 28 |
+
ListenerClosedError() {}
|
| 29 |
+
|
| 30 |
+
std::string what() const override;
|
| 31 |
+
};
|
| 32 |
+
|
| 33 |
+
class ConnectionClosedError final : public BaseError {
|
| 34 |
+
public:
|
| 35 |
+
ConnectionClosedError() {}
|
| 36 |
+
|
| 37 |
+
std::string what() const override;
|
| 38 |
+
};
|
| 39 |
+
|
| 40 |
+
class ContextNotViableError final : public BaseError {
|
| 41 |
+
public:
|
| 42 |
+
ContextNotViableError() {}
|
| 43 |
+
|
| 44 |
+
std::string what() const override;
|
| 45 |
+
};
|
| 46 |
+
|
| 47 |
+
} // namespace transport
|
| 48 |
+
} // namespace tensorpipe
|
| 49 |
+
|
| 50 |
+
#else
|
| 51 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 52 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/transport/ibv/error.h
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*
|
| 3 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 4 |
+
* All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the BSD-style license found in the
|
| 7 |
+
* LICENSE file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#pragma once
|
| 11 |
+
|
| 12 |
+
#include <string>
|
| 13 |
+
|
| 14 |
+
#include <tensorpipe/transport/error.h>
|
| 15 |
+
|
| 16 |
+
namespace tensorpipe {
|
| 17 |
+
namespace transport {
|
| 18 |
+
namespace ibv {
|
| 19 |
+
|
| 20 |
+
class IbvError final : public BaseError {
|
| 21 |
+
public:
|
| 22 |
+
explicit IbvError(std::string error) : error_(error) {}
|
| 23 |
+
|
| 24 |
+
std::string what() const override;
|
| 25 |
+
|
| 26 |
+
private:
|
| 27 |
+
std::string error_;
|
| 28 |
+
};
|
| 29 |
+
|
| 30 |
+
class GetaddrinfoError final : public BaseError {
|
| 31 |
+
public:
|
| 32 |
+
explicit GetaddrinfoError(int error) : error_(error) {}
|
| 33 |
+
|
| 34 |
+
std::string what() const override;
|
| 35 |
+
|
| 36 |
+
private:
|
| 37 |
+
int error_;
|
| 38 |
+
};
|
| 39 |
+
|
| 40 |
+
class NoAddrFoundError final : public BaseError {
|
| 41 |
+
public:
|
| 42 |
+
NoAddrFoundError() {}
|
| 43 |
+
|
| 44 |
+
std::string what() const override;
|
| 45 |
+
};
|
| 46 |
+
|
| 47 |
+
} // namespace ibv
|
| 48 |
+
} // namespace transport
|
| 49 |
+
} // namespace tensorpipe
|
| 50 |
+
|
| 51 |
+
#else
|
| 52 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 53 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/transport/ibv/factory.h
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*
|
| 3 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 4 |
+
* All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the BSD-style license found in the
|
| 7 |
+
* LICENSE file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#pragma once
|
| 11 |
+
|
| 12 |
+
#include <memory>
|
| 13 |
+
|
| 14 |
+
#include <tensorpipe/transport/context.h>
|
| 15 |
+
|
| 16 |
+
namespace tensorpipe {
|
| 17 |
+
namespace transport {
|
| 18 |
+
namespace ibv {
|
| 19 |
+
|
| 20 |
+
std::shared_ptr<Context> create();
|
| 21 |
+
|
| 22 |
+
} // namespace ibv
|
| 23 |
+
} // namespace transport
|
| 24 |
+
} // namespace tensorpipe
|
| 25 |
+
|
| 26 |
+
#else
|
| 27 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 28 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/transport/ibv/utility.h
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*
|
| 3 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 4 |
+
* All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the BSD-style license found in the
|
| 7 |
+
* LICENSE file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#pragma once
|
| 11 |
+
|
| 12 |
+
#include <string>
|
| 13 |
+
#include <tuple>
|
| 14 |
+
|
| 15 |
+
#include <tensorpipe/common/error.h>
|
| 16 |
+
|
| 17 |
+
namespace tensorpipe {
|
| 18 |
+
namespace transport {
|
| 19 |
+
namespace ibv {
|
| 20 |
+
|
| 21 |
+
std::tuple<Error, std::string> lookupAddrForIface(std::string iface);
|
| 22 |
+
|
| 23 |
+
std::tuple<Error, std::string> lookupAddrForHostname();
|
| 24 |
+
|
| 25 |
+
} // namespace ibv
|
| 26 |
+
} // namespace transport
|
| 27 |
+
} // namespace tensorpipe
|
| 28 |
+
|
| 29 |
+
#else
|
| 30 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 31 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/transport/shm/factory.h
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*
|
| 3 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 4 |
+
* All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the BSD-style license found in the
|
| 7 |
+
* LICENSE file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#pragma once
|
| 11 |
+
|
| 12 |
+
#include <memory>
|
| 13 |
+
|
| 14 |
+
#include <tensorpipe/transport/context.h>
|
| 15 |
+
|
| 16 |
+
namespace tensorpipe {
|
| 17 |
+
namespace transport {
|
| 18 |
+
namespace shm {
|
| 19 |
+
|
| 20 |
+
std::shared_ptr<Context> create();
|
| 21 |
+
|
| 22 |
+
} // namespace shm
|
| 23 |
+
} // namespace transport
|
| 24 |
+
} // namespace tensorpipe
|
| 25 |
+
|
| 26 |
+
#else
|
| 27 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 28 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/transport/uv/error.h
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*
|
| 3 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 4 |
+
* All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the BSD-style license found in the
|
| 7 |
+
* LICENSE file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#pragma once
|
| 11 |
+
|
| 12 |
+
#include <string>
|
| 13 |
+
|
| 14 |
+
#include <tensorpipe/transport/error.h>
|
| 15 |
+
|
| 16 |
+
namespace tensorpipe {
|
| 17 |
+
namespace transport {
|
| 18 |
+
namespace uv {
|
| 19 |
+
|
| 20 |
+
class UVError final : public BaseError {
|
| 21 |
+
public:
|
| 22 |
+
explicit UVError(int error) : error_(error) {}
|
| 23 |
+
|
| 24 |
+
std::string what() const override;
|
| 25 |
+
|
| 26 |
+
private:
|
| 27 |
+
int error_;
|
| 28 |
+
};
|
| 29 |
+
|
| 30 |
+
class NoAddrFoundError final : public BaseError {
|
| 31 |
+
public:
|
| 32 |
+
NoAddrFoundError() {}
|
| 33 |
+
|
| 34 |
+
std::string what() const override;
|
| 35 |
+
};
|
| 36 |
+
|
| 37 |
+
} // namespace uv
|
| 38 |
+
} // namespace transport
|
| 39 |
+
} // namespace tensorpipe
|
| 40 |
+
|
| 41 |
+
#else
|
| 42 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 43 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/transport/uv/factory.h
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*
|
| 3 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 4 |
+
* All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the BSD-style license found in the
|
| 7 |
+
* LICENSE file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#pragma once
|
| 11 |
+
|
| 12 |
+
#include <memory>
|
| 13 |
+
|
| 14 |
+
#include <tensorpipe/transport/context.h>
|
| 15 |
+
|
| 16 |
+
namespace tensorpipe {
|
| 17 |
+
namespace transport {
|
| 18 |
+
namespace uv {
|
| 19 |
+
|
| 20 |
+
std::shared_ptr<Context> create();
|
| 21 |
+
|
| 22 |
+
} // namespace uv
|
| 23 |
+
} // namespace transport
|
| 24 |
+
} // namespace tensorpipe
|
| 25 |
+
|
| 26 |
+
#else
|
| 27 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 28 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/tensorpipe/transport/uv/utility.h
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*
|
| 3 |
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 4 |
+
* All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the BSD-style license found in the
|
| 7 |
+
* LICENSE file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#pragma once
|
| 11 |
+
|
| 12 |
+
#include <string>
|
| 13 |
+
#include <tuple>
|
| 14 |
+
|
| 15 |
+
#include <sys/socket.h>
|
| 16 |
+
|
| 17 |
+
#include <tensorpipe/common/error.h>
|
| 18 |
+
#include <tensorpipe/common/optional.h>
|
| 19 |
+
|
| 20 |
+
namespace tensorpipe {
|
| 21 |
+
namespace transport {
|
| 22 |
+
namespace uv {
|
| 23 |
+
|
| 24 |
+
std::tuple<Error, std::string> lookupAddrForIface(std::string iface);
|
| 25 |
+
|
| 26 |
+
std::tuple<Error, std::string> lookupAddrForHostname();
|
| 27 |
+
|
| 28 |
+
// Try to replicate the same logic used by NCCL to find a node's own address.
|
| 29 |
+
// Roughly, it returns the "first" usable address it can find, and prioritizes
|
| 30 |
+
// the interfaces with an `ib` prefix and de-prioritizes those with a `docker`
|
| 31 |
+
// or `lo` prefix. It can optionally only return only IPv4 or IPv4 addresses.
|
| 32 |
+
std::tuple<Error, std::string> lookupAddrLikeNccl(
|
| 33 |
+
optional<sa_family_t> familyFilter = nullopt);
|
| 34 |
+
|
| 35 |
+
} // namespace uv
|
| 36 |
+
} // namespace transport
|
| 37 |
+
} // namespace tensorpipe
|
| 38 |
+
|
| 39 |
+
#else
|
| 40 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 41 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/CudaIPCTypes.h
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
#ifdef USE_CUDA
|
| 4 |
+
#include <c10/core/Allocator.h>
|
| 5 |
+
#include <c10/cuda/CUDACachingAllocator.h>
|
| 6 |
+
#include <c10/cuda/CUDAException.h>
|
| 7 |
+
#include <c10/util/Logging.h>
|
| 8 |
+
#include <cuda_runtime_api.h>
|
| 9 |
+
#include <torch/csrc/Export.h>
|
| 10 |
+
#include <cstddef>
|
| 11 |
+
namespace torch {
|
| 12 |
+
|
| 13 |
+
TORCH_CUDA_CU_API bool CudaIPCCollect();
|
| 14 |
+
|
| 15 |
+
struct CudaIPCReceivedData final {
|
| 16 |
+
CudaIPCReceivedData() = default;
|
| 17 |
+
explicit CudaIPCReceivedData(std::shared_ptr<void> shared_ptr)
|
| 18 |
+
: shared_ptr_(std::move(shared_ptr)) {}
|
| 19 |
+
std::shared_ptr<void> shared_ptr_;
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
struct CudaIPCSentData final {
|
| 23 |
+
std::string handle_;
|
| 24 |
+
uint64_t offset_;
|
| 25 |
+
uint64_t* counter_ptr_; // Reference counter shared memory block
|
| 26 |
+
at::DataPtr original_ptr_; // Original mem allocation
|
| 27 |
+
cudaEvent_t event_; // Sync cuEventDestroy
|
| 28 |
+
bool event_sync_required_;
|
| 29 |
+
at::Device device_;
|
| 30 |
+
|
| 31 |
+
CudaIPCSentData(
|
| 32 |
+
std::string handle,
|
| 33 |
+
uint64_t offset,
|
| 34 |
+
uint64_t* counter_ptr,
|
| 35 |
+
at::Device device);
|
| 36 |
+
~CudaIPCSentData();
|
| 37 |
+
|
| 38 |
+
uint64_t counter_value();
|
| 39 |
+
std::string handle() {
|
| 40 |
+
return handle_;
|
| 41 |
+
}
|
| 42 |
+
uint64_t offset() {
|
| 43 |
+
return offset_;
|
| 44 |
+
}
|
| 45 |
+
void set_original_ptr(at::DataPtr data_ptr) {
|
| 46 |
+
original_ptr_ = std::move(data_ptr);
|
| 47 |
+
}
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
TORCH_CUDA_CU_API at::DataPtr GetNewRefCountedSentData(
|
| 51 |
+
void* data,
|
| 52 |
+
at::Device device);
|
| 53 |
+
|
| 54 |
+
namespace {
|
| 55 |
+
|
| 56 |
+
inline constexpr int64_t CUDA_IPC_REF_COUNTER_FILE_SIZE = 10000;
|
| 57 |
+
inline constexpr int64_t CUDA_IPC_WARN_AFTER_X_BLOCKS_IN_LIMBO = 1000;
|
| 58 |
+
// This was determined empirically that CUDA (v10.1 and below) have the limit
|
| 59 |
+
// on the number of recorded blocking interprocess events. It is around ~22,000.
|
| 60 |
+
// And to give us leeway, we picked 1000 as it gives us enough events to share
|
| 61 |
+
// tensors effectively.
|
| 62 |
+
inline constexpr int64_t CUDA_IPC_MAXIMUM_EVENTS_TO_USE = 1000;
|
| 63 |
+
|
| 64 |
+
// All to be deleted data blocks with non zero reference counter goes there
|
| 65 |
+
struct CudaIPCSentDataLimbo final {
|
| 66 |
+
~CudaIPCSentDataLimbo();
|
| 67 |
+
bool collect();
|
| 68 |
+
void add(std::unique_ptr<CudaIPCSentData> shared_block);
|
| 69 |
+
uint64_t size();
|
| 70 |
+
|
| 71 |
+
private:
|
| 72 |
+
// TODO: Can be changed to FIFO in order to avoid full traverse on every
|
| 73 |
+
// collect()
|
| 74 |
+
std::vector<std::unique_ptr<CudaIPCSentData>> shared_blocks_;
|
| 75 |
+
std::mutex limbo_mutex_;
|
| 76 |
+
};
|
| 77 |
+
|
| 78 |
+
struct CudaIPCRefCountersFile final {
|
| 79 |
+
CudaIPCRefCountersFile(
|
| 80 |
+
std::string handle,
|
| 81 |
+
uint64_t size,
|
| 82 |
+
at::DataPtr data_ptr)
|
| 83 |
+
: size_(size),
|
| 84 |
+
|
| 85 |
+
handle_(std::move(handle)),
|
| 86 |
+
refcounted_shared_mem_(std::move(data_ptr)) {}
|
| 87 |
+
|
| 88 |
+
uint64_t* counter_ptr() {
|
| 89 |
+
return static_cast<uint64_t*>(refcounted_shared_mem_.get()) + next_offset_;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
void set_counter(uint64_t value) {
|
| 93 |
+
*counter_ptr() = value;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
bool have_offsets() {
|
| 97 |
+
return next_offset_ < size_;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
bool offsets_in_use() {
|
| 101 |
+
return used_slots_;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
uint64_t get_offset() {
|
| 105 |
+
return next_offset_;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
void rotate_offset() {
|
| 109 |
+
next_offset_++;
|
| 110 |
+
used_slots_++;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
void return_offset(uint64_t offset /* unused */) {
|
| 114 |
+
used_slots_--;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
std::string handle() {
|
| 118 |
+
return handle_;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
private:
|
| 122 |
+
uint64_t next_offset_{0};
|
| 123 |
+
uint64_t size_;
|
| 124 |
+
uint64_t used_slots_{0};
|
| 125 |
+
std::string handle_;
|
| 126 |
+
at::DataPtr refcounted_shared_mem_;
|
| 127 |
+
};
|
| 128 |
+
|
| 129 |
+
} // namespace
|
| 130 |
+
} // namespace torch
|
| 131 |
+
|
| 132 |
+
namespace c10 {
|
| 133 |
+
namespace {
|
| 134 |
+
class CudaIPCCollectCallback : public FreeMemoryCallback {
|
| 135 |
+
public:
|
| 136 |
+
bool Execute() override {
|
| 137 |
+
return torch::CudaIPCCollect();
|
| 138 |
+
}
|
| 139 |
+
};
|
| 140 |
+
} // namespace
|
| 141 |
+
|
| 142 |
+
} // namespace c10
|
| 143 |
+
|
| 144 |
+
#endif
|
| 145 |
+
|
| 146 |
+
#else
|
| 147 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 148 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/DataLoader.h
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <torch/csrc/python_headers.h>
|
| 5 |
+
|
| 6 |
+
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,cppcoreguidelines-avoid-non-const-global-variables,modernize-avoid-c-arrays)
|
| 7 |
+
extern PyMethodDef DataLoaderMethods[];
|
| 8 |
+
|
| 9 |
+
#else
|
| 10 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 11 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Device.h
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <torch/csrc/Export.h>
|
| 5 |
+
#include <torch/csrc/python_headers.h>
|
| 6 |
+
|
| 7 |
+
#include <ATen/Device.h>
|
| 8 |
+
|
| 9 |
+
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
|
| 10 |
+
struct TORCH_API THPDevice {
|
| 11 |
+
PyObject_HEAD
|
| 12 |
+
at::Device device;
|
| 13 |
+
};
|
| 14 |
+
|
| 15 |
+
TORCH_API extern PyTypeObject THPDeviceType;
|
| 16 |
+
|
| 17 |
+
inline bool THPDevice_Check(PyObject* obj) {
|
| 18 |
+
return Py_TYPE(obj) == &THPDeviceType;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
TORCH_API PyObject* THPDevice_New(const at::Device& device);
|
| 22 |
+
|
| 23 |
+
TORCH_API void THPDevice_init(PyObject* module);
|
| 24 |
+
|
| 25 |
+
#else
|
| 26 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 27 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/DeviceAccelerator.h
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#include <ATen/DeviceAccelerator.h>
|
| 3 |
+
#include <torch/csrc/utils/pybind.h>
|
| 4 |
+
|
| 5 |
+
namespace torch::accelerator {
|
| 6 |
+
|
| 7 |
+
void initModule(PyObject* module);
|
| 8 |
+
|
| 9 |
+
} // namespace torch::accelerator
|
| 10 |
+
|
| 11 |
+
#else
|
| 12 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 13 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Dtype.h
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <c10/core/ScalarType.h>
|
| 5 |
+
#include <torch/csrc/Export.h>
|
| 6 |
+
#include <torch/csrc/python_headers.h>
|
| 7 |
+
|
| 8 |
+
constexpr int DTYPE_NAME_LEN = 64;
|
| 9 |
+
|
| 10 |
+
struct TORCH_API THPDtype {
|
| 11 |
+
PyObject_HEAD
|
| 12 |
+
at::ScalarType scalar_type;
|
| 13 |
+
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
|
| 14 |
+
char name[DTYPE_NAME_LEN + 1];
|
| 15 |
+
};
|
| 16 |
+
|
| 17 |
+
TORCH_API extern PyTypeObject THPDtypeType;
|
| 18 |
+
|
| 19 |
+
inline bool THPDtype_Check(PyObject* obj) {
|
| 20 |
+
return Py_TYPE(obj) == &THPDtypeType;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
inline bool THPPythonScalarType_Check(PyObject* obj) {
|
| 24 |
+
return obj == (PyObject*)(&PyFloat_Type) ||
|
| 25 |
+
obj == (PyObject*)(&PyComplex_Type) || obj == (PyObject*)(&PyBool_Type) ||
|
| 26 |
+
obj == (PyObject*)(&PyLong_Type);
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
TORCH_API PyObject* THPDtype_New(
|
| 30 |
+
at::ScalarType scalar_type,
|
| 31 |
+
const std::string& name);
|
| 32 |
+
|
| 33 |
+
void THPDtype_init(PyObject* module);
|
| 34 |
+
|
| 35 |
+
#else
|
| 36 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 37 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/DynamicTypes.h
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
// Provides conversions between Python tensor objects and at::Tensor.
|
| 5 |
+
|
| 6 |
+
#include <torch/csrc/python_headers.h>
|
| 7 |
+
|
| 8 |
+
#include <ATen/Device.h>
|
| 9 |
+
#include <c10/core/Backend.h>
|
| 10 |
+
#include <c10/core/Layout.h>
|
| 11 |
+
#include <c10/core/ScalarType.h>
|
| 12 |
+
#include <c10/core/ScalarTypeToTypeMeta.h>
|
| 13 |
+
#include <torch/csrc/Export.h>
|
| 14 |
+
|
| 15 |
+
#include <memory>
|
| 16 |
+
#include <string>
|
| 17 |
+
|
| 18 |
+
struct THPDtype;
|
| 19 |
+
struct THPLayout;
|
| 20 |
+
|
| 21 |
+
namespace c10 {
|
| 22 |
+
struct Storage;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
namespace torch {
|
| 26 |
+
void registerDtypeObject(THPDtype* dtype, at::ScalarType scalarType);
|
| 27 |
+
void registerLayoutObject(THPLayout* thp_layout, at::Layout layout);
|
| 28 |
+
|
| 29 |
+
TORCH_PYTHON_API PyObject* createPyObject(const at::Storage& storage);
|
| 30 |
+
TORCH_PYTHON_API at::Storage createStorage(PyObject* obj);
|
| 31 |
+
TORCH_PYTHON_API std::tuple<at::Storage, at::ScalarType, bool>
|
| 32 |
+
createStorageGetType(PyObject* obj);
|
| 33 |
+
TORCH_PYTHON_API bool isStorage(PyObject* obj);
|
| 34 |
+
|
| 35 |
+
// Both methods below return a borrowed reference!
|
| 36 |
+
TORCH_PYTHON_API THPDtype* getTHPDtype(at::ScalarType scalarType);
|
| 37 |
+
TORCH_PYTHON_API THPLayout* getTHPLayout(at::Layout layout);
|
| 38 |
+
} // namespace torch
|
| 39 |
+
|
| 40 |
+
#else
|
| 41 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 42 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Event.h
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#ifndef THP_EVENT_INC
|
| 3 |
+
#define THP_EVENT_INC
|
| 4 |
+
|
| 5 |
+
#include <c10/core/Event.h>
|
| 6 |
+
#include <torch/csrc/python_headers.h>
|
| 7 |
+
|
| 8 |
+
struct TORCH_API THPEvent {
|
| 9 |
+
PyObject_HEAD
|
| 10 |
+
c10::Event event;
|
| 11 |
+
PyObject* weakreflist;
|
| 12 |
+
};
|
| 13 |
+
TORCH_API extern PyTypeObject* THPEventClass;
|
| 14 |
+
TORCH_API extern PyTypeObject THPEventType;
|
| 15 |
+
|
| 16 |
+
TORCH_API void THPEvent_init(PyObject* module);
|
| 17 |
+
TORCH_API PyObject* THPEvent_new(
|
| 18 |
+
c10::DeviceType device_type,
|
| 19 |
+
c10::EventFlag flag);
|
| 20 |
+
inline bool THPEvent_Check(PyObject* obj) {
|
| 21 |
+
return THPEventClass && PyObject_IsInstance(obj, (PyObject*)THPEventClass);
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
#endif // THP_EVENT_INC
|
| 25 |
+
|
| 26 |
+
#else
|
| 27 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 28 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Exceptions.h
ADDED
|
@@ -0,0 +1,405 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <exception>
|
| 5 |
+
#include <memory>
|
| 6 |
+
#include <string>
|
| 7 |
+
#include <system_error>
|
| 8 |
+
|
| 9 |
+
#include <ATen/detail/FunctionTraits.h>
|
| 10 |
+
#include <c10/util/C++17.h>
|
| 11 |
+
#include <c10/util/Exception.h>
|
| 12 |
+
#include <c10/util/StringUtil.h>
|
| 13 |
+
#include <pybind11/pybind11.h>
|
| 14 |
+
#include <torch/csrc/Export.h>
|
| 15 |
+
#include <torch/csrc/jit/runtime/jit_exception.h>
|
| 16 |
+
#include <torch/csrc/utils/cpp_stacktraces.h>
|
| 17 |
+
#include <torch/csrc/utils/pybind.h>
|
| 18 |
+
|
| 19 |
+
#if defined(USE_DISTRIBUTED)
|
| 20 |
+
#include <torch/csrc/distributed/c10d/exception.h>
|
| 21 |
+
#endif
|
| 22 |
+
|
| 23 |
+
inline void PyErr_SetString(PyObject* type, const std::string& message) {
|
| 24 |
+
PyErr_SetString(type, message.c_str());
|
| 25 |
+
}
|
| 26 |
+
/// NOTE [ Conversion Cpp Python Warning ]
|
| 27 |
+
/// The warning handler cannot set python warnings immediately
|
| 28 |
+
/// as it requires acquiring the GIL (potential deadlock)
|
| 29 |
+
/// and would need to cleanly exit if the warning raised a
|
| 30 |
+
/// python error. To solve this, we buffer the warnings and
|
| 31 |
+
/// process them when we go back to python.
|
| 32 |
+
/// This requires the two try/catch blocks below to handle the
|
| 33 |
+
/// following cases:
|
| 34 |
+
/// - If there is no Error raised in the inner try/catch, the
|
| 35 |
+
/// buffered warnings are processed as python warnings.
|
| 36 |
+
/// - If they don't raise an error, the function process with the
|
| 37 |
+
/// original return code.
|
| 38 |
+
/// - If any of them raise an error, the error is set (PyErr_*) and
|
| 39 |
+
/// the destructor will raise a cpp exception python_error() that
|
| 40 |
+
/// will be caught by the outer try/catch that will be able to change
|
| 41 |
+
/// the return value of the function to reflect the error.
|
| 42 |
+
/// - If an Error was raised in the inner try/catch, the inner try/catch
|
| 43 |
+
/// must set the python error. The buffered warnings are then
|
| 44 |
+
/// processed as cpp warnings as we cannot predict before hand
|
| 45 |
+
/// whether a python warning will raise an error or not and we
|
| 46 |
+
/// cannot handle two errors at the same time.
|
| 47 |
+
/// This advanced handler will only be used in the current thread.
|
| 48 |
+
/// If any other thread is used, warnings will be processed as
|
| 49 |
+
/// cpp warnings.
|
| 50 |
+
#define HANDLE_TH_ERRORS \
|
| 51 |
+
try { \
|
| 52 |
+
torch::PyWarningHandler __enforce_warning_buffer; \
|
| 53 |
+
try {
|
| 54 |
+
#define _CATCH_GENERIC_ERROR(ErrorType, PythonErrorType, retstmnt) \
|
| 55 |
+
catch (const c10::ErrorType& e) { \
|
| 56 |
+
auto msg = torch::get_cpp_stacktraces_enabled() \
|
| 57 |
+
? e.what() \
|
| 58 |
+
: e.what_without_backtrace(); \
|
| 59 |
+
PyErr_SetString(PythonErrorType, torch::processErrorMsg(msg)); \
|
| 60 |
+
retstmnt; \
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
// Only catch torch-specific exceptions
|
| 64 |
+
#define CATCH_CORE_ERRORS(retstmnt) \
|
| 65 |
+
catch (python_error & e) { \
|
| 66 |
+
e.restore(); \
|
| 67 |
+
retstmnt; \
|
| 68 |
+
} \
|
| 69 |
+
catch (py::error_already_set & e) { \
|
| 70 |
+
e.restore(); \
|
| 71 |
+
retstmnt; \
|
| 72 |
+
} \
|
| 73 |
+
_CATCH_GENERIC_ERROR(IndexError, PyExc_IndexError, retstmnt) \
|
| 74 |
+
_CATCH_GENERIC_ERROR(ValueError, PyExc_ValueError, retstmnt) \
|
| 75 |
+
_CATCH_GENERIC_ERROR(TypeError, PyExc_TypeError, retstmnt) \
|
| 76 |
+
_CATCH_GENERIC_ERROR( \
|
| 77 |
+
NotImplementedError, PyExc_NotImplementedError, retstmnt) \
|
| 78 |
+
_CATCH_GENERIC_ERROR(BufferError, PyExc_BufferError, retstmnt) \
|
| 79 |
+
_CATCH_GENERIC_ERROR(SyntaxError, PyExc_SyntaxError, retstmnt) \
|
| 80 |
+
_CATCH_GENERIC_ERROR(LinAlgError, THPException_LinAlgError, retstmnt) \
|
| 81 |
+
_CATCH_GENERIC_ERROR( \
|
| 82 |
+
OutOfMemoryError, THPException_OutOfMemoryError, retstmnt) \
|
| 83 |
+
_CATCH_GENERIC_ERROR( \
|
| 84 |
+
DistBackendError, THPException_DistBackendError, retstmnt) \
|
| 85 |
+
_CATCH_GENERIC_ERROR( \
|
| 86 |
+
DistNetworkError, THPException_DistNetworkError, retstmnt) \
|
| 87 |
+
_CATCH_GENERIC_ERROR( \
|
| 88 |
+
DistQueueEmptyError, THPException_DistQueueEmptyError, retstmnt) \
|
| 89 |
+
_CATCH_GENERIC_ERROR(DistStoreError, THPException_DistStoreError, retstmnt) \
|
| 90 |
+
_CATCH_GENERIC_ERROR(DistError, THPException_DistError, retstmnt) \
|
| 91 |
+
catch (c10::AcceleratorError & e) { \
|
| 92 |
+
auto exc = torch::detail::_new_accelerator_error_object(e); \
|
| 93 |
+
PyErr_SetObject(THPException_AcceleratorError, exc); \
|
| 94 |
+
Py_XDECREF(exc); \
|
| 95 |
+
retstmnt; \
|
| 96 |
+
} \
|
| 97 |
+
_CATCH_GENERIC_ERROR(Error, PyExc_RuntimeError, retstmnt) \
|
| 98 |
+
catch (torch::PyTorchError & e) { \
|
| 99 |
+
auto msg = torch::processErrorMsg(e.what()); \
|
| 100 |
+
PyErr_SetString(e.python_type(), msg); \
|
| 101 |
+
retstmnt; \
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
#define CATCH_TH_ERRORS(retstmnt) CATCH_CORE_ERRORS(retstmnt)
|
| 105 |
+
|
| 106 |
+
#define CATCH_ALL_ERRORS(retstmnt) \
|
| 107 |
+
CATCH_TH_ERRORS(retstmnt) \
|
| 108 |
+
catch (const std::exception& e) { \
|
| 109 |
+
auto msg = torch::processErrorMsg(e.what()); \
|
| 110 |
+
PyErr_SetString(PyExc_RuntimeError, msg); \
|
| 111 |
+
retstmnt; \
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
#define END_HANDLE_TH_ERRORS_PYBIND \
|
| 115 |
+
} \
|
| 116 |
+
catch (...) { \
|
| 117 |
+
__enforce_warning_buffer.set_in_exception(); \
|
| 118 |
+
throw; \
|
| 119 |
+
} \
|
| 120 |
+
} \
|
| 121 |
+
catch (py::error_already_set&) { \
|
| 122 |
+
throw; \
|
| 123 |
+
} \
|
| 124 |
+
catch (py::builtin_exception&) { \
|
| 125 |
+
throw; \
|
| 126 |
+
} \
|
| 127 |
+
catch (torch::jit::JITException&) { \
|
| 128 |
+
throw; \
|
| 129 |
+
} \
|
| 130 |
+
catch (const std::exception&) { \
|
| 131 |
+
torch::translate_exception_to_python(std::current_exception()); \
|
| 132 |
+
throw py::error_already_set(); \
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
#define END_HANDLE_TH_ERRORS_RET(retval) \
|
| 136 |
+
} \
|
| 137 |
+
catch (...) { \
|
| 138 |
+
__enforce_warning_buffer.set_in_exception(); \
|
| 139 |
+
throw; \
|
| 140 |
+
} \
|
| 141 |
+
} \
|
| 142 |
+
catch (const std::exception&) { \
|
| 143 |
+
torch::translate_exception_to_python(std::current_exception()); \
|
| 144 |
+
return retval; \
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
#define END_HANDLE_TH_ERRORS END_HANDLE_TH_ERRORS_RET(nullptr)
|
| 148 |
+
|
| 149 |
+
extern PyObject *THPException_FatalError, *THPException_LinAlgError,
|
| 150 |
+
*THPException_OutOfMemoryError, *THPException_DistError,
|
| 151 |
+
*THPException_DistBackendError, *THPException_DistNetworkError,
|
| 152 |
+
*THPException_DistStoreError, *THPException_DistQueueEmptyError,
|
| 153 |
+
*THPException_AcceleratorError;
|
| 154 |
+
|
| 155 |
+
// Throwing this exception means that the python error flags have been already
|
| 156 |
+
// set and control should be immediately returned to the interpreter.
|
| 157 |
+
struct python_error : public std::exception {
|
| 158 |
+
python_error() = default;
|
| 159 |
+
|
| 160 |
+
python_error(const python_error& other)
|
| 161 |
+
: type(other.type),
|
| 162 |
+
value(other.value),
|
| 163 |
+
traceback(other.traceback),
|
| 164 |
+
message(other.message) {
|
| 165 |
+
pybind11::gil_scoped_acquire gil;
|
| 166 |
+
Py_XINCREF(type);
|
| 167 |
+
Py_XINCREF(value);
|
| 168 |
+
Py_XINCREF(traceback);
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
python_error(python_error&& other) noexcept
|
| 172 |
+
: type(other.type),
|
| 173 |
+
value(other.value),
|
| 174 |
+
traceback(other.traceback),
|
| 175 |
+
message(std::move(other.message)) {
|
| 176 |
+
other.type = nullptr;
|
| 177 |
+
other.value = nullptr;
|
| 178 |
+
other.traceback = nullptr;
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
python_error& operator=(const python_error& other) = delete;
|
| 182 |
+
python_error& operator=(python_error&& other) = delete;
|
| 183 |
+
|
| 184 |
+
// NOLINTNEXTLINE(bugprone-exception-escape)
|
| 185 |
+
~python_error() override {
|
| 186 |
+
if (type || value || traceback) {
|
| 187 |
+
pybind11::gil_scoped_acquire gil;
|
| 188 |
+
Py_XDECREF(type);
|
| 189 |
+
Py_XDECREF(value);
|
| 190 |
+
Py_XDECREF(traceback);
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
const char* what() const noexcept override {
|
| 195 |
+
return message.c_str();
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
void build_message() {
|
| 199 |
+
// Ensure we have the GIL.
|
| 200 |
+
pybind11::gil_scoped_acquire gil;
|
| 201 |
+
|
| 202 |
+
// No errors should be set when we enter the function since PyErr_Fetch
|
| 203 |
+
// clears the error indicator.
|
| 204 |
+
TORCH_INTERNAL_ASSERT(!PyErr_Occurred());
|
| 205 |
+
|
| 206 |
+
// Default message.
|
| 207 |
+
message = "python_error";
|
| 208 |
+
|
| 209 |
+
// Try to retrieve the error message from the value.
|
| 210 |
+
if (value != nullptr) {
|
| 211 |
+
// Reference count should not be zero.
|
| 212 |
+
TORCH_INTERNAL_ASSERT(Py_REFCNT(value) > 0);
|
| 213 |
+
|
| 214 |
+
PyObject* pyStr = PyObject_Str(value);
|
| 215 |
+
if (pyStr != nullptr) {
|
| 216 |
+
PyObject* encodedString =
|
| 217 |
+
PyUnicode_AsEncodedString(pyStr, "utf-8", "strict");
|
| 218 |
+
if (encodedString != nullptr) {
|
| 219 |
+
char* bytes = PyBytes_AS_STRING(encodedString);
|
| 220 |
+
if (bytes != nullptr) {
|
| 221 |
+
// Set the message.
|
| 222 |
+
message = std::string(bytes);
|
| 223 |
+
}
|
| 224 |
+
Py_XDECREF(encodedString);
|
| 225 |
+
}
|
| 226 |
+
Py_XDECREF(pyStr);
|
| 227 |
+
}
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
// Clear any errors since we don't want to propagate errors for functions
|
| 231 |
+
// that are trying to build a string for the error message.
|
| 232 |
+
PyErr_Clear();
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
/** Saves the exception so that it can be re-thrown on a different thread */
|
| 236 |
+
inline void persist() {
|
| 237 |
+
if (type)
|
| 238 |
+
return; // Don't overwrite exceptions
|
| 239 |
+
// PyErr_Fetch overwrites the pointers
|
| 240 |
+
pybind11::gil_scoped_acquire gil;
|
| 241 |
+
Py_XDECREF(type);
|
| 242 |
+
Py_XDECREF(value);
|
| 243 |
+
Py_XDECREF(traceback);
|
| 244 |
+
PyErr_Fetch(&type, &value, &traceback);
|
| 245 |
+
build_message();
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
/** Sets the current Python error from this exception */
|
| 249 |
+
inline void restore() {
|
| 250 |
+
if (!type)
|
| 251 |
+
return;
|
| 252 |
+
// PyErr_Restore steals references
|
| 253 |
+
pybind11::gil_scoped_acquire gil;
|
| 254 |
+
Py_XINCREF(type);
|
| 255 |
+
Py_XINCREF(value);
|
| 256 |
+
Py_XINCREF(traceback);
|
| 257 |
+
PyErr_Restore(type, value, traceback);
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
PyObject* type{nullptr};
|
| 261 |
+
PyObject* value{nullptr};
|
| 262 |
+
PyObject* traceback{nullptr};
|
| 263 |
+
|
| 264 |
+
// Message to return to the user when 'what()' is invoked.
|
| 265 |
+
std::string message;
|
| 266 |
+
};
|
| 267 |
+
|
| 268 |
+
bool THPException_init(PyObject* module);
|
| 269 |
+
|
| 270 |
+
namespace torch {
|
| 271 |
+
|
| 272 |
+
// Set python current exception from a C++ exception
|
| 273 |
+
TORCH_PYTHON_API void translate_exception_to_python(
|
| 274 |
+
const std::exception_ptr& /*e_ptr*/);
|
| 275 |
+
|
| 276 |
+
TORCH_PYTHON_API std::string processErrorMsg(std::string str);
|
| 277 |
+
|
| 278 |
+
// Abstract base class for exceptions which translate to specific Python types
|
| 279 |
+
struct PyTorchError : public std::exception {
|
| 280 |
+
PyTorchError() = default;
|
| 281 |
+
PyTorchError(std::string msg_) : msg(std::move(msg_)) {}
|
| 282 |
+
virtual PyObject* python_type() = 0;
|
| 283 |
+
const char* what() const noexcept override {
|
| 284 |
+
return msg.c_str();
|
| 285 |
+
}
|
| 286 |
+
std::string msg;
|
| 287 |
+
};
|
| 288 |
+
|
| 289 |
+
// Translates to Python TypeError
|
| 290 |
+
struct TypeError : public PyTorchError {
|
| 291 |
+
TORCH_PYTHON_API TypeError() = default;
|
| 292 |
+
TORCH_PYTHON_API TypeError(std::string msg_)
|
| 293 |
+
: PyTorchError(std::move(msg_)) {}
|
| 294 |
+
using PyTorchError::PyTorchError;
|
| 295 |
+
PyObject* python_type() override {
|
| 296 |
+
return PyExc_TypeError;
|
| 297 |
+
}
|
| 298 |
+
};
|
| 299 |
+
|
| 300 |
+
// Translates to Python AttributeError
|
| 301 |
+
struct AttributeError : public PyTorchError {
|
| 302 |
+
using PyTorchError::PyTorchError;
|
| 303 |
+
PyObject* python_type() override {
|
| 304 |
+
return PyExc_AttributeError;
|
| 305 |
+
}
|
| 306 |
+
};
|
| 307 |
+
|
| 308 |
+
// ATen warning handler for Python
|
| 309 |
+
struct PyWarningHandler {
|
| 310 |
+
// Move actual handler into a separate class with a noexcept
|
| 311 |
+
// destructor. Otherwise, we need to force all WarningHandler
|
| 312 |
+
// subclasses to have a noexcept(false) destructor.
|
| 313 |
+
struct InternalHandler : at::WarningHandler {
|
| 314 |
+
~InternalHandler() override = default;
|
| 315 |
+
void process(const c10::Warning& warning) override;
|
| 316 |
+
|
| 317 |
+
std::vector<c10::Warning> warning_buffer_;
|
| 318 |
+
};
|
| 319 |
+
|
| 320 |
+
public:
|
| 321 |
+
/// See NOTE [ Conversion Cpp Python Warning ] for noexcept justification
|
| 322 |
+
TORCH_PYTHON_API PyWarningHandler() noexcept(true);
|
| 323 |
+
// NOLINTNEXTLINE(bugprone-exception-escape)
|
| 324 |
+
TORCH_PYTHON_API ~PyWarningHandler() noexcept(false);
|
| 325 |
+
|
| 326 |
+
/** Call if an exception has been thrown
|
| 327 |
+
|
| 328 |
+
* Necessary to determine if it is safe to throw from the destructor since
|
| 329 |
+
* std::uncaught_exception is buggy on some platforms and generally
|
| 330 |
+
* unreliable across dynamic library calls.
|
| 331 |
+
*/
|
| 332 |
+
void set_in_exception() {
|
| 333 |
+
in_exception_ = true;
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
private:
|
| 337 |
+
InternalHandler internal_handler_;
|
| 338 |
+
at::WarningHandler* prev_handler_;
|
| 339 |
+
bool in_exception_;
|
| 340 |
+
};
|
| 341 |
+
|
| 342 |
+
namespace detail {
|
| 343 |
+
|
| 344 |
+
struct noop_gil_scoped_release {
|
| 345 |
+
// user-defined constructor (i.e. not defaulted) to avoid
|
| 346 |
+
// unused-variable warnings at usage sites of this class
|
| 347 |
+
// NOLINTNEXTLINE(modernize-use-equals-default)
|
| 348 |
+
noop_gil_scoped_release() {}
|
| 349 |
+
};
|
| 350 |
+
|
| 351 |
+
template <bool release_gil>
|
| 352 |
+
using conditional_gil_scoped_release = std::conditional_t<
|
| 353 |
+
release_gil,
|
| 354 |
+
pybind11::gil_scoped_release,
|
| 355 |
+
noop_gil_scoped_release>;
|
| 356 |
+
|
| 357 |
+
template <typename Func, size_t i>
|
| 358 |
+
using Arg = typename invoke_traits<Func>::template arg<i>::type;
|
| 359 |
+
|
| 360 |
+
template <typename Func, size_t... Is, bool release_gil>
|
| 361 |
+
auto wrap_pybind_function_impl_(
|
| 362 |
+
Func&& f,
|
| 363 |
+
std::index_sequence<Is...> /*unused*/,
|
| 364 |
+
std::bool_constant<release_gil> /*unused*/) {
|
| 365 |
+
namespace py = pybind11;
|
| 366 |
+
|
| 367 |
+
// f=f is needed to handle function references on older compilers
|
| 368 |
+
return [f = std::forward<Func>(f)](Arg<Func, Is>... args) {
|
| 369 |
+
HANDLE_TH_ERRORS
|
| 370 |
+
conditional_gil_scoped_release<release_gil> no_gil;
|
| 371 |
+
return std::invoke(f, std::forward<Arg<Func, Is>>(args)...);
|
| 372 |
+
END_HANDLE_TH_ERRORS_PYBIND
|
| 373 |
+
};
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
PyObject* _new_accelerator_error_object(const c10::AcceleratorError& /*e*/);
|
| 377 |
+
} // namespace detail
|
| 378 |
+
|
| 379 |
+
// Wrap a function with TH error and warning handling.
|
| 380 |
+
// Returns a function object suitable for registering with pybind11.
|
| 381 |
+
template <typename Func>
|
| 382 |
+
auto wrap_pybind_function(Func&& f) {
|
| 383 |
+
using traits = invoke_traits<Func>;
|
| 384 |
+
return torch::detail::wrap_pybind_function_impl_(
|
| 385 |
+
std::forward<Func>(f),
|
| 386 |
+
std::make_index_sequence<traits::arity>{},
|
| 387 |
+
std::false_type{});
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
// Wrap a function with TH error, warning handling and releases the GIL.
|
| 391 |
+
// Returns a function object suitable for registering with pybind11.
|
| 392 |
+
template <typename Func>
|
| 393 |
+
auto wrap_pybind_function_no_gil(Func&& f) {
|
| 394 |
+
using traits = invoke_traits<Func>;
|
| 395 |
+
return torch::detail::wrap_pybind_function_impl_(
|
| 396 |
+
std::forward<Func>(f),
|
| 397 |
+
std::make_index_sequence<traits::arity>{},
|
| 398 |
+
std::true_type{});
|
| 399 |
+
}
|
| 400 |
+
|
| 401 |
+
} // namespace torch
|
| 402 |
+
|
| 403 |
+
#else
|
| 404 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 405 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Export.h
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <c10/macros/Export.h>
|
| 5 |
+
|
| 6 |
+
#ifdef THP_BUILD_MAIN_LIB
|
| 7 |
+
#define TORCH_PYTHON_API C10_EXPORT
|
| 8 |
+
#else
|
| 9 |
+
#define TORCH_PYTHON_API C10_IMPORT
|
| 10 |
+
#endif
|
| 11 |
+
|
| 12 |
+
#else
|
| 13 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 14 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Generator.h
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <ATen/core/Generator.h>
|
| 5 |
+
#include <torch/csrc/Export.h>
|
| 6 |
+
#include <torch/csrc/python_headers.h>
|
| 7 |
+
|
| 8 |
+
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
|
| 9 |
+
struct THPGenerator {
|
| 10 |
+
PyObject_HEAD
|
| 11 |
+
at::Generator cdata;
|
| 12 |
+
};
|
| 13 |
+
|
| 14 |
+
// Creates a new Python object wrapping the default at::Generator. The reference
|
| 15 |
+
// is borrowed. The caller should ensure that the at::Generator object lifetime
|
| 16 |
+
// last at least as long as the Python wrapper.
|
| 17 |
+
TORCH_PYTHON_API PyObject* THPGenerator_initDefaultGenerator(
|
| 18 |
+
const at::Generator& cdata);
|
| 19 |
+
|
| 20 |
+
#define THPGenerator_Check(obj) PyObject_IsInstance(obj, THPGeneratorClass)
|
| 21 |
+
|
| 22 |
+
TORCH_PYTHON_API extern PyObject* THPGeneratorClass;
|
| 23 |
+
|
| 24 |
+
bool THPGenerator_init(PyObject* module);
|
| 25 |
+
|
| 26 |
+
TORCH_PYTHON_API PyObject* THPGenerator_Wrap(const at::Generator& gen);
|
| 27 |
+
|
| 28 |
+
TORCH_PYTHON_API at::Generator THPGenerator_Unwrap(PyObject* state);
|
| 29 |
+
|
| 30 |
+
// Creates a new Python object for a Generator. The Generator must not already
|
| 31 |
+
// have a PyObject* associated with it.
|
| 32 |
+
PyObject* THPGenerator_NewWithVar(PyTypeObject* type, at::Generator gen);
|
| 33 |
+
|
| 34 |
+
#else
|
| 35 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 36 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Layout.h
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
#include <torch/csrc/Export.h>
|
| 4 |
+
#include <torch/csrc/python_headers.h>
|
| 5 |
+
|
| 6 |
+
#include <ATen/Layout.h>
|
| 7 |
+
|
| 8 |
+
#include <string>
|
| 9 |
+
|
| 10 |
+
const int LAYOUT_NAME_LEN = 64;
|
| 11 |
+
|
| 12 |
+
struct THPLayout {
|
| 13 |
+
PyObject_HEAD
|
| 14 |
+
at::Layout layout;
|
| 15 |
+
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
|
| 16 |
+
char name[LAYOUT_NAME_LEN + 1];
|
| 17 |
+
};
|
| 18 |
+
|
| 19 |
+
TORCH_PYTHON_API extern PyTypeObject THPLayoutType;
|
| 20 |
+
|
| 21 |
+
inline bool THPLayout_Check(PyObject* obj) {
|
| 22 |
+
return Py_TYPE(obj) == &THPLayoutType;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
PyObject* THPLayout_New(at::Layout layout, const std::string& name);
|
| 26 |
+
|
| 27 |
+
void THPLayout_init(PyObject* module);
|
| 28 |
+
|
| 29 |
+
#else
|
| 30 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 31 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/MemoryFormat.h
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <torch/csrc/Export.h>
|
| 5 |
+
#include <torch/csrc/python_headers.h>
|
| 6 |
+
|
| 7 |
+
#include <c10/core/MemoryFormat.h>
|
| 8 |
+
|
| 9 |
+
#include <string>
|
| 10 |
+
|
| 11 |
+
const int MEMORY_FORMAT_NAME_LEN = 64;
|
| 12 |
+
|
| 13 |
+
struct THPMemoryFormat {
|
| 14 |
+
PyObject_HEAD
|
| 15 |
+
at::MemoryFormat memory_format;
|
| 16 |
+
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
|
| 17 |
+
char name[MEMORY_FORMAT_NAME_LEN + 1];
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
+
TORCH_PYTHON_API extern PyTypeObject THPMemoryFormatType;
|
| 21 |
+
|
| 22 |
+
inline bool THPMemoryFormat_Check(PyObject* obj) {
|
| 23 |
+
return Py_TYPE(obj) == &THPMemoryFormatType;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
PyObject* THPMemoryFormat_New(
|
| 27 |
+
at::MemoryFormat memory_format,
|
| 28 |
+
const std::string& name);
|
| 29 |
+
|
| 30 |
+
void THPMemoryFormat_init(PyObject* module);
|
| 31 |
+
|
| 32 |
+
#else
|
| 33 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 34 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Module.h
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#ifndef THP_MODULE_INC
|
| 3 |
+
#define THP_MODULE_INC
|
| 4 |
+
|
| 5 |
+
#define THP_STATELESS_ATTRIBUTE_NAME "_torch"
|
| 6 |
+
|
| 7 |
+
#endif
|
| 8 |
+
|
| 9 |
+
#else
|
| 10 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 11 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/PyInterpreter.h
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <c10/core/impl/PyInterpreter.h>
|
| 5 |
+
#include <torch/csrc/Export.h>
|
| 6 |
+
#include <torch/csrc/utils/pybind.h>
|
| 7 |
+
|
| 8 |
+
namespace torch::detail {
|
| 9 |
+
TORCH_PYTHON_API py::handle getTorchApiFunction(const c10::OperatorHandle& op);
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
// TODO: Move these to a proper namespace
|
| 13 |
+
TORCH_PYTHON_API c10::impl::PyInterpreter* getPyInterpreter();
|
| 14 |
+
TORCH_PYTHON_API void initializeGlobalPyInterpreter();
|
| 15 |
+
|
| 16 |
+
#else
|
| 17 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 18 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/PyInterpreterHooks.h
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <c10/core/impl/PyInterpreterHooks.h>
|
| 5 |
+
|
| 6 |
+
namespace torch::detail {
|
| 7 |
+
|
| 8 |
+
// Concrete implementation of PyInterpreterHooks
|
| 9 |
+
class PyInterpreterHooks : public c10::impl::PyInterpreterHooksInterface {
|
| 10 |
+
public:
|
| 11 |
+
explicit PyInterpreterHooks(c10::impl::PyInterpreterHooksArgs /*unused*/);
|
| 12 |
+
|
| 13 |
+
c10::impl::PyInterpreter* getPyInterpreter() const override;
|
| 14 |
+
};
|
| 15 |
+
|
| 16 |
+
} // namespace torch::detail
|
| 17 |
+
|
| 18 |
+
#else
|
| 19 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 20 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/QScheme.h
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <torch/csrc/Export.h>
|
| 5 |
+
#include <torch/csrc/python_headers.h>
|
| 6 |
+
|
| 7 |
+
#include <c10/core/QScheme.h>
|
| 8 |
+
|
| 9 |
+
#include <string>
|
| 10 |
+
|
| 11 |
+
constexpr int QSCHEME_NAME_LEN = 64;
|
| 12 |
+
|
| 13 |
+
struct THPQScheme {
|
| 14 |
+
PyObject_HEAD
|
| 15 |
+
at::QScheme qscheme;
|
| 16 |
+
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
|
| 17 |
+
char name[QSCHEME_NAME_LEN + 1];
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
+
TORCH_PYTHON_API extern PyTypeObject THPQSchemeType;
|
| 21 |
+
|
| 22 |
+
inline bool THPQScheme_Check(PyObject* obj) {
|
| 23 |
+
return Py_TYPE(obj) == &THPQSchemeType;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
PyObject* THPQScheme_New(at::QScheme qscheme, const std::string& name);
|
| 27 |
+
|
| 28 |
+
void THPQScheme_init(PyObject* module);
|
| 29 |
+
|
| 30 |
+
#else
|
| 31 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 32 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Size.h
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <torch/csrc/Export.h>
|
| 5 |
+
#include <torch/csrc/autograd/variable.h>
|
| 6 |
+
#include <torch/csrc/python_headers.h>
|
| 7 |
+
#include <cstdint>
|
| 8 |
+
|
| 9 |
+
TORCH_PYTHON_API extern PyTypeObject THPSizeType;
|
| 10 |
+
|
| 11 |
+
#define THPSize_Check(obj) (Py_TYPE(obj) == &THPSizeType)
|
| 12 |
+
|
| 13 |
+
PyObject* THPSize_New(const torch::autograd::Variable& t);
|
| 14 |
+
PyObject* THPSize_NewFromSizes(int64_t dim, const int64_t* sizes);
|
| 15 |
+
PyObject* THPSize_NewFromSymSizes(const at::Tensor& t);
|
| 16 |
+
|
| 17 |
+
void THPSize_init(PyObject* module);
|
| 18 |
+
|
| 19 |
+
#else
|
| 20 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 21 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Storage.h
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#ifndef THP_STORAGE_INC
|
| 3 |
+
#define THP_STORAGE_INC
|
| 4 |
+
|
| 5 |
+
#include <Python.h>
|
| 6 |
+
#include <c10/core/Storage.h>
|
| 7 |
+
#include <torch/csrc/Exceptions.h>
|
| 8 |
+
#include <torch/csrc/Export.h>
|
| 9 |
+
#include <torch/csrc/Types.h>
|
| 10 |
+
|
| 11 |
+
#define THPStorageStr "torch.UntypedStorage"
|
| 12 |
+
|
| 13 |
+
struct THPStorage {
|
| 14 |
+
PyObject_HEAD
|
| 15 |
+
c10::Storage cdata;
|
| 16 |
+
};
|
| 17 |
+
|
| 18 |
+
TORCH_PYTHON_API PyObject* THPStorage_Wrap(c10::Storage storage);
|
| 19 |
+
TORCH_PYTHON_API PyObject* THPStorage_NewWithStorage(
|
| 20 |
+
PyTypeObject* type,
|
| 21 |
+
c10::Storage _storage);
|
| 22 |
+
TORCH_PYTHON_API extern PyTypeObject* THPStorageClass;
|
| 23 |
+
|
| 24 |
+
inline bool THPStorage_CheckTypeExact(PyTypeObject* tp) {
|
| 25 |
+
return tp == THPStorageClass;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
inline bool THPStorage_CheckExact(PyObject* obj) {
|
| 29 |
+
return THPStorage_CheckTypeExact(Py_TYPE(obj));
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
inline bool THPStorage_Check(PyObject* obj) {
|
| 33 |
+
if (!THPStorageClass)
|
| 34 |
+
return false;
|
| 35 |
+
|
| 36 |
+
const auto result = PyObject_IsInstance(obj, (PyObject*)THPStorageClass);
|
| 37 |
+
if (result == -1)
|
| 38 |
+
throw python_error();
|
| 39 |
+
return result;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
bool THPStorage_init(PyObject* module);
|
| 43 |
+
void THPStorage_postInit(PyObject* module);
|
| 44 |
+
|
| 45 |
+
void THPStorage_assertNotNull(THPStorage* storage);
|
| 46 |
+
TORCH_PYTHON_API void THPStorage_assertNotNull(PyObject* obj);
|
| 47 |
+
|
| 48 |
+
TORCH_PYTHON_API extern PyTypeObject THPStorageType;
|
| 49 |
+
|
| 50 |
+
inline const c10::Storage& THPStorage_Unpack(THPStorage* storage) {
|
| 51 |
+
return storage->cdata;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
inline const c10::Storage& THPStorage_Unpack(PyObject* obj) {
|
| 55 |
+
return THPStorage_Unpack(reinterpret_cast<THPStorage*>(obj));
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
#endif
|
| 59 |
+
|
| 60 |
+
#else
|
| 61 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 62 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/StorageMethods.h
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#ifndef THP_STORAGE_METHODS_INC
|
| 3 |
+
#define THP_STORAGE_METHODS_INC
|
| 4 |
+
|
| 5 |
+
#include <Python.h>
|
| 6 |
+
|
| 7 |
+
PyMethodDef* THPStorage_getMethods();
|
| 8 |
+
|
| 9 |
+
#endif
|
| 10 |
+
|
| 11 |
+
#else
|
| 12 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 13 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/StorageSharing.h
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#ifndef THP_STORAGE_SHARING_INC
|
| 3 |
+
#define THP_STORAGE_SHARING_INC
|
| 4 |
+
|
| 5 |
+
#include <Python.h>
|
| 6 |
+
|
| 7 |
+
PyMethodDef* THPStorage_getSharingMethods();
|
| 8 |
+
|
| 9 |
+
#endif
|
| 10 |
+
|
| 11 |
+
#else
|
| 12 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 13 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Stream.h
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#ifndef THP_STREAM_INC
|
| 3 |
+
#define THP_STREAM_INC
|
| 4 |
+
|
| 5 |
+
#include <c10/core/Stream.h>
|
| 6 |
+
#include <c10/macros/Export.h>
|
| 7 |
+
#include <torch/csrc/Export.h>
|
| 8 |
+
#include <torch/csrc/python_headers.h>
|
| 9 |
+
|
| 10 |
+
struct THPStream {
|
| 11 |
+
PyObject_HEAD
|
| 12 |
+
int64_t stream_id;
|
| 13 |
+
int64_t device_type;
|
| 14 |
+
int64_t device_index;
|
| 15 |
+
// Used to switch stream context management, initialized lazily.
|
| 16 |
+
PyObject* context;
|
| 17 |
+
PyObject* weakreflist;
|
| 18 |
+
};
|
| 19 |
+
extern TORCH_API PyTypeObject* THPStreamClass;
|
| 20 |
+
|
| 21 |
+
void THPStream_init(PyObject* module);
|
| 22 |
+
|
| 23 |
+
inline bool THPStream_Check(PyObject* obj) {
|
| 24 |
+
return THPStreamClass && PyObject_IsInstance(obj, (PyObject*)THPStreamClass);
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
TORCH_PYTHON_API PyObject* THPStream_Wrap(const c10::Stream& stream);
|
| 28 |
+
|
| 29 |
+
#endif // THP_STREAM_INC
|
| 30 |
+
|
| 31 |
+
#else
|
| 32 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 33 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/THConcat.h
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#define TH_CONCAT_STRING_2(x, y) TH_CONCAT_STRING_2_EXPAND(x, y)
|
| 5 |
+
#define TH_CONCAT_STRING_2_EXPAND(x, y) #x #y
|
| 6 |
+
|
| 7 |
+
#define TH_CONCAT_STRING_3(x, y, z) TH_CONCAT_STRING_3_EXPAND(x, y, z)
|
| 8 |
+
#define TH_CONCAT_STRING_3_EXPAND(x, y, z) #x #y #z
|
| 9 |
+
|
| 10 |
+
#define TH_CONCAT_STRING_4(x, y, z, w) TH_CONCAT_STRING_4_EXPAND(x, y, z, w)
|
| 11 |
+
#define TH_CONCAT_STRING_4_EXPAND(x, y, z, w) #x #y #z #w
|
| 12 |
+
|
| 13 |
+
#define TH_CONCAT_2(x, y) TH_CONCAT_2_EXPAND(x, y)
|
| 14 |
+
#define TH_CONCAT_2_EXPAND(x, y) x##y
|
| 15 |
+
|
| 16 |
+
#define TH_CONCAT_3(x, y, z) TH_CONCAT_3_EXPAND(x, y, z)
|
| 17 |
+
#define TH_CONCAT_3_EXPAND(x, y, z) x##y##z
|
| 18 |
+
|
| 19 |
+
#define TH_CONCAT_4_EXPAND(x, y, z, w) x##y##z##w
|
| 20 |
+
#define TH_CONCAT_4(x, y, z, w) TH_CONCAT_4_EXPAND(x, y, z, w)
|
| 21 |
+
|
| 22 |
+
#else
|
| 23 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 24 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/THP.h
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#ifndef THP_H
|
| 3 |
+
#define THP_H
|
| 4 |
+
|
| 5 |
+
#include <torch/csrc/Export.h>
|
| 6 |
+
#include <torch/csrc/python_headers.h>
|
| 7 |
+
|
| 8 |
+
#include <torch/csrc/Exceptions.h>
|
| 9 |
+
#include <torch/csrc/Generator.h>
|
| 10 |
+
#include <torch/csrc/Module.h>
|
| 11 |
+
#include <torch/csrc/Size.h>
|
| 12 |
+
#include <torch/csrc/Storage.h>
|
| 13 |
+
#include <torch/csrc/Types.h>
|
| 14 |
+
#include <torch/csrc/utils.h> // This requires defined Storage and Tensor types
|
| 15 |
+
#include <torch/csrc/utils/byte_order.h>
|
| 16 |
+
|
| 17 |
+
#include <torch/csrc/serialization.h>
|
| 18 |
+
|
| 19 |
+
#include <torch/csrc/autograd/python_autograd.h>
|
| 20 |
+
|
| 21 |
+
#endif
|
| 22 |
+
|
| 23 |
+
#else
|
| 24 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 25 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/TypeInfo.h
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <torch/csrc/Export.h>
|
| 5 |
+
#include <torch/csrc/python_headers.h>
|
| 6 |
+
|
| 7 |
+
#include <ATen/ATen.h>
|
| 8 |
+
|
| 9 |
+
struct THPDTypeInfo {
|
| 10 |
+
PyObject_HEAD
|
| 11 |
+
at::ScalarType type;
|
| 12 |
+
};
|
| 13 |
+
|
| 14 |
+
struct THPFInfo : THPDTypeInfo {};
|
| 15 |
+
|
| 16 |
+
struct THPIInfo : THPDTypeInfo {};
|
| 17 |
+
|
| 18 |
+
TORCH_PYTHON_API extern PyTypeObject THPFInfoType;
|
| 19 |
+
TORCH_PYTHON_API extern PyTypeObject THPIInfoType;
|
| 20 |
+
|
| 21 |
+
inline bool THPFInfo_Check(PyObject* obj) {
|
| 22 |
+
return Py_TYPE(obj) == &THPFInfoType;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
inline bool THPIInfo_Check(PyObject* obj) {
|
| 26 |
+
return Py_TYPE(obj) == &THPIInfoType;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
void THPDTypeInfo_init(PyObject* module);
|
| 30 |
+
|
| 31 |
+
#else
|
| 32 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 33 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/Types.h
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#ifndef THP_TYPES_INC
|
| 3 |
+
#define THP_TYPES_INC
|
| 4 |
+
|
| 5 |
+
#include <cstddef>
|
| 6 |
+
|
| 7 |
+
#ifndef INT64_MAX
|
| 8 |
+
#include <cstdint>
|
| 9 |
+
#endif
|
| 10 |
+
|
| 11 |
+
template <typename T>
|
| 12 |
+
struct THPTypeInfo {};
|
| 13 |
+
|
| 14 |
+
#endif
|
| 15 |
+
|
| 16 |
+
#else
|
| 17 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 18 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/acc/Module.h
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
#include <torch/csrc/python_headers.h>
|
| 4 |
+
|
| 5 |
+
namespace torch::acc {
|
| 6 |
+
// PyMethodDef* python_functions();
|
| 7 |
+
void initModule(PyObject* module);
|
| 8 |
+
|
| 9 |
+
} // namespace torch::acc
|
| 10 |
+
|
| 11 |
+
#else
|
| 12 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 13 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/all.h
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#if !defined(_MSC_VER) && __cplusplus < 201703L
|
| 5 |
+
#error C++17 or later compatible compiler is required to use PyTorch.
|
| 6 |
+
#endif
|
| 7 |
+
|
| 8 |
+
#include <torch/autograd.h>
|
| 9 |
+
#include <torch/cuda.h>
|
| 10 |
+
#include <torch/data.h>
|
| 11 |
+
#include <torch/enum.h>
|
| 12 |
+
#include <torch/fft.h>
|
| 13 |
+
#include <torch/jit.h>
|
| 14 |
+
#include <torch/mps.h>
|
| 15 |
+
#include <torch/nested.h>
|
| 16 |
+
#include <torch/nn.h>
|
| 17 |
+
#include <torch/optim.h>
|
| 18 |
+
#include <torch/serialize.h>
|
| 19 |
+
#include <torch/sparse.h>
|
| 20 |
+
#include <torch/special.h>
|
| 21 |
+
#include <torch/types.h>
|
| 22 |
+
#include <torch/utils.h>
|
| 23 |
+
#include <torch/version.h>
|
| 24 |
+
#include <torch/xpu.h>
|
| 25 |
+
|
| 26 |
+
#else
|
| 27 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 28 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/arg.h
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <utility>
|
| 5 |
+
|
| 6 |
+
#define TORCH_ARG(T, name) \
|
| 7 |
+
public: \
|
| 8 |
+
inline auto name(const T& new_##name) -> decltype(*this) { /* NOLINT */ \
|
| 9 |
+
this->name##_ = new_##name; \
|
| 10 |
+
return *this; \
|
| 11 |
+
} \
|
| 12 |
+
inline auto name(T&& new_##name) -> decltype(*this) { /* NOLINT */ \
|
| 13 |
+
this->name##_ = std::move(new_##name); \
|
| 14 |
+
return *this; \
|
| 15 |
+
} \
|
| 16 |
+
inline const T& name() const noexcept { /* NOLINT */ \
|
| 17 |
+
return this->name##_; \
|
| 18 |
+
} \
|
| 19 |
+
inline T& name() noexcept { /* NOLINT */ \
|
| 20 |
+
return this->name##_; \
|
| 21 |
+
} \
|
| 22 |
+
\
|
| 23 |
+
private: \
|
| 24 |
+
T name##_ /* NOLINT */
|
| 25 |
+
|
| 26 |
+
#else
|
| 27 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 28 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/autograd.h
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <torch/csrc/autograd/autograd.h>
|
| 5 |
+
#include <torch/csrc/autograd/autograd_not_implemented_fallback.h>
|
| 6 |
+
#include <torch/csrc/autograd/custom_function.h>
|
| 7 |
+
|
| 8 |
+
#else
|
| 9 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 10 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/cuda.h
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <c10/core/Device.h>
|
| 5 |
+
#include <c10/macros/Export.h>
|
| 6 |
+
|
| 7 |
+
#include <cstdint>
|
| 8 |
+
|
| 9 |
+
namespace torch::cuda {
|
| 10 |
+
|
| 11 |
+
/// Returns the number of CUDA devices available.
|
| 12 |
+
c10::DeviceIndex TORCH_API device_count();
|
| 13 |
+
|
| 14 |
+
/// Returns true if at least one CUDA device is available.
|
| 15 |
+
bool TORCH_API is_available();
|
| 16 |
+
|
| 17 |
+
/// Returns true if CUDA is available, and CuDNN is available.
|
| 18 |
+
bool TORCH_API cudnn_is_available();
|
| 19 |
+
|
| 20 |
+
/// Sets the seed for the current GPU.
|
| 21 |
+
void TORCH_API manual_seed(uint64_t seed);
|
| 22 |
+
|
| 23 |
+
/// Sets the seed for all available GPUs.
|
| 24 |
+
void TORCH_API manual_seed_all(uint64_t seed);
|
| 25 |
+
|
| 26 |
+
/// Waits for all kernels in all streams on a CUDA device to complete.
|
| 27 |
+
void TORCH_API synchronize(int64_t device_index = -1);
|
| 28 |
+
|
| 29 |
+
} // namespace torch::cuda
|
| 30 |
+
|
| 31 |
+
#else
|
| 32 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 33 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/data.h
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <torch/data/dataloader.h>
|
| 5 |
+
#include <torch/data/datasets.h>
|
| 6 |
+
#include <torch/data/samplers.h>
|
| 7 |
+
#include <torch/data/transforms.h>
|
| 8 |
+
|
| 9 |
+
// Some "exports".
|
| 10 |
+
|
| 11 |
+
namespace torch::data {
|
| 12 |
+
using datasets::BatchDataset; // NOLINT
|
| 13 |
+
using datasets::Dataset; // NOLINT
|
| 14 |
+
} // namespace torch::data
|
| 15 |
+
|
| 16 |
+
#else
|
| 17 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 18 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
miniconda3/envs/ladir/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <torch/data/dataloader/stateful.h>
|
| 5 |
+
#include <torch/data/dataloader/stateless.h>
|
| 6 |
+
|
| 7 |
+
#include <torch/csrc/utils/variadic.h>
|
| 8 |
+
|
| 9 |
+
#include <c10/util/Exception.h>
|
| 10 |
+
|
| 11 |
+
#include <cstddef>
|
| 12 |
+
#include <memory>
|
| 13 |
+
#include <type_traits>
|
| 14 |
+
#include <utility>
|
| 15 |
+
|
| 16 |
+
namespace torch::data {
|
| 17 |
+
|
| 18 |
+
/// Creates a `DataLoader` instance for a stateless `dataset`, a `sampler` and
|
| 19 |
+
/// some `options`.
|
| 20 |
+
template <typename Dataset, typename Sampler>
|
| 21 |
+
std::enable_if_t<
|
| 22 |
+
!Dataset::is_stateful,
|
| 23 |
+
std::unique_ptr<StatelessDataLoader<Dataset, Sampler>>>
|
| 24 |
+
make_data_loader(Dataset dataset, Sampler sampler, DataLoaderOptions options) {
|
| 25 |
+
return std::make_unique<StatelessDataLoader<Dataset, Sampler>>(
|
| 26 |
+
std::move(dataset), std::move(sampler), options);
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/// Creates a `DataLoader` instance for a stateless `dataset` and some
|
| 30 |
+
/// `options`. A sampler (by default a `RandomSampler`) will be constructed from
|
| 31 |
+
/// the size of the dataset.
|
| 32 |
+
template <typename Sampler = samplers::RandomSampler, typename Dataset>
|
| 33 |
+
std::enable_if_t<
|
| 34 |
+
!Dataset::is_stateful && std::is_constructible_v<Sampler, size_t>,
|
| 35 |
+
std::unique_ptr<StatelessDataLoader<Dataset, Sampler>>>
|
| 36 |
+
make_data_loader(
|
| 37 |
+
Dataset dataset,
|
| 38 |
+
DataLoaderOptions options = DataLoaderOptions()) {
|
| 39 |
+
const std::optional<size_t> size = dataset.size();
|
| 40 |
+
TORCH_CHECK(
|
| 41 |
+
size.has_value(),
|
| 42 |
+
"Expected the dataset to be sized in "
|
| 43 |
+
"order to construct the Sampler");
|
| 44 |
+
return make_data_loader(std::move(dataset), Sampler(*size), options);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/// Creates a `DataLoader` for a stateful `dataset` and some `options`.
|
| 48 |
+
template <typename Dataset, typename = std::enable_if_t<Dataset::is_stateful>>
|
| 49 |
+
std::unique_ptr<StatefulDataLoader<Dataset>> make_data_loader(
|
| 50 |
+
Dataset dataset,
|
| 51 |
+
DataLoaderOptions options = DataLoaderOptions()) {
|
| 52 |
+
return std::make_unique<StatefulDataLoader<Dataset>>(
|
| 53 |
+
std::move(dataset), options);
|
| 54 |
+
}
|
| 55 |
+
} // namespace torch::data
|
| 56 |
+
|
| 57 |
+
#else
|
| 58 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 59 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|