17#ifndef LUCI_INTERPRETER_PAL_BATCHMATMUL_H
18#define LUCI_INTERPRETER_PAL_BATCHMATMUL_H
20#include <tensorflow/lite/kernels/internal/reference/batch_matmul.h>
24inline void BatchMatMul(
const tflite::RuntimeShape &lhs_shape,
const float *lhs_data,
25 const tflite::RuntimeShape &rhs_shape,
const float *rhs_data,
26 const tflite::RuntimeShape &
output_shape,
float *output_data)
28 tflite::reference_ops::BatchMatMul(lhs_shape, lhs_data, rhs_shape, rhs_data,
output_shape,
34 const tflite::RuntimeShape &lhs_shape,
35 const tflite::RuntimeShape &rhs_shape)
39 auto lhs_rank = lhs_shape.DimensionsCount();
41 for (
int i = 0; i < lhs_rank - 2; ++i)
43 scratchpad_size.dim(i) = lhs_shape.Dims(i);
45 scratchpad_size.dim(lhs_rank - 2) = lhs_shape.Dims(lhs_rank - 1);
46 scratchpad_size.dim(lhs_rank - 1) = lhs_shape.Dims(lhs_rank - 2);
48 lhs_scratchpad->
resize(scratchpad_size);
52 auto rhs_rank = rhs_shape.DimensionsCount();
54 for (
int i = 0; i < rhs_rank - 2; ++i)
56 scratchpad_size.dim(i) = rhs_shape.Dims(i);
58 scratchpad_size.dim(rhs_rank - 2) = rhs_shape.Dims(rhs_rank - 1);
59 scratchpad_size.dim(rhs_rank - 1) = rhs_shape.Dims(rhs_rank - 2);
61 rhs_scratchpad->
resize(scratchpad_size);
void resize(const Shape &new_shape)
const luci_interpreter::RuntimeShape output_shape
void BatchMatMul(const tflite::RuntimeShape &lhs_shape, const float *lhs_data, const tflite::RuntimeShape &rhs_shape, const float *rhs_data, const tflite::RuntimeShape &output_shape, float *output_data)