// // Copyright (c) 2023 Apple Inc. All rights reserved. // Provided subject to the LICENSE file in the top level directory. // #pragma once #import #include #include #include #include namespace executorch { namespace backends { namespace mps { namespace delegate { #define INF std::numeric_limits::infinity() MPSDataType getMPSScalarType(executorch::aten::ScalarType scalar_type); executorch::aten::ScalarType getScalarType(MPSDataType mpsDataType); MPSGraphTensor *castMPSTensor(MPSGraph *mpsGraph, MPSGraphTensor *tensor, executorch::aten::ScalarType toType); MPSGraphTensor *castMPSTensor(MPSGraph *mpsGraph, MPSGraphTensor *tensor, MPSDataType toType); std::vector getMPSShapeVec(const MPSShape *shape); template std::vector flatbufferDimsToVector(const flatbuffers::Vector *dims) { std::vector dimsData; dimsData.reserve(dims->size()); for (auto dim : *dims) { dimsData.push_back(static_cast(dim)); } return dimsData; } id getMTLBufferStorage(const executorch::aten::Tensor &tensor); void *pageAlignedBlockPtr(const void *ptr, NSUInteger size, NSUInteger *alignedBlockSize); MPSGraphTensor *permuteTensor(MPSGraph *graph, MPSGraphTensor *inputTensor, NSArray *permuteOrder); } // namespace delegate } // namespace mps } // namespace backends } // namespace executorch