Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
6291f0aa
Unverified
Commit
6291f0aa
authored
5 years ago
by
aslepko
Committed by
GitHub
5 years ago
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3753 from NervanaSystems/nmostafa/update_mlir
Bump MLIR version
parents
27199cee
166fb921
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
20 deletions
+33
-20
external_mlir.cmake
cmake/external_mlir.cmake
+2
-2
compiler.cpp
src/contrib/mlir/compiler/compiler.cpp
+28
-9
ngraph_opt.cpp
src/contrib/mlir/tools/ngraph-opt/ngraph_opt.cpp
+2
-8
dot.in.cpp
test/backend/dot.in.cpp
+1
-1
No files found.
cmake/external_mlir.cmake
View file @
6291f0aa
...
...
@@ -20,8 +20,8 @@ set(MLIR_LLVM_REPO_URL https://github.com/llvm/llvm-project.git)
set
(
MLIR_REPO_URL https://github.com/tensorflow/mlir.git
)
# Change these commit IDs to move to latest stable versions
set
(
MLIR_LLVM_COMMIT_ID
4fe2732
)
set
(
MLIR_COMMIT_ID
40fe0fe7
)
set
(
MLIR_LLVM_COMMIT_ID
0845ac7331e
)
set
(
MLIR_COMMIT_ID
1f7893e0
)
# MLIR environment variables. Some of them are used by LIT tool.
set
(
MLIR_PROJECT_ROOT
${
CMAKE_CURRENT_BINARY_DIR
}
/mlir_project
)
...
...
This diff is collapsed.
Click to expand it.
src/contrib/mlir/compiler/compiler.cpp
View file @
6291f0aa
...
...
@@ -58,7 +58,7 @@
#include <llvm/Support/SourceMgr.h>
#include <llvm/Support/TargetSelect.h>
#include <llvm/Target/TargetMachine.h>
#include <mlir/Conversion/
ControlFlowToCFG/ConvertControlFlowToCFG
.h>
#include <mlir/Conversion/
LoopToStandard/ConvertLoopToStandard
.h>
#include <mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h>
#include <mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h>
#include <mlir/Dialect/LLVMIR/LLVMDialect.h>
...
...
@@ -360,7 +360,10 @@ void MLIRCompiler::lowerNgDialect()
// Apply any generic pass manager command line options.
mlir
::
applyPassManagerCLOptions
(
pm
);
pm
.
run
(
m_module
.
get
());
if
(
failed
(
pm
.
run
(
m_module
.
get
())))
{
NGRAPH_CHECK
(
false
,
"MLIR pass manager failed"
);
}
if
(
failed
(
m_module
->
verify
()))
{
...
...
@@ -709,7 +712,11 @@ void MLIRCompiler::optimizeNgDialect()
{
pm
.
addPass
(
mlir
::
createMemoryOptimizationPass
());
}
pm
.
run
(
m_module
.
get
());
if
(
failed
(
pm
.
run
(
m_module
.
get
())))
{
NGRAPH_CHECK
(
false
,
"MLIR pass manager failed"
);
}
}
// Binds MLIR function arguments to the proper values. This includes externally allocated tensors
...
...
@@ -729,11 +736,10 @@ void MLIRCompiler::bindArguments(std::vector<void*>& externalTensors)
m_externalTensors
=
&
externalTensors
;
// Create list with a type-erased double pointer for each invocation arguments.
// We currently use 'allocateMemrefArgs', which creates
a
//
SmallVector<StaticFloatMemref*>. StaticFloatMemref is just a struct with the
// actual pointer to the data.
// We currently use 'allocateMemrefArgs', which creates
the arguments list per call ABI (see
//
comment below).
//
StaticFloatMemref is just a struct with the
actual pointer to the data.
// create MemRef args
auto
expectedArguments
=
allocateMemrefArgs
();
NGRAPH_CHECK
(
expectedArguments
.
size
(),
"Arguments can't be created"
);
m_invokeArgs
=
std
::
move
(
expectedArguments
);
...
...
@@ -744,7 +750,8 @@ void MLIRCompiler::bindArguments(std::vector<void*>& externalTensors)
// Assign external tensor pointers to invocation arguments.
for
(
size_t
i
=
0
,
numArgs
=
m_invokeArgs
.
size
();
i
<
numArgs
;
++
i
)
{
((
mlir
::
StaticFloatMemRef
*
)
m_invokeArgs
[
i
])
->
data
=
(
float
*
)(
*
m_externalTensors
)[
i
];
auto
*
memRefArg
=
*
(
reinterpret_cast
<
mlir
::
StaticFloatMemRef
**>
(
m_invokeArgs
[
i
]));
memRefArg
->
data
=
reinterpret_cast
<
float
*>
((
*
m_externalTensors
)[
i
]);
}
}
...
...
@@ -770,6 +777,8 @@ void MLIRCompiler::cleanup()
// Free void double pointer arguments without freeing external tensor data.
for
(
auto
*
arg
:
m_invokeArgs
)
{
auto
*
memRefArg
=
*
(
reinterpret_cast
<
mlir
::
StaticFloatMemRef
**>
(
arg
));
free
(
memRefArg
);
free
(
arg
);
}
...
...
@@ -780,13 +789,23 @@ void MLIRCompiler::cleanup()
}
}
// The current call ABI takes a single arg pointer (argPtr) pointing to a list of args.
// Each arg is a pointer to a StaticFloatMemRef which contains a data pointer
//
// The args are laid out as follows
// argPtr-> arg[0]-> StaticFloatMemRef -> <data>
// arg[1]-> StaticFloatMemRef -> <data>
// ...
SmallVector
<
void
*
,
8
>
MLIRCompiler
::
allocateMemrefArgs
()
{
SmallVector
<
void
*
,
8
>
args
;
for
(
auto
i
=
0
;
i
<
m_externalTensors
->
size
();
i
++
)
{
auto
descriptor
=
allocateMemrefDescriptor
();
args
.
push_back
(
descriptor
);
mlir
::
StaticFloatMemRef
**
arg
=
reinterpret_cast
<
mlir
::
StaticFloatMemRef
**>
(
malloc
(
sizeof
(
mlir
::
StaticFloatMemRef
*
)));
*
arg
=
descriptor
;
args
.
push_back
(
arg
);
}
return
args
;
}
...
...
This diff is collapsed.
Click to expand it.
src/contrib/mlir/tools/ngraph-opt/ngraph_opt.cpp
View file @
6291f0aa
...
...
@@ -61,8 +61,6 @@ static llvm::cl::opt<bool>
llvm
::
cl
::
desc
(
"Run the verifier after each transformation pass"
),
llvm
::
cl
::
init
(
true
));
static
std
::
vector
<
const
mlir
::
PassRegistryEntry
*>*
pass_list
;
int
main
(
int
argc
,
char
**
argv
)
{
llvm
::
InitLLVM
y
(
argc
,
argv
);
...
...
@@ -70,11 +68,7 @@ int main(int argc, char** argv)
// Register any pass manager command line options.
mlir
::
registerPassManagerCLOptions
();
// Parse pass names in main to ensure static initialization completed.
llvm
::
cl
::
list
<
const
mlir
::
PassRegistryEntry
*
,
bool
,
mlir
::
PassNameParser
>
pass_list
(
""
,
llvm
::
cl
::
desc
(
"Compiler passes to run"
));
::
pass_list
=
&
pass_list
;
mlir
::
PassPipelineCLParser
passPipeline
(
""
,
"Compiler passes to run"
);
llvm
::
cl
::
ParseCommandLineOptions
(
argc
,
argv
,
"nGraph MLIR modular optimizer driver
\n
"
);
// Set up the input file.
...
...
@@ -87,7 +81,7 @@ int main(int argc, char** argv)
return
failed
(
mlir
::
MlirOptMain
(
output
->
os
(),
std
::
move
(
file
),
pass
_list
,
pass
Pipeline
,
split_input_file
,
verify_diagnostics
,
verify_passes
));
...
...
This diff is collapsed.
Click to expand it.
test/backend/dot.in.cpp
View file @
6291f0aa
...
...
@@ -254,7 +254,7 @@ NGRAPH_TEST(${BACKEND_NAME}, dot_0_0)
EXPECT_TRUE
(
test
::
all_close_f
((
vector
<
float
>
{
0
}),
read_vector
<
float
>
(
result
)));
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
dot_matrix_2x0_0x2
)
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
MLIR_DISABLE_TEST
(
dot_matrix_2x0_0x2
)
)
{
Shape
shape_a
{
2
,
0
};
Shape
shape_b
{
0
,
2
};
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment