mirror of https://github.com/llvm/torch-mlir
Replace c10::optional with std::optional (#3126)
They replaced all `c10::optional` usages with `std::optional` in
torchgen'd code in
fb90b4d4b2
causing the LTC build to break.
Replacing all usages of `c10::optional` with `std::optional` in
`projects/ltc` has fixed the issue
Issue: #3120
pull/3130/head
parent
184d8c13f4
commit
8951a8cc23
|
@ -123,12 +123,12 @@ class GenTorchMlirLTC:
|
|||
self.generated_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Create symlink to match doc structure
|
||||
generated_path = self.backend_path.joinpath("generated").resolve()
|
||||
if not generated_path.exists():
|
||||
generated_path.symlink_to(
|
||||
os.path.relpath(self.generated_path, generated_path.parent),
|
||||
target_is_directory=True,
|
||||
)
|
||||
generated_path = self.backend_path.joinpath("generated")
|
||||
generated_path.unlink(missing_ok=True)
|
||||
generated_path.symlink_to(
|
||||
os.path.relpath(self.generated_path, generated_path.parent),
|
||||
target_is_directory=True,
|
||||
)
|
||||
|
||||
self.tensor_class = "torch::lazy::LazyTensor"
|
||||
|
||||
|
@ -350,7 +350,15 @@ class GenTorchMlirLTC:
|
|||
def extract_signatures(text):
|
||||
signatures = set()
|
||||
for name, args in sig_re.findall(text):
|
||||
# Remove all whitespace from signature
|
||||
signature = re.sub(r"\s+", "", f"{name}({args})")
|
||||
# Ignore optional's namespace
|
||||
signature = re.sub(r":*\w*:*optional", "optional", signature)
|
||||
# Remove const type qualifier
|
||||
signature = re.sub(r"const", "", signature)
|
||||
# Remove type reference
|
||||
signature = re.sub(r"&", "", signature)
|
||||
|
||||
global_signatures[signature] = (name, args)
|
||||
signatures.add(signature)
|
||||
return signatures
|
||||
|
|
|
@ -50,6 +50,7 @@ cmake -S "$repo_root/externals/llvm-project/llvm" -B "$build_dir" \
|
|||
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$repo_root" \
|
||||
-DLLVM_TARGETS_TO_BUILD=host \
|
||||
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
|
||||
-DTORCH_MLIR_ENABLE_LTC=ON
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Build"
|
||||
|
|
|
@ -434,8 +434,6 @@ function clean_build() {
|
|||
}
|
||||
|
||||
function build_torch_mlir() {
|
||||
# Disable LTC build for releases to avoid linker issues
|
||||
export TORCH_MLIR_ENABLE_LTC=0
|
||||
local torch_version="$1"
|
||||
case $torch_version in
|
||||
nightly)
|
||||
|
|
|
@ -117,7 +117,7 @@ TorchMlirBackendImpl::GetComputationDataFromNode(const Node *node) const {
|
|||
|
||||
at::Tensor TorchMlirBackendImpl::MakeTensorFromComputationData(
|
||||
const BackendDataPtr data,
|
||||
c10::optional<at::ScalarType> logical_scalar_type) const {
|
||||
std::optional<at::ScalarType> logical_scalar_type) const {
|
||||
PRINT_FUNCTION();
|
||||
|
||||
TorchMlirBackendData *torch_mlir_data =
|
||||
|
|
|
@ -30,7 +30,7 @@ class TORCH_API TorchMlirBackendData : public BackendData {
|
|||
public:
|
||||
struct Info : public BackendData::Info {
|
||||
at::Tensor tensor;
|
||||
c10::optional<at::Scalar> scalar;
|
||||
std::optional<at::Scalar> scalar;
|
||||
bool requires_grad;
|
||||
std::string name;
|
||||
|
||||
|
@ -111,7 +111,7 @@ public:
|
|||
|
||||
virtual at::Tensor MakeTensorFromComputationData(
|
||||
const BackendDataPtr data,
|
||||
c10::optional<at::ScalarType> logical_scalar_type) const override;
|
||||
std::optional<at::ScalarType> logical_scalar_type) const override;
|
||||
|
||||
/**
|
||||
* Lowering, Compilation, Execution
|
||||
|
|
|
@ -34,7 +34,7 @@ struct TorchMlirIrBuilder : IrBuilder {
|
|||
NodePtr MakeDeviceData(const std::shared_ptr<BackendData>& data) const override { return MakeNode<DeviceData>(data); }
|
||||
NodePtr MakeScalar(const at::Scalar& value, const at::ScalarType& type) const override { return MakeNode<Scalar>(value, type); }
|
||||
NodePtr MakeExpand(const Value& input0, const std::vector<int64_t>& size, const bool& is_scalar_expand) const override { return MakeNode<Expand>(input0, size, is_scalar_expand); }
|
||||
NodePtr MakeCast(const Value& input0, const at::ScalarType& dtype, const c10::optional<at::ScalarType>& stype = c10::nullopt) const override { return MakeNode<Cast>(input0, dtype, stype); }
|
||||
NodePtr MakeCast(const Value& input0, const at::ScalarType& dtype, const std::optional<at::ScalarType>& stype = c10::nullopt) const override { return MakeNode<Cast>(input0, dtype, stype); }
|
||||
NodePtr MakeTensorList(const OpList& inputs) const override { return MakeNode<TorchMlirTensorList>(inputs); }
|
||||
NodePtr MakeGeneric(const OpKind& op, const OpList& operands, const Shape& shape, const size_t& num_outputs = 1, const hash_t& hash_seed = static_cast<uint32_t>(0x5a2d296e9)) const override { return MakeNode<Generic>(op, operands, shape, num_outputs, hash_seed); }
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ at::Tensor to_meta(const at::Tensor &tensor) {
|
|||
return out;
|
||||
}
|
||||
|
||||
c10::optional<at::Tensor> to_meta(const c10::optional<at::Tensor> &tensor) {
|
||||
std::optional<at::Tensor> to_meta(const std::optional<at::Tensor> &tensor) {
|
||||
if (tensor.has_value()) {
|
||||
return to_meta(*tensor);
|
||||
}
|
||||
|
@ -76,9 +76,9 @@ c10::optional<at::Tensor> to_meta(const c10::optional<at::Tensor> &tensor) {
|
|||
return outs;
|
||||
}
|
||||
|
||||
c10::List<c10::optional<at::Tensor>>
|
||||
to_meta(const c10::List<c10::optional<at::Tensor>> &t_list) {
|
||||
c10::List<c10::optional<at::Tensor>> outs;
|
||||
c10::List<std::optional<at::Tensor>>
|
||||
to_meta(const c10::List<std::optional<at::Tensor>> &t_list) {
|
||||
c10::List<std::optional<at::Tensor>> outs;
|
||||
outs.reserve(t_list.size());
|
||||
for (const auto &tensor : t_list) {
|
||||
outs.push_back(to_meta(tensor));
|
||||
|
@ -94,7 +94,7 @@ namespace {
|
|||
|
||||
[[maybe_unused]] at::Tensor
|
||||
CreateLtcTensor(const at::Tensor &tensor,
|
||||
const c10::optional<torch::lazy::BackendDevice> &device) {
|
||||
const std::optional<torch::lazy::BackendDevice> &device) {
|
||||
if (tensor.defined() && device) {
|
||||
return torch::lazy::CreateAtenFromLtcTensor(
|
||||
torch::lazy::LazyTensor::Create(tensor, *device));
|
||||
|
@ -102,8 +102,8 @@ CreateLtcTensor(const at::Tensor &tensor,
|
|||
return tensor;
|
||||
}
|
||||
|
||||
[[maybe_unused]] c10::optional<torch::lazy::BackendDevice>
|
||||
GetLtcDevice(const c10::optional<c10::Device> &device) {
|
||||
[[maybe_unused]] std::optional<torch::lazy::BackendDevice>
|
||||
GetLtcDevice(const std::optional<c10::Device> &device) {
|
||||
if (!device) {
|
||||
return c10::nullopt;
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ void copy_(torch::lazy::LazyTensorPtr &input, torch::lazy::LazyTensorPtr &src) {
|
|||
// This should be safe to do, because every operator in the LT is functional.
|
||||
at::Tensor
|
||||
LazyNativeFunctions::clone(const at::Tensor &self,
|
||||
c10::optional<at::MemoryFormat> memory_format) {
|
||||
std::optional<at::MemoryFormat> memory_format) {
|
||||
auto self_lt = torch::lazy::TryGetLtcTensor(self);
|
||||
return torch::lazy::CreateAtenFromLtcTensor(
|
||||
self_lt->Create(self_lt->GetIrValue(), self_lt->GetDevice()));
|
||||
|
@ -234,10 +234,10 @@ at::Tensor LazyNativeFunctions::_copy_from_and_resize(const at::Tensor &self,
|
|||
}
|
||||
|
||||
at::Tensor LazyNativeFunctions::_to_copy(
|
||||
const at::Tensor &self, c10::optional<at::ScalarType> dtype,
|
||||
c10::optional<at::Layout> layout, c10::optional<at::Device> device,
|
||||
c10::optional<bool> pin_memory, bool non_blocking,
|
||||
c10::optional<at::MemoryFormat> memory_format) {
|
||||
const at::Tensor &self, std::optional<at::ScalarType> dtype,
|
||||
std::optional<at::Layout> layout, std::optional<at::Device> device,
|
||||
std::optional<bool> pin_memory, bool non_blocking,
|
||||
std::optional<at::MemoryFormat> memory_format) {
|
||||
PRINT_FUNCTION();
|
||||
auto options = self.options();
|
||||
if (dtype) {
|
||||
|
@ -482,7 +482,7 @@ LazyNativeFunctions::split_copy_symint(const at::Tensor &self,
|
|||
|
||||
at::Tensor LazyNativeFunctions::index(
|
||||
const at::Tensor &self,
|
||||
const c10::List<c10::optional<at::Tensor>> &indices) {
|
||||
const c10::List<std::optional<at::Tensor>> &indices) {
|
||||
TORCH_LAZY_FN_COUNTER("lazy::");
|
||||
auto common_device = torch::lazy::GetBackendDevice(self);
|
||||
TORCH_INTERNAL_ASSERT(common_device);
|
||||
|
@ -491,7 +491,7 @@ at::Tensor LazyNativeFunctions::index(
|
|||
|
||||
std::vector<torch::lazy::Value> values;
|
||||
for (const auto &it : indices) {
|
||||
c10::optional<at::Tensor> tensor = it;
|
||||
std::optional<at::Tensor> tensor = it;
|
||||
LazyTensorPtr lazy_tensor =
|
||||
torch::lazy::TryGetLtcTensor(tensor.value_or(at::Tensor()));
|
||||
values.push_back(
|
||||
|
@ -532,7 +532,7 @@ at::Tensor LazyNativeFunctions::index(
|
|||
}
|
||||
|
||||
at::Tensor LazyNativeFunctions::index_put(
|
||||
const at::Tensor &self, const c10::List<c10::optional<at::Tensor>> &indices,
|
||||
const at::Tensor &self, const c10::List<std::optional<at::Tensor>> &indices,
|
||||
const at::Tensor &values, bool accumulate) {
|
||||
TORCH_LAZY_FN_COUNTER("lazy::");
|
||||
auto common_device = torch::lazy::GetBackendDevice(self);
|
||||
|
@ -544,7 +544,7 @@ at::Tensor LazyNativeFunctions::index_put(
|
|||
|
||||
std::vector<torch::lazy::Value> indices_vector;
|
||||
for (const auto &it : indices) {
|
||||
c10::optional<at::Tensor> tensor = it;
|
||||
std::optional<at::Tensor> tensor = it;
|
||||
LazyTensorPtr lazy_tensor =
|
||||
torch::lazy::TryGetLtcTensor(tensor.value_or(at::Tensor()));
|
||||
indices_vector.push_back(
|
||||
|
@ -616,9 +616,9 @@ at::Tensor LazyNativeFunctions::block_diag(at::TensorList tensors) {
|
|||
}
|
||||
at::Tensor LazyNativeFunctions::new_empty_strided_symint(
|
||||
const at::Tensor &self, c10::SymIntArrayRef size,
|
||||
c10::SymIntArrayRef stride, c10::optional<at::ScalarType> dtype,
|
||||
c10::optional<at::Layout> layout, c10::optional<at::Device> device,
|
||||
c10::optional<bool> pin_memory) {
|
||||
c10::SymIntArrayRef stride, std::optional<at::ScalarType> dtype,
|
||||
std::optional<at::Layout> layout, std::optional<at::Device> device,
|
||||
std::optional<bool> pin_memory) {
|
||||
if (!device || device->type() == c10::DeviceType::Lazy) {
|
||||
return at::functionalization::functionalize_aten_op_symint<ATEN_OP(
|
||||
new_empty_strided)>::call(self, size, stride, dtype, layout, device,
|
||||
|
@ -628,8 +628,8 @@ at::Tensor LazyNativeFunctions::new_empty_strided_symint(
|
|||
// lazy_tensor.new_empty_strided(..., "cpu") we need to avoid explicit
|
||||
// functionalization. To do that we create regular cpu tensors.
|
||||
at::Tensor t = at::empty_symint(
|
||||
size, (dtype ? dtype : c10::optional<at::ScalarType>(self.scalar_type())),
|
||||
(layout ? layout : c10::optional<at::Layout>(self.layout())), device,
|
||||
size, (dtype ? dtype : std::optional<at::ScalarType>(self.scalar_type())),
|
||||
(layout ? layout : std::optional<at::Layout>(self.layout())), device,
|
||||
pin_memory, c10::nullopt);
|
||||
return t.as_strided_symint(size, stride, /*storage_offset=*/0);
|
||||
}
|
||||
|
@ -679,8 +679,8 @@ at::Tensor LazyNativeFunctions::_trilinear(
|
|||
unroll_dim);
|
||||
}
|
||||
at::Tensor LazyNativeFunctions::linalg_pinv(
|
||||
const at::Tensor &self, const c10::optional<at::Tensor> &atol,
|
||||
const c10::optional<at::Tensor> &rtol, bool hermitian) {
|
||||
const at::Tensor &self, const std::optional<at::Tensor> &atol,
|
||||
const std::optional<at::Tensor> &rtol, bool hermitian) {
|
||||
return at::functionalization::functionalize_aten_op<ATEN_OP2(
|
||||
linalg_pinv, atol_rtol_tensor)>::call(self, atol, rtol, hermitian);
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ c10::TensorType &cast_tensor_type(c10::TypePtr value_type) {
|
|||
return *tensor_type.get();
|
||||
}
|
||||
|
||||
c10::optional<std::vector<int64_t>>
|
||||
std::optional<std::vector<int64_t>>
|
||||
get_tensor_type_shape(c10::TensorType &tensor_type) {
|
||||
auto &symbolic_shape = tensor_type.symbolic_sizes();
|
||||
if (!symbolic_shape.rank()) {
|
||||
|
|
|
@ -25,11 +25,11 @@ namespace lazy {
|
|||
class ToCopy : public torch::lazy::TorchMlirNode {
|
||||
public:
|
||||
ToCopy(const torch::lazy::Value &self,
|
||||
const c10::optional<at::ScalarType> &dtype,
|
||||
const c10::optional<at::Layout> &layout,
|
||||
const c10::optional<at::Device> &device,
|
||||
const c10::optional<bool> &pin_memory, const bool &non_blocking,
|
||||
const c10::optional<at::MemoryFormat> &memory_format,
|
||||
const std::optional<at::ScalarType> &dtype,
|
||||
const std::optional<at::Layout> &layout,
|
||||
const std::optional<at::Device> &device,
|
||||
const std::optional<bool> &pin_memory, const bool &non_blocking,
|
||||
const std::optional<at::MemoryFormat> &memory_format,
|
||||
std::vector<torch::lazy::Shape> &&shapes)
|
||||
: torch::lazy::TorchMlirNode(
|
||||
torch::lazy::OpKind(at::aten::_to_copy), {self}, std::move(shapes),
|
||||
|
@ -95,12 +95,12 @@ public:
|
|||
return _to_copy_out;
|
||||
}
|
||||
|
||||
c10::optional<at::ScalarType> dtype;
|
||||
c10::optional<at::Layout> layout;
|
||||
c10::optional<at::Device> device;
|
||||
c10::optional<bool> pin_memory;
|
||||
std::optional<at::ScalarType> dtype;
|
||||
std::optional<at::Layout> layout;
|
||||
std::optional<at::Device> device;
|
||||
std::optional<bool> pin_memory;
|
||||
bool non_blocking;
|
||||
c10::optional<at::MemoryFormat> memory_format;
|
||||
std::optional<at::MemoryFormat> memory_format;
|
||||
};
|
||||
} // namespace lazy
|
||||
} // namespace torch
|
||||
|
|
|
@ -149,15 +149,22 @@ std::vector<torch::lazy::Shape> compute_shape_mul(const at::Tensor &self,
|
|||
|
||||
std::vector<torch::lazy::Shape>
|
||||
compute_shape_var(const at::Tensor &self, at::OptionalIntArrayRef dim,
|
||||
const c10::optional<at::Scalar> &correction, bool keepdim) {
|
||||
const ::std::optional<at::Scalar> &correction, bool keepdim) {
|
||||
// Result of variance is scalar tensor.
|
||||
return {Shape(self.scalar_type(), {})};
|
||||
}
|
||||
|
||||
std::vector<torch::lazy::Shape>
|
||||
compute_shape_nan_to_num(const at::Tensor &self, c10::optional<double> nan,
|
||||
c10::optional<double> posinf,
|
||||
c10::optional<double> neginf) {
|
||||
compute_shape_var(const at::Tensor &self, at::OptionalIntArrayRef dim,
|
||||
::std::optional<at::Scalar> &correction, bool keepdim) {
|
||||
// Result of variance is scalar tensor.
|
||||
return {Shape(self.scalar_type(), {})};
|
||||
}
|
||||
|
||||
std::vector<torch::lazy::Shape>
|
||||
compute_shape_nan_to_num(const at::Tensor &self, ::std::optional<double> nan,
|
||||
::std::optional<double> posinf,
|
||||
::std::optional<double> neginf) {
|
||||
return {Shape(self.scalar_type(), self.sizes().vec())};
|
||||
}
|
||||
|
||||
|
@ -226,8 +233,8 @@ std::vector<torch::lazy::Shape> compute_shape_fmod(const at::Tensor &self,
|
|||
}
|
||||
|
||||
std::vector<torch::lazy::Shape> compute_shape_native_group_norm(
|
||||
const at::Tensor &input, const c10::optional<at::Tensor> &weight,
|
||||
const c10::optional<at::Tensor> &bias, int64_t N, int64_t C, int64_t HxW,
|
||||
const at::Tensor &input, const ::std::optional<at::Tensor> &weight,
|
||||
const ::std::optional<at::Tensor> &bias, int64_t N, int64_t C, int64_t HxW,
|
||||
int64_t group, double eps) {
|
||||
|
||||
TORCH_CHECK(input.sizes().size() >= 2,
|
||||
|
@ -263,8 +270,9 @@ compute_shape_im2col(const at::Tensor &self, at::IntArrayRef kernel_size,
|
|||
|
||||
std::vector<torch::lazy::Shape> compute_shape_native_group_norm_backward(
|
||||
const at::Tensor &grad_out, const at::Tensor &input, const at::Tensor &mean,
|
||||
const at::Tensor &rstd, const c10::optional<at::Tensor> &weight, int64_t N,
|
||||
int64_t C, int64_t HxW, int64_t group, ::std::array<bool, 3> output_mask) {
|
||||
const at::Tensor &rstd, const ::std::optional<at::Tensor> &weight,
|
||||
int64_t N, int64_t C, int64_t HxW, int64_t group,
|
||||
::std::array<bool, 3> output_mask) {
|
||||
|
||||
TORCH_CHECK(input.sizes().size() >= 2,
|
||||
"Input tensor must have at least batch and channel dimensions!");
|
||||
|
@ -317,20 +325,20 @@ compute_shape_reflection_pad2d(const at::Tensor &self,
|
|||
|
||||
std::vector<torch::lazy::Shape>
|
||||
compute_shape_uniform(const at::Tensor &self, double from, double to,
|
||||
c10::optional<at::Generator> generator) {
|
||||
::std::optional<at::Generator> generator) {
|
||||
return {Shape(self.scalar_type(), self.sizes().vec())};
|
||||
}
|
||||
|
||||
std::vector<torch::lazy::Shape>
|
||||
compute_shape_normal_functional(const at::Tensor &self, double mean, double std,
|
||||
c10::optional<at::Generator> generator) {
|
||||
::std::optional<at::Generator> generator) {
|
||||
return {Shape(self.scalar_type(), self.sizes().vec())};
|
||||
}
|
||||
|
||||
std::vector<torch::lazy::Shape>
|
||||
compute_shape_multinomial(const at::Tensor &self, int64_t num_samples,
|
||||
bool replacement,
|
||||
c10::optional<at::Generator> generator) {
|
||||
::std::optional<at::Generator> generator) {
|
||||
// Input tensor can be either 1D or 2D. The last dim of output
|
||||
// should be 'num_samples'. So the output shape can be either
|
||||
// [num_samples] or [m, num_samples].
|
||||
|
@ -341,30 +349,29 @@ compute_shape_multinomial(const at::Tensor &self, int64_t num_samples,
|
|||
}
|
||||
|
||||
std::vector<torch::lazy::Shape>
|
||||
compute_shape_eye(int64_t n, c10::optional<at::ScalarType> dtype,
|
||||
c10::optional<at::Layout> layout,
|
||||
c10::optional<at::Device> device,
|
||||
c10::optional<bool> pin_memory) {
|
||||
compute_shape_eye(int64_t n, ::std::optional<at::ScalarType> dtype,
|
||||
::std::optional<at::Layout> layout,
|
||||
::std::optional<at::Device> device,
|
||||
::std::optional<bool> pin_memory) {
|
||||
auto out_meta =
|
||||
at::eye(n, dtype, layout, c10::Device(c10::kMeta), pin_memory);
|
||||
return {Shape(out_meta.scalar_type(), out_meta.sizes().vec())};
|
||||
}
|
||||
|
||||
std::vector<torch::lazy::Shape>
|
||||
compute_shape_eye(int64_t n, int64_t m, c10::optional<at::ScalarType> dtype,
|
||||
c10::optional<at::Layout> layout,
|
||||
c10::optional<at::Device> device,
|
||||
c10::optional<bool> pin_memory) {
|
||||
compute_shape_eye(int64_t n, int64_t m, ::std::optional<at::ScalarType> dtype,
|
||||
::std::optional<at::Layout> layout,
|
||||
::std::optional<at::Device> device,
|
||||
::std::optional<bool> pin_memory) {
|
||||
auto out_meta =
|
||||
at::eye(n, m, dtype, layout, c10::Device(c10::kMeta), pin_memory);
|
||||
return {Shape(out_meta.scalar_type(), out_meta.sizes().vec())};
|
||||
}
|
||||
|
||||
std::vector<torch::lazy::Shape>
|
||||
compute_shape_arange(const at::Scalar &end, c10::optional<at::ScalarType> dtype,
|
||||
c10::optional<at::Layout> layout,
|
||||
c10::optional<at::Device> device,
|
||||
c10::optional<bool> pin_memory) {
|
||||
std::vector<torch::lazy::Shape> compute_shape_arange(
|
||||
const at::Scalar &end, ::std::optional<at::ScalarType> dtype,
|
||||
::std::optional<at::Layout> layout, ::std::optional<at::Device> device,
|
||||
::std::optional<bool> pin_memory) {
|
||||
auto out_meta =
|
||||
at::arange(end, dtype, layout, c10::Device(c10::kMeta), pin_memory);
|
||||
return {Shape(out_meta.scalar_type(), out_meta.sizes().vec())};
|
||||
|
@ -372,8 +379,8 @@ compute_shape_arange(const at::Scalar &end, c10::optional<at::ScalarType> dtype,
|
|||
|
||||
std::vector<torch::lazy::Shape> compute_shape_arange(
|
||||
const at::Scalar &start, const at::Scalar &end,
|
||||
c10::optional<at::ScalarType> dtype, c10::optional<at::Layout> layout,
|
||||
c10::optional<at::Device> device, c10::optional<bool> pin_memory) {
|
||||
::std::optional<at::ScalarType> dtype, ::std::optional<at::Layout> layout,
|
||||
::std::optional<at::Device> device, ::std::optional<bool> pin_memory) {
|
||||
auto out_meta = at::arange(start, end, dtype, layout, c10::Device(c10::kMeta),
|
||||
pin_memory);
|
||||
return {Shape(out_meta.scalar_type(), out_meta.sizes().vec())};
|
||||
|
@ -381,8 +388,8 @@ std::vector<torch::lazy::Shape> compute_shape_arange(
|
|||
|
||||
std::vector<torch::lazy::Shape> compute_shape_arange(
|
||||
const at::Scalar &start, const at::Scalar &end, const at::Scalar &step,
|
||||
c10::optional<at::ScalarType> dtype, c10::optional<at::Layout> layout,
|
||||
c10::optional<at::Device> device, c10::optional<bool> pin_memory) {
|
||||
::std::optional<at::ScalarType> dtype, ::std::optional<at::Layout> layout,
|
||||
::std::optional<at::Device> device, ::std::optional<bool> pin_memory) {
|
||||
auto out_meta = at::arange(start, end, step, dtype, layout,
|
||||
c10::Device(c10::kMeta), pin_memory);
|
||||
return {Shape(out_meta.scalar_type(), out_meta.sizes().vec())};
|
||||
|
@ -390,44 +397,44 @@ std::vector<torch::lazy::Shape> compute_shape_arange(
|
|||
|
||||
std::vector<torch::lazy::Shape> compute_shape_full(
|
||||
at::IntArrayRef size, const at::Scalar &fill_value,
|
||||
c10::optional<at::ScalarType> dtype, c10::optional<at::Layout> layout,
|
||||
c10::optional<at::Device> device, c10::optional<bool> pin_memory) {
|
||||
::std::optional<at::ScalarType> dtype, ::std::optional<at::Layout> layout,
|
||||
::std::optional<at::Device> device, ::std::optional<bool> pin_memory) {
|
||||
return {
|
||||
Shape(dtype.value_or(at::get_default_dtype_as_scalartype()), size.vec())};
|
||||
}
|
||||
|
||||
std::vector<torch::lazy::Shape>
|
||||
compute_shape_ones(at::IntArrayRef size, c10::optional<at::ScalarType> dtype,
|
||||
c10::optional<at::Layout> layout,
|
||||
c10::optional<at::Device> device,
|
||||
c10::optional<bool> pin_memory) {
|
||||
compute_shape_ones(at::IntArrayRef size, ::std::optional<at::ScalarType> dtype,
|
||||
::std::optional<at::Layout> layout,
|
||||
::std::optional<at::Device> device,
|
||||
::std::optional<bool> pin_memory) {
|
||||
return {
|
||||
Shape(dtype.value_or(at::get_default_dtype_as_scalartype()), size.vec())};
|
||||
}
|
||||
|
||||
std::vector<torch::lazy::Shape>
|
||||
compute_shape_zeros(at::IntArrayRef size, c10::optional<at::ScalarType> dtype,
|
||||
c10::optional<at::Layout> layout,
|
||||
c10::optional<at::Device> device,
|
||||
c10::optional<bool> pin_memory) {
|
||||
compute_shape_zeros(at::IntArrayRef size, ::std::optional<at::ScalarType> dtype,
|
||||
::std::optional<at::Layout> layout,
|
||||
::std::optional<at::Device> device,
|
||||
::std::optional<bool> pin_memory) {
|
||||
return {
|
||||
Shape(dtype.value_or(at::get_default_dtype_as_scalartype()), size.vec())};
|
||||
}
|
||||
|
||||
std::vector<torch::lazy::Shape>
|
||||
compute_shape_empty(at::IntArrayRef size, c10::optional<at::ScalarType> dtype,
|
||||
c10::optional<at::Layout> layout,
|
||||
c10::optional<at::Device> device,
|
||||
c10::optional<bool> pin_memory,
|
||||
c10::optional<at::MemoryFormat> memory_format) {
|
||||
compute_shape_empty(at::IntArrayRef size, ::std::optional<at::ScalarType> dtype,
|
||||
::std::optional<at::Layout> layout,
|
||||
::std::optional<at::Device> device,
|
||||
::std::optional<bool> pin_memory,
|
||||
::std::optional<at::MemoryFormat> memory_format) {
|
||||
return {
|
||||
Shape(dtype.value_or(at::get_default_dtype_as_scalartype()), size.vec())};
|
||||
}
|
||||
|
||||
std::vector<torch::lazy::Shape> compute_shape_empty_strided(
|
||||
at::IntArrayRef size, at::IntArrayRef stride,
|
||||
c10::optional<at::ScalarType> dtype, c10::optional<at::Layout> layout,
|
||||
c10::optional<at::Device> device, c10::optional<bool> pin_memory) {
|
||||
::std::optional<at::ScalarType> dtype, ::std::optional<at::Layout> layout,
|
||||
::std::optional<at::Device> device, ::std::optional<bool> pin_memory) {
|
||||
return {
|
||||
Shape(dtype.value_or(at::get_default_dtype_as_scalartype()), size.vec())};
|
||||
}
|
||||
|
@ -443,46 +450,46 @@ std::vector<torch::lazy::Shape> compute_shape_fill(const at::Tensor &self,
|
|||
}
|
||||
|
||||
std::vector<torch::lazy::Shape>
|
||||
compute_shape_randn(at::IntArrayRef size, c10::optional<at::ScalarType> dtype,
|
||||
c10::optional<at::Layout> layout,
|
||||
c10::optional<at::Device> device,
|
||||
c10::optional<bool> pin_memory) {
|
||||
compute_shape_randn(at::IntArrayRef size, ::std::optional<at::ScalarType> dtype,
|
||||
::std::optional<at::Layout> layout,
|
||||
::std::optional<at::Device> device,
|
||||
::std::optional<bool> pin_memory) {
|
||||
return {
|
||||
Shape(dtype.value_or(at::get_default_dtype_as_scalartype()), size.vec())};
|
||||
}
|
||||
|
||||
std::vector<torch::lazy::Shape> compute_shape_randint(
|
||||
int64_t high, at::IntArrayRef size, c10::optional<at::ScalarType> dtype,
|
||||
c10::optional<at::Layout> layout, c10::optional<at::Device> device,
|
||||
c10::optional<bool> pin_memory) {
|
||||
int64_t high, at::IntArrayRef size, ::std::optional<at::ScalarType> dtype,
|
||||
::std::optional<at::Layout> layout, ::std::optional<at::Device> device,
|
||||
::std::optional<bool> pin_memory) {
|
||||
return {
|
||||
Shape(dtype.value_or(at::get_default_dtype_as_scalartype()), size.vec())};
|
||||
}
|
||||
|
||||
std::vector<torch::lazy::Shape> compute_shape_randint(
|
||||
int64_t low, int64_t high, at::IntArrayRef size,
|
||||
c10::optional<at::ScalarType> dtype, c10::optional<at::Layout> layout,
|
||||
c10::optional<at::Device> device, c10::optional<bool> pin_memory) {
|
||||
::std::optional<at::ScalarType> dtype, ::std::optional<at::Layout> layout,
|
||||
::std::optional<at::Device> device, ::std::optional<bool> pin_memory) {
|
||||
return {
|
||||
Shape(dtype.value_or(at::get_default_dtype_as_scalartype()), size.vec())};
|
||||
}
|
||||
|
||||
std::vector<torch::lazy::Shape>
|
||||
compute_shape_resize(const at::Tensor &self, at::IntArrayRef size,
|
||||
c10::optional<at::MemoryFormat> memory_format) {
|
||||
::std::optional<at::MemoryFormat> memory_format) {
|
||||
return {Shape(self.scalar_type(), size.vec())};
|
||||
}
|
||||
|
||||
std::vector<torch::lazy::Shape>
|
||||
compute_shape_bernoulli(const at::Tensor &self, const at::Tensor &p,
|
||||
c10::optional<at::Generator> generator) {
|
||||
::std::optional<at::Generator> generator) {
|
||||
return {Shape(self.scalar_type(), self.sizes().vec())};
|
||||
}
|
||||
|
||||
std::vector<torch::lazy::Shape> compute_shape_scalar_tensor(
|
||||
const at::Scalar &s, c10::optional<at::ScalarType> dtype,
|
||||
c10::optional<at::Layout> layout, c10::optional<at::Device> device,
|
||||
c10::optional<bool> pin_memory) {
|
||||
const at::Scalar &s, ::std::optional<at::ScalarType> dtype,
|
||||
::std::optional<at::Layout> layout, ::std::optional<at::Device> device,
|
||||
::std::optional<bool> pin_memory) {
|
||||
return {Shape(dtype.value_or(s.type()), c10::ArrayRef<int64_t>{})};
|
||||
}
|
||||
|
||||
|
@ -494,8 +501,8 @@ std::vector<torch::lazy::Shape> compute_shape_roll(const at::Tensor &self,
|
|||
|
||||
std::vector<torch::lazy::Shape> compute_shape_linspace(
|
||||
const at::Scalar &start, const at::Scalar &end, int64_t steps,
|
||||
c10::optional<at::ScalarType> dtype, c10::optional<at::Layout> layout,
|
||||
c10::optional<at::Device> device, c10::optional<bool> pin_memory) {
|
||||
::std::optional<at::ScalarType> dtype, ::std::optional<at::Layout> layout,
|
||||
::std::optional<at::Device> device, ::std::optional<bool> pin_memory) {
|
||||
auto out_meta = at::linspace(start, end, steps, dtype, layout,
|
||||
c10::Device(c10::kMeta), pin_memory);
|
||||
return {Shape(out_meta.scalar_type(), out_meta.sizes().vec())};
|
||||
|
|
|
@ -75,7 +75,7 @@ torch::lazy::DeviceData *device_data_cast(const torch::lazy::Value &value) {
|
|||
|
||||
torch::lazy::DeviceData *
|
||||
device_data_cast(const at::Tensor &tensor,
|
||||
c10::optional<torch::lazy::BackendDevice> device) {
|
||||
std::optional<torch::lazy::BackendDevice> device) {
|
||||
if (!device) {
|
||||
device = torch::lazy::GetBackendDevice(tensor);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ TORCH_API torch::lazy::DeviceData *
|
|||
device_data_cast(const torch::lazy::Value &value);
|
||||
TORCH_API torch::lazy::DeviceData *device_data_cast(
|
||||
const at::Tensor &tensor,
|
||||
c10::optional<torch::lazy::BackendDevice> device = c10::nullopt);
|
||||
std::optional<torch::lazy::BackendDevice> device = c10::nullopt);
|
||||
|
||||
} // namespace lazy
|
||||
} // namespace torch
|
||||
|
|
Loading…
Reference in New Issue