-- automatically generated by the FlatBuffers compiler, do not modify

-- namespace: ppx

local flatbuffers = require('flatbuffers')

local Tensor = {} -- the module
local Tensor_mt = {} -- the class metatable

function Tensor.New()
    local o = {}
    setmetatable(o, {__index = Tensor_mt})
    return o
end
function Tensor.GetRootAsTensor(buf, offset)
    if type(buf) == "string" then
        buf = flatbuffers.binaryArray.New(buf)
    end
    local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
    local o = Tensor.New()
    o:Init(buf, n + offset)
    return o
end
function Tensor_mt:Init(buf, pos)
    self.view = flatbuffers.view.New(buf, pos)
end
function Tensor_mt:Data(j)
    local o = self.view:Offset(4)
    if o ~= 0 then
        local a = self.view:Vector(o)
        return self.view:Get(flatbuffers.N.Float64, a + ((j-1) * 8))
    end
    return 0
end
function Tensor_mt:DataLength()
    local o = self.view:Offset(4)
    if o ~= 0 then
        return self.view:VectorLen(o)
    end
    return 0
end
function Tensor_mt:Shape(j)
    local o = self.view:Offset(6)
    if o ~= 0 then
        local a = self.view:Vector(o)
        return self.view:Get(flatbuffers.N.Int32, a + ((j-1) * 4))
    end
    return 0
end
function Tensor_mt:ShapeLength()
    local o = self.view:Offset(6)
    if o ~= 0 then
        return self.view:VectorLen(o)
    end
    return 0
end
function Tensor.Start(builder) builder:StartObject(2) end
function Tensor.AddData(builder, data) builder:PrependUOffsetTRelativeSlot(0, data, 0) end
function Tensor.StartDataVector(builder, numElems) return builder:StartVector(8, numElems, 8) end
function Tensor.AddShape(builder, shape) builder:PrependUOffsetTRelativeSlot(1, shape, 0) end
function Tensor.StartShapeVector(builder, numElems) return builder:StartVector(4, numElems, 4) end
function Tensor.End(builder) return builder:EndObject() end

return Tensor -- return the module