mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Summary: Added the MatMul operator for caffe2 Test Plan: buck test //caffe2/torch/fb/model_transform/c2_convert:c2_pt_converter_test Reviewed By: bugra Differential Revision: D24920937 fbshipit-source-id: 7ba09ba0439cb9bd15d6a41fd8ff1a86d8d11437
37 lines
873 B
Python
37 lines
873 B
Python
## @package algebra
|
|
# Module caffe2.python.helpers.algebra
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def transpose(model, blob_in, blob_out, use_cudnn=False, **kwargs):
|
|
"""Transpose."""
|
|
if use_cudnn:
|
|
kwargs['engine'] = 'CUDNN'
|
|
return model.net.Transpose(blob_in, blob_out, **kwargs)
|
|
|
|
|
|
def sum(model, blob_in, blob_out, **kwargs):
|
|
"""Sum"""
|
|
return model.net.Sum(blob_in, blob_out, **kwargs)
|
|
|
|
|
|
def sub(model, blob_in, blob_out, **kwargs):
|
|
"""Subtract"""
|
|
return model.net.Sub(blob_in, blob_out, **kwargs)
|
|
|
|
|
|
def mat_mul(model, blob_in, blob_out, **kwargs):
|
|
"""Matrix multiplication"""
|
|
return model.net.MatMul(blob_in, blob_out, **kwargs)
|
|
|
|
|
|
def batch_mat_mul(model, blob_in, blob_out,
|
|
enable_tensor_core=False, **kwargs):
|
|
if enable_tensor_core:
|
|
kwargs['engine'] = 'TENSORCORE'
|
|
|
|
return model.net.BatchMatMul(blob_in, blob_out, **kwargs)
|