Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ET-VK] Remove Functions.h/cpp #2245

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions backends/vulkan/runtime/graph/ops/Functions.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion backends/vulkan/runtime/graph/ops/OperatorRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <executorch/backends/vulkan/runtime/graph/ops/OperatorRegistry.h>

#include <executorch/backends/vulkan/runtime/graph/ops/Functions.h>
#include <executorch/backends/vulkan/runtime/graph/ops/impl/Arithmetic.h>

namespace at {
namespace native {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,16 @@

#ifdef USE_VULKAN_API

#include <ATen/native/vulkan/impl/Arithmetic.h>

#include <executorch/backends/vulkan/runtime/graph/ComputeGraph.h>

namespace at {
namespace native {
namespace vulkan {

#define DEFINE_OP_FN(name) \
ValueRef name(ComputeGraph& graph, const std::vector<ValueRef>& args);

DEFINE_OP_FN(add);
DEFINE_OP_FN(sub);
DEFINE_OP_FN(mul);
DEFINE_OP_FN(div);
DEFINE_OP_FN(floor_div);
DEFINE_OP_FN(pow);
#define DECLARE_OP_FN(function) \
ValueRef function(ComputeGraph& graph, const std::vector<ValueRef>& args);

} // namespace vulkan
} // namespace native
Expand Down
48 changes: 33 additions & 15 deletions backends/vulkan/runtime/graph/ops/impl/Arithmetic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,39 @@ namespace at {
namespace native {
namespace vulkan {

#define DEFINE_ARITHMETIC_FN(function, op_type) \
ValueRef function(ComputeGraph& graph, const std::vector<ValueRef>& args) { \
return add_arithmetic_node( \
graph, \
args[0], \
args[1], \
args[2], \
arithmetic::OpType::op_type, \
args[3]); \
}

DEFINE_ARITHMETIC_FN(add, ADD);
DEFINE_ARITHMETIC_FN(sub, SUB);
DEFINE_ARITHMETIC_FN(mul, MUL);
DEFINE_ARITHMETIC_FN(div, DIV);
DEFINE_ARITHMETIC_FN(floor_div, FLOOR_DIV);
DEFINE_ARITHMETIC_FN(pow, POW);

ValueRef add_arithmetic_node(
ComputeGraph& graph,
const ValueRef t1,
const ValueRef t2,
const float alpha,
const arithmetic::OpType optype,
const int64_t shared_object_idx) {
std::vector<int64_t> t1_sizes = graph.get_val_sizes(t1);
api::ScalarType t1_dtype = graph.get_val_dtype(t1);

ValueRef out = graph.add_tensor(t1_sizes, t1_dtype, shared_object_idx);
add_arithmetic_node(graph, t1, t2, out, alpha, optype);
return out;
}

void add_arithmetic_node(
ComputeGraph& graph,
const ValueRef t1,
Expand Down Expand Up @@ -46,21 +79,6 @@ void add_arithmetic_node(
new ArithmeticNode(arg1, arg2, out, alpha, optype));
}

ValueRef add_arithmetic_node(
ComputeGraph& graph,
const ValueRef t1,
const ValueRef t2,
const float alpha,
const arithmetic::OpType optype,
const int64_t shared_object_idx) {
std::vector<int64_t> t1_sizes = graph.get_val_sizes(t1);
api::ScalarType t1_dtype = graph.get_val_dtype(t1);

ValueRef out = graph.add_tensor(t1_sizes, t1_dtype, shared_object_idx);
add_arithmetic_node(graph, t1, t2, out, alpha, optype);
return out;
}

ArithmeticPrepack::ArithmeticPrepack(const ValueRef tref, const ValueRef packed)
: PrepackNode(tref, packed) {}

Expand Down
21 changes: 15 additions & 6 deletions backends/vulkan/runtime/graph/ops/impl/Arithmetic.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,34 @@

#include <executorch/backends/vulkan/runtime/graph/ComputeGraph.h>

#include <executorch/backends/vulkan/runtime/graph/ops/Utils.h>

namespace at {
namespace native {
namespace vulkan {

void add_arithmetic_node(
DECLARE_OP_FN(add);
DECLARE_OP_FN(sub);
DECLARE_OP_FN(mul);
DECLARE_OP_FN(div);
DECLARE_OP_FN(floor_div);
DECLARE_OP_FN(pow);

ValueRef add_arithmetic_node(
ComputeGraph& graph,
const ValueRef t1,
const ValueRef t2,
const ValueRef out,
const float alpha,
const arithmetic::OpType optype);
const arithmetic::OpType optype,
const int64_t shared_object_idx = -1);

ValueRef add_arithmetic_node(
void add_arithmetic_node(
ComputeGraph& graph,
const ValueRef t1,
const ValueRef t2,
const ValueRef out,
const float alpha,
const arithmetic::OpType optype,
const int64_t shared_object_idx = -1);
const arithmetic::OpType optype);

class ArithmeticPrepack : public virtual PrepackNode {
public:
Expand Down
Loading