--- /dev/null
+#ifndef __NNKIT_TENSOR_CONTEXT_H__
+#define __NNKIT_TENSOR_CONTEXT_H__
+
+#include <nncc/core/ADT/tensor/Shape.h>
+#include <nncc/core/ADT/tensor/Reader.h>
+#include <nncc/core/ADT/tensor/Accessor.h>
+
+#include <string>
+#include <functional>
+
+#include <cstdint>
+
+namespace nnkit
+{
+
+// NOTE This interface is subject to change.
+struct TensorContext
+{
+ template<typename T>
+ using TypedReader = std::function<void (const TensorContext &, uint32_t n, const nncc::core::ADT::tensor::Reader<T> &)>;
+
+ template<typename T>
+ using TypedAccessor = std::function<void (const TensorContext &, uint32_t n, nncc::core::ADT::tensor::Accessor<T> &)>;
+
+ virtual ~TensorContext() = default;
+
+ // The number of tensors that this context provides
+ virtual uint32_t size(void) const = 0;
+
+ // Query on properties of each tensor
+ virtual std::string name(uint32_t n) const = 0;
+ virtual nncc::core::ADT::tensor::Shape shape(uint32_t n) const = 0;
+
+ // TODO Support generic byte tensor
+ // TODO Support typed tensor for primitive types such as half(fp16), double(fp64), int8(s8), int32(s32), uint8(u8), uint(u32)
+
+ // Float (fp32) tensor support
+ virtual bool isFloatTensor(uint32_t n) const = 0;
+
+ virtual void getMutableFloatTensor(uint32_t n, const TypedAccessor<float> &cb) = 0;
+ void getMutableFloatTensor(uint32_t n, const std::function<void (nncc::core::ADT::tensor::Accessor<float> &)> &f)
+ {
+ getMutableFloatTensor(n, [&f] (const TensorContext &, uint32_t, nncc::core::ADT::tensor::Accessor<float> &t)
+ {
+ f(t);
+ });
+ }
+
+ virtual void getConstFloatTensor(uint32_t n, const TypedReader<float> &cb) const = 0;
+ void getConstFloatTensor(uint32_t n, const std::function<void (const nncc::core::ADT::tensor::Reader<float> &)> &f) const
+ {
+ getConstFloatTensor(n, [&f] (const TensorContext &, uint32_t, const nncc::core::ADT::tensor::Reader<float> &t)
+ {
+ f(t);
+ });
+ }
+};
+
+} // namespace nnkit
+
+#endif // __NNKIT_TENSOR_CONTEXT_H__