SPB Git

spb/forge Public MIT

Forge — LLM training from scratch in pure C++20 + Metal on Apple Silicon.

C++ 61.2% C 23% Python 7.6% TeX 7.2% CMake 1.1%
3.3 KB · 98 lines cpp
Raw Blame History
1//-------------------------------------------------------------------------------------------------------------------------------------------------------------2//3// Metal/MTL4BinaryFunctionDescriptor.hpp4//5// Copyright 2020-2025 Apple Inc.6//7// Licensed under the Apache License, Version 2.0 (the "License");8// you may not use this file except in compliance with the License.9// You may obtain a copy of the License at10//11//     http://www.apache.org/licenses/LICENSE-2.012//13// Unless required by applicable law or agreed to in writing, software14// distributed under the License is distributed on an "AS IS" BASIS,15// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.16// See the License for the specific language governing permissions and17// limitations under the License.18//19//-------------------------------------------------------------------------------------------------------------------------------------------------------------2021#pragma once2223#include "../Foundation/Foundation.hpp"24#include "MTLDefines.hpp"25#include "MTLHeaderBridge.hpp"26#include "MTLPrivate.hpp"2728namespace MTL429{30class BinaryFunctionDescriptor;31class FunctionDescriptor;3233_MTL_OPTIONS(NS::UInteger, BinaryFunctionOptions) {34    BinaryFunctionOptionNone = 0,35    BinaryFunctionOptionPipelineIndependent = 1 << 1,36};3738class BinaryFunctionDescriptor : public NS::Copying<BinaryFunctionDescriptor>39{40public:41    static BinaryFunctionDescriptor* alloc();4243    FunctionDescriptor*              functionDescriptor() const;4445    BinaryFunctionDescriptor*        init();4647    NS::String*                      name() const;4849    BinaryFunctionOptions            options() const;5051    void                             setFunctionDescriptor(const MTL4::FunctionDescriptor* functionDescriptor);5253    void                             setName(const NS::String* name);5455    void                             setOptions(MTL4::BinaryFunctionOptions options);56};5758}59_MTL_INLINE MTL4::BinaryFunctionDescriptor* MTL4::BinaryFunctionDescriptor::alloc()60{61    return NS::Object::alloc<MTL4::BinaryFunctionDescriptor>(_MTL_PRIVATE_CLS(MTL4BinaryFunctionDescriptor));62}6364_MTL_INLINE MTL4::FunctionDescriptor* MTL4::BinaryFunctionDescriptor::functionDescriptor() const65{66    return Object::sendMessage<MTL4::FunctionDescriptor*>(this, _MTL_PRIVATE_SEL(functionDescriptor));67}6869_MTL_INLINE MTL4::BinaryFunctionDescriptor* MTL4::BinaryFunctionDescriptor::init()70{71    return NS::Object::init<MTL4::BinaryFunctionDescriptor>();72}7374_MTL_INLINE NS::String* MTL4::BinaryFunctionDescriptor::name() const75{76    return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(name));77}7879_MTL_INLINE MTL4::BinaryFunctionOptions MTL4::BinaryFunctionDescriptor::options() const80{81    return Object::sendMessage<MTL4::BinaryFunctionOptions>(this, _MTL_PRIVATE_SEL(options));82}8384_MTL_INLINE void MTL4::BinaryFunctionDescriptor::setFunctionDescriptor(const MTL4::FunctionDescriptor* functionDescriptor)85{86    Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFunctionDescriptor_), functionDescriptor);87}8889_MTL_INLINE void MTL4::BinaryFunctionDescriptor::setName(const NS::String* name)90{91    Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setName_), name);92}9394_MTL_INLINE void MTL4::BinaryFunctionDescriptor::setOptions(MTL4::BinaryFunctionOptions options)95{96    Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setOptions_), options);97}98