}
::neurun::internal::operand::Shape shape(type->dimensionCount);
+ ::neurun::internal::operand::TypeInfo typeInfo((OperandCode)(type->type), type->scale,
+ type->zeroPoint);
for (uint32_t axis = 0; axis < type->dimensionCount; ++axis)
{
shape.set(type->type, type->scale, type->zeroPoint);
- model->deref().addOperand(shape);
+ model->deref().addOperand(shape, typeInfo);
// NOTE We do NOT allocate CLTensor here as we do not how to interpret this one.
// TensorFlow Lite may interpret a rank-4 tensor either as a feature map (with batch) or
namespace graph
{
-operand::Index Graph::addOperand(const ::neurun::internal::operand::Shape &shape)
+operand::Index Graph::addOperand(const ::neurun::internal::operand::Shape &shape,
+ const ::neurun::internal::operand::TypeInfo &type)
{
assert(_phase == Phase::BUILDING);
- return _operands.append(shape);
+ return _operands.append(shape, type);
}
operation::Index Graph::addOperation(std::unique_ptr<operation::Node> &&node)
// Graph Building
public:
- operand::Index addOperand(const ::neurun::internal::operand::Shape &shape);
+ operand::Index addOperand(const ::neurun::internal::operand::Shape &shape,
+ const ::neurun::internal::operand::TypeInfo &type);
operation::Index addOperation(std::unique_ptr<operation::Node> &&node);
void setOperandValue(const operand::Index &ind,
std::unique_ptr<::neurun::internal::operand::Data> &&data);
namespace operand
{
-Index Set::append(const internal::Shape &shape)
+Index Set::append(const internal::Shape &shape, const internal::TypeInfo &type)
{
uint32_t index = _objects.size();
- _objects.emplace_back(new internal::Object{shape});
+ _objects.emplace_back(new internal::Object{shape, type});
return Index{index};
}
#include <memory>
#include <vector>
-#include "internal/Model.h"
+#include "internal/operand/Object.h"
#include "Index.h"
namespace neurun
Set() = default;
public:
- Index append(const internal::Shape &);
+ Index append(const internal::Shape &, const internal::TypeInfo &);
public:
const internal::Object &at(const Index &) const;
#include "Shape.h"
#include "Data.h"
+#include "TypeInfo.h"
namespace neurun
{
class Object
{
public:
- explicit Object(const Shape &shape) : _shape{shape}, _usage{OperandUsage::NOT_DEFINED}
+ explicit Object(const Shape &shape, const TypeInfo &type)
+ : _shape{shape}, _type{type}, _usage{OperandUsage::NOT_DEFINED}
{
// DO NOTHING
}
private:
const Shape _shape;
+ const TypeInfo _type;
std::unique_ptr<Data> _data;
OperandUsage _usage;
};
shape1.dim(2) = 30;
shape1.dim(3) = 40;
- set.append(shape0);
- set.append(shape1);
+ ::neurun::internal::operand::TypeInfo type{ANEURALNETWORKS_TENSOR_INT32, 0, 0};
+
+ set.append(shape0, type);
+ set.append(shape1, type);
ASSERT_EQ(set.exist(neurun::graph::operand::Index{0u}), true);
ASSERT_EQ(set.exist(neurun::graph::operand::Index{1u}), true);
neurun::graph::Graph graph;
neurun::internal::operand::Shape shape{1u};
+ neurun::internal::operand::TypeInfo type{ANEURALNETWORKS_TENSOR_INT32, 0, 0};
shape.dim(0) = 3;
// Add Conv
std::vector<uint32_t> params;
for (int i = 0; i < 7; ++i)
{
- params.emplace_back(graph.addOperand(shape).asInt());
+ params.emplace_back(graph.addOperand(shape, type).asInt());
}
- uint32_t outoperand = graph.addOperand(shape).asInt();
+ uint32_t outoperand = graph.addOperand(shape, type).asInt();
using Param = internal::tflite::op::Conv2D::implicit::Param;
using Node = internal::tflite::op::Conv2D::implicit::Node;
neurun::graph::Graph graph;
neurun::internal::operand::Shape shape{1u};
+ neurun::internal::operand::TypeInfo type{ANEURALNETWORKS_TENSOR_INT32, 0, 0};
shape.dim(0) = 3;
// Add Concat
std::vector<uint32_t> params;
for (int i = 0; i < 7; ++i)
{
- params.emplace_back(graph.addOperand(shape).asInt());
+ params.emplace_back(graph.addOperand(shape, type).asInt());
}
- uint32_t outoperand = graph.addOperand(shape).asInt();
+ uint32_t outoperand = graph.addOperand(shape, type).asInt();
using Param = internal::tflite::op::Concat::Param;
using Node = internal::tflite::op::Concat::Node;
neurun::graph::verifier::DAGChecker verifier;
::neurun::internal::operand::Shape shape{1u};
+ ::neurun::internal::operand::TypeInfo type{ANEURALNETWORKS_TENSOR_INT32, 0, 0};
shape.dim(0) = 3;
- auto operand1 = graph.addOperand(shape);
- auto operand2 = graph.addOperand(shape);
+ auto operand1 = graph.addOperand(shape, type);
+ auto operand2 = graph.addOperand(shape, type);
graph.addInput(operand1);
graph.addOutput(operand2);