2023-08-30 18:29:39 +08:00
|
|
|
//===- index.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 IndexTensor : public torch::lazy::TorchMlirNode {
|
2024-01-30 01:59:33 +08:00
|
|
|
public:
|
2023-08-30 18:29:39 +08:00
|
|
|
static torch::lazy::OpKind ClassOpKind() {
|
|
|
|
return torch::lazy::OpKind(at::aten::index);
|
|
|
|
}
|
|
|
|
|
2024-01-30 01:59:33 +08:00
|
|
|
IndexTensor(const torch::lazy::Value &self, const torch::lazy::Value &indices,
|
|
|
|
std::vector<torch::lazy::Shape> &&shapes);
|
2023-08-30 18:29:39 +08:00
|
|
|
|
|
|
|
std::string ToString() const override;
|
|
|
|
|
2024-01-30 01:59:33 +08:00
|
|
|
bool CanBeReused(const torch::lazy::Value &self,
|
|
|
|
const torch::lazy::Value &indices) const;
|
2023-08-30 18:29:39 +08:00
|
|
|
|
|
|
|
TorchMlirOpVector Lower(TorchMlirFunction function,
|
2024-01-30 01:59:33 +08:00
|
|
|
TorchMlirLoweringContext *loctx) const override;
|
2023-08-30 18:29:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class IndexPut : public torch::lazy::TorchMlirNode {
|
2024-01-30 01:59:33 +08:00
|
|
|
public:
|
2023-08-30 18:29:39 +08:00
|
|
|
static torch::lazy::OpKind ClassOpKind() {
|
|
|
|
return torch::lazy::OpKind(at::aten::index_put);
|
|
|
|
}
|
|
|
|
|
2024-01-30 01:59:33 +08:00
|
|
|
IndexPut(const torch::lazy::Value &self, const torch::lazy::Value &indices,
|
|
|
|
const torch::lazy::Value &values, bool accumulate,
|
|
|
|
std::vector<torch::lazy::Shape> &&shapes);
|
2023-08-30 18:29:39 +08:00
|
|
|
|
|
|
|
std::string ToString() const override;
|
|
|
|
|
2024-01-30 01:59:33 +08:00
|
|
|
bool CanBeReused(const torch::lazy::Value &self,
|
|
|
|
const torch::lazy::Value &indices,
|
|
|
|
const torch::lazy::Value &values, bool accumulate) const;
|
2023-08-30 18:29:39 +08:00
|
|
|
|
|
|
|
TorchMlirOpVector Lower(TorchMlirFunction function,
|
2024-01-30 01:59:33 +08:00
|
|
|
TorchMlirLoweringContext *loctx) const override;
|
2023-08-30 18:29:39 +08:00
|
|
|
|
|
|
|
bool accumulate;
|
|
|
|
};
|
|
|
|
|
2024-01-30 01:59:33 +08:00
|
|
|
} // namespace lazy
|
|
|
|
} // namespace torch
|