blob: 3965c6f4de8ccd7755d64c5f486917866b52f7bb [file]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/*!
* \file ptx.h
* \brief Code generation with inlined PTX code.
*/
#ifndef TVM_TARGET_SOURCE_PTX_H_
#define TVM_TARGET_SOURCE_PTX_H_
#include <tvm/ffi/error.h>
#include <string>
#include <tuple>
#include "codegen_cuda.h"
namespace tvm {
namespace codegen {
/*!
* \brief Print MMA assembly string given parameters.
* \param shape The shape string mMnNkK
* \param A_layout The layout of multiplicand A, can be either "row" or "col".
* \param B_layout The layout of multiplicand B, can be either "row" or "col".
* \param A_dtype The data type of multiplicand A.
* \param B_dtype The data type of multiplicand B.
* \param C_dtype The data type of multiplicand C.
* \param a_ptr Pointer to buffer A.
* \param a_offset The offset of element in A.
* \param b_ptr Pointer to buffer B.
* \param b_offset The offset of element in B.
* \param c_ptr Pointer to buffer C.
* \param c_offset The offset of element in C.
* \param bit_op The bit operator used in 1-bit mma, can be either "xor" or "and".
* \param saturate Whether saturate output or not.
*/
/*!
* \brief ldmatrix assembly emitter. Offsets are element offsets in the
* buffer's dtype; the generated C pointer arithmetic ``ptr + offset``
* scales them to bytes.
*/
std::string PrintLoadMatrixAssembly(bool trans, int num, const std::string& type,
const std::string& local_ptr,
const std::string& local_elem_offset,
const std::string& smem_ptr,
const std::string& smem_elem_offset);
std::string PrintMMAAssembly(const std::string& shape, const std::string& A_layout,
const std::string& B_layout, const std::string& A_dtype,
const std::string& B_dtype, const std::string& C_dtype,
const std::string& a_ptr, const std::string& a_offset,
const std::string& b_ptr, const std::string& b_offset,
const std::string& c_ptr, const std::string& c_offset,
const std::string& bit_op, bool saturate);
} // namespace codegen
} // namespace tvm
#endif // TVM_TARGET_SOURCE_PTX_H_