Commit 80edd992 authored by PanZezhong's avatar PanZezhong
Browse files

issue/71 合并infiniStatus

parent e77735ef
#ifndef __INFINIOP_STATUS__
#define __INFINIOP_STATUS__
typedef enum {
INFINIOP_STATUS_SUCCESS = 0,
INFINIOP_STATUS_INTERNAL_ERROR = 1,
INFINIOP_STATUS_BAD_PARAM = 2,
INFINIOP_STATUS_BAD_TENSOR_DTYPE = 3,
INFINIOP_STATUS_BAD_TENSOR_SHAPE = 4,
INFINIOP_STATUS_BAD_TENSOR_STRIDES = 5,
INFINIOP_STATUS_NULL_POINTER = 6,
INFINIOP_STATUS_INSUFFICIENT_WORKSPACE = 7,
INFINIOP_STATUS_DEVICE_TYPE_NOT_SUPPORTED = 8,
INFINIOP_STATUS_BAD_DEVICE = 9,
INFINIOP_STATUS_UNDEFINED_BEHAVIOR = 10,
} infiniopStatus_t;
#endif
......@@ -2,7 +2,6 @@
#define __INFINIOP_TENSOR_DESCRIPTOR__
#include "../infinicore.h"
#include "status.h"
struct InfiniopTensorDescriptor {
// Datatype
......@@ -17,8 +16,8 @@ struct InfiniopTensorDescriptor {
typedef struct InfiniopTensorDescriptor *infiniopTensorDescriptor_t;
__C __export infiniopStatus_t infiniopCreateTensorDescriptor(infiniopTensorDescriptor_t *desc_ptr, size_t ndim, const size_t *shape, const ptrdiff_t *strides, infiniDtype_t dtype);
__C __export infiniStatus_t infiniopCreateTensorDescriptor(infiniopTensorDescriptor_t *desc_ptr, size_t ndim, const size_t *shape, const ptrdiff_t *strides, infiniDtype_t dtype);
__C __export infiniopStatus_t infiniopDestroyTensorDescriptor(infiniopTensorDescriptor_t desc);
__C __export infiniStatus_t infiniopDestroyTensorDescriptor(infiniopTensorDescriptor_t desc);
#endif // __INFINIOP_TENSOR_DESCRIPTOR__
#include "common_ascend.h"
infiniopStatus_t createAscendHandle(infiniopAscendHandle_t *handle_ptr) {
infiniStatus_t createAscendHandle(infiniopAscendHandle_t *handle_ptr) {
int device_id = 0;
auto ret = aclrtGetDevice(&device_id);
CHECK_RET(ret == ACL_SUCCESS,
LOG_ERROR("aclrtGetDevice failed. ERROR: %d\n", ret));
return INFINI_STATUS_DEVICE_NOT_INITIALIZED);
*handle_ptr = new InfiniopAscendHandle{INFINI_DEVICE_ASCEND, device_id};
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
infiniopStatus_t destroyAscendHandle(infiniopAscendHandle_t handle_ptr) {
infiniStatus_t destroyAscendHandle(infiniopAscendHandle_t handle_ptr) {
delete handle_ptr;
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
......@@ -7,8 +7,8 @@
struct InfiniopAscendHandle;
typedef struct InfiniopAscendHandle *infiniopAscendHandle_t;
infiniopStatus_t createAscendHandle(infiniopAscendHandle_t *handle_ptr);
infiniStatus_t createAscendHandle(infiniopAscendHandle_t *handle_ptr);
infiniopStatus_t destroyAscendHandle(infiniopAscendHandle_t handle_ptr);
infiniStatus_t destroyAscendHandle(infiniopAscendHandle_t handle_ptr);
#endif
......@@ -8,26 +8,26 @@ int64_t numElements(const int64_t *shape, int64_t num) {
return numEle;
}
infiniopStatus_t mallocWorkspace(void **workspaceAddr, size_t workspaceSize) {
infiniStatus_t mallocWorkspace(void **workspaceAddr, size_t workspaceSize) {
*workspaceAddr = nullptr;
if (workspaceSize > 0) {
auto ret = aclrtMalloc(workspaceAddr, workspaceSize,
ACL_MEM_MALLOC_HUGE_FIRST);
CHECK_RET(ret == ACL_SUCCESS,
LOG_PRINT("aclrtMalloc failed. ERROR: %d\n", ret);
return INFINIOP_STATUS_INTERNAL_ERROR);
return INFINI_STATUS_INTERNAL_ERROR);
}
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
infiniopStatus_t freeWorkspace(void *workspaceAddr) {
infiniStatus_t freeWorkspace(void *workspaceAddr) {
if (workspaceAddr != nullptr) {
auto ret = aclrtFree(workspaceAddr);
CHECK_RET(ret == ACL_SUCCESS,
LOG_PRINT("aclrtFree failed, ERROR: %d\n", ret);
return INFINIOP_STATUS_INTERNAL_ERROR);
return INFINI_STATUS_INTERNAL_ERROR);
}
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
aclDataType toAclDataType(infiniDtype_t dt) {
......
......@@ -28,10 +28,10 @@ extern "C" {
printf(message, ##__VA_ARGS__); \
} while (0)
#define LOG_ERROR(message, ...) \
do { \
printf(message, ##__VA_ARGS__); \
return INFINIOP_STATUS_INTERNAL_ERROR; \
#define LOG_ERROR(message, ...) \
do { \
printf(message, ##__VA_ARGS__); \
return INFINI_STATUS_INTERNAL_ERROR; \
} while (0)
#ifdef __cplusplus
......@@ -46,8 +46,8 @@ struct InfiniopAscendHandle {
int64_t numElements(const int64_t *shape, int64_t num);
const char *dataTypeToString(aclDataType dtype);
const char *formatToString(aclFormat format);
infiniopStatus_t mallocWorkspace(void **workspaceAddr, size_t workspaceSize);
infiniopStatus_t freeWorkspace(void *workspaceAddr);
infiniStatus_t mallocWorkspace(void **workspaceAddr, size_t workspaceSize);
infiniStatus_t freeWorkspace(void *workspaceAddr);
aclDataType toAclDataType(infiniDtype_t dt);
#endif
......@@ -2,9 +2,9 @@
#include "../../ops/utils.h"
#include <algorithm>
infiniopStatus_t aclnnTensorDescriptor::setDescriptor(aclDataType dtype, const std::vector<int64_t> &shape, const std::vector<int64_t> &strides) {
infiniStatus_t aclnnTensorDescriptor::setDescriptor(aclDataType dtype, const std::vector<int64_t> &shape, const std::vector<int64_t> &strides) {
if (shape.size() != strides.size()) {
return INFINIOP_STATUS_BAD_TENSOR_STRIDES;
return INFINI_STATUS_BAD_TENSOR_STRIDES;
}
this->ndim = shape.size();
this->shape = std::vector<int64_t>(shape);
......@@ -16,26 +16,26 @@ infiniopStatus_t aclnnTensorDescriptor::setDescriptor(aclDataType dtype, const s
aclFormat format = aclFormat::ACL_FORMAT_ND;
this->format = format;
CHECK_STATUS(this->inferStorageShape(), INFINIOP_STATUS_SUCCESS);
CHECK_STATUS(this->inferStorageShape(), INFINI_STATUS_SUCCESS);
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
/// @brief Infer storage shape. For now this ruturns a 1D shape of the total tensor storage size.
/// We don't see why higher dimensional storage shape is ever needed. To change if necesary.
infiniopStatus_t aclnnTensorDescriptor::inferStorageShape() {
infiniStatus_t aclnnTensorDescriptor::inferStorageShape() {
auto index = std::max_element(this->strides.begin(), this->strides.end());
uint64_t max_stride_index = std::distance(this->strides.begin(), index);
this->storageNdim = 1;
this->storageShape = std::vector<int64_t>({this->shape[max_stride_index] * this->strides[max_stride_index]});
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
/// @brief Set aclnnTensorDescriptor from infiniopTensorDescriptor
/// @param y infiniopTensorDescriptor
/// @return infiniopStatus_t
infiniopStatus_t aclnnTensorDescriptor::fromInfiniOpTensorDescriptor(infiniopTensorDescriptor_t y) {
infiniStatus_t aclnnTensorDescriptor::fromInfiniOpTensorDescriptor(infiniopTensorDescriptor_t y) {
uint64_t ndim = y->ndim;
// Cast shape type
auto shape = std::vector<int64_t>(ndim);
......@@ -53,9 +53,9 @@ infiniopStatus_t aclnnTensorDescriptor::fromInfiniOpTensorDescriptor(infiniopTen
/// @param data Data ptr on device global mem.
/// @param tensor Pointer of pointer of aclTensor.
/// @return
infiniopStatus_t aclnnTensorDescriptor::createTensor(void *data) {
infiniStatus_t aclnnTensorDescriptor::createTensor(void *data) {
if (this->t) {
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
this->t = aclCreateTensor(this->shape.data(),
this->ndim,
......@@ -66,17 +66,17 @@ infiniopStatus_t aclnnTensorDescriptor::createTensor(void *data) {
this->storageShape.data(),
this->storageNdim,
data);
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
infiniopStatus_t aclnnTensorDescriptor::destroyTensor() {
infiniStatus_t aclnnTensorDescriptor::destroyTensor() {
auto ret = aclDestroyTensor(this->t);
CHECK_RET(ret == ACL_SUCCESS,
LOG_PRINT("aclDesctroyTensor failed, ERROR: %d\n", ret);
return INFINIOP_STATUS_INTERNAL_ERROR);
return INFINI_STATUS_INTERNAL_ERROR);
t = nullptr;
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
aclnnTensorDescriptor::~aclnnTensorDescriptor() {
......
......@@ -23,12 +23,12 @@ struct aclnnTensorDescriptor {
aclTensor *t;
// Transfer from infiniOp DT to aclDataType
infiniopStatus_t setDescriptor(aclDataType dtype, const std::vector<int64_t> &shape, const std::vector<int64_t> &strides);
infiniopStatus_t inferStorageShape();
infiniStatus_t setDescriptor(aclDataType dtype, const std::vector<int64_t> &shape, const std::vector<int64_t> &strides);
infiniStatus_t inferStorageShape();
// Convert form InfiniOpTensorDescriptor
infiniopStatus_t fromInfiniOpTensorDescriptor(infiniopTensorDescriptor_t y_desc);
infiniopStatus_t createTensor(void *data = nullptr);
infiniopStatus_t destroyTensor();
infiniStatus_t fromInfiniOpTensorDescriptor(infiniopTensorDescriptor_t y_desc);
infiniStatus_t createTensor(void *data = nullptr);
infiniStatus_t destroyTensor();
~aclnnTensorDescriptor();
char *toString();
......
......@@ -2,10 +2,10 @@
#include "common_bang.h"
#include <memory>
infiniopStatus_t createBangHandle(infiniopBangHandle_t *handle_ptr) {
infiniStatus_t createBangHandle(infiniopBangHandle_t *handle_ptr) {
int device_id = 0;
if (cnrtGetDevice(&device_id) != cnrtSuccess) {
return INFINIOP_STATUS_BAD_DEVICE;
return INFINI_STATUS_DEVICE_NOT_INITIALIZED;
}
auto pool = std::make_shared<Pool<cnnlHandle_t>>();
......@@ -16,10 +16,10 @@ infiniopStatus_t createBangHandle(infiniopBangHandle_t *handle_ptr) {
*handle_ptr = new InfiniopBangHandle{INFINI_DEVICE_CAMBRICON, device_id,
std::move(pool)};
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
infiniopStatus_t destroyBangHandle(infiniopBangHandle_t handle) {
infiniStatus_t destroyBangHandle(infiniopBangHandle_t handle) {
delete handle;
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
......@@ -6,7 +6,7 @@
struct InfiniopBangHandle;
typedef struct InfiniopBangHandle *infiniopBangHandle_t;
infiniopStatus_t createBangHandle(infiniopBangHandle_t *handle_ptr);
infiniopStatus_t destroyBangHandle(infiniopBangHandle_t handle);
infiniStatus_t createBangHandle(infiniopBangHandle_t *handle_ptr);
infiniStatus_t destroyBangHandle(infiniopBangHandle_t handle);
#endif
#include "cpu_handle.h"
infiniopStatus_t createCpuHandle(infiniopCpuHandle_t *handle_ptr) {
infiniStatus_t createCpuHandle(infiniopCpuHandle_t *handle_ptr) {
*handle_ptr = new InfiniopHandle{INFINI_DEVICE_CPU, 0};
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
infiniopStatus_t destroyCpuHandle(infiniopCpuHandle_t handle) {
infiniStatus_t destroyCpuHandle(infiniopCpuHandle_t handle) {
delete handle;
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
......@@ -5,8 +5,8 @@
typedef infiniopHandle_t infiniopCpuHandle_t;
infiniopStatus_t createCpuHandle(infiniopCpuHandle_t *handle_ptr);
infiniStatus_t createCpuHandle(infiniopCpuHandle_t *handle_ptr);
infiniopStatus_t destroyCpuHandle(infiniopCpuHandle_t handle);
infiniStatus_t destroyCpuHandle(infiniopCpuHandle_t handle);
#endif
......@@ -17,7 +17,7 @@
} \
} while (0)
#define CHECK_CUDA(call) CHECK_CUDA_OR_RETURN(call, INFINIOP_STATUS_INTERNAL_ERROR)
#define CHECK_CUDA(call) CHECK_CUDA_OR_RETURN(call, INFINI_STATUS_INTERNAL_ERROR)
#define CHECK_CUDNN(call) \
do { \
......@@ -25,7 +25,7 @@
std::cerr << "CUDNN error: " << cudnnGetErrorString(status) \
<< " in file " << __FILE__ << ", function " << __func__ \
<< ", line " << __LINE__ << std::endl; \
return INFINIOP_STATUS_INTERNAL_ERROR; \
return INFINI_STATUS_INTERNAL_ERROR; \
} \
} while (0)
......
#include "common_cuda.cuh"
infiniopStatus_t createCudaHandle(infiniopCudaHandle_t *handle_ptr, infiniDevice_t cuda_device_type) {
infiniStatus_t createCudaHandle(infiniopCudaHandle_t *handle_ptr, infiniDevice_t cuda_device_type) {
// Create a new cublas handle pool
int device_id = 0;
CHECK_CUDA(cudaGetDevice(&device_id));
CHECK_CUDA_OR_RETURN(cudaGetDevice(&device_id), INFINI_STATUS_DEVICE_NOT_INITIALIZED);
auto pool = std::make_shared<Pool<cublasHandle_t>>();
cublasHandle_t handle;
cublasCreate(&handle);
......@@ -35,13 +35,13 @@ infiniopStatus_t createCudaHandle(infiniopCudaHandle_t *handle_ptr, infiniDevice
capability_minor,
};
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
infiniopStatus_t destroyCudaHandle(infiniopCudaHandle_t handle_ptr) {
infiniStatus_t destroyCudaHandle(infiniopCudaHandle_t handle_ptr) {
handle_ptr->cublas_handle_pool = nullptr;
handle_ptr->cudnn_handle_pool = nullptr;
delete handle_ptr;
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
......@@ -6,8 +6,8 @@
struct InfiniopCudaHandle;
typedef struct InfiniopCudaHandle *infiniopCudaHandle_t;
infiniopStatus_t createCudaHandle(infiniopCudaHandle_t *handle_ptr, infiniDevice_t cuda_device_type);
infiniStatus_t createCudaHandle(infiniopCudaHandle_t *handle_ptr, infiniDevice_t cuda_device_type);
infiniopStatus_t destroyCudaHandle(infiniopCudaHandle_t handle_ptr);
infiniStatus_t destroyCudaHandle(infiniopCudaHandle_t handle_ptr);
#endif
......@@ -12,10 +12,10 @@
#include "ascend/ascend_handle.h"
#endif
__C infiniopStatus_t infiniopCreateHandle(infiniopHandle_t *handle_ptr,
infiniDevice_t device) {
__C infiniStatus_t infiniopCreateHandle(infiniopHandle_t *handle_ptr,
infiniDevice_t device) {
if (handle_ptr == nullptr) {
return INFINIOP_STATUS_NULL_POINTER;
return INFINI_STATUS_NULL_POINTER;
}
switch (device) {
......@@ -39,10 +39,10 @@ __C infiniopStatus_t infiniopCreateHandle(infiniopHandle_t *handle_ptr,
}
#endif
}
return INFINIOP_STATUS_DEVICE_TYPE_NOT_SUPPORTED;
return INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED;
}
__C infiniopStatus_t infiniopDestroyHandle(infiniopHandle_t handle) {
__C infiniStatus_t infiniopDestroyHandle(infiniopHandle_t handle) {
switch (handle->device) {
#ifdef ENABLE_CPU_API
case INFINI_DEVICE_CPU:
......@@ -64,5 +64,5 @@ __C infiniopStatus_t infiniopDestroyHandle(infiniopHandle_t handle) {
}
#endif
}
return INFINIOP_STATUS_DEVICE_TYPE_NOT_SUPPORTED;
return INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED;
}
#include "infiniop/operator.h"
infiniopStatus_t infiniopGetDescriptorDeviceType(
infiniStatus_t infiniopGetDescriptorDeviceType(
const InfiniopDescriptor *desc_ptr,
infiniDevice_t *device_type) {
*device_type = desc_ptr->device_type;
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
infiniopStatus_t infiniopGetDescriptorDeviceId(
infiniStatus_t infiniopGetDescriptorDeviceId(
const InfiniopDescriptor *desc_ptr,
int *device_id) {
*device_id = desc_ptr->device_id;
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
#include "infiniop/ops/causal_softmax.h"
__C infiniopStatus_t infiniopCreateCausalSoftmaxDescriptor(
__C infiniStatus_t infiniopCreateCausalSoftmaxDescriptor(
infiniopHandle_t handle,
infiniopCausalSoftmaxDescriptor_t *desc_ptr,
infiniopTensorDescriptor_t y_desc) {
......@@ -37,10 +37,10 @@ __C infiniopStatus_t infiniopCreateCausalSoftmaxDescriptor(
}
#endif
}
return INFINIOP_STATUS_DEVICE_TYPE_NOT_SUPPORTED;
return INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED;
}
__C infiniopStatus_t infiniopGetCausalSoftmaxWorkspaceSize(infiniopCausalSoftmaxDescriptor_t desc, size_t *size) {
__C infiniStatus_t infiniopGetCausalSoftmaxWorkspaceSize(infiniopCausalSoftmaxDescriptor_t desc, size_t *size) {
switch (desc->device_type) {
#ifdef ENABLE_CPU
case DevCpu:
......@@ -75,10 +75,10 @@ __C infiniopStatus_t infiniopGetCausalSoftmaxWorkspaceSize(infiniopCausalSoftmax
}
#endif
}
return INFINIOP_STATUS_DEVICE_TYPE_NOT_SUPPORTED;
return INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED;
}
__C infiniopStatus_t infiniopCausalSoftmax(infiniopCausalSoftmaxDescriptor_t desc, void *workspace, size_t workspace_size, void *data, void *stream) {
__C infiniStatus_t infiniopCausalSoftmax(infiniopCausalSoftmaxDescriptor_t desc, void *workspace, size_t workspace_size, void *data, void *stream) {
switch (desc->device_type) {
#ifdef ENABLE_CPU
case DevCpu:
......@@ -112,10 +112,10 @@ __C infiniopStatus_t infiniopCausalSoftmax(infiniopCausalSoftmaxDescriptor_t des
}
#endif
}
return INFINIOP_STATUS_DEVICE_TYPE_NOT_SUPPORTED;
return INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED;
}
__C infiniopStatus_t infiniopDestroyCausalSoftmaxDescriptor(infiniopCausalSoftmaxDescriptor_t desc) {
__C infiniStatus_t infiniopDestroyCausalSoftmaxDescriptor(infiniopCausalSoftmaxDescriptor_t desc) {
switch (desc->device_type) {
#ifdef ENABLE_CPU
case DevCpu:
......@@ -148,5 +148,5 @@ __C infiniopStatus_t infiniopDestroyCausalSoftmaxDescriptor(infiniopCausalSoftma
return musaDestroyCausalSoftmaxDescriptor((CausalSoftmaxMusaDescriptor_t)desc);
#endif
}
return INFINIOP_STATUS_DEVICE_TYPE_NOT_SUPPORTED;
return INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED;
}
......@@ -29,7 +29,7 @@ Descriptor::~Descriptor() {
delete _opaque;
}
infiniopStatus_t Descriptor::create(
infiniStatus_t Descriptor::create(
infiniopHandle_t handle_,
Descriptor **desc_ptr,
infiniopTensorDescriptor_t c_desc,
......@@ -39,12 +39,12 @@ infiniopStatus_t Descriptor::create(
auto dtype = c_desc->dtype;
if (dtype != INFINI_DTYPE_F16 && dtype != INFINI_DTYPE_F32) {
return INFINIOP_STATUS_BAD_TENSOR_DTYPE;
return INFINI_STATUS_BAD_TENSOR_DTYPE;
}
infiniopStatus_t status;
infiniStatus_t status;
auto info = MatmulInfo(c_desc, a_desc, b_desc, &status, MatrixLayout::ROW_MAJOR);
if (status != INFINIOP_STATUS_SUCCESS) {
if (status != INFINI_STATUS_SUCCESS) {
return status;
}
......@@ -59,23 +59,23 @@ infiniopStatus_t Descriptor::create(
{static_cast<int64_t>(info.c_matrix.rows),
static_cast<int64_t>(info.c_matrix.cols)},
{info.c_matrix.row_stride, info.c_matrix.col_stride}),
INFINIOP_STATUS_SUCCESS);
INFINI_STATUS_SUCCESS);
CHECK_STATUS(a->setDescriptor(
toAclDataType(a_desc->dtype),
{static_cast<int64_t>(info.a_matrix.rows),
static_cast<int64_t>(info.a_matrix.cols)},
{info.a_matrix.row_stride, info.a_matrix.col_stride}),
INFINIOP_STATUS_SUCCESS);
INFINI_STATUS_SUCCESS);
CHECK_STATUS(b->setDescriptor(
toAclDataType(b_desc->dtype),
{static_cast<int64_t>(info.b_matrix.rows),
static_cast<int64_t>(info.b_matrix.cols)},
{info.b_matrix.row_stride, info.b_matrix.col_stride}),
INFINIOP_STATUS_SUCCESS);
INFINI_STATUS_SUCCESS);
CHECK_STATUS(c->createTensor(), INFINIOP_STATUS_SUCCESS);
CHECK_STATUS(a->createTensor(), INFINIOP_STATUS_SUCCESS);
CHECK_STATUS(b->createTensor(), INFINIOP_STATUS_SUCCESS);
CHECK_STATUS(c->createTensor(), INFINI_STATUS_SUCCESS);
CHECK_STATUS(a->createTensor(), INFINI_STATUS_SUCCESS);
CHECK_STATUS(b->createTensor(), INFINI_STATUS_SUCCESS);
auto tc = c->t,
ta = a->t,
......@@ -91,7 +91,7 @@ infiniopStatus_t Descriptor::create(
auto ret = aclnnGemmGetWorkspaceSize(ta, tb, tc, .5, .5, 0, 0, tc, mt, &workspace_size, &executor);
CHECK_RET(ret == ACL_SUCCESS,
LOG_PRINT("aclnnGemmGetWorkspaceSize failed. ERROR: %d\n", ret);
return INFINIOP_STATUS_INTERNAL_ERROR);
return INFINI_STATUS_INTERNAL_ERROR);
aclSetAclOpExecutorRepeatable(executor);
*desc_ptr = new Descriptor(
......@@ -104,10 +104,10 @@ infiniopStatus_t Descriptor::create(
mt,
},
handle->device, handle->device_id);
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
infiniopStatus_t Descriptor::calculate(
infiniStatus_t Descriptor::calculate(
void *workspace,
size_t workspaceSize_,
void *c,
......@@ -127,9 +127,9 @@ infiniopStatus_t Descriptor::calculate(
&workspace_size, &(_opaque->executor));
CHECK_RET(ret == ACL_SUCCESS,
LOG_PRINT("aclnnGemmGetWorkspaceSize failed. ERROR: %d\n", ret);
return INFINIOP_STATUS_INTERNAL_ERROR);
return INFINI_STATUS_INTERNAL_ERROR);
if (workspaceSize_ < workspace_size) {
return INFINIOP_STATUS_INSUFFICIENT_WORKSPACE;
return INFINI_STATUS_INSUFFICIENT_WORKSPACE;
}
aclSetAclOpExecutorRepeatable(_opaque->executor);
......@@ -142,10 +142,10 @@ infiniopStatus_t Descriptor::calculate(
ret = aclnnGemm(workspace, workspace_size, _opaque->executor, stream);
CHECK_RET(ret == ACL_SUCCESS,
LOG_PRINT("aclnnGemm failed. ERROR: %d\n", ret);
return INFINIOP_STATUS_INTERNAL_ERROR);
return INFINI_STATUS_INTERNAL_ERROR);
}
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
} // namespace matmul::ascend
......@@ -59,7 +59,7 @@ Descriptor::~Descriptor() {
delete _opaque;
}
infiniopStatus_t Descriptor::create(
infiniStatus_t Descriptor::create(
infiniopHandle_t handle_,
Descriptor **desc_ptr,
infiniopTensorDescriptor_t c_desc,
......@@ -69,12 +69,12 @@ infiniopStatus_t Descriptor::create(
auto dtype = c_desc->dtype;
if (dtype != INFINI_DTYPE_F16 && dtype != INFINI_DTYPE_F32) {
return INFINIOP_STATUS_BAD_TENSOR_DTYPE;
return INFINI_STATUS_BAD_TENSOR_DTYPE;
}
infiniopStatus_t status;
infiniStatus_t status;
auto info = MatmulInfo(c_desc, a_desc, b_desc, &status, MatrixLayout::ROW_MAJOR);
if (status != INFINIOP_STATUS_SUCCESS) {
if (status != INFINI_STATUS_SUCCESS) {
return status;
}
......@@ -122,10 +122,10 @@ infiniopStatus_t Descriptor::create(
c,
handle->cnnl_handle_pool},
handle->device, handle->device_id);
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
infiniopStatus_t Descriptor::calculate(
infiniStatus_t Descriptor::calculate(
void *workspace,
size_t workspace_size,
void *c,
......@@ -155,7 +155,7 @@ infiniopStatus_t Descriptor::calculate(
});
cnrtQueueSync((cnrtQueue_t)stream);
return INFINIOP_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
}
} // namespace matmul::bang
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment