2023-08-21 04:32:11 +08:00
|
|
|
//===- split.h ------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
// Also available under a BSD-style license. See LICENSE.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../mlir_node.h"
|
|
|
|
|
|
|
|
namespace torch {
|
|
|
|
namespace lazy {
|
|
|
|
|
|
|
|
class SplitWithSizesCopy : public torch::lazy::TorchMlirNode {
|
|
|
|
public:
|
|
|
|
static torch::lazy::OpKind ClassOpKind() {
|
|
|
|
return torch::lazy::OpKind(at::aten::split_with_sizes_copy);
|
|
|
|
}
|
|
|
|
|
2024-01-30 01:59:33 +08:00
|
|
|
SplitWithSizesCopy(const torch::lazy::Value &self,
|
|
|
|
const ::std::vector<int64_t> &split_sizes,
|
|
|
|
const int64_t &dim,
|
|
|
|
std::vector<torch::lazy::Shape> &&shapes);
|
2023-08-21 04:32:11 +08:00
|
|
|
|
|
|
|
std::string ToString() const override;
|
|
|
|
|
2024-01-30 01:59:33 +08:00
|
|
|
bool CanBeReused(const torch::lazy::Value &self,
|
|
|
|
const ::std::vector<int64_t> &split_sizes,
|
|
|
|
const int64_t &dim) const;
|
2023-08-21 04:32:11 +08:00
|
|
|
|
|
|
|
TorchMlirOpVector Lower(TorchMlirFunction function,
|
2024-01-30 01:59:33 +08:00
|
|
|
TorchMlirLoweringContext *loctx) const override;
|
2023-08-21 04:32:11 +08:00
|
|
|
|
|
|
|
std::vector<int64_t> split_sizes;
|
|
|
|
int64_t dim;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SplitCopyTensor : public torch::lazy::TorchMlirNode {
|
|
|
|
public:
|
|
|
|
static torch::lazy::OpKind ClassOpKind() {
|
|
|
|
return torch::lazy::OpKind(at::aten::split_copy);
|
|
|
|
}
|
|
|
|
|
2024-01-30 01:59:33 +08:00
|
|
|
SplitCopyTensor(const torch::lazy::Value &self,
|
|
|
|
const torch::lazy::Value &split_size, const int64_t &dim,
|
|
|
|
std::vector<torch::lazy::Shape> &&shapes,
|
2023-08-21 04:32:11 +08:00
|
|
|
const size_t num_outputs = 1);
|
|
|
|
|
|
|
|
std::string ToString() const override;
|
|
|
|
|
2024-01-30 01:59:33 +08:00
|
|
|
bool CanBeReused(const torch::lazy::Value &self,
|
|
|
|
const torch::lazy::Value &split_size,
|
|
|
|
const int64_t &dim) const;
|
2023-08-21 04:32:11 +08:00
|
|
|
|
|
|
|
TorchMlirOpVector Lower(TorchMlirFunction function,
|
2024-01-30 01:59:33 +08:00
|
|
|
TorchMlirLoweringContext *loctx) const override;
|
2023-08-21 04:32:11 +08:00
|
|
|
|
|
|
|
int64_t dim;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace lazy
|
|
|
|
} // namespace torch
|