-
Notifications
You must be signed in to change notification settings - Fork 247
Expand file tree
/
Copy pathoperatorBase.cpp
More file actions
51 lines (43 loc) · 1.83 KB
/
operatorBase.cpp
File metadata and controls
51 lines (43 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "uTensor/core/operatorBase.hpp"
#include "uTensor/core/context.hpp"
namespace uTensor {
// EVENTS AND ERRORS
DEFINE_ERROR(OperatorIOSizeMismatchError);
// OperatorBase::OperatorBase(TensorMapInterface* inputs, TensorMapInterface*
// outputs) : inputs(inputs), outputs(outputs) {
// Context* ctx = Context::get_default_context();
// // ctx.push_op_tensors(*this, inputs);
// // ctx.push_op_tensors(*this, outputs);
//}
// The preferred interface
OperatorBase::OperatorBase(TensorMapInterface* inputs) : _p_inputs(inputs) {
// Context* ctx = Context::get_default_context();
// ctx.push_op_tensors(*this, inputs);
}
OperatorBase::OperatorBase() {}
OperatorBase::OperatorBase(uTensor::string op_name) : op_name(op_name) {}
void OperatorBase::set_inputs(TensorMapInterface* inputs) {
this->_p_inputs = inputs;
// Context* ctx = Context::get_default_context();
// ctx.push_op_tensors(*this, inputs);
}
void OperatorBase::set_outputs(TensorMapInterface* outputs) {
this->_p_outputs = outputs;
// Context* ctx = Context::get_default_context();
// ctx.push_op_tensors(*this, outputs);
}
void OperatorBase::eval() { compute(); }
OperatorBase::~OperatorBase() {
// Context* ctx = Context::get_default_context();
// ctx.pop_op_tensors(*this, inputs); // Inputs are no longer needed
}
void OperatorBase::set_name(uTensor::string _name) { op_name = _name; }
size_t FastOperator::get_readable_block(const Tensor& t, const void*& buffer,
uint16_t num_elems, int linear_index) {
return t->get_readable_block(buffer, num_elems, linear_index);
}
size_t FastOperator::get_writeable_block(Tensor& t, void*& buffer,
uint16_t num_elems, int linear_index) {
return t->get_writeable_block(buffer, num_elems, linear_index);
}
} // namespace uTensor