Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Npu test #10358

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Npu test #10358

Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/build
/build1
hjchen2 marked this conversation as resolved.
Show resolved Hide resolved
/build-*
/docs/build/
/docs/build-cn/
Expand Down
1 change: 1 addition & 0 deletions cmake/caches/cn/cpu.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
set(BUILD_CUDA NO CACHE BOOL "")
set(BUILD_SHARED_LIBS YES CACHE BOOL "")
hjchen2 marked this conversation as resolved.
Show resolved Hide resolved
set(THIRD_PARTY_MIRROR aliyun CACHE STRING "")
set(PIP_INDEX_MIRROR "https://pypi.tuna.tsinghua.edu.cn/simple" CACHE STRING "")
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ limitations under the License.
// huawei ascend sdk headers
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
#include "op_proto/built-in/inc/all_ops.h"
#include "built-in/op_proto/inc/all_ops.h"
#pragma GCC diagnostic pop

namespace mlir {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ static flatbuffers_vec_ref_t createLiteOpAttrs(FlatbufferBuilder& builder, Opera
} else if (attrType.value() == ::oneflow::kAtListString) {
strAttrType = "strs";
serializeStringsAttr(attrBuilder, attrValue);
} else if (attrType.value() == ::oneflow::kAtBytes) {
hjchen2 marked this conversation as resolved.
Show resolved Hide resolved
strAttrType = "str";
serializeStringAttr(attrBuilder, attrValue);
} else {
llvm::errs() << "error attribute type: " << attrType.value() << "\n";
exit(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ limitations under the License.
// huawei ascend sdk headers
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
#include "op_proto/built-in/inc/all_ops.h"
#include "built-in/op_proto/inc/all_ops.h"
#pragma GCC diagnostic pop

namespace mlir {
Expand Down Expand Up @@ -168,7 +168,7 @@ void AscendCompiler::addInputs(llvm::SmallVector<Value, 4>& operands) {
}

void AscendCompiler::lowerOp(VariableOp op, StringRef checkpointDir) {
auto ascendType = convertAscendType(op.data_typeAttr(), op.shapeAttr());
auto ascendType = convertAscendType(op.getDataTypeAttr(), op.getShapeAttr());
llvm::SmallString<128> inputFilename;
llvm::sys::path::native(checkpointDir + "/" + op.getOpName() + "/out", inputFilename);
std::string errorMessage;
Expand All @@ -191,11 +191,11 @@ void AscendCompiler::lowerOp(VariableOp op, StringRef checkpointDir) {

void AscendCompiler::lowerOp(Conv2DOp op) {
auto conv2DOp = createOp<ge::op::Conv2D>(op.getOpName());
conv2DOp->set_attr_pads(convertPaddings(op.padding_before()));
conv2DOp->set_attr_pads(convertPaddings(op.getPaddingBefore()));
conv2DOp->set_attr_dilations(convertDilations(op.getDilationRate()));
conv2DOp->set_attr_strides(convertStrides(op.getStrides()));
conv2DOp->set_attr_groups(op.getGroups());
conv2DOp->set_attr_data_format(convertDataFormat(op.data_format()).data());
conv2DOp->set_attr_data_format(convertDataFormat(op.getDataFormat()).data());

SET_INPUT(conv2DOp, x, getValue(op.getIn()));
SET_INPUT(conv2DOp, filter, getValue(op.getWeight()));
Expand All @@ -205,10 +205,10 @@ void AscendCompiler::lowerOp(Conv2DOp op) {

auto output = AscendValue(conv2DOp, outType, "y");

if (op._add_to_output()) {
if (op.get_addToOutput()) {
auto addOp = createOp<ge::op::AddV2>(op.getOpName() + "_add_to_output");
SET_INPUT(addOp, x1, output);
SET_INPUT(addOp, x2, getValue(op._add_to_output()));
SET_INPUT(addOp, x2, getValue(op.get_addToOutput()));
addOp->update_output_desc_y(outType);
output = AscendValue(addOp, outType, "y");
}
Expand All @@ -229,10 +229,10 @@ void AscendCompiler::lowerOp(NormalizationInferenceOp op) {
batchNormOp->update_output_desc_y(outType);

auto output = AscendValue(batchNormOp, outType, "y");
if (op._add_to_output()) {
if (op.get_addToOutput()) {
auto addOp = createOp<ge::op::AddV2>(op.getOpName() + "_add_to_output");
SET_INPUT(addOp, x1, output);
SET_INPUT(addOp, x2, getValue(op._add_to_output()));
SET_INPUT(addOp, x2, getValue(op.get_addToOutput()));
addOp->update_output_desc_y(outType);
output = AscendValue(addOp, outType, "y");
}
Expand All @@ -252,7 +252,7 @@ void AscendCompiler::lowerOp(MaxPool2DOp op) {
maxPoolOp->set_attr_ksize(convertKernelSize(op.getKernelSize()));
maxPoolOp->set_attr_pads(convertPaddings(op.getPadding()));
maxPoolOp->set_attr_strides(convertStrides(op.getStride()));
maxPoolOp->set_attr_ceil_mode(op.ceil_mode());
maxPoolOp->set_attr_ceil_mode(op.getCeilMode());
maxPoolOp->set_attr_padding_mode("CALCULATED");
maxPoolOp->set_attr_global_pooling(false);

Expand All @@ -267,10 +267,10 @@ void AscendCompiler::lowerOp(AvgPool2DOp op) {
avgPoolOp->set_attr_ksize(convertKernelSize(op.getKernelSize()));
avgPoolOp->set_attr_pads(convertPaddings(op.getPadding()));
avgPoolOp->set_attr_strides(convertStrides(op.getStride()));
avgPoolOp->set_attr_ceil_mode(op.ceil_mode());
avgPoolOp->set_attr_ceil_mode(op.getCeilMode());
avgPoolOp->set_attr_padding_mode("CALCULATED");
avgPoolOp->set_attr_global_pooling(false);
avgPoolOp->set_attr_exclusive(!op.count_include_pad());
avgPoolOp->set_attr_exclusive(!op.getCountIncludePad());

SET_INPUT(avgPoolOp, x, getValue(op.getX()));
auto outType = convertAscendType(op.getY().getType());
Expand All @@ -289,7 +289,7 @@ void AscendCompiler::lowerOp(Add2Op op) {

void AscendCompiler::lowerOp(AdaptiveAvgPool2DOp op) {
auto adaptiveAvgPoolOp = createOp<ge::op::AdaptiveAvgPool2d>(op.getOpName());
ArrayAttr output_size = op.output_size();
ArrayAttr output_size = op.getOutputSize();
assert(output_size.size() == 2);
int64_t s0 = output_size[0].dyn_cast<IntegerAttr>().getSInt();
int64_t s1 = output_size[1].dyn_cast<IntegerAttr>().getSInt();
Expand All @@ -311,10 +311,10 @@ void AscendCompiler::lowerOp(MatmulOp op) {
matmulOp->update_output_desc_y(outType);

auto output = AscendValue(matmulOp, outType, "y");
if (op._add_to_output()) {
if (op.get_addToOutput()) {
auto addOp = createOp<ge::op::AddV2>(op.getOpName() + "_add_to_output");
SET_INPUT(addOp, x1, output);
SET_INPUT(addOp, x2, getValue(op._add_to_output()));
SET_INPUT(addOp, x2, getValue(op.get_addToOutput()));
addOp->update_output_desc_y(outType);
output = AscendValue(addOp, outType, "y");
}
Expand Down
Loading