tensorflow/compiler/mlir/tfrt/jit/tf_jitrt_kernels.cc
// Converts Tensor to the Memref Descriptor and verifies that the Tensor
// value is compatible with the memref type.
Converts Tensor to the Memref Descriptor and verifies that the Tensor
value is compatible with the memref type.
Converts Tensor to the Memref Descriptor and verifies that the Tensor value is compatible with the memref type .
static void ConvertTensorToMemrefDesc(const tensorflow::Tensor& tensor,
                                      MemrefDesc* memref) {
  memref->dtype = tfd::GetTfrtDtype(tensor.dtype());
  memref->data = const_cast<void*>(tensor.data());
  memref->offset = 0;
  int rank = tensor.dims();
  memref->sizes.resize_for_overwrite(rank);
  memref->strides.resize_for_overwrite(rank);
  int64_t multiplier = 1;
  for (int i = rank - 1; i >= 0; --i) {
    int64_t dim_size = tensor.dim_size(i);
    memref->sizes[i] = dim_size;
    memref->strides[i] = multiplier;
    multiplier *= dim_size;
  }
}
static void ConvertTensorToMemrefDesc ( const tensorflow :: Tensor & tensor , MemrefDesc * memref ) { memref -> dtype = tfd :: GetTfrtDtype ( tensor . dtype ( ) ) ; memref -> data = const_cast < void * > ( tensor . data ( ) ) ; memref -> offset = 0 ; int rank = tensor . dims ( ) ; memref -> sizes . resize_for_overwrite ( rank ) ; memref -> strides . resize_for_overwrite ( rank ) ; int64_t multiplier = 1 ; for ( int i = rank - 1 ; i >= 0 ; -- i ) { int64_t dim_size = tensor . dim_size ( i ) ; memref -> sizes [ i ] = dim_size ; memref -> strides [ i ] = multiplier ; multiplier *= dim_size ; } }
Converts Tensor to the Memref Descriptor and verifies that the Tensor
value is compatible with the memref type.
Converts Tensor to the Memref Descriptor and verifies that the Tensor value is compatible with the memref type .
// Fill memref sizes and compute strides from the tensor dimensions.